# Cryptanalysis of Permutation-Diffusion-Based Lightweight Chaotic Image Encryption Scheme Using CPA
## 3 Cryptanalysis of the Original Scheme
### Obtain the Permutation Rule \(l_{p}\)
Obviously, one can deterministically find out all of the correct plaintext elements by one-to-one mapping all pixels of the permutation-only image into the original plain image. Case 2: If the size of a plaintext image \(\mathbf{I}\) is \(512\times 512\), only three chosen plaintext images will be required to obtain the permutation rule \(\mathbf{I}_{p}\). For the plaintext image \(\mathbf{I}\) of size \(512\times 512\) which will be restored using three chose plaintext images, the position vector \(\mathbf{pos}_{p}=\big{\{}\mathit{pos}_{p}(i)\big{\}}_{i=0}^{M\times N-1}\) of all pixels in the plaintext image can be rearranged row by row in the matrix \(\mathbf{A}\), where each element  
Figure 5: A schematic diagram of permutation correspondence. includes three digits in base 256 across the character set \([0,\ 1,\ 2,\ \cdots,\ 255]\) to express the position of \([0,\ 1,\ 2,\ \cdots,\ 512\times 512-1]\). \[A=\left[ \begin{array}{cccccc}(0)(0)(0)&\cdots&(0)(0)(255)&(0)(1)(0)&\cdots&(0 )(1)(255)\\ \vdots&\ddots&\vdots&\vdots&\ddots&\vdots\\ (0)(254)(0)&\cdots&(0)(254)(255)&(0)(255)(0)&\cdots&(0)(255)(255)\\ (1)(0)(0)&\cdots&(1)(0)(255)&(1)(1)(0)&\cdots&(1)(1)(255)\\ \vdots&\ddots&\vdots&\vdots&\ddots&\vdots\\ (3)(254)(0)&\cdots&(3)(254)(255)&(3)(255)(0)&\cdots&(3)(255)(255)\\ \end{array} \right]_{512\times 512}. \tag{13}\]  
In a similar manner, the permutation rule of the original cryptosystem can also be revealed by the three chosen-plaintext images. Here, we will not describe the similar process again. Once permutation rule \(I_{p}\) is accurately revealed, the exploited test image--**I**--in the original cryptosystem can be restored by decrypting the permutation-only image **P**. Algorithm 4 also describes the generation of the exploited test image **I** in the original cryptosystem in detail. Apparently, the permutation-only image **P** can be successfully obtained. ```
1:The permutation-only image **P**, and \(n\) pairs of permutation-only images of chosen images
2:The deciphering image **I**
3:procedureDe_confusion(**P**, **P**\({}_{1}\), **P**\({}_{2}\), \(\ldots\), **P**\({}_{n}\))
4:\(M\), \(N\leftarrow\)size(**P**) // Get the size of the image
5:\(\textbf{I}\leftarrow\)zeros(\(M\), \(N\))
6:\(I_{p}\), \(\textbf{B}\leftarrow\)Rule(**P\({}_{1}\), **P\({}_{2}\), \(\ldots\), **P\({}_{n}\)) // Invoke algorithm 2 to obtain the permutation rule
7:\(x\), \(y\gets 0\)
8:for\(i\)from \(1\)to\(M\)
9:for\(j\)from \(1\)to\(N\)
10:\(x\leftarrow\)floor(\(B(i,j)\) / \(M\)) // Obtain the original row number
11:\(y\leftarrow\)mod(\(B(i,j)\), \(M\)) // Obtain the original column number
12:\(I(x,y)\gets P(i,j)\) // Return the permutation-only image
13:end
14:end
15:end
16:endprocedure
```  
**Algorithm 4** Proposed confusion attack algorithm  
For clarity and the ease explanation, Figure 6 shows the process of chosen-plaintext attack for obtaining the permutation rule \(I_{p}\). In Figure 6, the first, second, and third columns represent plaintext, final ciphertext, and permutation-only images, respectively; Figure 6(a1,b1) represents the two original chosen-plaintext images; Figure 6(a2,b2) represents the final ciphertext image of Figure 6(a1,b1) encrypted by the original cryptosystem; and Figure 6(a3,b3) is the permutation-only images obtained by decrypting the final ciphertext images Figure 6(a2,b2) with the revealed diffusion secret key \(R\) in the previous section. Once the permutation-only images are obtained, the original plaintext image can be found by one-to-one maps the permuted positions into the original positions, as mentioned above. In addition, the element of the first pixel position \((1,\ 1)\) of the original plaintext image is also marked for analyzing the permutation rule of the original scheme. After obtaining the permutation-only image, the element of the first pixel position \((1,\ 1)\) of the original plaintext image has been scrambled into position \((93,\ 45)\) in the permutation-only image, indicating that based on [PERSON] et al. 's work [18], a one-to-one map can be successfully established.