*3.1. Simultaneous Horizontal Confusion and Diffusion*

• Step 1. Generate diffusion matrix *S*1.

Iterate Equation (4) *n*<sup>1</sup> + *M* × *N* times with initial value *x*1(1), *x*1(2) and control parameter *u*1. *M*, *N* are the height and width of the image *I* that is being processed, respectively. Then, the diffusion matrix *S*<sup>1</sup> is obtained by the generated chaotic sequence *x*<sup>1</sup> using Equation (6).

$$S\_1(i,j) = \left\lfloor \mathbf{x}\_1(n\_1 + (i-1) \times M + j) \times 10^6 \right\rfloor \bmod 256. \tag{6}$$

where *i* = 1, 2, ..., *M* and *j* = 1, 2, ..., *N*. *S*<sup>1</sup> is the matrix of *M* by *N*, each value of which is derived from the chaotic sequence *x*1. With the given parameter *u*1, the generated chaotic sequence *x*<sup>1</sup> has considerable randomness.


Obtain *x*2(1), *x*2(2), *n*2, *u*<sup>2</sup> from the secret key and and calculate the initial value as well as iteration time of chaotic map by adjusting them with the pixel value of image *I* according to Equation (7).

$$\begin{cases} \mathbf{x}\_2^i(1) = (\mathbf{x}\_2(1) + I(r\_i, 1) / 255) mod 1, \\ \mathbf{x}\_2^i(2) = \mathbf{x}\_2(2), \\ \mathbf{n}\_2^i = n\_2 + I(r\_i, N) \end{cases} \tag{7}$$

where:

$$r\_i = \begin{cases} M, & i = 1 \\ i - 1, & elsc. \end{cases} \tag{8}$$

Then, using initial value *x<sup>i</sup>* <sup>2</sup>(1), *<sup>x</sup><sup>i</sup>* <sup>2</sup>(2) and parameter *<sup>u</sup>*2, iterate Equation (4) *<sup>n</sup><sup>i</sup>* <sup>2</sup> + 2 times. Obtain *bi* <sup>1</sup> and *t i* <sup>1</sup> according to Equation (9).

$$\begin{cases} b\_1^i = \left\lfloor \mathbf{x}\_2^i (n\_2^i + 1) \times 10^6 \right\rfloor mod N\\ t\_1^i = \left\lfloor \mathbf{x}\_2^i (n\_2^i + 2) \times 10^6 \right\rfloor mod N. \end{cases} \tag{9}$$
