Image Encryption and Decryption Using Chaotic Maps and Modular Arithmetic

In this paper we have proposed a scheme which incorporates the concept of modular arithmetic and chaos theory, for image encryption and decryption. In the proposed scheme, we have used chaos theory to generate the necessary random matrix and used the same for Image encryption. For Decryption, we have used look-up table approach to find the element by element modular inverse of the random matrix and use it for decryption of an encrypted image. Our proposed scheme seems to be robust against various attacks.


Introduction
In the past few years, the non-linear dynamics and chaos theory have gained a significant role in cryptography [1][2][3][4][5][6][7][8][9]. Cryptography is nothing but the study of hiding information. The aim of cryptography is to develop a cryptosystem that can transform the original data into a non-readable data. On decryption side, the cryptosystem should be able to convert the non-readable data into a readable form. Data can be of any form such as text, audio, video or else an image. Generally, we use cryptosystem for protecting our data against any unauthorised people. Hence, cryptography allows us protection against hackers and spies. Chaotic systems have high sensitivity to the initial conditions and parameters. If a slight change has been made in these parameters, the system will run into different orbits [9]. Hence it contains strong cryptographic properties. Hence we have considered chaotic system for the cryptography of an image. In this paper, we have combined modular arithmetic and chaotic system. The paper is organised as follows. In section 2, we discuss about modular multiplicative inverse. The proposed encryption scheme is explained in section 3. The decryption process is outlined in section 4. The observed experimental results are enumerated in section 5. Section 6 deals with security analysis and section 7 draws conclusions.

Modular Multiplicative Inverse
In this paper, we have used the modular arithmetic for the proposed scheme. The modular multiplicative inverse of a number is taken and stored in a look-up table. During decryption, this look up table is made use of. Let us now see what this modular multiplicative inverse is all about.In a set Z n , the two numbers a and b are multiplicative inverse of each other if × ≡ 1( ) (1) For the modulus 10, the multiplicative inverse of 3 is 7. i.e. (3 × 7) 10 = 1 . It is possible to prove that a has a multiplicative inverse in Z n if gcd(n,a)=1. Whereaandn are said to be relatively prime.The Extended Euclidean algorithm can be used to find the multipicative inverse of b in Z n [10], [11]. Hence, using Extended Euclidean algorithm we calculate the inverse of a number and store it in a look-up table.

Proposed Encryption Scheme
We have proposed a chaotic cryptosystem and we have used three different maps (Logistic map [9], Chebyshev map [12] and Sine map). We have used modular multiplicative inverse and a look-up table for decryption.
The equations of these maps are as follows: a) Logistic map (4) All the above mentioned three maps have been used in our proposed scheme. We have chosen r value as 3.98031221556815 [13]. This r value is chosen because it gives highly chaotic sequences for these maps [13]. The reason for chaotic sequence generation is to get random values which can be used for encryption. Along with randomness, we look for low correlation and non-predictability of the system. Hence, we use the chaotic maps. In our proposed scheme, we have scaled up the sequence from 0-1 to 0-256. While scaling we have removed the decimal places to get the whole numbers.This scaling is done as the grey scale image contains pixel values ranging from 0 to 255. After scaling, we have chosen only the odd numbers. The reason for choosing the odd number is because only the odd numbers are relatively prime to the number 256. After generating the scaled odd number, we arrange the sequences in a matrix and we do element-by-element modular multiplication with the image matrix to get the encrypted image. Here the modulus value chosen is 256. The reason for modulus to be 256 is that the pixel values range from 0 to 255 in a typical grey scale or RGB image where each R,G, and B planes contain intensity values between 0 and 255.

Present Proposed Scheme
From the algorithms 1,2,and 3 shown below, we see that xx is the vector containing odd numbers and is generated using Logistic map-equation 2. xn1 is a matrix of size × generated by converting a vector xx into a matrix. Then xn1 is multiplied element by element with the three image matrices (R,G,B). Hence, we get the R,G,B components of the encrypted colour Image.
The algorithms 1,2and3 in the proposed Scheme use different chaotic maps: = 1; In algorithm 2, we use Chebyshev map. We get the negative values. In order to remove the negative values, we have introduced an AND operation. The logic × + > 0 helps us to remove the negative numbers in our selection of positive odd numbers.

Decryption
The decryption is similar to encryption in terms of modular element by element multiplication. Since the decryption is an inverse process of encryption, we generate a matrix which contains element-wise modular multiplicative inverse of the random matrix used for encryption. In order to enhance decryption speed, we go for look-up table approach [14]. This look-up table contains the modular inverse of the odd numbers which lies in the same range as modulus 256.
The Figure. 1below explains look-up  In Figure. 1, xn denotes a matrix which is formed by placing the generated sequence from the chaotic maps in zig-zag ordering. The inverse matrix dn is generated by passing it through the Look-Up-Table. From Figure. 1, it is clear that the modular multiplicative inverse for the number 163 is 11. Similarly we have modular multiplicative inverse for the rest of the matrix elements.
We then multiply the matrix got from the Look-Up-Table with the encrypted image matrices. As a result we will get a matrix containing very large values. Then we apply modulus operation to get the decrypted Image.

Experimental Results
In this section, we show the experimental results of our proposed scheme with different chaotic maps using a 512 × 512 Lenna colour Image. Look-Up- Table concept in the proposed scheme makes the decryption time to be much faster. We shall see the time performance of our scheme with the corresponding chaotic maps in the next section 6.7. We have also carried out various attacks and the results are shown in the section 6. Our proposed scheme happens to be robust and faster when compared to the other schemes.
The Figures

Key Space Analysis
The robustness of a cryptosystem depends entirely on the secret keys. These secret keys must be very sensitive and the key space should be large enough so that the brute-force attacks will fail. The key space size tells us the number of different keys that can be used for the encryption of an image.
In our experiment we have used 10 -14 precision [13]. We find that our proposed scheme is very sensitive to secret key mismatch. We have chosen the initial value of chaotic maps to be 0.20040226556816 having 10 -14 precision [13].
We have generated keys using logistic map. If the precision is 10 -14 then the size of the key space for initial condition is 2 128 . Hence the brute-force attack is difficult in our case.

Key Sensitivity Test
The secret key for our proposed scheme is produced using the logistic map. Our image encryption process is sensitive to the secret key. When a change of 1 digit is made in the secret key, we get a completely a different encrypted image [15]. The following are the steps used to test the key sensitivity of our proposed scheme:  3. Then the above two ciphered images are compared. The comparison is done by taking the absolute difference between the two ciphered images and is shown in image 5(d).
4. The result of comparison is that the image encrypted with the key value 1489035384202401 has 0.0034correlation with the encrypted image with the key value 1489035384202402. This small correlation is an indication of the large difference between the two ciphered images with a difference of 1 digit. The Figures.from 5 to 7 show the key sensitivity test for our proposed scheme using different the chaotic maps.
In our experiment, we have used 16 digit key to encrypt an image. When a slight change of 1 digit is made to this key and when the decryption is applied then the decryption of the ciphered image fails. Figure. 8 shows us that the encrypted image with the key 1489035384202401 cannot be decrypted using the key 1489035384202402 [15].
The Figures.from 8 to 10 show us the failure of decryption with a one digit change in the secret key for our proposed scheme with different chaotic maps.

Histogram Analysis
Histogram analysis is one of the security analysis which tells us the statistical properties of the ciphered image. Histogram of a ciphered image tells us how pixels in an image are distributed. It is done by plotting the number of pixels against the colour intensity levels [7,8,15]. In order to have a perfect ciphered image in terms of histogram, the histogram of the image must have uniform distribution of pixels against the colour intensity value. In our proposed scheme, we see that our method leads to this uniform distribution. Thus, our scheme do not provide any room for the statistical attacks.

Correlation Coefficient Analysis
Another type of statistical analysis is the correlation coefficient analysis. In this we analyse the correlation between two horizontally, vertically and diagonally adjacent pixels in the original Lenna image and its various encrypted images [7,8,15]. The Figure. 15tells us the correlation between two horizontally, vertically and diagonally adjacent pixels of the original image. We see that for the original image the adjacent pixels have high correlation (horizontally, vertically, and diagonally). We calculate the correlation coefficient using the following formulae: ( , ) = ( − ( ))( − ( )) Here, x and y are the intensity values of two adjacent pixels in the image. r xy is the correlation coefficient. The cov(x,y), E(x) and D(x) are given as follows: (9) We shall now calculate correlation coefficient of two adjacent pixels for the R-component of the original image and all the encrypted images. The Table 1 shows us the correlation coefficients. The correlation coefficient Table 1 explains that the correlation coefficient of the encrypted images by our proposed scheme is very less. This proves that our proposed scheme is robust when the correlation coefficient analysis is done.
The test image for the correlation coefficient analysis was Lenna × image. We randomly choose 1000 pairs of two adjacent pixels (horizontal, vertical and diagonal) and plotted in a graph against each other. From Figures. 16 to 18, it is clear that there is a very negligible correlation between the two adjacent pixels in the encrypted images.

The Maximum Deviation Measuring Factor
For measuring the quality of the encryption schemes, the maximum deviation measuring factor is used. This factor measures the deviation between the original image and the encrypted image [16]. The steps to measure this factor is as follows: 1) First we count the number of pixels of each of grayscale value in the range between 0 and 255 for both original image and the encrypted image.
2) Secondly, we calculate the absolute difference or else deviation between the original and encrypted image.
3) Lastly, we count the area under the absolute difference. This is the sum of deviations (D) and this value represent the encrytpion quality. D is given as follows: We have tested the red, green and blue components deviation of the Lenna image. All the values of the deviation seem to be very high. Thus the quality of encryption in terms of intensity is high.

Chosen/Known-Plaintext Attack
Chosen/Known-plaintext attack is one of the attacks where one can choose a set of plaintexts images and observe the corresponding cipher text images. In current era, this type of attacks occurs more frequently. In order for a ciphered image to be of highly secured, the security should be high against the known-plaintext and chosen plaintext attacks.
The XOR-ing based techniques are not secured against these types of attacks. The system is not secured even when the secret key is changed for each plain text images [17]. We found out that our proposed scheme is robust against this kind of attacks.
We shall now see how our scheme is secured against chosen/known-plaintext attack. Let us consider three × images: I, I' and J'. Here I' is the encrypted image of the image I using a key k. J' is the another cipher text image which was encrypted using the same algorithm with the same key k. I m is the mask image which was obtained by XOR-ing the plaintext image I with its corresponding cipher text image I'. If we use the XOR-ing based techniques for encryption, then we can recover the unknown plaintext image J by XOR-ing the I m mask with the unknown cipher text image J' [17]. But our proposed schemes are very much robust that there is no scope of recovering the unknown plain text image J.
If the encryption technique is XOR based then the recovery of unknown image J is possible [17]. This is done by the following equations: ' ' (14) In our proposed scheme, we have not used the XOR-ing techniques and hence our proposed scheme is robust against the chosen/known plain text attacks. From Figures. 19 to 21, we see the failed attempt to crack the cipher image of Baboon. Figure 19. Chosen/known-plaintext attack for the Logistic map. (a) Original Lenna Image, (b) Encrypted Lenna Image, (c) XOR mask, (d) Unknown cipher-text ( the original image was "Baboon"), and (e) Failed attempt to crack the cipher image of "Baboon".

Speed Performance Analysis
The security of the image is important but at the same time the speed of the proposed scheme is also important. The speed of an algorithm is one of the factors for a good encryption algorithm. We have measured the encryption and decryption time of our proposed scheme with the corresponding chaotic maps. The performance analysis was done on a computer having a specification as Intel(R) Core(TM)2 Duo CPU E7400 @2.80GHz 2.79GHz, 1.96 GB RAM. The average encryption/decryption time taken by the proposed scheme is done on 512 × 512image. The Table 3 shows the encryption and decryption time of our proposed scheme. By viewing the data, we see that the logistic map and our schemehas the least time and hence is the fastest of our proposed scheme with different chaotic maps.

Conclusions
In this paper, we have proposed encryption and decryption of an image using chaotic maps and modular arithmetic. We have dealt with three different combinations of our proposed scheme. We have made use of look-up table for faster decryption process. One of the best features of our algorithm is the simplicity as well as speed. Our proposed scheme is also robust against many attacks. In a chaos-based encryption algorithm, the relationship between one pixel and another pixel is very negligible or else nil. Our proposed scheme also depicts this property.
Out of the three different maps used, we find that the logistic map is the fastest of all and hence is considered to be the best algorithm for encryption and decryption.