# SC-SA: Byte-Oriented Lightweight Stream Ciphers Based on S-Box Substitution
## 2 SC-SA Cipher
Details of the Update Vector Function (UVF) will be explained later, the round function of the cipher is shown in Algorithm 1. ```
Input: Key K, Substitution Table S Output: Substitution Table S, Queue T, Address Data Group A, State Data Group V. Procedure RF(K, S) \(T\gets K[0-63]\) \(A\gets K[64-71]\) \(V\gets K[72-79]\) for i = 1 \(\rightarrow\) 80 do \(Swap(S[A],S[V])\) \(V=S[V]\) A = T.pop() T.push(V) \(V=V\oplus A+0b0111111\) \(A=T[0][2]||T[1][4]||T[2][0]||T[3][6]||T[4][1]||T[5][3]||T[6][7]||T[7][5]\) end for return S, T, A, V end procedure
```  
**Algorithm 1**Round function of the cipher. Update Vector Function (UVF):  
Step 1: When the iterative processing of the cipher's Round Function is completed, at this point, the Index Data Group A and State Data Group V are in their updated states. The State Data Group is used as the key stream for encrypting the plaintext sequence. Let C represent the ciphertext and P represent the plaintext. The encryption process can be represented by Formula (2), as follows:  
\[\text{C}=\text{P}\oplus\text{V}, \tag{2}\]  
Step 2: during the vector group update process, to make the update process more nonlinear, let the Index Data Group A undergo arithmetic addition with the value 0b10000000, denoted as A = A + 0b1000000, where 0b1000000 is binary for 128;Step 3: Through the previous step, the values in the Address Data Group A are updated. The value of the State Data Group V serves as the index address for the S-box, and S[A] is inserted at the tail of the Queue T; simultaneously, S[A] is assigned to A. Before that, ensure that the head of the Queue T[0] is removed and assigned to the State Data Group V, denoted as V = T.pop(), T.push (A);  
Step 4: Through the previous step, the values of the Index Data Group A are updated, the data in the Queue T are updated, and the State Data Group is updated as well. Similarly, the iterative update of the State Data Group V uses arithmetic addition, denoted as V = V\(\oplus\)A + 0b01111111;  
Step 5: In the iterative update of the Index Data Group A, A[0]-A[7] take values, respectively, from T[0][2], T[1][4], T[2][0], T[3][6], T[4][1], T[5][3], T[6][7], and T[7][5], denoted as A = T[0][2] | I T[1][4] | I T[2][0] | I T[3][6] | I T[4][1] | I T[5][3] | I T[6][7] | I T[7][5]. Check if there are any plaintext sequences left to be encrypted. If so, jump to the first step; otherwise, stop the cipher algorithm, the update vector function (UVF) proposed in this paper is shown in Algorithm 2. ```
Input: Queue T, Address Data Group A, State Data Group V, Substitution Table S, Plaintext Byte P. Output: Ciphertext Byte C procedure UVF(T, A, V, S, P) while(C!= NULL) P = C\(\oplus\) V A = A+0b1000000 A = S[A] V = T.pop() T.push(A) V = V\(\oplus\)A+0b0111111 A = T[0][2] | I T[1][4] | I T[2][0] | I T[3][6] | I T[4][1] | I T[5][3] | I T[6][7] | I T[7][5]  return C end procedure
```  
**Algorithm 2** The Update Vector Function (UVF) proposed in this paper. S-box is the main nonlinear component in the cryptographic scheme proposed in this paper, and linear fractional transformation (LFT) is one of the most commonly used mapping methods. However, generating dynamic S-boxes using LFT is complex and time-consuming, making it less suitable for lightweight cipher algorithm design. By modifying the cubic fractional transformation (CFT) function [23] proposed by [PERSON] et al., as shown in Formula (3), and using it as the S-box random generator Random () followed by screening the generated S-boxes, a well-performing S-box can be obtained. \[C(z)=\frac{1}{\alpha\cdot z^{3}+\beta}(MOD(2^{n}+1)),\alpha,\beta,z\in Z, \tag{3}\]  
After transforming Equation (3) into operations in \(GF(2^{8})\) with n = 8, the specific implementation flowchart is shown in Figure 4. The S-box generation process, by setting different parameters, will be used to generate S-boxes randomly.