# Advancement of the DRPE Encryption Algorithm for Phase CGHs by Random Pixel Shuffling
## 4 Results Discussion and Performance Analysis
### Key Space
#### 4.2.1 Remarks on Pixel Shuffling  
The data size to be managed in this work is a matrix of \(Z=N\times M\) integer values, which can be within the range [0-255], that is, 256 different values.  
Let us assume that each pixel value appears a certain number of times, denoted as \(R_{i}\); that is, \((R_{1},R_{2},R_{3},...,R_{256})\), where \(R_{i}\) can take a value within the interval [1-Z], with the restriction that the sum of all values \(R_{i}\) will equal \(Z\).  
Let us assume that we start with the \(Z\) pixels placed in a bag, and we extract them one by one without replacement to place them into a matrix of size \(N\times M\) pixels. Therefore, \(Z\) extractions must be performed. The extractions are assumed to be statistically independent.  
* Probability that the first selected pixel matches the first pixel of the image: Suppose the first pixel has the value \(j\) within the range [0-255], and it appears \(R_{j}\) times; then \[P_{1}=\frac{R_{j}}{N\times M}\] (4)
* Probability that the second extraction matches the second pixel of the image: Suppose the second pixel has the value \(k\) within the range [0-255], and it appears \(R_{k}\) times; then \[P_{2}=\frac{R_{k}}{(N\times M)-1}\] (5) However, it is also possible that it has the value \(j\), in which case, the probability would be \[P_{2}=\frac{R_{j}-1}{(N\times M)-1}\] (6)
* Following this reasoning, the probability that the \(L\)-th extraction matches the \(L\)-th pixel of the image: Suppose the \(L\)-th pixel has the value \(m\) within the range [0-255], and it appears \(R_{m}\) times but has already appeared \(n\) times previously; then \[P_{L}=\frac{R_{m}-n}{(N\times M)-(L-1)}\] (7) Iterating this process, the final probability of successfully reconstructing the image by extraction would be given by the probability of matching all the pixels of the CGH; that is, \[P=\prod_{i=1}^{Z}P_{i}=\frac{\prod_{i=1}^{Z}R_{i}!}{Z!}\] (8)  
The combinatorial explosion depends on the range of values that can be taken and the size of the matrix. In our case, the range is [0-255] and the size is \(1920\times 1080\). To make an estimation, we know that the histograms of the phases encoded in a png file are practically uniform; that is, the frequency values in these histograms tend to satisfy the following equality: \(R_{1}=R_{2}=...=R_{256}=Z/256\). In this case, we can make the following estimation:\[P=\frac{(Z/256)!^{256}}{Z!}=\frac{8100!^{256}}{2073600!} \tag{9}\]  
The factorial is an extraordinarily large number. Using [PERSON]'s approximation [48], an estimation can be made as follows:  
\[n!\approx\sqrt{2\pi n}(\frac{n}{e})^{n} \tag{10}\]  
To determine the size of this number, we can calculate the number of digits it has.  
\[\log_{10}(n!)\approx n\log_{10}(n)-n \tag{11}\]  
A quantitative approximation for the images we are using would yield the following result:  
\[P\approx\frac{(10^{23558})^{256}}{10^{11024760}}=\frac{10^{6030848}}{10^{1102 4760}}=\frac{1}{10^{4993912}} \tag{12}\]  
The denominator contains nearly 5 million digits, making the probability of reconstructing the \(N\times M\) matrix practically zero. If a processing machine required \(10^{-12}\) s per possibility, it would take \(10^{4993912}\times 10^{-12}\) s, an extraordinarily long period compared with any human or even geological time scale (for reference, the age of the universe is in the order of \(10^{17}\) s).  
This pixel shuffling method of a scene, in which a mathematical transformation operation has been previously applied (the synthesis of a CGH can be likened to this operator), already provides a fairly robust encryption against statistical analysis (the phase distribution in a histogram is practically flat) or brute force attacks.