# A Tweak-Cube Color Image Encryption Scheme Jointly Manipulated by Chaos and Hyper-Chaos
## 3 The Proposed Image Cryptosystem  
### Key Stream Generation  
In this subsection, we introduce the key stream generation process of the encryption scheme in this paper. The specific steps are as follows:  
Step 1: Decompose the plain image \(\mathrm{P}\) of size \(\mathrm{m}\times\mathrm{n}\) into three matrixes, \(\mathrm{P}_{\mathrm{R}}\), \(\mathrm{P}_{\mathrm{G}}\), and \(\mathrm{P}_{\mathrm{B}}\). Set initial values \(\mathrm{x}_{10}\) and \(\left\{\mathrm{x}_{0},\mathrm{y}_{0},\mathrm{z}_{0},\mathrm{w}_{0}\right\}\) for the LFHCM and 4D hyperchaotic system, respectively. Then apply the plain image \(\mathrm{P}\) to update the initial values according to Equation (6)  
\[\left\{ \begin{array}{l}\mathrm{x}_{20}=\mathrm{x}_{10}+\frac{\sum_{i=1}^{m} \sum_{j=1}^{n}\mathrm{P}_{\mathrm{R}}(\mathrm{i}j)}{256^{3}}\times\frac{ \mathrm{x}_{0}+1}{\mathrm{x}_{0}+\mathrm{y}_{0}+\mathrm{z}_{0}+\mathrm{z}_{0} +\mathrm{z}_{0}+2}\\ \mathrm{x}_{20}{{}^{\prime}}=\mathrm{x}_{10}+\frac{\sum_{i=1}^{m}\sum_{j=1}^{m} \mathrm{P}_{\mathrm{R}}(\mathrm{i}j)}{2\times 256^{3}}\times\frac{\mathrm{y}_{0}+ \mathrm{z}_{0}+1}{\mathrm{x}_{0}+\mathrm{y}_{0}+\mathrm{z}_{0}+\mathrm{z}_{0} +2}\end{array} \right. \tag{6}\]  
\[\left\{ \begin{array}{l}\mathrm{x}^{\prime}_{0}=\mathrm{x}_{0}+\frac{\sum_{i=1 }^{m}\sum_{j=1}^{n}\mathrm{P}_{\mathrm{G}}(\mathrm{i}j)}{256^{2}}\times\frac{ \mathrm{y}_{0}+1}{\mathrm{x}_{10}+\mathrm{y}_{0}+\mathrm{w}_{0}+2}\\ \mathrm{y}_{0}{{}^{\prime}}=\mathrm{y}_{0}+\frac{\sum_{i=1}^{m}\sum_{j=1}^{m} \mathrm{P}_{\mathrm{G}}(\mathrm{i}j)}{2\times 256^{2}}\times\frac{\mathrm{z}_{0}+1}{ \mathrm{x}_{10}+\mathrm{x}_{0}+\mathrm{z}_{0}+2}\\ \mathrm{z}^{\prime}_{0}=\mathrm{z}_{0}+\frac{\sum_{i=1}^{m}\sum_{j=1}^{m} \mathrm{P}_{\mathrm{B}}(\mathrm{i}j)}{3\times 256^{3}}\times\frac{\mathrm{w}_{0}+1}{ \mathrm{x}_{10}+\mathrm{y}_{0}+\mathrm{w}_{0}+2}\\ \mathrm{w}_{0}{{}^{\prime}}=\mathrm{w}_{0}+\frac{\sum_{i=1}^{m}\sum_{j=1}^{m} \mathrm{P}_{\mathrm{B}}(\mathrm{i}j)}{4\times 256^{3}}\times\frac{\mathrm{w}_{0}+1}{ \mathrm{x}_{10}+\mathrm{w}_{0}+\mathrm{z}_{0}+2}\end{array} \right. \tag{7}\]  
Figure 3: The phase trajectories of the (**a**) x, y plane; (**b**) x, z plane; (**c**) x, w plane; (**d**) y, z plane; (**e**) y, w plane; (**f**) x, y, z space. Step 2: Select two control parameters \(\{c_{1},c_{2}\}\) for the LFHCM, and iterate it \((\mathrm{m}+500)\) and \((\mathrm{n}+500)\) times with the initial values \(\{x_{20},x_{20}{}^{\prime}\}\). Discard the first 500 elements to form two chaotic sequences, labeled \(\left(x_{21}(\mathrm{k})\right)_{\mathrm{k}=1}^{\mathrm{m}}\) and \(\left(x_{22}(\mathrm{k})\right)_{\mathrm{k}=1}^{\mathrm{n}}\). Step 3: Pre-iterate the 4D hyperchaotic system described in the former section 1000 times. Then, iterate another \(\mathrm{u}\) and \(\mathrm{v}\) times to generate two pseudo-random sequences, \(\mathrm{s}_{1}(\mathrm{k})\) and \(\mathrm{s}_{2}(\mathrm{k})\), with initial values \(\left\{x_{0}{}^{\prime},y^{\prime}{}_{0},x^{\prime}{}_{0},w^{\prime}{}_{0}\right\}\), respectively. They can be defined as follows:  
\[\left\{ \begin{array}{l}\mathrm{u}=\left\lceil(\mathrm{m}+1)/4\right\rceil \\ \mathrm{v}=\left\lceil(\mathrm{n}+1)/4\right\rceil\end{array} \right.