# Cryptanalysis of Permutation-Diffusion-Based Lightweight Chaotic Image Encryption Scheme Using CPA
## 3 Cryptanalysis of the Original Scheme
### Obtain the Permutation Rule \(l_{p}\)
\begin{array}{ccccc}(0)(0)&(0)(1)&(0)(2)&\cdots&(0)(255)\\ (1)(0)&(1)(1)&(1)(2)&\cdots&(1)(255)\\ \vdots&\vdots&\vdots&\ddots&\vdots\\ (254)(0)&(254)(1)&(254)(2)&\cdots&(254)(255)\\ (255)(0)&(255)(1)&(255)(2)&\cdots&(255)(255)\end{array} \right]_{256\times 256}, \tag{10}\]  
where the element \((p_{i})(q_{j})\) is exactly the position \(256\times p_{i}+q_{j}\) of the position vector \(\boldsymbol{pos}_{p}\). Since the pixel value in the original plaintext image \(\mathbf{I}\) varies from 0 to 255, i.e., all of the entries \(L=256\) in (9), we can obtain the two matrices with entries \([0,\;1,\;2,\;\cdots,\;255]\) by splitting matrix \(\mathbf{A}\) into two bit-plane images. Actually, the bit-plane images are exactly the chosen plaintext images \(\mathbf{I}_{1}\) and \(\mathbf{I}_{2}\) mentioned above, as shown in (11,12). \[\mathbf{I}_{1}=\left[ \begin{array}{ccccc}0&0&0&\cdots&0\\ 1&1&1&\cdots&1\\ \vdots&\vdots&\vdots&\ddots&\vdots\\ 254&254&254&\cdots&254\\ 255&255&255&\cdots&255\end{array} \right]_{256\times 256}, \tag{11}\]  
\[\mathbf{I}_{2}=\left[ \begin{array}{ccccc}0&1&2&\cdots&255\\ 0&1&2&\cdots&255\\ \vdots&\vdots&\vdots&\ddots&\vdots\\ 0&1&2&\cdots&255\\ 0&1&2&\cdots&255\end{array} \right]_{256\times 256}. \tag{12}\]  
Based on above, the pixel position vector \(\boldsymbol{pos}_{p}=\left\{\boldsymbol{pos}_{p}(i)\right\}_{i=0}^{M\times N -1}\) of the original plaintext image \(\mathbf{I}\) has completely relied on \(\mathbf{I}_{1}\) and \(\mathbf{I}_{2}\). In the following, we only need to generate the pixel position vector \(\boldsymbol{pos}_{p}=\left\{\boldsymbol{pos}_{p}(i)\right\}_{i=0}^{M\times N -1}\) of the permutation-only image \(\mathbf{P}\) by recovering the final ciphertext image \(\mathbf{C}\) of the original plaintext image \(\mathbf{I}\) into the permutation-only phase, the permutation rule of the original permutation phase will be able to be revealed. Here, the final ciphertext image--\(\mathbf{C}\)--includes two parts--\(\mathbf{C}_{1}\) and \(\mathbf{C}_{2}\) (encrypted by the original permutation and diffusion phases). Furthermore, the pixel position vector \(\boldsymbol{pos}_{p}=\left\{\boldsymbol{pos}_{p}(i)\right\}_{i=0}^{M\times N -1}\) of permutation-only image \(\mathbf{P}\) is indirectly determined by \(\mathbf{C}_{1}\) and \(\mathbf{C}_{2}\). With the help of the generated diffusion key \(R\), the ciphertext images \(\mathbf{C}_{1}\) and \(\mathbf{C}_{2}\) can be easily restored to the permutation-only images \(\mathbf{P}_{1}\) and \(\mathbf{P}_{2}\); the position vector \(\boldsymbol{pos}_{p}=\left\{\boldsymbol{pos}_{p}(i)\right\}_{i=0}^{M\times N -1}\) of permutation-only image \(\mathbf{P}\) is exactly the combination resultant of the two obtained \(\mathbf{P}_{1}\) and \(\mathbf{P}_{2}\) is exactly the position vector \(\boldsymbol{pos}_{e}=\left\{\boldsymbol{pos}_{e}(i)\right\}_{i=0}^{M\times N -1}\) of the permutation-only image \(\mathbf{P}\). Therefore, the permutation rule \(\mathbf{I}_{p}\) has been revealed, which can be seen in Algorithm 3. In Algorithm 3, one can easily find that a one-to-one map between the permutation rule \(I_{p}\) and the position vector \(\mathbf{pos}_{p}=\big{\{}\mathit{pos}_{p}(i)\big{\}}_{i=0}^{M\times N-1}\) of the original plaintext has been established. For clarity, Figure 4 further illustrates the map between permutation rule \(\mathbf{I}_{p}\) and the position vector \(\mathbf{pos}_{p}=\big{\{}\mathit{pos}_{p}(i)\big{\}}_{i=0}^{M\times N-1}\) of the original plaintext image. As depicted in Figure 5, we reshape the chosen-plaintext images--\(\mathbf{I}_{1}\) and \(\mathbf{I}_{2}\)--into the position vector \(\mathbf{pos}_{p}=\big{\{}\mathit{pos}_{p}(i)\big{\}}_{i=0}^{M\times N-1}\) of the original plaintext image in the top half part, and \(\mathbf{P}_{1}\) and \(\mathbf{P}_{2}\) into the position vector \(\mathbf{pos}_{p}=\big{\{}\mathit{pos}_{p}(i)\big{\}}_{i=0}^{M\times N-1}\) of the permutation-only images in the upper half part, respectively.