Image Encryption Using Chaos Maps
Aarya Arun, Indu Rallabhandi, Rachana Jayaram
November 2019
1 Introduction
1.1 What is encryption?
The process of encoding a message so that only authorised parties can access
it is called encryption.The process of encrypting an image is called image
encryption.
1.2 What is chaotic behavious?
Erratic-looking temporal behaviour is a superficial indicator of possible chaos.
Chaotic sequences look haphazard but are deterministic. Chaotic sequences
are also extremely sensitive to small changes in the initial condition. In fact,
the ’Butterfly Effect’ is based on this very sensitivity. Most chaotic sequences
are calculated iteratively, with the value in each iteration being dependent on
the previous one.
1.3 Chaos maps
Chaotic systems are a simple sub-type of nonlinear dynamical systems. They
may contain very few interacting parts and these may follow very simple rules,
but these systems all have a very sensitive dependence on their initial conditions.
When it comes to chaos, a map (or a function) is an equation or a rule which
specifies how a dynamic system evolves with time.
An n-dimensional map is a function that deals with n features.
1.4 Chaos Maps for encryption
Traditional encrypting mechanisms AES and RSA exhibit some drawbacks and
weakness in the encryption of digital images and high computing
• Large computational time for large images
• High computing power for large images
1
Consequently, there might be better techniques for image encryption.
A few chaos based algorithms provide a good combination of speed, high
security complexity, low computational overheads. Moreover, certain chaos-
based and other dynamical systems based algorithms have many important
properties such as
• sensitive dependence on initial parameters
• pseudorandom properties
• ergodicity
• non periodicity
Chaos technology encrypts images such that the possibility of deciphering is
reduced greatly as the cipher text presents a randomness. Chaos based encryp-
tion is a very important means of modern digital encryption. The statistical
characteristic if the original image is transformed, thereby increasing the diffi-
culty of unauthorized breaking of the encryption.
2 Proposal
Images are one of the most important and popular forms of multi-media. Along
with being stored on devices like phones, CD’s, pen drives etc, images are shared
across multiple platforms and across the internet. With this kind of large scale
usage of images, it has become more difficult to keep images secure and safe
from unauthorised users. With a more secure system, images can be shared and
used more confidently. Most encryption algorithms were used to encrypt text
messages. The conventional algorithms are not suitable for image encryption
as images generally have large data capacity and require large computational
volume. An efficient algorithm for image encryption is needed to make it difficult
for unauthorised users to view or use the images.
3 Implementation
The above proposal can be implemented in the following way:
Arnold cat map Arnold’s Cat chaotic mapping of two dimensions can be
used to change the position of the pixel of the image without removing any
information from the image. The pixel image can be assumed by:
S = {(x, y) |x, y = 0, 1, 2...N − 1}
The 2-D image of Arnold’s cat map can be written as:
0
x x
=A× × (modn)
y0 y
2
1 p
x
q (pq + 1) × × (modn)
y
Where p and q are positive integers, the determinant (A) = 1. (x ’, y’) is
the new position of the original pixel position (x, y), when Arnold’s Cat Map
algorithm performed once.
Implementation of Arnold cat Map:
ArnoldCatTransform(img, num):
rows, cols
ch <- img.shape
n <-rows
arnoldi mg < −np.zeroes([rows, cols, ch])
f orxinrange(0, rows) :
f oryinrange(0, cols) :
arnoldi mg[x][y] < −img[(x + y)
returnarnoldi mg
ArnoldCatEncryption(imageN ame, key) :
img < −cv2.imread(imageN ame)
f oriinrange(0, key) :
img < −ArnoldCatT ransf orm(img, i)cv2.imwrite(imageN ame.split(0 .0 )[0]+
”A rnoldcatEnc.png”, img)
returnimg
Duffing map:
T heDuf f ingM apisa2Dimplementationof achaosmapthatf ollowsthef ollowingf unction :
xn+1 = y n
y n+1 = −bxn + ay n − y 3
T hismaphaschaoticbehaviourf orb = 0.2anda = 2.75.
Algorithm to encrypt an image of size m:
Using this map we generate two random sequences savex1 , savey1 and savex2 ,
savey2 of size m2 where savexi and saveyi contain the x and y values generated
from the function where each ith set has started from a different initial value of
x and y.
x1 =-0.04
y1 =0.2
3
for i in range(1,m2 ):
xi+1 = y
yi+1 = -0.2x + 2.75y - y3
savex1 =xi+1
savey1 =yi+1
x=xi+1
y=yi+1
Similar iterations are run for initial values x2 =0.23 and y2 =-0.13 but saved to
savex2 and savey2 .
for i in range(0,m2 ):
h1 [i]=0 if savex1 <savex2 , else 1
h2 [i]=0 if savey2 <savey1 , else 1
encryptedimage= bitwise-xor(h1,h2,imagematrix)
decryptedimage=bitwise-xor(h1,h2,imagematrix)
h1 and h2 can be found by knowing the initial values x1 , x2 , y1 ,y2 , which
makes them the secret keys for this encryption.
Henon map:
It is a 2-D dynamic system. Two different chaotic sequences are generated by
the Henon chaotic map. These sequences are then applied to the row and col-
umn permutations of the original/plain image. XOR models are used to produce
pixel values diffusion by unimodal skew tent map. Hussain’s substitution box
is used to substitute each pixel into a new random pixel in the last stage of the
algorithm.
Consider:
x( i + 1) = y( i + 1) + 1 − αx2i
y( i + 1) = βxi
Where, the initial point is (x0 , y0 ) and α, β are the initial parameters. Each
point (xn , yn ) is mapped to a new point (x( n + 1), y( n + 1)) through the Henon
map.
Algorithm for Henon map implementation:
for i in range (m2 ):
x( i + 1) = y( i + 1) + 1 − αx2i
y( i + 1) = βxi
bit=0 if xi <=0.4 else 1
(Only the value of x is used. This is appended as rows of lists of 8-bit numbers,
so that we can have a bitwise xor with the image).
4
encryptedimage=bitwisexor(imagematrix,bitmatrix for R,G,B values in each
pixel of imagematrix)
decryptedimage=bitwisexor(imagematrix,bitmatrix for R,G,B values in each
pixel of imagematrix)
The bit matrix can be generated by knowing the inital values applied in the
Henon map, making them the secret keys in this operation.
Logistic map with key mixing: The logistic map instead uses a nonlin-
ear difference equation to look at discrete time steps. It’s called the logistic
map because it maps the population value at any time step to its value at the
next time step.
The basic formula is: X( t + 1) = r.Xt .(1 − Xt )
where Xt is a number between zero and one that represents the ratio of existing
population to the maximum possible population. The values of interest for the
parameter r (sometimes also denoted ) are those in the interval [0,4].
For this implementation we have included key mixing based on the paper.
The initial values of the chaos map is recalculated after every pixel encryption
based on the previous encryption value as well as the changed key value.
3.1 Proposal including modified paper implementation:
Arnold-Henon composite map
Based on the paper "A Chaotic Cryptosystem for Images Based on Henon and
Arnold Cat Map" by Ali Soleymani, Md Jan Nordin, and Elankovan Sundarara-
jan, a modified version of the scheme proposed in the paper has been imple-
mented as part of this project.
Algorithm:
• Use Henon map to generate two secret images A and B based on the secret
key (i.e initial value of the Henon map) where the x values make up A
and y values generated make up B and this is done m2 times, so that it
can correspond to each pixel in the original image using:
pixA.append(abs(math.floor(xN*paramlambda))%256)
pixB.append(abs(math.floor(yN*paramgamma))%256)
where
paramlambda=math.floor(x*m*5000)
paramgamma=math.floor(y*m*5000)
paramlambda and paramgamma can be found using x y, or the initial
values, and therefore are not part of the secret key, as they can be derived
from it.
5
• Simultaneously, we record values in arrays Pvalues and Qvalues as follows:
Pvalues.append(abs(math.floor(savethexmat[i]*math.pow(10,14)))%alpha)
Qvalues.append(abs(math.floor(savetheymat[i]*math.pow(10,14)))%beta)
where
alpha=26010
beta=15080
Here, 26010 and 15080 were randomly chosen because they were the dates
for Republic Day and Independence Day. Thus, alpha and beta too come
under the secret key.
• Run the Arnold-Cat map m/3 times on the original image with the matrix-
multiplication algorithm mentioned earlier in the paper, but with different
values of P and Q based on the iterator i, with the values being taken from
the lists
Perform a bitwise XOR of secret images A and B, and then run the Arnold-
Cat algorithm on the xor-ed imaged 5m/7 times.
• Note: m/3 and 5m/7 are values chosen to be part of the alogirthm as the
algorithm was found to be most robust for these values. As such, these
can be found through knowing the image size and are public knowledge in
terms of the values of m/3 and 5m/7 and do not form part of the secret
key.
• Perform a bitwise XOR of the final images obtained in the previous step
and the step before it. This is the encrypted image.
4 Analysis
The measure the effectiveness and the security of the encryption algorithms we
have used three analyses - namely, Intensity histogram analysis, Adjacent pixel
autocorrelation test and the key sensitivity tests.
4.1 Histogram Analysis
The ciphertext image histogram analysis is one of the most straight-forward
methods of illustrating the image encryption quality. A good image encryption
method tends to encrypt a plaintext image to a random incomprehensible form.
Thus a good image encryption technique generates a cipher image that has a
uniformly distributed intensity histogram.
Figures 3, 4 and 5 show the histograms for the various encryption schemes
discussed. The Arnold cat encryption system has an identical intensity his-
togram to the original image. This is because the Arnold Cat method essentially
just shuffles the pixels but does not change any pixel values. The logistic map
6
Figure 1: The original image
Figure 2: The intensity histogram for original image
based encryption system has the most uniform histogram indicating that is an
effective encryption algorithm.
4.2 Adjacent Pixel Autocorrelation Test
Since images exhibit high information redundancy, it is desirable to have an
encryption algorithm that breaks this redundancy. Thus as a metric of encryp-
tion performance we find the correlation between adjacent pixels in a direction
(Horizontal, Vertical or Diagonal). We have considered the Horizontal direction.
For this test, 1024 random pixels are picked up from the image and its cor-
relation between it’s right most neighbour is found and plotted. For a good
algorithm, the correlation plot should appear random with no discern able pat-
tern.
Figures 6, 7, 8 and 9 shows the Adjacent pixel autocorrelation plots for the
original image and its encrypted forms. shows that there is high information
redundancy in the original image with a clear linear pattern in the graph. The
Arnold cat map produces a cipher image with less obvious patterns. The out-
come of the autocorrelation test for the Arnold cat map relies heavily on the
number of iterations of transformations preformed. The autocorrelation graph
7
Figure 3: The intensity histogram for Arnold cat map
Figure 4: The intensity histogram for Henon map
for the image encrypted with logistic chaos maps seems to be more random than
the graph corresponding to the Henon encrypted image, once again showing that
logistic chaos maps with key mixing functions as a better algorithm.
4.3 Key sensitivity
An ideal image encryption algorithm should be sensitive with respect to the
secret key i.e a small change in the key should produce a completely different
encrypted image.
To test the key sensitivity the we encrypt the plain image with the three
algorithms. We then try decrypting them with a slightly changed key. Figure
? shows us that for the Arnold cat algorithm, while a change in key doesn’t
decrypt the image correctly,the resultant image has discernible features that
appear similar to the plain image.This is due to the fact that on applying a
8
Figure 5: The intensity histogram for Logistic map
certain number of Arnold Cat transformations, the initial image can be easily
recovered. By applying brute force it becomes possible for a person without a
key to decrypt an image encrypted using Arnold cat maps. This proves that the
Arnold cat algorithm, owing to its periodicity is unsafe for practical use. Both
Henon map and Logistic map encryption appear to be sensitive to key changes.
9
Figure 6: Intensity histogram for Duffing Map
Figure 7: Adjacent pixel auto-correlation for the original image
10
Figure 8: Adjacent pixel auto-correlation for the Arnold Map
Figure 9: Adjacent pixel auto-correlation for the Henon Map
11
Figure 10: Adjacent pixel auto-correlation for the Logistic Map
Figure 11: Auto-correlation plot for Duffing Map
12
Figure 12: Key sensitivity for Arnold Map
Figure 13: Key sensitivity for Henon Map
Figure 14: Key sensitivity for Logistic Map
13
Figure 15: The original image for Arnold-Henon map
Figure 16: Histogram for original image before Henon-Arnold composite map
14
Figure 17: Histogram for image after Arnold encryption in the Henon-Arnold
composite map
15
Figure 18: Histogram for Henon-Arnold composite
Figure 19: Auto-correlation for original image before Henon-Arnold map
16
Figure 20: Auto-correlation plot for Henon-Arnold composite map
17