# An Image Encryption Algorithm Based on Hyperchaotic System and Variable-Step Josephus Problem

Authors: Xuncai Zhang; Lingfei Wang; Yanfeng Wang; Ying Niu; Yinhua Li
Journal: International Journal of Optics
 (2020)

---

## Abstract

In this paper, an image encryption algorithm based on a hyperchaotic system and variable-step Josephus problem is proposed. Based on an in-depth analysis of the classic Josephus problem, a new variable-step Josephus problem that combines the pseudorandom sequence with the Josephus problem is proposed. Firstly, the hash value of the plaintext image is calculated, which is converted to the initial value of the chaotic system. Secondly, the chaotic system is iterated to generate four pseudorandom sequencesX, Y, Z, and W. The sequences X, Y, and Z are input as parameters into the variable-step Josephus function to scramble the positions of the rows, pixel bits, and columns of the image, respectively. Finally, the elements of the sequence W and the image pixels are used to perform the addition operation. According to the experiments, the information entropy of the encrypted image with size 256∗256 reaches 7.997 and the adjacent correlations in three directions are within ±0.01. The experimental results show that image encryption algorithm proposed in this paper has plaintext sensitivity and can resist the common attacks.


---

## Body

## 1. Introduction

With the rapid development of modern information technology, more and more image information is transmitted on social networks, and many of these digital images carry private information. How to protect private information from being leaked has become a research hotspot [1]. Some traditional encryption methods such as Data Encryption Standard (DES) or Advanced Encryption Standard (AES) are mainly used for text information. Unlike text information, there are some inherent characteristics such as strong correlation and high redundancy between adjacent pixels in digital images. Therefore, the traditional encryption algorithm has the disadvantage of low efficiency when encrypting digital images [2]. Based on the huge demands for protecting information security, in recent years, many researchers have proposed a number of new encryption algorithms to protect information security [3–8]. Thus, finding a suitable image encryption algorithm has been the goal pursued by researchers.In 1997, Fridrich proposed an encryption algorithm based on the chaotic map, which applied the chaotic system to image encryption for the first time [9]. The chaotic system is a kind of nonlinear dynamic system [10]. It has complex pseudorandomness, neither periodicity nor convergence. The chaotic system is very sensitive to the initial values of the system. Slight changes in the initial values will affect the evolution of the whole system, it is of great value in cryptography. Because of the sensitivity to the initial values and the characteristics of strong track ergodicity, the chaotic system is often used as the pseudorandom number generator. The encryption algorithm using the chaotic system has high security, which can make up for the shortcomings of the traditional encryption algorithm. In recent years, many image encryption algorithms based on chaotic systems have been proposed, and chaotic systems have gradually evolved from low-dimensional chaotic systems to hyperchaotic systems, multilevel chaotic systems, and hybrid chaotic systems [11–13]. These new chaotic systems enrich the content of cryptography.However, most of the previous chaotic-based encryption technologies are based on low-dimensional discrete chaotic maps [14–17]. In view of the limitation of computational accuracy, low-dimensional chaotic systems have the weaknesses of small periods and fewer periodic orbits, leading to weak cryptographic systems security. In order to overcome the fixed point and dynamic key space problems of one-dimensional chaotic systems, the literature [18] upgrades two one-dimensional chaotic maps into two-dimensional chaotic maps, and then encrypts the image. Hua et al. [19] proposed a two-dimensional chaotic sequence generation model combining a sine map and logistic map in 2015. The model uses sine mapping and parameters to adjust the output of a logistic map to enhance the nonlinearity of the two-dimensional chaotic sequence. And randomness improves the security of the encryption system to a certain extent. Due to its large key space and two or more Lyapunov exponents, hyperchaotic systems have more complex and unpredictable nonlinear behaviors. They have great application potential in the field of image encryption and have aroused strong research interest among scholars. In 2014, Benyamin proposed a simple, sensitive, and secure image encryption algorithm based on hyperchaotic systems [20]. This algorithm uses the randomness of pseudorandom sequences generated by hyperchaotic systems, and uses only one scrambling process to achieve a good scrambling effect. The chaotic sequence generated by the hyperchaotic system is a pseudorandom sequence, and its structure is very complex and difficult to analyze and predict. Therefore, the hyperchaotic system can improve the security of our image encryption system. This article will also use hyperchaotic systems to increase the security of the system.While new chaotic image encryption algorithms are constantly proposed, cryptographic analysis of the chaotic image encryption algorithms is also continually carried out. Many image encryption algorithms based on chaotic systems have been cracked due to their inability to resist selected-plaintext attacks and known-plaintext attacks [21]. Some studies combine other encryption techniques to improve the security of chaotic image encryption [22]. In 2012, Ye and Wong proposed a new algorithm for image encryption using the hyperchaotic system and DNA sequence [23]. This algorithm uses a four-dimensional hyperchaotic system to generate pseudorandom sequences, converts pseudorandom sequences into DNA molecular sequences, and performs image diffusion operations. This algorithm can effectively resist plaintext attacks and has good encryption effect. In 2018, Wang et al. proposed an encryption algorithm based on the combination of Josephus traversal and four one-dimensional chaotic systems [24], which used Josephus traversal to scramble pixel positions and the chaotic system to displace pixels. The analysis results show that the algorithm satisfies the basic requirements of image encryption algorithm. In the same year, Patro and Acharya proposed a secure multilevel permutation operation to encrypt color image [25], and the proposed encryption technique uses three levels of permutation operation to permutation color image.To improve the coupling of the confusion and diffusion structure and improve the efficiency of encryption, image encryption algorithms based on pixel bit position permutation are widely studied. The permutation of the pixel bit can not only change the position of the bit but also diffuse the pixel value. In this paper, based on the traditional Josephus traversal method and the pseudorandom sequence generated by the hyperchaotic system, a random-step Josephus traversal method is proposed and applied to image scrambling process. This scrambling method simplifies the scrambling process by eliminating the need to sort the pseudorandom sequences, and the degree of scrambling cipher using this scrambling method is no less than that of the chaotic sequence sorting scrambling algorithm.The remaining parts of this paper are organized as follows: Section2 introduces the basic theory of the chaotic system and Josephus problem. Section 3 introduces the encryption scheme, and Section 4 analyzes the security of this scheme. The last section concludes the paper.


## 2. Fundamental Theory

### 2.1. Josephus Problem

The Josephus problem is a counting-out problem, and it originated from the story of the famous Jewish historian Josephus [26]. When the Jews were invaded by the Romans, Josephus and his friends were hiding in a hole with 39 Jews. These 39 Jews did not want to be caught by the enemies, so they decided to suicide. They stood in a cycle and reported numbers one by one. The man who reported the number 3 must suicide, then restart counting from the next person. However, Josephus and his friends did not want to die. How to be the last two people to be recycled? Josephus carefully calculated and placed him and his friends in the 16th and 31st positions. Finally, they escaped from the death game.The Josephus problem is described as follows: rearrangingM elements into a circle. Then, we repeat looping the circle by deleting the Nth element and restart counting by the N + 1th element [24, 27]. We repeat doing these operations until the last element is selected. The Josephus problem is expressed as a function f (M, N). For example, the solution of the function f(8, 3) is to rearrange the elements {1, 2, 3, 4, 5, 6, 7, 8} in a circle, then loop the circle, and delete the 3rd element. In this Josephus problem, the elements that are sequentially deleted in the circle are {3, 6, 1, 5, 2, 8, 4, 7}. There is another solution to these problems. Still taking f(8, 3) as an example, first we rearrange the elements {1, 2, 3, 4, 5, 6, 7, 8} into a one-dimensional sequence; then, the total of these elements is 8, we calculate mod (3, 8) = 3 and delete the 3rd element which is 3. Then, we rearrange the remaining elements into a new sequence {4, 5, 6, 7, 8, 1, 2}, because the total of the elements in the new sequence is 7, and we calculate mod (3, 7) = 3 and delete the 3rd element in the new sequence which is 6. Repeat doing these operations until the last element is selected. By using this method, the Josephus problem can be solved quickly.In order to increase its diversity, some scholars had added the starting pointS to the original rule and expanded the Josephus function as f(M, N, S). This method can choose the starting point in the Josephus circle, then the Josephus problem is more interesting. On the basis of the expanded Josephus problem, Guo et al. added the cycle direction and the number space to the Josephus problem and extended the Josephus function to f(M, N, S, D, L) [28]. The parameter D is the cycle direction. When D = 1, it represents a clockwise loop will be done, and when D = −1, it represents a counterclockwise loop will be done. The parameter L is the number space, and it represents report one number every L counts.This paper continues to improve the Josephus problem based on the above expansion methods and proposes a variable-step Josephus problem. This method combines the Josephus problem with the chaotic system and expands the parameterN into a pseudorandom sequence N′=N1′,N2′,…,NM′. When traversing the Josephus circle, the parameter N in the ith looping is N = ni′. Because the elements in sequence N′ have pseudorandomness, they can be expanded infinitely, and the solution of the Josephus problem is greatly increased. For example, when N′ = {1, 2, 3, 4, 5, 6, 7, 8}, the result of the function f(8, {1, 2, 3, 4, 5, 6, 7, 8}, 1, 1, 0) is {1, 3, 6, 4, 5, 2, 7, 8}.The proposed method can also be used to expand parametersD and L, and it will not be described here. Finally, this expanded Josephus problem will have a solution method in M!


### 2.2. Hyperchaotic System

In 2019, Zhang et al. proposed the new hyperchaotic system, which is used to scramble and permute operations in this encryption algorithm [29]. The definition of the hyperchaotic system is shown:(1)x˙=ay−bx,y˙=z−fcx−dxy,z˙=gz−w−cx−dxy,w˙=ez−w,.where a, b, c, d, e, f, and g are the system parameters. When a = 1.55, b = 1.24, c = 0.25, d = 0.05, e = 2.6, f = 0.21, and g= 0.48, the system is in a hyperchaotic state. It is proved in the reference that when the chaotic system is in a hyperchaotic state, it has positive Lyapunov coefficients. This chaotic system has passed the NIST test [29], and it has extreme security. Iterating the hyperchaotic system by the Runge–Kutta method with the step size of 0.002, the phase diagram of the hyperchaotic system is shown in Figure 1.Figure 1
The phase diagram of the hyperchaotic system.
(a)(b)(c)(d)


## 2.1. Josephus Problem

The Josephus problem is a counting-out problem, and it originated from the story of the famous Jewish historian Josephus [26]. When the Jews were invaded by the Romans, Josephus and his friends were hiding in a hole with 39 Jews. These 39 Jews did not want to be caught by the enemies, so they decided to suicide. They stood in a cycle and reported numbers one by one. The man who reported the number 3 must suicide, then restart counting from the next person. However, Josephus and his friends did not want to die. How to be the last two people to be recycled? Josephus carefully calculated and placed him and his friends in the 16th and 31st positions. Finally, they escaped from the death game.The Josephus problem is described as follows: rearrangingM elements into a circle. Then, we repeat looping the circle by deleting the Nth element and restart counting by the N + 1th element [24, 27]. We repeat doing these operations until the last element is selected. The Josephus problem is expressed as a function f (M, N). For example, the solution of the function f(8, 3) is to rearrange the elements {1, 2, 3, 4, 5, 6, 7, 8} in a circle, then loop the circle, and delete the 3rd element. In this Josephus problem, the elements that are sequentially deleted in the circle are {3, 6, 1, 5, 2, 8, 4, 7}. There is another solution to these problems. Still taking f(8, 3) as an example, first we rearrange the elements {1, 2, 3, 4, 5, 6, 7, 8} into a one-dimensional sequence; then, the total of these elements is 8, we calculate mod (3, 8) = 3 and delete the 3rd element which is 3. Then, we rearrange the remaining elements into a new sequence {4, 5, 6, 7, 8, 1, 2}, because the total of the elements in the new sequence is 7, and we calculate mod (3, 7) = 3 and delete the 3rd element in the new sequence which is 6. Repeat doing these operations until the last element is selected. By using this method, the Josephus problem can be solved quickly.In order to increase its diversity, some scholars had added the starting pointS to the original rule and expanded the Josephus function as f(M, N, S). This method can choose the starting point in the Josephus circle, then the Josephus problem is more interesting. On the basis of the expanded Josephus problem, Guo et al. added the cycle direction and the number space to the Josephus problem and extended the Josephus function to f(M, N, S, D, L) [28]. The parameter D is the cycle direction. When D = 1, it represents a clockwise loop will be done, and when D = −1, it represents a counterclockwise loop will be done. The parameter L is the number space, and it represents report one number every L counts.This paper continues to improve the Josephus problem based on the above expansion methods and proposes a variable-step Josephus problem. This method combines the Josephus problem with the chaotic system and expands the parameterN into a pseudorandom sequence N′=N1′,N2′,…,NM′. When traversing the Josephus circle, the parameter N in the ith looping is N = ni′. Because the elements in sequence N′ have pseudorandomness, they can be expanded infinitely, and the solution of the Josephus problem is greatly increased. For example, when N′ = {1, 2, 3, 4, 5, 6, 7, 8}, the result of the function f(8, {1, 2, 3, 4, 5, 6, 7, 8}, 1, 1, 0) is {1, 3, 6, 4, 5, 2, 7, 8}.The proposed method can also be used to expand parametersD and L, and it will not be described here. Finally, this expanded Josephus problem will have a solution method in M!


## 2.2. Hyperchaotic System

In 2019, Zhang et al. proposed the new hyperchaotic system, which is used to scramble and permute operations in this encryption algorithm [29]. The definition of the hyperchaotic system is shown:(1)x˙=ay−bx,y˙=z−fcx−dxy,z˙=gz−w−cx−dxy,w˙=ez−w,.where a, b, c, d, e, f, and g are the system parameters. When a = 1.55, b = 1.24, c = 0.25, d = 0.05, e = 2.6, f = 0.21, and g= 0.48, the system is in a hyperchaotic state. It is proved in the reference that when the chaotic system is in a hyperchaotic state, it has positive Lyapunov coefficients. This chaotic system has passed the NIST test [29], and it has extreme security. Iterating the hyperchaotic system by the Runge–Kutta method with the step size of 0.002, the phase diagram of the hyperchaotic system is shown in Figure 1.Figure 1
The phase diagram of the hyperchaotic system.
(a)(b)(c)(d)


## 3. Encryption Scheme

The encryption scheme consists of key generation, scrambling process, and permutation process. The details of these processes are as follows.


### 3.1. Key Generator

This encryption scheme uses SHA-256 algorithm as a key generation function. The SHA-256 algorithm is a type of hash function, and it can convert any length of data into a series of 256-bit binary hash sequences. The SHA-256 algorithm has a key space of 2128, which can resist brute force attack. By inputting the original image into the SHA-256 algorithm, a 256-bit binary sequence H as the key of the encryption algorithm is obtained. The hyperchaotic system used for encryption algorithm has four initial values. In order to obtain these initial values, the sequence H is divided into 32 equal-length sequences as h1, h2, h3, …, h32, and then the initial values x1, y1, z1, w1 of the hyperchaotic system are calculated by(2)x1=h1⊕h2⊕…h7⊕h8256+x1′,y1=h9⊕h10⊕…h15⊕h16256+y1′,z1=h17⊕h18⊕…h23⊕h24256+z1′,w1=h25⊕h26⊕…h31⊕h32256+w1′..Here,x1′,y1′,z1′,w1′ are the given initial values. After the initial values are obtained, the chaotic system is iterated and the values of the first 1000 iterations are discarded to remove the transient effect. Then, four pseudorandom sequences X, Y, Z, and W for scrambling and permutation are obtained.


### 3.2. Scrambling Method

Scrambling is a commonly used method for changing the position of the pixels. It can be applied to encrypt the sequence with a certain rule. The scrambling method used in this paper is matching the position of the elements in the original sequence with the position of the elements in the pseudorandom sequences=s1,s2,s3,…,sM of equal length, and then the new sequence s′=s1′,s2′,…,sM′ is obtained by rearranging the sequence s=s1,s2,s3,…,sM under a certain rule. The original sequence is scrambled to a new sequence according to this rule and the encrypted sequence is obtained. The flowchart of the scrambling process is shown in Figure 2. The decryption process of the scrambling method is the inverse process of encryption, and it will not be described again.Figure 2
The flowchart of the scrambling process.In this paper, the scrambling method is used to scramble the pixel position and the bit position. In this pixel position scrambling method, the parameterN′ in Josephus problem is generated by the hyperchaotic system and the index sequence s′=s1′,s2′,…,sM′ is obtained. The pixel sequence is scrambled by the rule of s = {1, 2, 3, …, M}⟶s′=s1′,s2′,…,sM′. In the bit position scrambling method, the bit position in pixel is disordered by the fixed step size Josephus problem. The pixels in the image can be converted to 8-bit binary numbers. So, the total number M is 8, and the index sequence generated by the Josephus problem is s′ = f(8, N). Finally, the bits of the pixel are scrambled by the rules of s = {1, 2, 3, 4, …, 8}⟶s′=s1′,s2′,…,s8′.


### 3.3. Pixel Permutation

This paper uses a 2-bit binary number addition and subtraction method to perform a permutation operation on the pixels. In the 2-bit binary numbers, there is a special addition and subtraction rule regardless of the carry and borrow in the addition and subtraction process. Only the last two binary digits in the operation result are retained. For example, ‘10’ + ‘11’ = ‘01’ and ‘01’ − ‘10’ = ‘11’. There are 32 possible cases when using this addition and subtraction rules. These 32 cases are shown in Table1.Table 1
32 cases in the 2-bit binary numbers addition and subtraction rules.
+00011011−0001101100000110110000111001010110110001010011101010110001101001001111110001101111100100When permuting two pixels with the 2-bit binary number addition and subtraction rules, the pixels should first be converted into two 8-bit binary numbers, and then the 8-bit binary numbers are split into 2-bit binary numbers. For example, using 225 and 108 for two-bit binary number addition and subtraction, first 225 and 101 should be converted into 8-bit binary digits “11100001” and “01101100”, respectively, and then the two numbers are split into 2-bit binary numbers for addition. The result of the calculation is “00001101”. We convert this number into a decimal number, and the result is 13. The two-bit binary addition and subtraction operations are reciprocal process.


### 3.4. Encryption Process

In this paper, an image encryption algorithm based on the hyperchaotic system and variable-step Josephus problem is proposed. Assuming the size of the original image is height × width, the steps of the encryption scheme are as follows:Step 1. A 256-bit binary sequence H is obtained by inputting the original image into the SHA-256 function, and the initial values of the hyperchaotic system are calculated by formula (2)Step 2. Four pseudorandom sequences X, Y, Z, and W are obtained by iterating the hyperchaotic system. And in the chaotic system, the values of the first 1000 iterations are discarding to remove the transient effect.Step 3. The sequence X is converted into a new matrix X1 by formula (3), and then we input each row sequence in the matrix X1 as the parameter N′ into the Josephus problem function to scramble each row pixel sequence in the original image. The cipher image I1 is obtained:(3)X1=reshapemod106∗102∗X:−102∗X:,256+1,height,width.Step 4. Converting the sequence Y into a new matrix Y1 by formula (4), each element in matrix Y1 is in the interval [1,29]. The elements are used in matrix Y1 as the parameter N to scramble the pixel corresponding to its position in cipher image I1 to achieve pixel bit scrambling. The cipher image I2 is obtained:(4)Y1=reshapemod106∗102∗Y:−102∗Y:,30+1,height,width.Step 5. The sequence Z is converted into a new matrix Z1 by formula (5), and then we input each column sequence in the matrix Z1 as the parameter N′ into the Josephus problem function to scramble each column pixel sequence in cipher image I2. The cipher image I3 is obtained:(5)Z1=reshapemod106∗102∗Z:−102∗Z:,256+1,height,width.Step 6. Converting the sequence W into a new matrix W1 by formula (6), each element in matrix W1 is in the interval [0, 255]. A cipher image C is obtained by using a 2-bit binary number addition operation to encrypt the cipher image I3 with matrix W1:(6)W1=reshapemod1010∗102∗W:−102∗W:,256,height,width.The flowchart of the encryption process is shown in Figure3. The decryption process of the encryption algorithm is the inverse process of encryption, which will not be described again.Figure 3
The flowchart of the encryption process.


## 3.1. Key Generator

This encryption scheme uses SHA-256 algorithm as a key generation function. The SHA-256 algorithm is a type of hash function, and it can convert any length of data into a series of 256-bit binary hash sequences. The SHA-256 algorithm has a key space of 2128, which can resist brute force attack. By inputting the original image into the SHA-256 algorithm, a 256-bit binary sequence H as the key of the encryption algorithm is obtained. The hyperchaotic system used for encryption algorithm has four initial values. In order to obtain these initial values, the sequence H is divided into 32 equal-length sequences as h1, h2, h3, …, h32, and then the initial values x1, y1, z1, w1 of the hyperchaotic system are calculated by(2)x1=h1⊕h2⊕…h7⊕h8256+x1′,y1=h9⊕h10⊕…h15⊕h16256+y1′,z1=h17⊕h18⊕…h23⊕h24256+z1′,w1=h25⊕h26⊕…h31⊕h32256+w1′..Here,x1′,y1′,z1′,w1′ are the given initial values. After the initial values are obtained, the chaotic system is iterated and the values of the first 1000 iterations are discarded to remove the transient effect. Then, four pseudorandom sequences X, Y, Z, and W for scrambling and permutation are obtained.


## 3.2. Scrambling Method

Scrambling is a commonly used method for changing the position of the pixels. It can be applied to encrypt the sequence with a certain rule. The scrambling method used in this paper is matching the position of the elements in the original sequence with the position of the elements in the pseudorandom sequences=s1,s2,s3,…,sM of equal length, and then the new sequence s′=s1′,s2′,…,sM′ is obtained by rearranging the sequence s=s1,s2,s3,…,sM under a certain rule. The original sequence is scrambled to a new sequence according to this rule and the encrypted sequence is obtained. The flowchart of the scrambling process is shown in Figure 2. The decryption process of the scrambling method is the inverse process of encryption, and it will not be described again.Figure 2
The flowchart of the scrambling process.In this paper, the scrambling method is used to scramble the pixel position and the bit position. In this pixel position scrambling method, the parameterN′ in Josephus problem is generated by the hyperchaotic system and the index sequence s′=s1′,s2′,…,sM′ is obtained. The pixel sequence is scrambled by the rule of s = {1, 2, 3, …, M}⟶s′=s1′,s2′,…,sM′. In the bit position scrambling method, the bit position in pixel is disordered by the fixed step size Josephus problem. The pixels in the image can be converted to 8-bit binary numbers. So, the total number M is 8, and the index sequence generated by the Josephus problem is s′ = f(8, N). Finally, the bits of the pixel are scrambled by the rules of s = {1, 2, 3, 4, …, 8}⟶s′=s1′,s2′,…,s8′.


## 3.3. Pixel Permutation

This paper uses a 2-bit binary number addition and subtraction method to perform a permutation operation on the pixels. In the 2-bit binary numbers, there is a special addition and subtraction rule regardless of the carry and borrow in the addition and subtraction process. Only the last two binary digits in the operation result are retained. For example, ‘10’ + ‘11’ = ‘01’ and ‘01’ − ‘10’ = ‘11’. There are 32 possible cases when using this addition and subtraction rules. These 32 cases are shown in Table1.Table 1
32 cases in the 2-bit binary numbers addition and subtraction rules.
+00011011−0001101100000110110000111001010110110001010011101010110001101001001111110001101111100100When permuting two pixels with the 2-bit binary number addition and subtraction rules, the pixels should first be converted into two 8-bit binary numbers, and then the 8-bit binary numbers are split into 2-bit binary numbers. For example, using 225 and 108 for two-bit binary number addition and subtraction, first 225 and 101 should be converted into 8-bit binary digits “11100001” and “01101100”, respectively, and then the two numbers are split into 2-bit binary numbers for addition. The result of the calculation is “00001101”. We convert this number into a decimal number, and the result is 13. The two-bit binary addition and subtraction operations are reciprocal process.


## 3.4. Encryption Process

In this paper, an image encryption algorithm based on the hyperchaotic system and variable-step Josephus problem is proposed. Assuming the size of the original image is height × width, the steps of the encryption scheme are as follows:Step 1. A 256-bit binary sequence H is obtained by inputting the original image into the SHA-256 function, and the initial values of the hyperchaotic system are calculated by formula (2)Step 2. Four pseudorandom sequences X, Y, Z, and W are obtained by iterating the hyperchaotic system. And in the chaotic system, the values of the first 1000 iterations are discarding to remove the transient effect.Step 3. The sequence X is converted into a new matrix X1 by formula (3), and then we input each row sequence in the matrix X1 as the parameter N′ into the Josephus problem function to scramble each row pixel sequence in the original image. The cipher image I1 is obtained:(3)X1=reshapemod106∗102∗X:−102∗X:,256+1,height,width.Step 4. Converting the sequence Y into a new matrix Y1 by formula (4), each element in matrix Y1 is in the interval [1,29]. The elements are used in matrix Y1 as the parameter N to scramble the pixel corresponding to its position in cipher image I1 to achieve pixel bit scrambling. The cipher image I2 is obtained:(4)Y1=reshapemod106∗102∗Y:−102∗Y:,30+1,height,width.Step 5. The sequence Z is converted into a new matrix Z1 by formula (5), and then we input each column sequence in the matrix Z1 as the parameter N′ into the Josephus problem function to scramble each column pixel sequence in cipher image I2. The cipher image I3 is obtained:(5)Z1=reshapemod106∗102∗Z:−102∗Z:,256+1,height,width.Step 6. Converting the sequence W into a new matrix W1 by formula (6), each element in matrix W1 is in the interval [0, 255]. A cipher image C is obtained by using a 2-bit binary number addition operation to encrypt the cipher image I3 with matrix W1:(6)W1=reshapemod1010∗102∗W:−102∗W:,256,height,width.The flowchart of the encryption process is shown in Figure3. The decryption process of the encryption algorithm is the inverse process of encryption, which will not be described again.Figure 3
The flowchart of the encryption process.


## 4. Simulation Results and Security Analysis

The simulation experiment platform is Matlab R2018a, and the computer configuration environment is Windows 7, 4.00 GB RAM, Intel (R) Core (TM) i3-4130 CPU @3.4 GHz. This encryption algorithm is used to encrypt any size of the digital image. The original images cameraman 128 × 128, cameraman 256 × 256, brain 256 × 256, white 256 × 256, black 256 × 256, and their cipher images encrypted by this encryption algorithm are shown in Figure4. The hash sequence used as the initial key is generated from the original image. The other part of the key is a=1.55,b=1.24,c=0.25,d=0.05,e=2.6,f=0.21,g=0.48,S=1,D=1,L=0,x1′=0,y1′=0,z1′=0,andw1′=0. The examples of cipher images listed in Figure 4 have completely lost the characteristics of the original image, and the encryption algorithm works well. Moreover, the algorithm is lossless and the decrypted image is identical with the original image.Figure 4
Original images and their cipher images. (a) Original cameraman 128 × 128. (b) Original cameraman 256 × 256. (c) Original brain 256 × 256. (d) Original white 256 × 256. (e) Original black 256 × 256. (f) Cipher cameraman 128 × 128. (g) Cipher cameraman 256 × 256. (h) Cipher brain 256 × 256. (i) Cipher white 256 × 256. (j) Cipher lack 256 × 256.
(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)


### 4.1. Key Analysis

#### 4.1.1. Key Space Analysis

This encryption algorithm uses the SHA-3 algorithm to generate the encryption key. And the initial values of the hyperchaotic system are generated by the key. Among them, the key space of SHA-3(256) is 2128, and the key spaces of the four initial values of the hyperchaotic system are 1040. Therefore, the key space of the encryption algorithm is 3.4028 × 1078.


#### 4.1.2. Encryption Key Sensitivity Analysis

During the encryption process, a small change in the key will cause a great change in the cipher. This phenomenon becomes the encryption sensitivity of the key. We usually use NPCR (pixel change rate) and UACI (pixel average change intensity) to measure the sensitivity of the encryption key. NPCR and UACI are shown in the following equations:(7)NPCR=∑i,jP1i,j⊕P2i,jM×N×100%,(8)UACI=∑i,jP1i,j−P2i,j255×M×N×100%.The expected values of NPCR and UACI are 100% and 33.4635%, respectively. Taking the cameraman 256 × 256 image as an example, when the key is changed by 10−12, the values of NPCR and UACI between the cipher image and the original cipher image are shown in Table 2. It can be seen from the comparison that the algorithm has strong sensitivity to key encryption.Table 2
Key sensitivity of encryption process.
Initial valuesNPCR (%)UACI (%)x1 + 10−1299.621533.3213y1 + 10−1299.609333.4764z1 + 10−1299.600233.7886w1 + 10−1299.630733.6475


#### 4.1.3. Decryption Key Sensitivity Analysis

The sensitivity of the key is more obvious in the decryption process. When the key is changed slightly, the decrypted image is significantly different from the original image. The plain cameraman image and decrypted images when the keys change slightly are shown in Figure5. Generally, NPCR, UACI, MSE, and PSNR are used to measure the differences between these images. MSE (mean square error) and PSNR (peak signal-to-noise ratio) are two indicators to measure the similarity of two images. In general, when MSE ≤ 30 dB, there is no significant difference between the two images. When MSE > 30, the closer the MSE value is to 30, the smaller the difference between the two images. PSNR reflects the magnitude of image distortion. The larger the PSNR, the smaller the image distortion. MSE (mean square error) and PSNR (peak signal-to-noise ratio) are shown in the following equations:(9)MSE=1height×width∑i=1width−1∑j=1height−1P1i,j−P2i,j2,(10)PSNR=10×lgheight×width×2552∑i=0height−1∑j=0width−1P1i,j−P2i,j2.Figure 5
The plain cameraman image and decrypted images when the keys change slightly. (a) Plain cameraman image. (b) Correct decrypted image. (c) Decrypted image withx1 + 10−10. (d) Decrypted image with y1 + 10−10. (e) Decrypted image with z1 + 10−10. (f) Decrypted image with w1 + 10−10.
(a)(b)(c)(d)(e)(f)When the key changes slightly, the indicators of the difference between the decrypted image and the original image are shown in Table3. By comparison, the algorithm has strong sensitivity to key decryption. When the key changes slightly, the image cannot be decrypted.Table 3
Key sensitivity of decryption process.
Initial valuesNPCRUACIMSEPSNRx1 + 10−1099.589533.9695113417.5841y1 + 10−1099.581933.2737115097.5201z1 + 10−1099.556033.4204115827.4928w1 + 10−1099.620033.43491158917.4903


### 4.2. Differential Attack Analysis

The differential attack analysis refers to making minor changes to the original image and encrypting it, then analyzing the cipher image and analyzing its sensitivity to plaintext. NPCR (number of pixels change rate) and UACI (unified average changing intensity) are used to measure the ability of resisting differential attacks. Table4 lists the values of NPCRs and UACIs between the cipher images and the cipher images when the original image changes by 1 bit. The data in Table 4 are close to the theoretical values. This reflects that there is a strong correlation between the cipher image encrypted by this encryption algorithm and the original image. Even if the original image changes slightly by 1 bit, the cipher image encrypted by this encryption algorithm will undergo a thorough change. This algorithm is effective against differential attacks.Table 4
The NPCRs and UACIs for differential attack analysis.
ImagesNPCRUACICameraman 128∗12899.621633.2842Cameraman 256∗25699.610933.3735Cameraman 512∗51299.594133.4795Brain 128∗12899.554433.3126Brain 256∗25699.578933.3460Brain 512∗51299.609433.4677White 128∗12899.603333.7762White 256∗25699.650633.4553White 512∗51299.610933.5130


### 4.3. Histogram Analysis

The histogram is an indicator of statistics in the image, which reflects the total pixel numbers of each value in the image [30]. The histograms of the original cameraman 256 × 256 image and brain 256 × 256 image and their cipher images are listed in Figure 6. By comparing and analyzing the histograms of the original images and the cipher images, it can be seen that the distribution of the pixel values of the original images is relatively centralized, which has certain statistical characteristics and has no resistance to brute force attacks. However, the pixels of cipher image are distributed more uniform, which breaks the rule of distribution of pixels and does not have statistical characteristics. The attacker cannot use statistical characteristics to restore the original information of the image, so it can resist statistical attacks well.Figure 6
The histogram original images and their cipher images. (a) Histogram of the cameraman 256 × 256 image. (b) Histogram of the cipher cameraman 256 × 256 image. (c) Histogram of the brain 256 × 256 image. (d) Histogram of the cipher brain 256 × 256 image.
(a)(b)(c)(d)The distribution law of the pixel histogram is measured by the chi-square (χ2) distribution, using histi (i = 0, 1, ..., 255) represents the histogram of an image, and the formula for calculating the χ2 distribution is described in the following formula:(11)χ2=1256∑i=0255histi−1256∑i=0255histi2.The histogram obeys the chi-square distribution with 255 degrees of freedom. Given a significant level ofα, make Pχ2≥χα2n−1=α, namely, χ2<χα2n−1, accept the hypothesis. When a significant levels α = 0.01, 0.05, and 0.1, there are χ0.012255=310.45739,χ0.052255=293.24783,andχ0.12255=284.33591. The chi-square distribution of some images is shown in Table 5. The commonly used significant level is α = 0.05, and all the cipher images in Table 5 passed the test. By comparison, it can be seen that the algorithm greatly changes the histogram distribution of the image and has a good ability to break the statistical characteristics of the plain images.Table 5
Chi-square distribution of histograms with size 256 × 256.
ImagesPlain imagesCipher imagesResultsLena 256 × 25639851.3281244.8906PassedCameraman 256 × 256161271.875215.1563PassedBaboon 256 × 25679056.9063204.2656PassedBoat 256 × 256100853.492254.9766PassedBrain 256 × 2561044635.67264.0469Passed


### 4.4. Information Entropy Analysis

The information entropy is a concept used to quantify and measure information. It is used to measure the randomness and uniform distribution of pixels in an image. For a grayscale image, 256 states may appear for each pixel, so the probability of each state for each pixel will be 1/256. For a completely random image, its ideal information entropy should be 8. The calculation method of information entropy is shown as formula (12). p(i) denotes the probability of each pixel:(12)Hs=∑npilog1pi.Table6 lists some information entropies of the images encrypted by the proposed encryption algorithm. By comparison, the cipher images have good information entropies, which is close to the ideal value of 8, and the cipher images have good randomness.Table 6
Entropies of original images and cipher images.
ImagesEntropiesOriginal imagesCipher imagesCameraman 128∗1286.87947.9873Cameraman 256∗2566.90467.9976Cameraman 512∗5126.91027.9994Brain 128∗1284.98917.9854Brain 256∗2565.03307.9971Brain 512∗5125.44987.9993White 128∗12807.9891White 256∗25607.9973White 512∗51207.9993Black 256∗25607.9973In order to quantify the degree of randomness in the local area of the image, we used the concept of local Shannon entropy to test the cipher image. The local Shannon entropy can be defined as follows:(13)Hk,TBS=∑i=1kHSik.In formula (13), k represents the total blocks. S1, S2,…,Sk are nonoverlapping blocks with TB pixels randomly selected in the image, and H(Si) means the entropy of the chosen pixels in Si. When k = 30 and TB = 1936, the results of the local Shannon entropy are shown in Table 7. It can be seen from the results that the cipher image possesses high randomness.Table 7
The results of local Shannon entropy.
ImagesOriginal imagesCipher imagesCameraman 256∗2565.53197.9037Brain 256∗2564.69367.8998White 256∗25607.9033Lena 256∗2566.53557.9040


### 4.5. Correlation Analysis

(14)Ex=1N∑i=1Nxi,Dx=1N∑i=1Nxi−Ex2,covx,y=1N∑i=1Nxi−Exyi−Ey,rxy=covx,yDxDy.For the original images, the values of adjacent pixels in most regions are very close. The correlation between the values of adjacent pixels in the image is very strong. Figure7 shows the correlation analysis of the cameraman plain image and cipher image in three directions. Breaking the strong correlation between adjacent pixels is of great significance to resist statistical attacks. The calculation method of correlation coefficient between adjacent pixels is shown in formula (14).Figure 7
Correlation analysis of the cameraman plain image and cipher image in three directions. (a) Horizontal correlation of the cameraman plain image. (b) Vertical correlation of the cameraman plain image. (c) Diagonal correlation of the cameraman plain image. (d) Horizontal correlation of the cameraman cipher image. (e) Vertical correlation of the cameraman cipher image. (f) Diagonal correlation of the cameraman cipher image.
(a)(b)(c)(d)(e)(f)We randomly selected 5000 pairs of pixels to calculate the correlation coefficients of the original image and cipher image in horizontal, vertical, and diagonal directions. The statistical results are shown in Table8. Statistical results show that in the original image, the correlations between randomly selected pixels are very strong, while in the cipher image, the correlation coefficients between pixels are close to 0. The proposed algorithm can better disturb the correlations between pixels, so it can better resist statistical attacks.Table 8
The correlation coefficients of the images in different directions.
ImagesCorrelationOriginal imageEncrypted imageHorizontalVerticalDiagonalHorizontalVerticalDiagonalCameraman 128∗1280.95300.90840.8812−0.01620.00150.0053Cameraman 256∗2560.95730.91340.9066−0.00460.00110.0159Cameraman 512∗5120.99060.97990.97100.00820.00190.0088Brain 128∗1280.98290.97720.9637−0.00490.0004−0.0057Brain 256∗2560.98570.98320.9779−0.0095−0.0035−0.0002Brain 512∗5120.99690.99610.9934−0.00460.00730.0063White 128∗128———0.00020.0043−0.0002White 256∗256———0.0164−0.00110.0003White 512∗512———0.00550.00370.0056Black 256∗256———0.0112−0.00270.0040


### 4.6. Noise Attack Analysis

In the process of information transmission, it is often interfered by various kinds of noise, resulting in signal distortion. Common noise interferences include Gaussian noise, Poisson noise, and salt and pepper noise. The recovery ability of cipher disturbed by noise is one of the standards to evaluate the performance of encryption algorithm. Here, the salt and pepper noise with intensity of 0.01, 0.05, and 0.1 are interfered to the cipher, and the decrypted images are shown in Figure8.Figure 8
The cipher images and the corresponding decrypted images under noise attack. (a) Cipher image under 0.01 noise intensity. (b) Cipher image under 0.05 noise intensity. (c) Cipher image under 0.1 noise intensity. (d) Decrypted image under 0.01 noise intensity. (e) Decrypted image under 0.05 noise intensity. (f) Decrypted image under 0.1 noise intensity.
(a)(b)(c)(d)(e)(f)Correlations, NPCR, UACI, MSE, and PSNR are used to measure the recovery degree of the algorithm suffered from noise attack, and the details are shown in Table9. According to the data in Table 9, the encryption algorithm has a strong recovery ability against the noise interference and can resist the noise attack very well.Table 9
The resistance ability to noise attack of this algorithm.
Noisy intensityCorrelationsNPCRUACIMSEPSNRHorizontalVerticalDiagonal00.95730.91340.9066000Inf0.010.93300.89390.87101.03910.3646123.476427.21500.050.83240.80830.78524.89961.7195585.630220.45460.10.73010.71380.70929.95793.4740117217.4417


### 4.7. Data Loss Attack Analysis

Data loss attacks are attacks that intercept cipher images and delete some data. A certain amount of data are lost after the cipher image is attacked. If the recovery ability of the decryption algorithm is bad, the decrypted image of the cipher image after losing information cannot provide enough effective information. The test and analysis of data loss attacks refers to deleting some pixels of cipher image, then comparing, and analyzing the decrypted image with the original image through corresponding decryption algorithm, and its statistic recovery degree. Figure9 shows the cipher images and corresponding decrypted images after data loss attacks.Figure 9
The cipher images and their decrypted images after data loss attacks. (a) 1/64 occlusion. (b) 1/16 occlusion. (c) 1/4 occlusion. (d) Decrypted image with 1/64 occlusion. (e) Decrypted image with 1/16 occlusion. (f) Decrypted image with 1/4 occlusion.
(a)(b)(c)(d)(e)(f)Correlations, MSE, PSNR, NPCR, and UACI are as indicators to measure the similarity of the two images. Table10 lists the indicators of decrypted cameraman images after data loss attacks. Through comparison, it can be seen that the algorithm has recovery ability when it is attacked by data loss and has resistance ability to data loss attacks.Table 10
The indicators of decrypted cameraman images after data loss attacks.
ImagesCorrelationsNPCRUACIMSEPSNRHorizontalVerticalDiagonalOriginal image0.95730.91340.906600001/640.91700.90320.86261.55640.5450185.805725.44021/160.81270.77870.76476.23022.1481723.788319.53471/40.50530.47040.450424.90398.59632887.413.5257


### 4.8. Classical Attack Analysis

There are four classical types of attacks: cipher-only attack (COA), known-plaintext attack (KPA), chosen-cipher attack (CCA), and chosen-plaintext attack (CPA). Among these four classical types of attacks, the COA refers to the attack performed under the cipher is known; the KPA refers to the attack under attacker masters a certain plaintext and the corresponding cipher; the CCA refers to when the attacker uses this encryption algorithm to construct the cipher corresponding to plaintext; the CPA refers to when the attacker knows the plaintext corresponding to a certain number of ciphers. In these four attack methods, if the encryption algorithm can effectively resist CPA, it must be able to resist the other three classical types of attack methods.Attacker mostly use special image, such as white and all black to attack the image encryption methods and find the key. In this proposed algorithm, the scramble process and the pixel permutation process all related to the hyperchaotic system, and the initial values of the hyperchaotic system are very sensitive to the plain images; this has been proven in the key analysis and differential attack analysis, and so this algorithm can resist the CPA very well. The proposed algorithm can effectively resist the four classic attacks. Figure4 shows the encryption results of all-black and all-white images of size 256 × 256. Tables 6 and 8 show the information entropy and three kinds of correlation of images.


### 4.9. Performance Comparison Analysis

This section lists and analyzes the security analysis of some image encryption algorithms in the references. The comparison analysis of the literature results can illustrate the security of the encryption algorithm very well. Table11 lists some security analysis indicators of the encryption algorithm. It can be shown in Table 11 that the proposed encryption algorithm has good encryption performance and can be applied in the field of image encryption.Table 11
Performance comparisons with the existing methods for cameraman image in size 256∗256.
MethodNPCR (%)UACI (%)EntropyCorrelationsHorizontalVerticalDiagonal[24]99.559033.44397.99710.0047−0.00660.0031[28]99.604733.50507.9963−0.00740.0069−0.0191[31]99.562031.1169—0.00020.00270.0031[17]99.6033.44957.90310.00940.0023−0.0031[32]99.644533.67117.99750.0072−0.0113−0.0065[33]99.612433.64357.99760.0010−0.0048−0.0080[34]99.611433.46827.99720.00140.0027−0.0004Proposed99.610933.37357.9976−0.00460.00110.0159


### 4.10. Randomness Test of Cipher Image

SP800 is a series of guidelines on information security issued by the National Institute of Standards and Technology (NIST). In the NIST standard series of documents, although NIST SP is not a formal statutory standard, in actual work, it has become a de facto standard and authoritative guide widely recognized by the United States and the international information security community. This paper selects 14 test methods given in SP800-22 Revision la to test the random characteristics of cipher images encrypted by the proposed algorithm. The test results of the 14 test indicators and cipher random performance are shown in Table12. When the test result is greater than 0.01, it means that the test object is random. Therefore, the image encrypted with this encryption algorithm has good random performance.Table 12
Cipher randomness test.
Test itemsEncrypted cameraman imageEncrypted Lena imageEncrypted white imageThe frequency (monobit) test0.01450.34450.0145Frequency test within a block0.55790.20920.5579The runs test0.99380.43670.9938Tests for the longest-run-of-ones in a block0.27980.76770.2798The binary matrix rank test0.02230.19240.0225The discrete Fourier transform (spectral) test0.96000.30870.9600The nonoverlapping template matching test0.07750.04780.0775The overlapping template matching test0.34500.53070.3450Maurer’s “universal statistical” test0.18780.01820.1878The serial test0.01610.41320.01610.89520.62530.8952The approximate entropy test0.87760.99520.8776The cumulative sums (CUSUMs) test0.47520.85800.47520.94310.63840.9431The random excursions test0.30750.01780.30750.43090.03640.43090.93710.05950.93710.84690.08690.84690.86450.29590.86450.18060.68630.18060.25380.71970.25380.43150.49170.4315The random excursions variant test0.64410.28750.64410.55500.35910.55500.65970.34900.65970.81830.37570.81830.71900.38850.71900.81030.18480.81030.82030.06820.82030.94150.03340.94150.65670.00970.65670.48490.29260.48490.21260.97980.21260.06490.75370.06490.01870.79090.01870.00490.96500.00490.00050.82220.00050.00090.76110.00090.00910.68360.00910.03490.53730.0349


### 4.11. Complexity Analysis

#### 4.11.1. Speed Analysis

The simulation platform and the computer configuration environment are shown in Section4. Table 13 shows the encryption time to encrypt common images using the proposed algorithm. It can be seen that the proposed algorithm can encrypt the original image very fast.Table 13
Time taken from the proposed algorithm.
ImagesEncryption speed (seconds)Lena 256∗2561.112Cameraman 256∗2561.256White 256∗2561.239Boat 256∗2561.316


#### 4.11.2. Computational Complexity Analysis

When the height and width of the original image areM and N, respectively, the computational complexity of generating the hyperchaotic system is O(4∗M∗N), the computational complexity of two Josephus scramble process is O(2∗M∗N), the computational complexity of bit scramble is O(8∗M∗N), and the computational complexity of pixel permutation is O(M∗N).


### 4.12. Test Images of USC-SIPI Miscellaneous Database

In order to further verify the performance of this scheme. The proposed scheme has been tested on theUSC-SIPI miscellaneous database. Performance evaluations include differential attack, correlation coefficients, and information entropy. The results are shown in Table 14.Table 14
Test images of USC-SIPI miscellaneous database.
ImageInformation entropyNPCRUACICorrelation coefficientHorizontalVerticalDiagonalDiagonal5.1.097.9972499.639933.42790.00490.01160.0012−0.00295.1.107.9972399.604833.46740.00290.00300.00160.01805.1.117.9965399.594133.4989−0.00190.0090−0.0018−0.00945.1.127.9971799.585033.4592−0.0267−0.0017−0.0018−0.00125.1.137.9969299.656733.3297−0.00130.00740.0093−0.01245.1.147.9976199.581933.52710.00720.00220.00190.00265.2.087.9992899.628133.5026−0.00260.0183−0.0028−0.00995.2.097.9993599.618133.4418−0.00170.02280.01770.01325.2.107.9992999.609833.43950.00720.0131−0.00720.00537.1.017.9993499.620833.39990.0200−0.0252−0.00050.01987.1.027.9992399.588033.49190.00630.0164−0.01530.02127.1.037.9992799.606333.43980.0234−0.01560.00290.03587.1.047.9994199.603733.52540.00150.02780.01500.01417.1.057.9992999.598733.45580.00730.00270.0167−0.01437.1.067.9993399.601433.37110.0228−0.0036−0.0148−0.00217.1.077.9992299.610133.46040.0021−0.00220.0025−0.00147.1.087.9992499.615933.41800.0108−0.0074−0.00480.01037.1.097.9992699.612833.48410.0031−0.0033−0.0148−0.00077.1.107.9992899.605633.44880.0088−0.01120.0056−0.0012Boat 0.5127.9992299.640733.4799−0.0011−0.00350.0005−0.0003Gray 21.5127.9991999.618133.4631−0.00470.00350.00110.0024Ruler 0.5127.9992799.617833.46480.00160.00420.00210.0039


## 4.1. Key Analysis

### 4.1.1. Key Space Analysis

This encryption algorithm uses the SHA-3 algorithm to generate the encryption key. And the initial values of the hyperchaotic system are generated by the key. Among them, the key space of SHA-3(256) is 2128, and the key spaces of the four initial values of the hyperchaotic system are 1040. Therefore, the key space of the encryption algorithm is 3.4028 × 1078.


### 4.1.2. Encryption Key Sensitivity Analysis

During the encryption process, a small change in the key will cause a great change in the cipher. This phenomenon becomes the encryption sensitivity of the key. We usually use NPCR (pixel change rate) and UACI (pixel average change intensity) to measure the sensitivity of the encryption key. NPCR and UACI are shown in the following equations:(7)NPCR=∑i,jP1i,j⊕P2i,jM×N×100%,(8)UACI=∑i,jP1i,j−P2i,j255×M×N×100%.The expected values of NPCR and UACI are 100% and 33.4635%, respectively. Taking the cameraman 256 × 256 image as an example, when the key is changed by 10−12, the values of NPCR and UACI between the cipher image and the original cipher image are shown in Table 2. It can be seen from the comparison that the algorithm has strong sensitivity to key encryption.Table 2
Key sensitivity of encryption process.
Initial valuesNPCR (%)UACI (%)x1 + 10−1299.621533.3213y1 + 10−1299.609333.4764z1 + 10−1299.600233.7886w1 + 10−1299.630733.6475


### 4.1.3. Decryption Key Sensitivity Analysis

The sensitivity of the key is more obvious in the decryption process. When the key is changed slightly, the decrypted image is significantly different from the original image. The plain cameraman image and decrypted images when the keys change slightly are shown in Figure5. Generally, NPCR, UACI, MSE, and PSNR are used to measure the differences between these images. MSE (mean square error) and PSNR (peak signal-to-noise ratio) are two indicators to measure the similarity of two images. In general, when MSE ≤ 30 dB, there is no significant difference between the two images. When MSE > 30, the closer the MSE value is to 30, the smaller the difference between the two images. PSNR reflects the magnitude of image distortion. The larger the PSNR, the smaller the image distortion. MSE (mean square error) and PSNR (peak signal-to-noise ratio) are shown in the following equations:(9)MSE=1height×width∑i=1width−1∑j=1height−1P1i,j−P2i,j2,(10)PSNR=10×lgheight×width×2552∑i=0height−1∑j=0width−1P1i,j−P2i,j2.Figure 5
The plain cameraman image and decrypted images when the keys change slightly. (a) Plain cameraman image. (b) Correct decrypted image. (c) Decrypted image withx1 + 10−10. (d) Decrypted image with y1 + 10−10. (e) Decrypted image with z1 + 10−10. (f) Decrypted image with w1 + 10−10.
(a)(b)(c)(d)(e)(f)When the key changes slightly, the indicators of the difference between the decrypted image and the original image are shown in Table3. By comparison, the algorithm has strong sensitivity to key decryption. When the key changes slightly, the image cannot be decrypted.Table 3
Key sensitivity of decryption process.
Initial valuesNPCRUACIMSEPSNRx1 + 10−1099.589533.9695113417.5841y1 + 10−1099.581933.2737115097.5201z1 + 10−1099.556033.4204115827.4928w1 + 10−1099.620033.43491158917.4903


## 4.1.1. Key Space Analysis

This encryption algorithm uses the SHA-3 algorithm to generate the encryption key. And the initial values of the hyperchaotic system are generated by the key. Among them, the key space of SHA-3(256) is 2128, and the key spaces of the four initial values of the hyperchaotic system are 1040. Therefore, the key space of the encryption algorithm is 3.4028 × 1078.


## 4.1.2. Encryption Key Sensitivity Analysis

During the encryption process, a small change in the key will cause a great change in the cipher. This phenomenon becomes the encryption sensitivity of the key. We usually use NPCR (pixel change rate) and UACI (pixel average change intensity) to measure the sensitivity of the encryption key. NPCR and UACI are shown in the following equations:(7)NPCR=∑i,jP1i,j⊕P2i,jM×N×100%,(8)UACI=∑i,jP1i,j−P2i,j255×M×N×100%.The expected values of NPCR and UACI are 100% and 33.4635%, respectively. Taking the cameraman 256 × 256 image as an example, when the key is changed by 10−12, the values of NPCR and UACI between the cipher image and the original cipher image are shown in Table 2. It can be seen from the comparison that the algorithm has strong sensitivity to key encryption.Table 2
Key sensitivity of encryption process.
Initial valuesNPCR (%)UACI (%)x1 + 10−1299.621533.3213y1 + 10−1299.609333.4764z1 + 10−1299.600233.7886w1 + 10−1299.630733.6475


## 4.1.3. Decryption Key Sensitivity Analysis

The sensitivity of the key is more obvious in the decryption process. When the key is changed slightly, the decrypted image is significantly different from the original image. The plain cameraman image and decrypted images when the keys change slightly are shown in Figure5. Generally, NPCR, UACI, MSE, and PSNR are used to measure the differences between these images. MSE (mean square error) and PSNR (peak signal-to-noise ratio) are two indicators to measure the similarity of two images. In general, when MSE ≤ 30 dB, there is no significant difference between the two images. When MSE > 30, the closer the MSE value is to 30, the smaller the difference between the two images. PSNR reflects the magnitude of image distortion. The larger the PSNR, the smaller the image distortion. MSE (mean square error) and PSNR (peak signal-to-noise ratio) are shown in the following equations:(9)MSE=1height×width∑i=1width−1∑j=1height−1P1i,j−P2i,j2,(10)PSNR=10×lgheight×width×2552∑i=0height−1∑j=0width−1P1i,j−P2i,j2.Figure 5
The plain cameraman image and decrypted images when the keys change slightly. (a) Plain cameraman image. (b) Correct decrypted image. (c) Decrypted image withx1 + 10−10. (d) Decrypted image with y1 + 10−10. (e) Decrypted image with z1 + 10−10. (f) Decrypted image with w1 + 10−10.
(a)(b)(c)(d)(e)(f)When the key changes slightly, the indicators of the difference between the decrypted image and the original image are shown in Table3. By comparison, the algorithm has strong sensitivity to key decryption. When the key changes slightly, the image cannot be decrypted.Table 3
Key sensitivity of decryption process.
Initial valuesNPCRUACIMSEPSNRx1 + 10−1099.589533.9695113417.5841y1 + 10−1099.581933.2737115097.5201z1 + 10−1099.556033.4204115827.4928w1 + 10−1099.620033.43491158917.4903


## 4.2. Differential Attack Analysis

The differential attack analysis refers to making minor changes to the original image and encrypting it, then analyzing the cipher image and analyzing its sensitivity to plaintext. NPCR (number of pixels change rate) and UACI (unified average changing intensity) are used to measure the ability of resisting differential attacks. Table4 lists the values of NPCRs and UACIs between the cipher images and the cipher images when the original image changes by 1 bit. The data in Table 4 are close to the theoretical values. This reflects that there is a strong correlation between the cipher image encrypted by this encryption algorithm and the original image. Even if the original image changes slightly by 1 bit, the cipher image encrypted by this encryption algorithm will undergo a thorough change. This algorithm is effective against differential attacks.Table 4
The NPCRs and UACIs for differential attack analysis.
ImagesNPCRUACICameraman 128∗12899.621633.2842Cameraman 256∗25699.610933.3735Cameraman 512∗51299.594133.4795Brain 128∗12899.554433.3126Brain 256∗25699.578933.3460Brain 512∗51299.609433.4677White 128∗12899.603333.7762White 256∗25699.650633.4553White 512∗51299.610933.5130


## 4.3. Histogram Analysis

The histogram is an indicator of statistics in the image, which reflects the total pixel numbers of each value in the image [30]. The histograms of the original cameraman 256 × 256 image and brain 256 × 256 image and their cipher images are listed in Figure 6. By comparing and analyzing the histograms of the original images and the cipher images, it can be seen that the distribution of the pixel values of the original images is relatively centralized, which has certain statistical characteristics and has no resistance to brute force attacks. However, the pixels of cipher image are distributed more uniform, which breaks the rule of distribution of pixels and does not have statistical characteristics. The attacker cannot use statistical characteristics to restore the original information of the image, so it can resist statistical attacks well.Figure 6
The histogram original images and their cipher images. (a) Histogram of the cameraman 256 × 256 image. (b) Histogram of the cipher cameraman 256 × 256 image. (c) Histogram of the brain 256 × 256 image. (d) Histogram of the cipher brain 256 × 256 image.
(a)(b)(c)(d)The distribution law of the pixel histogram is measured by the chi-square (χ2) distribution, using histi (i = 0, 1, ..., 255) represents the histogram of an image, and the formula for calculating the χ2 distribution is described in the following formula:(11)χ2=1256∑i=0255histi−1256∑i=0255histi2.The histogram obeys the chi-square distribution with 255 degrees of freedom. Given a significant level ofα, make Pχ2≥χα2n−1=α, namely, χ2<χα2n−1, accept the hypothesis. When a significant levels α = 0.01, 0.05, and 0.1, there are χ0.012255=310.45739,χ0.052255=293.24783,andχ0.12255=284.33591. The chi-square distribution of some images is shown in Table 5. The commonly used significant level is α = 0.05, and all the cipher images in Table 5 passed the test. By comparison, it can be seen that the algorithm greatly changes the histogram distribution of the image and has a good ability to break the statistical characteristics of the plain images.Table 5
Chi-square distribution of histograms with size 256 × 256.
ImagesPlain imagesCipher imagesResultsLena 256 × 25639851.3281244.8906PassedCameraman 256 × 256161271.875215.1563PassedBaboon 256 × 25679056.9063204.2656PassedBoat 256 × 256100853.492254.9766PassedBrain 256 × 2561044635.67264.0469Passed


## 4.4. Information Entropy Analysis

The information entropy is a concept used to quantify and measure information. It is used to measure the randomness and uniform distribution of pixels in an image. For a grayscale image, 256 states may appear for each pixel, so the probability of each state for each pixel will be 1/256. For a completely random image, its ideal information entropy should be 8. The calculation method of information entropy is shown as formula (12). p(i) denotes the probability of each pixel:(12)Hs=∑npilog1pi.Table6 lists some information entropies of the images encrypted by the proposed encryption algorithm. By comparison, the cipher images have good information entropies, which is close to the ideal value of 8, and the cipher images have good randomness.Table 6
Entropies of original images and cipher images.
ImagesEntropiesOriginal imagesCipher imagesCameraman 128∗1286.87947.9873Cameraman 256∗2566.90467.9976Cameraman 512∗5126.91027.9994Brain 128∗1284.98917.9854Brain 256∗2565.03307.9971Brain 512∗5125.44987.9993White 128∗12807.9891White 256∗25607.9973White 512∗51207.9993Black 256∗25607.9973In order to quantify the degree of randomness in the local area of the image, we used the concept of local Shannon entropy to test the cipher image. The local Shannon entropy can be defined as follows:(13)Hk,TBS=∑i=1kHSik.In formula (13), k represents the total blocks. S1, S2,…,Sk are nonoverlapping blocks with TB pixels randomly selected in the image, and H(Si) means the entropy of the chosen pixels in Si. When k = 30 and TB = 1936, the results of the local Shannon entropy are shown in Table 7. It can be seen from the results that the cipher image possesses high randomness.Table 7
The results of local Shannon entropy.
ImagesOriginal imagesCipher imagesCameraman 256∗2565.53197.9037Brain 256∗2564.69367.8998White 256∗25607.9033Lena 256∗2566.53557.9040


## 4.5. Correlation Analysis

(14)Ex=1N∑i=1Nxi,Dx=1N∑i=1Nxi−Ex2,covx,y=1N∑i=1Nxi−Exyi−Ey,rxy=covx,yDxDy.For the original images, the values of adjacent pixels in most regions are very close. The correlation between the values of adjacent pixels in the image is very strong. Figure7 shows the correlation analysis of the cameraman plain image and cipher image in three directions. Breaking the strong correlation between adjacent pixels is of great significance to resist statistical attacks. The calculation method of correlation coefficient between adjacent pixels is shown in formula (14).Figure 7
Correlation analysis of the cameraman plain image and cipher image in three directions. (a) Horizontal correlation of the cameraman plain image. (b) Vertical correlation of the cameraman plain image. (c) Diagonal correlation of the cameraman plain image. (d) Horizontal correlation of the cameraman cipher image. (e) Vertical correlation of the cameraman cipher image. (f) Diagonal correlation of the cameraman cipher image.
(a)(b)(c)(d)(e)(f)We randomly selected 5000 pairs of pixels to calculate the correlation coefficients of the original image and cipher image in horizontal, vertical, and diagonal directions. The statistical results are shown in Table8. Statistical results show that in the original image, the correlations between randomly selected pixels are very strong, while in the cipher image, the correlation coefficients between pixels are close to 0. The proposed algorithm can better disturb the correlations between pixels, so it can better resist statistical attacks.Table 8
The correlation coefficients of the images in different directions.
ImagesCorrelationOriginal imageEncrypted imageHorizontalVerticalDiagonalHorizontalVerticalDiagonalCameraman 128∗1280.95300.90840.8812−0.01620.00150.0053Cameraman 256∗2560.95730.91340.9066−0.00460.00110.0159Cameraman 512∗5120.99060.97990.97100.00820.00190.0088Brain 128∗1280.98290.97720.9637−0.00490.0004−0.0057Brain 256∗2560.98570.98320.9779−0.0095−0.0035−0.0002Brain 512∗5120.99690.99610.9934−0.00460.00730.0063White 128∗128———0.00020.0043−0.0002White 256∗256———0.0164−0.00110.0003White 512∗512———0.00550.00370.0056Black 256∗256———0.0112−0.00270.0040


## 4.6. Noise Attack Analysis

In the process of information transmission, it is often interfered by various kinds of noise, resulting in signal distortion. Common noise interferences include Gaussian noise, Poisson noise, and salt and pepper noise. The recovery ability of cipher disturbed by noise is one of the standards to evaluate the performance of encryption algorithm. Here, the salt and pepper noise with intensity of 0.01, 0.05, and 0.1 are interfered to the cipher, and the decrypted images are shown in Figure8.Figure 8
The cipher images and the corresponding decrypted images under noise attack. (a) Cipher image under 0.01 noise intensity. (b) Cipher image under 0.05 noise intensity. (c) Cipher image under 0.1 noise intensity. (d) Decrypted image under 0.01 noise intensity. (e) Decrypted image under 0.05 noise intensity. (f) Decrypted image under 0.1 noise intensity.
(a)(b)(c)(d)(e)(f)Correlations, NPCR, UACI, MSE, and PSNR are used to measure the recovery degree of the algorithm suffered from noise attack, and the details are shown in Table9. According to the data in Table 9, the encryption algorithm has a strong recovery ability against the noise interference and can resist the noise attack very well.Table 9
The resistance ability to noise attack of this algorithm.
Noisy intensityCorrelationsNPCRUACIMSEPSNRHorizontalVerticalDiagonal00.95730.91340.9066000Inf0.010.93300.89390.87101.03910.3646123.476427.21500.050.83240.80830.78524.89961.7195585.630220.45460.10.73010.71380.70929.95793.4740117217.4417


## 4.7. Data Loss Attack Analysis

Data loss attacks are attacks that intercept cipher images and delete some data. A certain amount of data are lost after the cipher image is attacked. If the recovery ability of the decryption algorithm is bad, the decrypted image of the cipher image after losing information cannot provide enough effective information. The test and analysis of data loss attacks refers to deleting some pixels of cipher image, then comparing, and analyzing the decrypted image with the original image through corresponding decryption algorithm, and its statistic recovery degree. Figure9 shows the cipher images and corresponding decrypted images after data loss attacks.Figure 9
The cipher images and their decrypted images after data loss attacks. (a) 1/64 occlusion. (b) 1/16 occlusion. (c) 1/4 occlusion. (d) Decrypted image with 1/64 occlusion. (e) Decrypted image with 1/16 occlusion. (f) Decrypted image with 1/4 occlusion.
(a)(b)(c)(d)(e)(f)Correlations, MSE, PSNR, NPCR, and UACI are as indicators to measure the similarity of the two images. Table10 lists the indicators of decrypted cameraman images after data loss attacks. Through comparison, it can be seen that the algorithm has recovery ability when it is attacked by data loss and has resistance ability to data loss attacks.Table 10
The indicators of decrypted cameraman images after data loss attacks.
ImagesCorrelationsNPCRUACIMSEPSNRHorizontalVerticalDiagonalOriginal image0.95730.91340.906600001/640.91700.90320.86261.55640.5450185.805725.44021/160.81270.77870.76476.23022.1481723.788319.53471/40.50530.47040.450424.90398.59632887.413.5257


## 4.8. Classical Attack Analysis

There are four classical types of attacks: cipher-only attack (COA), known-plaintext attack (KPA), chosen-cipher attack (CCA), and chosen-plaintext attack (CPA). Among these four classical types of attacks, the COA refers to the attack performed under the cipher is known; the KPA refers to the attack under attacker masters a certain plaintext and the corresponding cipher; the CCA refers to when the attacker uses this encryption algorithm to construct the cipher corresponding to plaintext; the CPA refers to when the attacker knows the plaintext corresponding to a certain number of ciphers. In these four attack methods, if the encryption algorithm can effectively resist CPA, it must be able to resist the other three classical types of attack methods.Attacker mostly use special image, such as white and all black to attack the image encryption methods and find the key. In this proposed algorithm, the scramble process and the pixel permutation process all related to the hyperchaotic system, and the initial values of the hyperchaotic system are very sensitive to the plain images; this has been proven in the key analysis and differential attack analysis, and so this algorithm can resist the CPA very well. The proposed algorithm can effectively resist the four classic attacks. Figure4 shows the encryption results of all-black and all-white images of size 256 × 256. Tables 6 and 8 show the information entropy and three kinds of correlation of images.


## 4.9. Performance Comparison Analysis

This section lists and analyzes the security analysis of some image encryption algorithms in the references. The comparison analysis of the literature results can illustrate the security of the encryption algorithm very well. Table11 lists some security analysis indicators of the encryption algorithm. It can be shown in Table 11 that the proposed encryption algorithm has good encryption performance and can be applied in the field of image encryption.Table 11
Performance comparisons with the existing methods for cameraman image in size 256∗256.
MethodNPCR (%)UACI (%)EntropyCorrelationsHorizontalVerticalDiagonal[24]99.559033.44397.99710.0047−0.00660.0031[28]99.604733.50507.9963−0.00740.0069−0.0191[31]99.562031.1169—0.00020.00270.0031[17]99.6033.44957.90310.00940.0023−0.0031[32]99.644533.67117.99750.0072−0.0113−0.0065[33]99.612433.64357.99760.0010−0.0048−0.0080[34]99.611433.46827.99720.00140.0027−0.0004Proposed99.610933.37357.9976−0.00460.00110.0159


## 4.10. Randomness Test of Cipher Image

SP800 is a series of guidelines on information security issued by the National Institute of Standards and Technology (NIST). In the NIST standard series of documents, although NIST SP is not a formal statutory standard, in actual work, it has become a de facto standard and authoritative guide widely recognized by the United States and the international information security community. This paper selects 14 test methods given in SP800-22 Revision la to test the random characteristics of cipher images encrypted by the proposed algorithm. The test results of the 14 test indicators and cipher random performance are shown in Table12. When the test result is greater than 0.01, it means that the test object is random. Therefore, the image encrypted with this encryption algorithm has good random performance.Table 12
Cipher randomness test.
Test itemsEncrypted cameraman imageEncrypted Lena imageEncrypted white imageThe frequency (monobit) test0.01450.34450.0145Frequency test within a block0.55790.20920.5579The runs test0.99380.43670.9938Tests for the longest-run-of-ones in a block0.27980.76770.2798The binary matrix rank test0.02230.19240.0225The discrete Fourier transform (spectral) test0.96000.30870.9600The nonoverlapping template matching test0.07750.04780.0775The overlapping template matching test0.34500.53070.3450Maurer’s “universal statistical” test0.18780.01820.1878The serial test0.01610.41320.01610.89520.62530.8952The approximate entropy test0.87760.99520.8776The cumulative sums (CUSUMs) test0.47520.85800.47520.94310.63840.9431The random excursions test0.30750.01780.30750.43090.03640.43090.93710.05950.93710.84690.08690.84690.86450.29590.86450.18060.68630.18060.25380.71970.25380.43150.49170.4315The random excursions variant test0.64410.28750.64410.55500.35910.55500.65970.34900.65970.81830.37570.81830.71900.38850.71900.81030.18480.81030.82030.06820.82030.94150.03340.94150.65670.00970.65670.48490.29260.48490.21260.97980.21260.06490.75370.06490.01870.79090.01870.00490.96500.00490.00050.82220.00050.00090.76110.00090.00910.68360.00910.03490.53730.0349


## 4.11. Complexity Analysis

### 4.11.1. Speed Analysis

The simulation platform and the computer configuration environment are shown in Section4. Table 13 shows the encryption time to encrypt common images using the proposed algorithm. It can be seen that the proposed algorithm can encrypt the original image very fast.Table 13
Time taken from the proposed algorithm.
ImagesEncryption speed (seconds)Lena 256∗2561.112Cameraman 256∗2561.256White 256∗2561.239Boat 256∗2561.316


### 4.11.2. Computational Complexity Analysis

When the height and width of the original image areM and N, respectively, the computational complexity of generating the hyperchaotic system is O(4∗M∗N), the computational complexity of two Josephus scramble process is O(2∗M∗N), the computational complexity of bit scramble is O(8∗M∗N), and the computational complexity of pixel permutation is O(M∗N).


## 4.11.1. Speed Analysis

The simulation platform and the computer configuration environment are shown in Section4. Table 13 shows the encryption time to encrypt common images using the proposed algorithm. It can be seen that the proposed algorithm can encrypt the original image very fast.Table 13
Time taken from the proposed algorithm.
ImagesEncryption speed (seconds)Lena 256∗2561.112Cameraman 256∗2561.256White 256∗2561.239Boat 256∗2561.316


## 4.11.2. Computational Complexity Analysis

When the height and width of the original image areM and N, respectively, the computational complexity of generating the hyperchaotic system is O(4∗M∗N), the computational complexity of two Josephus scramble process is O(2∗M∗N), the computational complexity of bit scramble is O(8∗M∗N), and the computational complexity of pixel permutation is O(M∗N).


## 4.12. Test Images of USC-SIPI Miscellaneous Database

In order to further verify the performance of this scheme. The proposed scheme has been tested on theUSC-SIPI miscellaneous database. Performance evaluations include differential attack, correlation coefficients, and information entropy. The results are shown in Table 14.Table 14
Test images of USC-SIPI miscellaneous database.
ImageInformation entropyNPCRUACICorrelation coefficientHorizontalVerticalDiagonalDiagonal5.1.097.9972499.639933.42790.00490.01160.0012−0.00295.1.107.9972399.604833.46740.00290.00300.00160.01805.1.117.9965399.594133.4989−0.00190.0090−0.0018−0.00945.1.127.9971799.585033.4592−0.0267−0.0017−0.0018−0.00125.1.137.9969299.656733.3297−0.00130.00740.0093−0.01245.1.147.9976199.581933.52710.00720.00220.00190.00265.2.087.9992899.628133.5026−0.00260.0183−0.0028−0.00995.2.097.9993599.618133.4418−0.00170.02280.01770.01325.2.107.9992999.609833.43950.00720.0131−0.00720.00537.1.017.9993499.620833.39990.0200−0.0252−0.00050.01987.1.027.9992399.588033.49190.00630.0164−0.01530.02127.1.037.9992799.606333.43980.0234−0.01560.00290.03587.1.047.9994199.603733.52540.00150.02780.01500.01417.1.057.9992999.598733.45580.00730.00270.0167−0.01437.1.067.9993399.601433.37110.0228−0.0036−0.0148−0.00217.1.077.9992299.610133.46040.0021−0.00220.0025−0.00147.1.087.9992499.615933.41800.0108−0.0074−0.00480.01037.1.097.9992699.612833.48410.0031−0.0033−0.0148−0.00077.1.107.9992899.605633.44880.0088−0.01120.0056−0.0012Boat 0.5127.9992299.640733.4799−0.0011−0.00350.0005−0.0003Gray 21.5127.9991999.618133.4631−0.00470.00350.00110.0024Ruler 0.5127.9992799.617833.46480.00160.00420.00210.0039


## 5. Conclusions

By analyzing and improving the Josephus problem, an image encryption algorithm based on the hyperchaotic system and variable-step Josephus problem is proposed in this paper. This method combines pseudorandom sequences generated by the hyperchaotic system with the Josephus problem, adds rules for the Josephus problem, and adds a method for scrambling pixel positions. The experimental results of the encryption algorithm show that the algorithm has a large key space to resist brute attacks and also can resist statistical attacks, differential attacks, data loss attacks, and other typical attacks. It can be widely used in the security transmission of images.



---

*Source: 6102824-2020-10-21.xml*