3.1.4. Diffusion

After permutation, a diffusion scheme by 3D Zigzag transformation is proposed, as follows. An initial cipher image would be split and placed on the surfaces of an *N* × *N* × 6 cube, termed as *P*, as described in Section 2.2. Additionally, chaotic matrix *S*2 would also be placed on another two *N* × *N* × 6 cubes, since diffusion would implement two rounds. For the first *N* × *N* × 6 numbers in *S*2, each number would be placed on a cube in order, which could be called cube *SC*1.For the last *N* × *N* × 6 numbers in *S*2, cube *SC*2 could be generated by the same process.

Subsequently, diffusion would start from origin point of cube *P* on the front side, and its coordinate is [1, 1, 1]. At each iteration, the pixel's value *Ci*,*j*,*<sup>m</sup>* is calculated by Equation (9).

$$C\_{i,j,m} = (P\_{i,j,m} \oplus (T + \mathcal{X}\_{i,j,m;1})) \bmod 256 \tag{9}$$

where *i*, *j*, *m* are the coordinates of pixel at the *ith* row, *jth* column, and *mth* side on the cube. *T* is the previous one diffused pixel's *C* value, if *i*, *j*, *m* = 1, 1, 1, *T* is a user-defined constant. *xi*,*j*,*<sup>m</sup>*;1is the corresponding coordinate's value in *SC*1.

For the second round of diffusion, Equation (9) would change to Equation (10).

$$D\_{i,j,m} = (\mathbb{C}\_{i,j,m} \oplus (T' + \mathbb{x}\_{i,j,m;2})) \bmod 256 \tag{10}$$

where D is result of diffusion, and *T* is the previous one diffused pixel's *D* value, and, if *i*, *j*, *m* = 1, 1, 1, *T* is the last pixel's *C* value after the first round diffusion. While *xi*,*j*,*<sup>m</sup>*;2 is corresponding coordinate's value in *SC*2.

Through these two round diffusions, *D* cube is generated. Additionally, recover the D's *N* × *N* × 6 matrix by reversing processes of image splitting and cube placement in Section 2.2. A diffused *N* × *N* × 3 matrix *Dmat* is obtained.

#### 3.1.5. RNA Operation

The encryption from diffused matrix *Dmat* through RNA operation could be described, as follows:


$$B = \{b\_{i,j,m}\}. \quad i, j = 1, 2, \dots, N; m = 1, 2, 3 \tag{11}$$

Each *bi*,*j*,*<sup>m</sup>* could be expressed as eight binary numbers, which could be depicted as *<sup>b</sup>i*,*j*,*<sup>m</sup>* 0*<sup>b</sup>i*,*j*,*<sup>m</sup>* 1*<sup>b</sup>i*,*j*,*<sup>m</sup>* 2*<sup>b</sup>i*,*j*,*<sup>m</sup>* 3*<sup>b</sup>i*,*j*,*<sup>m</sup>* 4*<sup>b</sup>i*,*j*,*<sup>m</sup>* 5*<sup>b</sup>i*,*j*,*<sup>m</sup>* 6*<sup>b</sup>i*,*j*,*<sup>m</sup>* 7.

• Step 3: divide *bi*,*j*,*<sup>m</sup>* into four pieces, each two bits are one piece, which are recorded as:

$$\begin{aligned} b r\_1^{i,j,m} &= b\_0^{i,j,m} b\_1^{i,j,m} \\ b r\_2^{i,j,m} &= b\_2^{i,j,m} b\_3^{i,j,m} \\ b r\_3^{i,j,m} &= b\_4^{i,j,m} b\_5^{i,j,m} \\ b r\_4^{i,j,m} &= b\_6^{i,j,m} b\_7^{i,j,m} \end{aligned} \tag{12}$$

 Additionally, combine three channels' *bt*s at the same coordinate together:

$$\begin{cases} bt\_1^{i,j} = bt\_1^{i,j,1}bt\_1^{i,j,2}bt\_1^{i,j,3} \\ bt\_2^{i,j} = bt\_2^{i,j,1}bt\_2^{i,j,2}bt\_2^{i,j,3} \\ bt\_3^{i,j} = bt\_3^{i,j,1}bt\_3^{i,j,2}bt\_3^{i,j,3} \\ bt\_4^{i,j} = bt\_4^{i,j,1}bt\_4^{i,j,2}bt\_4^{i,j,3} \end{cases} \tag{13}$$

Therefore, each *bti*,*j* has six bits that could transfer to RNA codons according to Table 1. Exchange each two bits in *bt*s to RNA base one-by-one according to the principle

of row priority, *bt*s could be coded to codons. And put them into a one-dimension sequence *BS* as Equation (14).

$$BS = \{bt\_1^{1,1}, bt\_2^{1,1}, bt\_3^{1,1}, bt\_4^{1,1}, bt\_1^{1,2}, bt\_2^{1,2}, \dots, bt\_4^{2,1}, bt\_1^{2,2}, \dots, bt\_3^{N,N}, bt\_4^{N,N}\}.\tag{14}$$

• Step 4: convert key to binary format. 256-bit key could be changed into a binary sequence *BK*.

$$\begin{aligned} key &= [key\_0, key\_1, \dots, key\_{31}] \\ key\_i &= key\_{i,0}, key\_{i,1}, \dots, key\_{i,7} \\ BK &= [key\_{1,0}, key\_{1,1}, \dots, key\_{1,7}, key\_{2,0}, key\_{2,1}, \dots, key\_{31,7}] \end{aligned} \tag{15}$$

Walk through sequence *BS*, and find corresponding index *id* of each codon in *BS* from Table 2. For each codon in *BS*, check 2-bits table number *z* in sequence *BK*.

$$z = BK\_{\text{in }mod\ 2048}BK\_{\left(n+1\right) \mid mod\ 2048} \tag{16}$$

where *n* is the walking times.

Take the codon *Tz*(*id*) to replace the origin codon *BS*(*n*).

When iterations termination, an encrypted sequence is generated.

•Step 5: decode each base in encrypted sequence *BS* to binary format by Table 1, put all of the binary digits back to original coordinates by reversing operations in Step 3. Additionally, change binary matrix into 2-bit matrix. The cipher image is generated.

The HCZRNA encryption has four stages: hyper-chaotic matrices generation (Sections 3.1.1 and 3.1.2), hyper-chaotic permutation (Section 3.1.3), 3D transformed Zigzag diffusion on surfaces of cubes, which is generated from initial cipher image (Section 3.1.4), and a bit-level RNA operation (Section 3.1.5). The major steps of the HCZRNA are Sections 3.1.4 and 3.1.5, i.e., the transformed Zigzag diffusion on 3D cubes and bit-level RNA substitutions with hyper-chaotic matrix, respectively. The HCZRNA uses the strategy of "divide and conquer" that is widely used in various applications to decompose the original encryption task into a couple of simpler sub-tasks [38,39].
