# Privacy Preserving Face Recognition in Cloud Robotics: A Comparative Study
## 3 Overview of the Encryption Algorithms under Study
### Rubik's Cube Principle (RCP)  
This encryption scheme follows the strategy of Rubik's Cube Principle. In this, the gray-scale image pixels are encrypted by changing the position of the individual pixels, and this change follows the principle of Rubik's Cube. Initially, two keys are generated randomly; with these keys, image pixels are gone through the XOR operation bit by bit between odd row-wise and columns-wise. In the same way, image pixels are gone through the XOR operation bit by bit between even row-wise and columns-wise with flipped versions of two secret keys. This process is repeated until the maximum or termination criteria reached [26]. Algorithm 4 shows the detailed description of the RCP algorithm for image encryption.  
1. Let us assume an image \(I_{o}\) of size \(M\times N\), and assume it is represented with \(\alpha\)-bits. Now, two randomly generated vectors \(L_{S}\) and \(L_{D}\) of size \(M\) and \(N\), respectively. Each elements in \(L_{S}(i)\) and \(L_{D}(j)\) can take a random number between a set A of range between 0 to \(2\alpha-1\).  
2. Pre-define the maximum iterations count (ittmax), and set itr to zero.  
3. For every iterations, it is incremented by one: itr = itr + 1.  
4. For every row of image \(I_{o}\),  
(a) calculate addition of all pixels in ith row, and is calculated by  
\[\alpha(i)=\sum_{j=1}^{N}I_{0}(i,j),i=1,2,3,4,.....,M, \tag{1}\]  
(b) Now, calculate \(M\alpha(i)\) by doing modulo 2 of \(\alpha\) (i),  
(c) The ith row is shifted right or left or circular by \(L_{S}(i)\) positions (pixels of images are moved to right or left direction by \(K_{R}(i)\); after this operation, the first pixel becomes the last, and the last pixel becomes first), as per the following equation:  
\[if\bigg{\{}\begin{array}{r@{\quad}l@{\quad}l}M\alpha(i)\quad&=0\quad& right\quad&circular\quad&shift\\ M\alpha(i)\quad&\
eq 0\quad&left\quad&circular\quad&shift\end{array} \tag{2}\]  
5. Similarly, for every column of image \(I_{o}\),  
(a) calculate addition of all pixels \(\beta(i)\) in jth column, and is calculated by  
\[\beta(i)=\sum_{i=1}^{N}I_{0}(i,j),i=1,2,3,4,5....,M, \tag{3}\]  
(b) now, calculate M\(\beta(j)\) by doing modulo 2 of \(\beta(j)\).  
(c) the jth column of image is shifted up or circular or down by \(L_{D}(i)\) positions,  
by following equations:  
\[if\bigg{\{}\begin{array}{r@{\quad}l@{\quad}l}M\beta(i)\quad&=0\quad&up\quad &circular\quad&shift\\ M\beta(i)\quad&\
eq 0\quad&down\quad&circular\quad&shift\end{array} \tag{4}\]  
These steps (4 & 5) create a scrambled image \(I_{SCR}(i)\).  
6. With the help of vector \(L_{D}\), a bit-wise XOR operation is performed on each row of scrambled image \(I_{SCR}(i)\) by means of following equation:  
\[I_{1}(2i-1,j)=I_{SCR}(2i-1,j)\oplus L_{D}(j), \tag{5}\]  
\[I_{1}(2i,j)=I_{SCR}(2i,j)\oplus rot180(L_{D}(j)). \tag{6}\]  
In the above equation, \(\oplus\) shows XOR operation (bit-wise) and rot180(\(L_{D}\)) shows a flip operation on vector \(K_{C}\) from right to left.  
7. With the help of vector \(L_{S}\), the XOR operation (bit-wise) is performed on the column of scrambled image by means of following equation:  
\[I_{\text{ENC}}(i,2j-1)=I_{1}(i,2j-1)\oplus(L_{S}(j)), \tag{7}\]  
\[I_{\text{ENC}}(i,2j)=I_{1}(i,2j)rot180\oplus(L_{S}(j)), \tag{8}\]  
where \(rot180(L_{S}(j))\) shows the flip operation from left to right with respect to vector \(K_{R}\).  
8. Repeat step 1 to step 7 until itr = itrmax. 9. Finally, encrypted image \(I_{ENC}\) is generated and process is terminated; otherwise, the algorithm moves to step 3.