A new image encryption algorithm based on the OF-LSTMS and chaotic sequences

In this paper, a novel image encryption algorithm based on the Once Forward Long Short Term Memory Structure (OF-LSTMS) and the Two-Dimensional Coupled Map Lattice (2DCML) fractional-order chaotic system is proposed. The original image is divided into several image blocks, each of which is input into the OF-LSTMS as a pixel sub-sequence. According to the chaotic sequences generated by the 2DCML fractional-order chaotic system, the parameters of the input gate, output gate and memory unit of the OF-LSTMS are initialized, and the pixel positions are changed at the same time of changing the pixel values, achieving the synchronization of permutation and diffusion operations, which greatly improves the efficiency of image encryption and reduces the time consumption. In addition the 2DCML fractional-order chaotic system has better chaotic ergodicity and the values of chaotic sequences are larger than the traditional chaotic system. Therefore, it is very suitable to image encryption. Many simulation results show that the proposed scheme has higher security and efficiency comparing with previous schemes.

www.nature.com/scientificreports/ the pixel position while changing the pixel value, that is, permutation and diffusion are carried out at the same time, so the time consumption is less and the proposed encryption algorithm is efficient. The rest of this paper is organized as follows. In "The application of OF-LSTMS in the proposed algorithm" and "The 2DCML fractional-order chaotic system" sections the OF-LSTMS and the 2DCML fractional-order chaotic system are presented respectively. The proposed image encryption and decryption scheme are described in "The proposed image encryption and decryption algorithm" section. Simulation results and performance analyses are reported in "Performance analyses" section.

The application of OF-LSTMS in the proposed algorithm
LSTM structure is a chain structure with recurrent neural network module. It adopts matrix multiplication calculation method and gradient update parameter training method. LSTM structure consists of four parts: memory unit, forgetting gate, input gate and output gate 29,[46][47][48][49][50] . Image encryption algorithm requires reversibility and does not need to learn features of the sequence, so it is necessary to modify the structure of LSTM. Based on the structure of LSTM, we propose the Once Forward Long Short Term Memory Structure (OF-LSTMS), which uses XOR operation instead of traditional matrix operation. The OF-LSTMS can realize that the encrypted image be obtained after only one forward propagation after original image entering the algorithm. The OF-LSTMS is as shown in Fig. 1.
The operation used by the Neural Network (NN) structure of the traditional LSTM is matrix multiplication (MM), but it is not applicable in the image encryption task. MM cannot make the sum items (after being activated by MOD function) included in the output neurons be accurately restored to the input neurons during the decryption process, so the operation used by the NN structure of OF-LSTMS is XOR. The blue box NN in Fig. 1 (the part of The OF-LSTMS) shows the formal representation of NN structure and Fig. 2 shows the details of the XOR operation used by the NN structure of OF-LSTMS. As shown in Fig. 2, there are four original pixels, each of which contains 8-bit binary values. These pixels are divided into four groups of binary values, and XOR operation is performed with the same four sets of binary values (the values are from chaotic sequences). This operation process is called segmentation as shown in Fig. 2 (The part on the left which marked by green). In addition, the four groups of binary values in each rectangle in Fig. 2 come from the binary values of four different original pixels, which are finally calculated and then converted to decimal values. This operation process is called recombination as shown in Fig. 2 (The part on the right which marked by yellow).
The length of binary value used for recombination is 8 in order to ensure that no information is lost in the process of converting binary value to decimal value. Therefore, the number of neurons in the process of  where bitDic(X t ) is a multivalued function that the binaries of the input X t divide into 4 parts and each part has 2 bits. NN(X t , CS X t ) is a mathematical formula for the NN structure of the OF-LSTMS that contains 4 neurons. CS X t (from the chaotic sequences) is the parameters of the corresponding inputs at the current moment. bitCon(x bit 1 , x bit 2 , x bit 3 , x bit 4 ) is a function that combines 4 binaries of 2 bits into 8 bits and converts them to decimals. X NN t is the outputs of the NN structure of the OF-LSTMS. The function of the forgetting gate in the traditional LSTM is to determine which information inherited from the cell body at the previous moment to discard, which is determined by the input sequence at the current moment and the output at the previous moment. But it is not applicable in the image encryption task. The essence   www.nature.com/scientificreports/ of the image encryption task is to scramble the image, and the less original image information contains in the encrypted image, the better the encryption effect. Therefore, the OF-LSTMS proposed in this paper designs the forgetting gate to the increasing gate, as shown in blue box A in Fig. 3. The cell body information at the current moment is obtained by accumulating with Eq. (2) the inputs' parameters at the previous moment and the information inherited from the cell body at the previous moment chaotically.
where C t−1 is the information inherited from the cell body at the previous moment. CS X t−1 is the inputs' parameter at the previous moment. C temp t is the information at the current moment after the increasing gate. The function of the input gate in the traditional LSTM is to determine which information is added to the information at the current moment after the increasing gate, and it uses the multiplication operation. But the input gate in the OF-LSTMS uses add operation, which is due to the limitations in the image encryption. The input gate in the OF-LSTMS is shown in blue box I in Fig. 3 and can be represented by where C temp t is the information to be added to the information of the cell body at the current moment after the input gate.
The operation used in the OF-LSTMS is different from the operation used in traditional LSTM, and it uses XOR. As shown in blue box C in Fig. 3, it can be represented by where C t is the information of the memory unit in the cell body that will be used to encrypt the input sequence at the current moment.
The function of the output gate in the OF-LSTMS is to use the information in the cell body and additional chaotic sequences to encrypt the input sequence. It is shown in blue box O in Fig. 3, and can be represented by  . In this algorithm, the original image sequence enters into the OF-LSTMS in order to operate with different chaotic sequences. The memory information C t and the encrypted pixel value O t can be obtained at the same time. According to the memory information C t , the new position of the encrypted pixel can be obtained, that is, the encrypted pixel position and pixel value are determined at the same time. The synchronization of permutation and diffusion can improve the efficiency of encryption.
The 2DCML fractional-order chaotic system The proposed chaotic system. Comparison with the traditional logistic map, the fractional-order logistic map contains larger key space and more parameters. Zhang et al. 52 exhibited the features of the fractionalorder chaotic system in dynamical behaviors. The following iteration equation is obtained 52 : The parameters α, μ, r and the initial values x 0 of the fractional-order logistic system can be designed the secret keys.
Based on the fractional-order logistic map, the proposed system coupled by the neighborhood links of the 2DCML system 53 as follows: where i , j are the lattices ( 1 ≤ i, j ≤ L ) , ε is the coupling parameter ( 0 ≤ ε ≤ 1 ), n is the time index (n = 1,2,3, …) and f (x) is the fractional-order logistic map with the iteration equation is obtained as Eq. (6).
The new features of the proposed chaotic system in dynamical behaviors. To qualify the new features of the proposed system in dynamical behaviors mathematically, the bifurcation diagrams, the Lyapunov exponents, the space-amplitude diagrams and the patterns diagrams are widely analyzed theoretically in this section.
In the proposed system, the bifurcation diagrams are shown in Fig. 4c. In Fig. 4a the parameter μ in the traditional logistic map is (3.57, 4). In Fig. 4b the parameter μ in the fractional-order logistic differential map breaks the range of µ ∈ (3.57, 4) and the numerical range of chaotic sequence x n also breaks the range of (0,1). While an important phenomenon in Fig. 4c is that the proposed system not only retains the advantages of the www.nature.com/scientificreports/ fractional-order logistic map, but also its periodic windows are reduced substantially compared with the Fig. 4a,b and the gaps between bifurcation points vary closer. Due to the neighborhood coupling leading the instability of the possible periods of orbits, the times of period doubling bifurcations is misled and unobvious. Therefore, both the parameter range and the values of chaotic sequences of the proposed system are larger than the traditional logistic mapping and the fractional-order chaotic logistic system. In our encryption algorithm, the proposed chaotic system is selected to generate chaotic sequences, and the parameters are selected as secret keys. Any system holding chaotic behavior presented at least one positive Lyapunov exponent. In Fig. 5, comparing with the Lyapunov exponents of the fractional-order chaotic logistic system and the traditional logistic maps system, the positive interval of Lyapunov exponents of the proposed chaotic system is far greater than that of the former two systems. Therefore, the proposed chaotic system has strong chaotic characteristics and can generate better chaotic sequences. It is more suitable for encryption algorithm.
Because the fractional-order logistic map contains larger key space and more parameters comparing with the traditional logistic map, the proposed system contains more universality of chaos in space than the 2DCML system with the same parameter ε, which is shown in the space-amplitude plots as Fig. 6. In addition, the snapshot patterns shown in Fig. 7 indicate that the proposed system presents more complex chaotic resolutions than the 2DCML system. For example, Fig. 7f indicates that the same parameter ε which lead the proposed system www.nature.com/scientificreports/ in fully developed turbulence pattern, can only lead the 2DCML system in defect turbulence pattern which is shown in Fig. 7e.

The proposed image encryption and decryption algorithm
Without loss of generality, the images are employed to present the encryption scheme for simplicity. The corresponding encryption algorithm and decryption algorithm can be presented as follows.
Step 1. Generate the key sequence K and the initial values α ′ , µ ′ , x ′ , r ′ and ε ′ of the proposed system. The proposed algorithm utilizes a 160-bit secret key K, which is generated by the hash algorithm MD2. For source images, even if only one bit is changed, its hash value will change completely. By dividing the 160-bit secret key into 16-bit blocks (K i ), and the new initial values can be obtained by the following formulas:  www.nature.com/scientificreports/ where α , µ , x 0 , r and ε are the initial given values.
Step 2. The chaotic sequences are iterated according to Eq. (7), and the chaotic sequences used in the OF-LSTMS are determined.
The original image is transformed into a sequence, and each 4 pixels value is regarded as a subsequence.
The subsequences are encrypted in the OF-LSTMS according to "The application of OF-LSTMS in the proposed algorithm" section. Assume the size of the encrypted image is 512 × 512 and the image is divided into 65,536 pixel sequences with 4 pixels as a group. Then the shape of input data into the OF-LSTMS is [1,65,536,4].
Finally, the ciphered image is obtained. The encryption process is shown as Fig. 8.

Decryption algorithm.
The decryption process is contrary to the encryption process. Using the secret keys provided by the sender, the receivers decrypt the cipher image according to the contrary operations of the encryption algorithm. The decryption process is shown as Fig. 9.

Performance analyses
In order to evaluate the security of the proposed encryption algorithm, we undertake a series of statistical analysis on the encryption and decryption results, and show the analysis results in detail in this section.
Key space. Only if the key space is large enough, it can resist violent attacks. The secret keys include decimal parameters α, μ, r, ε and the initial value x 0 . The total key space is 10 80 if the accuracy of the computer is 10 16 . In the proposed encryption algorithm, because the total key space is more than 2 425 that the key space can satisfy the security requirements.
Key sensitivity. The characteristic of chaotic system is that the small change of initial value will lead to completely different chaotic sequences. We modify one of the parameter values, while the others remain unchanged. Simulation and analysis show that small changes in the key will lead to significant changes in the output, so the algorithm is very sensitive to the key. Figure 12 shows the results of the corresponding μ, α, r, x 0 and ε tests, respectively.

Histogram analysis.
Histogram analysis is an important image analysis method, which can reflect the frequency distribution of pixel values in the image. Figures 13 and 14 show that encrypted images have completely different histograms against the original images. It shows that the encrypted image has no relationship with the original image. Therefore, the proposed image encryption algorithm can resist histogram analysis attacks.
Differential attack. To evaluate the encryption algorithm's ability to resist differential attacks, we employ the unified average changing intensity (UACI) and the number of pixels change rate (NPCR) which are defined by  Table 1, which shows that the proposed encryption algorithm is very sensitive to a pixel change in the original image. Mean Squared Error (MSE) and Peak Signal to Noise Ratio (PSNR) can be used to test the efficiency of encryption and decryption 40,41 . We calculate the PSNR and the MSE of the original images and the encrypted images. It can be seen from Table 2 that the PSNR value is lower, while the MSE value is higher, which indicates that the image encryption process is more efficient. Similarly, we also calculate the PSNR and the MSE of the original images and the decrypted images. The results in Table 2 show that the PSNR value is higher and the MSE value is lower, indicating that the image decryption of algorithm is efficient too. www.nature.com/scientificreports/ Correlation analysis. An efficient encryption scheme should reduce the correlation between adjacent pixels in the ciphered image significantly. In order to test the image correlation, we randomly select 3000 pairs of adjacent pixels from the image to calculate the correlation coefficients of adjacent pixels in the vertical, horizontal and diagonal directions using the following equation: where x and y represent two adjacent pixels and S is the total number of adjacent pixels (x, y). E(x) is the expectation of x and D(x) is the variance of x, respectively. The pixels distribution of the plain images and the cipher images in three directions are shown in Figs. 15,16,17,18,19,20. From figures it shows that the points in the encrypted images are randomly distributed, and the correlation of the images are greatly reduced. Meanwhile, Table 3 lists the correlation coefficients of the encrypted images which values are almost close to 0.

Information entropy.
Information entropy is the most important criterion to evaluate the efficiency of an image encryption algorithm. We calculate the information entropy of the cipher images and the results are listed in Table 4. The entropy of encrypted images are close to 8, which proves the proposed scheme is sufficient to withstand entropy-based attacks.
Comparison with existing algorithms. In recent years, some researchers have combined chaotic maps with optimization methods, DNA coding, S-box and mathematical transformation to propose secure and effective image encryption schemes 1,4,25,40,41 . Some encryption algorithms have improved the efficiency of encryption by optimizing the permutation and diffusion process 16,18 . In this paper, a new efficient image encryption algorithm is proposed by combining the OF-LSTMS with the 2DCML fractional-order chaotic system. By using the OF-LSTMS, the pixel position is changed while the pixel value is changed, which realizes the synchronization of permutation and diffusion. At the same time, the 2DCML fractional-order chaotic system has better chaotic ergodicity than traditional chaotic system. Compared with some recent literature, it is clear that the proposed encryption algorithm is better in performance, as shown in Table 5.

Robustness analysis.
A feasible encryption algorithm needs the ability of anti-interference, and robustness is an important indicator 2,7,26,44 . We add Salt-and-Pepper noise with different intensities to the ciphertext images, and we also make different degrees of data loss to the ciphertext image at different locations. The decryption effects are shown in Fig. 21. The quantitative results of resisting noise and occlusion attacks are listed in  www.nature.com/scientificreports/      In addition, the 2DCML fractional-order chaotic system contains good features as larger key space, better chaotic sequences which it is more suitable for encryption algorithm. The parameters used in the input gate, the output gate and memory unit of the OF-LSTMS are initialized according to the proposed chaotic system generated, which are different from the traditional LSTM initialization method. The proposed encryption algorithm greatly reduces the time consumption and improves the efficiency of image encryption. The extensive simulated experimental results such as key sensitivity, correlation, NPCR, UACI, information entropy and robustness analysis prove that proposed algorithm is high security and efficiency for image encryption applications.     www.nature.com/scientificreports/