Abstract
Securing image data from prying hackers is crucial in safeguarding the secrecy of data. Over the years, this was done by encrypting the image using an algorithm and a key, where the visible image was converted into a meaningless object. It is a difficult problem to design an image encryption technique based on chaotic systems with predictable cryptographic features. In this paper, the Quaternion, along with the Rossler attractor, was used to generate the key combination. The ciphering was done using the Least Square Approximation Algorithm (LSA). The algorithm was tested on a grayscale image database. The algorithm was initially tested in software using MATLAB R2018b, and was implemented in the Cyclone II EP2C35F672C6 device FPGA. On average, for a cipher image, the Peak Signal to Noise ratio (PSNR) was 9.09303 dB and the entropy was 7.9990 bits. For the cipher image, the Number of Pixels Change Rate (NPCR) and Unified Average Change Intensity (UACI) were 99.6039 and 33.4980, respectively. This proved that the algorithm could effectively mitigate the statistical and differential attacks. The key space was 2 (M ×N ×7 ×8), which was sufficiently high and mitigated the brute force attacks. The obtained results confirm that the cipher images resulting from the proposed ciphering scheme possess good cryptographic properties in terms of entropy, PSNR, UACI, NPCR, and keyspace analysis. Furthermore, the strength of the key is evaluated by the NIST test suite.
Keywords
Introduction
Over the decades, scrambling the image through encryption has become the norm for transmitting the image without being hacked. Several algorithms have been designed and implemented for encryption, with varying results. Many researchers have been investigating sensor networks in pursuit of a more robust security mechanism that incorporates modern cryptographic methods. The quaternion cryptosystem is a recent encryption technology that is efficient and resilient in many ways [1]. Because of the vast quantity of information they can contain, images are often employed as information carriers in Internet communication, and they are also the centre of private information that must be secured [2]. The Internet of Things (IoT) is defined as anything that has a sensor linked to it and can communicate data through the internet from one device to another or to humans. Wireless sensors, computing devices, apps, and actuators are examples of IoT products. These are linked to a particular item on the Internet, enabling automated data flow between things or people without the need for human involvement. Developing technology in integrated circuits and wireless communications has resulted in small devices that are effective, low-cost, and low-energy for use in remote sensing jobs [3].
We may encrypt them to preserve crucial information contained by the photographs. As a result of the above considerations, picture encryption is critical. In recent years, a plethora of image encryption methods have been created. However, traditional encryption techniques such as DES and RSA are unsuitable for picture encryption since image data demands high real-time properties in communications [4].
Literature survey
Hui liu et.al proposed an encryption algorithm based on a message passing algorithm with a chaotic external message. The message passing algorithm was used to interact with the adjacent pixels. The key was generated using a 2D logistic map [5]. An encryption system based on compressive sensing and memristive chaotic systems was proposed by Haiying hu et.al. The encryption system compressed the image twice, and block scrambling was used to scramble the image pixels. A compression ratio of 0.25 was achieved [6].
Yi He et al. proposed an encryption algorithm based on the Once Forward Long Short-Term Memory structure. The image was sub-divided into several image blocks and given as input to the memory structure. A two-dimensional coupled lattice chaotic system was used to generate the key. The system had good security features [7]. Noha A. Hikal and Marwa M.Eid proposed an encryption algorithm based on a hyperchaotic system. The system involved a five-dimensional hyperchaotic system and used DNA coding and classical scrambling diffusion encryption structure. Two rounds of diffusion were adopted. The algorithm provided good key space and resisted differential attacks [8]. An encryption scheme for securing palm print images was presented by Shuqin Zhu and Congxu Zhu. The scheme based on hybrid chaotic maps was used to suit the diffusion, confusion, and key space requirements. A combination of multiple chaotic maps was used in this scheme. The encryption system withstood all the attacks effectively [9].
An image encryption technique to encrypt multiple images was proposed by Alain Tiedeu et.al. The model involved a mixing technique involving mathematical expression governed by Cramer’s rule. The key was generated using the May-Gompertz map and a linear chaotic map. The image was sub-divided into blocks, and permutation and diffusion were carried out [10]. In [11], circle index table scrambling and partition diffusion mechanisms were used for image encryption. The plain image was transformed into coefficients using wavelets. Noise addition was done to the coefficients and two-level diffusion was done to the images. The algorithm was resistant to statistical and differential attacks.An encryption algorithm in the discrete domain was proposed by Guodong Ye et.al. The scheme used the Discrete Cosine Transform for performing substitution and permutation. The key was generated using a quantum logistic map [12]. A perturbation algorithm was implemented by Ibrahim Yasser et al. for data encryption. The original image was converted into coefficients using the Discrete Wavelet Transform, and the key was generated using a chaotic map. Permutation and Diffusion were done using a key and the algorithm could mitigate the statistical attacks [13].
Based on Modified Chua’s Circuit (MCC), which has hyper-chaotic behaviour, the image encryption was proposed by Batuhan Arpacı et.al. Bit level scrambling of the image and MCC were used to encrypt the image. The algorithm was resistant to differential attacks [14]. Using the jigsaw method, an encryption system was proposed in [15]. The jigsaw method involves revolving and shifting operations. The image was initially partitioned into sub blocks and shifted using control sequences generated by the hyper-chaotic Lorenz system. The preprocessing and postprocessing effectively increased the security of the image. A DNA-based computing method was proposed by S. Arunpandian and S. S. Dhenakaran for the encryption of greyscale images. DNA sequences were scrambled to add complexity to the image. The algorithm resisted differential and statistical attacks [16]. Various such algorithms [17–25], designed for encryption with a focus on time consumption with a focus on encryption, failed to pass several tests. Algorithms [26–32] talk about how to implement them in hardware and how to implement them in software.
Chen Yang suggested an image encryption approach for compressive sensing based on the mixed Bernoulli’s measurement matrix block. By combining chaotic sequence measurement with BCS, the suggested encryption technique is created. It improves the quality of the reconstructed picture while minimising compression. The plaintext image’s SHA256 function was utilised to produce the initial seed for the desired chaotic sequence, which increased the scheme’s capacity to withstand the selective plaintext attack. The plaintext attack might be mitigated by the encryption algorithm [33].
Vinoth Raj performed a security analysis on the reversible logic gate cryptography design using the LFSR key on a 32-bit microcontroller. The proposed encryption mechanism uses reversible logic gates as diffusion units, whereas a 4 bit LFSR serves as the key. There was no confusion unit involved in the encryption scheme. Hence, there will be visible traces of the original images that appeared on the encrypted images. Even though the obtained statistical results are better, they failed in randomness. test conducted by NIST SP 800-22. The cryptanalysis was conducted by performing edge detection on the encrypted images. The traces of the original images are obtained thanks to the confusionless encryption scheme. To solve this, a simple confusion unit made up of a LFSR is proposed to solve the problems of the schemes that don’t use confusion [34].
Xinyu Gao presented many image encryption techniques based on the 3D cube and hyperchaotic map. To produce the cipher cube, the following operations were performed: rotation, swapping, DNA addition, and DNA mutation. The encryption simulation results for several picture sizes demonstrate that the approach may be employed regardless of the quantity and size of images. The suggested system is verified using standard statistical and differential analysis. In addition to the aforementioned analyses, dataloss and noise attack analyses are carried out. The suggested approach has a wider keyspace, hence the algorithm is resistant to bruteforce attacks [35].
Vinoth Raj investigated the optimal concurrency on an FPGA for lightweight medical image encryption. The proposed encryption technique comprises of a Lorentz attractor that acts as a key for the diffusion process, and the confusion is accomplished by the use of pseudo random sequences generated by the LFSR. Statistical studies, keyspace analysis, and hardware analysis are used to assess the strength of the proposed encryption architecture. The NIST test suite evaluates the key’s strength [36].
Xudong Liu implemented a discrete chaotic system for the image encryption application. A chaotic S-box generation algorithm supporting multi-objective optimization is designed based on the non-domination sorting genetic algorithm. and a novel gene modification method we designed. The constructed s-box offers greater nonlinearity and is highly resistant to statistical and differential attacks. The proposed scheme is also designed for color image encryption. From the obtained cipher images, the proposed ciphering scheme provides better cryptographic characteristics [37].
This paper involves the design of a new algorithm involving quaternion and Rossler’s attractor for the generation of keys. The encryption was performed here using the LSA method. As the proposed algorithm involves three stages of diffusion and a single stage of confusion operations, involving quaternion rotation, deciphering the cipher is close to impossible.
The significant contributions of this paper include Combined use of quaternion and Rossler attractor for generation of a key, which increases the key space to 2 (M×N×7×8) Implementation of LSA and quaternion together for encryption, which makes the algorithm more rigid towards attacks.
The rest of the paper is organized as follows. Section 3 discusses the generation of keys and the proposed algorithm, along with the decryption. The results were discussed and analysed using the metrics in Section 4. The results were compared with contemporary algorithms and relevant graphs in Section 5. The concluding remarks, along with future improvements, were deliberated in Section 6.
Proposed methodology
The algorithm designed for encrypting the image involves three levels of diffusion operation interleaved with one level of confusion operation. The sequence of pre-Bit-XOR and post-Bit-XOR operations, with the Least Square Approximation (LSA) mechanism in between them, completes the diffusion operation. The confusion operation is done using the position map obtained from the generated key. The algorithm design is given in Fig. 1.

Encryption system.
As per the Kerchoff’s principle, any encryption system is only as strong as the key. The strength of the key is achieved by the generation of random numbers. The randomness in the key is achieved by the combination of the Rossler attractor and the Quaternion. As a hyper-complex number system with extra imaginary components, the Quaternion, invented in 1843, could be used in Pseudo Random Number Generation (PRNG). A quaternion, represented as q (k, v), has a scalar component “k” and a vector component “v”, comprising imaginary components “l i”, “m j”, and “n k”. The quaternion is represented by Equation 1.
Where k, l, m, and n are real numbers. As such, the quaternion is formed with k, l, m, and n as inputs, and a quaternion rotation matrix of order 3 x 3 is framed. This framed matrix is of the type of real numbers. As the algorithm deals with the image data, which is of integer type, the framed matrix is conditioned, processed, and converted into an integer matrix. The quaternion rotation matrix Γ(q), is given by Equation 2.
To achieve randomness for the key, a 3D Rossler attractor is used. Due to its chaotic nature, the generated Rossler attractor, combined with Quaternions, provides a good pseudo-random number that could be used as a key. The 3D Rossler attractor is governed by the Equations 3, 4, and 5.
Where a, b, and c are the real numbers, which can be varied to produce different random numbers. The obtained x, y and z can be together framed as a matrix of order 3×N. Here, N is the total size (rows x columns) of the input image. The framed matrix has real numbers. As the image data is of type integer, the framed matrix is conditioned, processed, and converted into integers. To generate the key, the Rossler attractor matrix of order (3×N) is rotated using the quaternion rotation matrix of order (3×3), to generate the PRNG matrix of order (3×N), given by Equation 6.
The chaotic nature of Rossler attractor is given by the bifurcation diagram given in Fig. 2. The figure shows that, even a smallest change in any one parameter could drastically alter the outcome of the chaotic sequences generated.

Bifurcation diagram for Rossler’s attractor. (a) ‘a’ vary; b, c fixed (b) ‘b’ vary; c, a fixed (c) ‘c’ vary; a, b fixed.
As the processed image data is a 1D row vector, the PRNG matrix is converted to a row vector by performing Bit-XOR of all the three rows with each other. The resultant 1D PRNG sequence is used as the key for encrypting the image. The key generation process is given in Fig. 3.

Key Generation.
The Least Square Approximation (LSA) technique minimises the sum of the squares of the difference between two parameters. This could be employed in encrypting the image. The image is converted into a stream of one-dimensional data. An independent matrix, A, is created for the manipulation. The image data is converted into a one-dimensional column vector (b). Each column vector (b) is manipulated with A to get the encrypted column vector. Thus, all the image data is converted into encrypted values, such that the resultant image is a cipher image. The LSA is governed by Equation 7.
The algorithm for encrypting the image is a five-step process.

LSA Encryption.
LSA Encryption The numerical example for generation of position map and rearrangement of data is given in Fig. 5.

Rearrangement using Position map.
The cipher image is decrypted to get back the original plain image. This is done by first reordering the cipher image pixels using the position map obtained from the key, K. The re-ordered cipher image is bit-xored with key K, and this is followed by performing an inverse LSA on the image data. The obtained data is again Bit-XORed with the key, to get the original plain image. The decryption is a five-step process. At the receiver side, upon receiving the initial conditions such as the key and the encrypted image, the decryption steps are carried out. The decryption mechanism is given in Fig. 6.

Decryption mechanism.
The decryption algorithm is a five-step process.
The algorithm was tested with images from a grayscale image database [34] and the cipher images were obtained. The algorithm’s performance was tested using metrics. The algorithm passed all the metric tests, and hence the algorithm could be used as an effective algorithm for image encryption.
Statistical analysis
Visual perception and analysis
The ideal cipher image should be a visually meaningless object. The peak signal-to-noise ratio (PSNR) between the plain image and the cipher image can be used as a metric to check the quality of the cipher image. The PSNR is calculated by finding the Mean Square Error (MSE). If the error between the input plain image and the output cipher image is high, then the MSE is high. Higher the MSE, lower the PSNR. Hence, if the PSNR is low for a cipher image, it could mean that the cipher image is a good, meaningless object. The PSNR between the plain image and the cipher image is calculated by Equations 8 and 9.
Where,
m, n –row and column of the image respectively.
Max f –Maximum pixel value in an image.
f (m,n) –pixel value of plain image
g (m,n) –pixel value of cipher image
A histogram of an image is used to depict the number of times each pixel occurs in an image. If all the pixels of an image occur an equal number of times, then the histogram appears flat. Hence, for an ideal cipher image, the histogram should be flat.
Entropy analysis
For a good cipher image, the number of bits required to represent each pixel must not be predictable. The extent to which uncertainty exists in the number of bits required to represent each pixel in a given image is given by entropy. Calculation of entropy is given by Equation 10.
Where,
p(xi) –probability of occurrence of symbol xi
The cipher image is a completely meaningless object if the neighbouring pixels have no relation to each other. The correlation between the adjacent pixels is found by the correlation coefficient. The relations between each neighbouring pixel in horizontal, vertical, and diagonal directions are found by the Equations 11–14.
Where, a’, b’ –Mean of a, b respectively,M –Total number of pixels Cov (a,b) –covariance of a, b
The most of the contrast in the image helps the viewer to clearly distinguish items in a image. Because the image is encrypted, the degree of chaos is increased. As a consequence, it raises the amount of contrast to a fairly high level high worth Contrast is truly related to the amount. The perplexity caused by the S-box inside the original image. Where m, n depicts the pixels of image.
The encrypted image is measured via energy analysis. To conduct energy, the gray-level co-occurrence matrix is used. The suggested encryption strategy outperforms the prior encryption system published in the literature. The energy’s mathematical expression is
The image data has a natural distribution that corresponds to the contents of the relevant image. We run the homogeneity function, which computes the proximity of the scattered components. This is often referred to as a gray-tone spatial dependence matrix. The homogeneity is often defined by
The differential attack could be mitigated if the cipher image could withstand the NPCR (Number of Pixels Change Rate) and UACI (Unified Average Changing Intensity) tests [38–40]. The attacker could make small changes in the plain image and alter the encrypted image. The NPCR and UACI are given by Equations 18, 19.
Where,
D(m,n) –value of each pixel
W, H –total number of rows and columns in an image
C1 –Cipher image
C2 –One-pixel changed Cipher image
The PSNR, on an average, is 9.09303 dB and the entropy, on an average, is 7.99903 bits. The correlation coefficients in all three directions were found for an encrypted image. The neighbouring pixels were highly uncorrelated, with the horizontal, vertical, and diagonal coefficients being –0.00094, 0.00115, and –0.0001 respectively. The test results are shown in Table 1. This analysis against statistical attacks meets the required values and hence the algorithm could effectively mitigate the statistical attacks. The analysis was also done to check whether the algorithm withstands differential attacks. The results were promising and, on average, the NPCR was 99.6039 and the average UACI was 33.498. Hence, the algorithm could mitigate the differential attacks. The results are shown in Table 2.
Statistical analysis
Statistical analysis
Differential analysis
Figure 7 shows that the histogram of the cipher image is flat, which proves that the cipher image is imperceptible to the naked eye. The flat histogram also means that all the pixels occur an equal number of times, and hence the image is encrypted. The neighbouring pixels in the cipher image are not related to each other, and this is shown by the correlation graphs. The algorithm was tested for a chosen plaintext attack. The algorithm effectively mitigated these attacks. The functionality of the algorithm was initially tested using the software MATLAB R2018b.

Encryption Algorithm Analysis (a) Plain Image (b) Cipher Image (c) Histogram of Plain Image (d) Histogram of Cipher image (e) Horizontal Correlation of Plain Image (f) Vertical Correlation of Plain Image (g) Diagonal Correlation of Plain Image (h) Horizontal Correlation of Cipher Image (i) Vertical Correlation of Cipher Image (j) Diagonal Correlation of Cipher Image.
The algorithm encrypted the plain image effectively, and hence the algorithm was implemented in the Cyclone II FPGA. As the key generation using the Rossler attractor involved floating point numbers, the numbers were converted using IEEE 754 single precision floating point conversion for FPGA implementation. The multiplier and matrix inversions were designed with the minimum logic elements, and the functionality was verified. The implemented design in hardware involves a multiplexer, matrix inversion logic, and matrix multiplication logic. The design was done in an optimised way such that the logic elements involved for matrix multiplication were just 33. The hardware design model is given in Fig. 8. The net list for the matrix inverse operation and matrix multiplier is given in Fig. 9.

Hardware model of encryption system.

Netlists (a) Multiplier (b) Matrix inversion (c) Encryption system.
The encryption algorithm is as strong as the key. The key generated here through a combination of Rossler attractor and Quaternion has a total of seven variables. Each variable is 8 bits, so the total key space is 2 (M ×N ×7 ×8). Performing a brute force attack on such a large keyspace could take 10∧63 years, in the case where the image size is 512×512. The brute force attack becomes nearly impossible as the image size increases. The Slightest change in any one of the input variable sets could modify the key, and hence the deciphering/hacking becomes impossible. The higher the key sensitivity, the higher the security. The generated key was tested with the NIST 800-22 test suite. The generated stream of random numbers successfully passed the NIST test with good margins. The test results are shown in Table 3.
Results of NIST Test suite
Results of NIST Test suite
The algorithm was implemented and tested for chosen plain text attacks. The two plain images were XORed and compared with the XOR of the corresponding cipher images. It was found that the two images were not the same, and hence it could be said that the algorithm successfully mitigated the chosen plain text attack. This is shown in figure 10. The algorithm also withstood the brute force attack, as the key length is high and it has a higher key sensitivity.

Chosen Plain Text attack analysis.
The algorithm results were compared with those of contemporary algorithms. The comparison shows that the algorithm is good for the encryption of grayscale images. The proposed algorithm has a PSNR of 8.4116 dB, which is well below the 10 dB range. The comparison is given in Table 5. The graphical comparison is given in Fig. 11. while 11.a depicts the PSNR comparison while Fig. 11. b, c & d implies the comparison of entropy, NPCR & UACI respectively. The entropy is 7.9994 bits, which is close to 8 bits. The entropy is higher when compared to similar encryption schemes reported in Table 5. The horizontal correlation coefficient is in the negative direction with a value of –0.0029. The vertical and diagonal correlation coefficients are 0.0001 and are close to zero. The obtained results ensure the proposed encryption scheme breaks the correlation among adjacent pixels. The NPCR value is near 100 and the UACI value is in the proper mid-range. In addition to the standard analysis, the proposed scheme was compared with the [38] and [40] in terms of energy, contrast, and homogeneity. The obtained values outperform the rest of the schemes and are tabulated in Table 6. Hence, the proposed algorithm is good for the encryption of images.
Comparison of correlation coefficients
Comparison of correlation coefficients

(a) PSNR comparison (b) Entropy comparison (c) NPCR comparison (d) UACI comparison.
Comparison of contrast, Energy & homogeneity
The algorithm was also tested for noise attacks. The cipher image was subjected to noise, and it was decrypted and compared with the plain image. The PSNR and the SSIM were in good order and hence could be aid that the algorithm withstood the noise attacks. This is shown in Table 4.
Attack analysis with Noise
The encryption algorithm implanted in the FPGA for grayscale images passed all metric tests. The algorithm involved encryption using LSA and Bit-XOR. The PRNG was generated using quaternion and the Rossler attractor. The PRNG had good randomness and was tested using the NIST suite. The algorithm withstood the statistical and differential attacks. The algorithm has also withstood the chosen plain text attacks. The algorithm could be further tested for medical images in formats such as DICOM and colour images in formats such as RGB. As the image size increases and the number of planes in the image increases, the complexity of implementation using FPGA increases. This is because of the constrained memory space in FPGA and the number of logic elements involved. After taking into consideration these intricacies, if such a design evolves, then this algorithm would become a universal algorithm for all modalities of images. In order to develop a prototype, the proposed encryption architecture was implemented in Cyclone II FPGA. To develop an indigenous cryptosystem. The proposed encryption architecture is going to be implemented on an ASIC chip.
