An Efficient Image Cryptosystem Utilizing Difference Matrix and Genetic Algorithm

Aiming at addressing the security and efficiency challenges during image transmission, an efficient image cryptosystem utilizing difference matrix and genetic algorithm is proposed in this paper. A difference matrix is a typical combinatorial structure that exhibits properties of discretization and approximate uniformity. It can serve as a pseudo-random sequence, offering various scrambling techniques while occupying a small storage space. The genetic algorithm generates multiple ciphertext images with strong randomness through local crossover and mutation operations, then obtains high-quality ciphertext images through multiple iterations using the optimal preservation strategy. The whole encryption process is divided into three stages: first, the difference matrix is generated; second, it is utilized for initial encryption to ensure that the resulting ciphertext image has relatively good initial randomness; finally, multiple rounds of local genetic operations are used to optimize the output. The proposed cryptosystem is demonstrated to be effective and robust through simulation experiments and statistical analyses, highlighting its superiority over other existing algorithms.


Introduction
With the increasing transmission of multimedia information over the internet, it has become essential to protect against unauthorized access.Digital images are a widely used data format for storing more vivid information.Image encryption mainly involves converting a meaningful image into a meaningless one through two fundamental techniques, namely, scrambling and diffusion, thereby rendering it inaccessible to unauthorized individuals.Scrambling involves the modification of the positioning or ordering of pixels within an image.On the other hand, diffusion modifies pixel values to achieve a randomized effect.These techniques can be applied independently or combined to create more complex encryption schemes.
Numerous image encryption algorithms have been put forward recently, with chaosbased ones garnering significant attention in this field due to their distinctive properties [1][2][3].Chaotic systems are nonlinear dynamical systems that exhibit complex and unpredictable behavior, making them suitable for cryptographic systems due to their ergodicity, sensitivity to initial conditions, non-periodicity and non-convergence.However, attackers can exploit regions of regularity or low chaos within these systems to break encryption schemes, particularly if they possess knowledge of the plaintext used in encryption or can select it.Therefore, chaotic systems are frequently employed in conjunction with other technologies to enhance their level of security, such as DNA [4][5][6][7], genetic operations [8][9][10], compressive sensing [11][12][13], fractal sorting matrix [14], bit matrix [15], combinatorial design structures [16][17][18][19][20][21][22][23], and others.
Most concepts in combinational design theory are directly defined on finite sets, which can compensate for the limitations of applying chaos theory to cryptography.To date, many combinational design structures have been implemented in the field of cryptography, including Latin squares [16][17][18], orthogonal arrays [19], Latin cubes [20][21][22], Hadamard matrices [24], etc. Latin squares are commonly utilized in image encryption thanks to their distinctive properties of dispersion, uniformity, and abundance.These algorithms initially employ Latin squares to generate 1D maps for scrambling, then perform XOR operations directly on 2D images.However, they suffer from the drawbacks of low scrambling efficiency and susceptibility to specific attacks.The utilization of orthogonal Latin squares enables the direct construction of a 2D map, resulting in an enhanced scrambling efficiency [25].Orthogonal arrays can be utilized to select appropriate rows for generating a pair of orthogonal Latin squares, albeit at the cost of requiring a relatively large storage space.Latin cubes are particularly useful in encryption, especially when dealing with more complex scenarios.Therefore, here we adopt another typical combinatorial design structure: the difference matrix.With its discreteness and approximate uniformity, it requires only a small storage space, making it an ideal candidate to serve as a pseudo-random sequence.Moreover, each difference matrix possesses a crucial property in that selecting any nonzero row generates a Latin square, while choosing any two non-zero rows produces a pair of orthogonal Latin squares.Therefore, a difference matrix can provide multiple pseudo-random sequences and a variety of scrambling methods, making it highly suitable for image encryption.
In recent years, the utilization of genetic algorithms (GA) in encryption technology has emerged as a prominent research frontier within the realm of image encryption.GAs are a type of optimization algorithm that operate on the principle of natural selection and evolution.Advantages such as simplicity, robustness, intrinsic parallelism, and self-adaptation have made them a popular choice in various fields, including cryptography, combinatorial optimization, and more.In 2012, Abdullah et al. put forward a hybrid model combining a GA and a chaotic function [8].It employed the correlation coefficient as the fitness function.This approach has weaknesses against certain attacks, however, primarily due to its reliance on plaintext images and the utilization of identical chaotic sequences to encrypt different images.Thus far, various enhanced genetic algorithms have emerged for image encryption by leveraging the optimization capabilities of GAs to generate high-quality ciphertext images [26][27][28][29], optimizing chaotic sequences [30], and employing genetic operations directly for encryption [10,31,32].Additionally, some approaches have integrated novel technologies along with GAs to improve the security and efficiency of the resulting cryptosystem [33][34][35].In 2018, Pashakolaee et al. put forward a novel image encryption algorithm (IEA) named Hyper-chaotic Feeded GA (HFGA) [26].This algorithm mainly uses a GA in combination with a hyperchaotic system to optimize cryptographic images and provide a secure decryption mechanism for authorized recipients.In the same year, Mozaffari proposed a parallel IEA on the basis of bit-plane decomposition [27].In this approach, a GA was utilized to perform permutation and replacement steps through crossover and mutation operations.The resulting algorithm enables parallel processing of multi-bit-plane encryption, thereby enhancing the encryption speed and rendering it suitable for real-time applications.In 2019, Premkumar et al. put forward a secure composite 3D chaos-based image encryption algorithm utilizing a GA [31].The algorithm was implemented by arithmetic crossover, multi-point crossover, and permutation of combinatorial mutation operators.In 2021, Zhang put forward a new IEA integrating genetic mutation and ML-NCML [34].The proposed encryption scheme employs DNA mutation and crossover operations by chaotic sequences.By integrating chaotic systems into the DNA operations, the scheme can effectively counter man-in-the-middle attacks, which are prevalent in traditional DNA addition and subtraction operations.In 2022, Qobbi proposed a novel encryption scheme combining a 2D logical mapping and genetic manipulations [10].The algorithm's security was guaranteed through the use of CBC with genetic manipulations.In 2022, Liang proposed an image cryptosystem combining the Fibonacci-Q matrix and GA [29].The four-layer encryption framework employed to bolster the encryption security of this cryptosystem consists of diffusion, scrambling, diffusion, and optimization.In 2023, Bhowmik put forward an IEA employing a modified chaotic system integrated with DE and GA [30].The GA was used to generate a unique key-string that was employed for the transposition process in the confusion stage.In summary, GAs represent a meta-heuristic optimization technique that can be applied to enhance the behavior of chaotic sequences or to improve the stochastic properties of ciphertext images during the encryption process.By introducing a GA into image encryption, it is possible to achieve a highly secure and efficient method for encrypting images.
To realize the advantageous properties of a difference matrix together with the optimization capabilities of a GA, we propose an efficient image cryptosystem utilizing both techniques.Difference matrices can serve as generators for Latin squares or pseudo-random sequences, while GA operations of crossover and mutation are employed to generate new individuals.This is followed by local optimization to achieve overall image optimization.The proposed cryptosystem first generates a difference matrix, which is then utilized for initial encryption.Subsequently, genetic operations are employed to cross and mutate the encrypted image blocks, followed by multiple rounds of optimal preservation to enhance the randomness of the final ciphertext image.The novel contributions of this research are summarized below.

•
We introduce a novel combinatorial structure for image encryption consisting of a difference matrix.It can be utilized to generate Latin squares or serve as a pseudorandom sequence while maintaining simplicity and requiring only a small amount of memory.

•
The above structure is used to generate a novel row-scrambling method using a pair of orthogonal Latin squares.

•
We define the formula for a single-point mutation.New individuals are then generated through crossover and mutation operations.Multiple rounds of local optimization using the optimal preservation strategy are used to further enhance the output.

•
Our simulation results demonstrate the effectiveness of this cryptosystem in both encryption and decryption processes, exhibiting both robustness and practicality against conventional attacks.
The remaining sections of this paper are organized as follows: Section 2 presents a concise overview of the definitions for the difference matrix and the GA; Section 3 is dedicated to presenting the detailed processes for encryption and decryption; our simulation results and security analyses are presented in Section 4; finally, Section 5 serves to summarize this article.

Difference Matrix
Let (G, +) be an Abel group of order n.An (n, k; 1)-difference matrix is a k × n matrix D = (d ij ) with entries from G such that for any 1 ≤ i < j ≤ k, the multiset {d is − d js : 1 ≤ s ≤ n} (called the difference list) contains every element of G exactly once [36].Removing any row from an (n, k; 1)-difference matrix results in an (n, k − 1; 1)-difference matrix.
A Latin square of order n (defined on an n-set S) is an n × n array in which each cell contains a single symbol; thus, each symbol occurs exactly once in each row and column.Two Latin squares of order n A = (a ij ) and B = (b ij ) are orthogonal if every ordered pair in S × S occurs exactly once in the juxtaposition array C = ((a ij , b ij )).
Theorem 2 demonstrates that each nonzero row in a difference matrix can be used to generate a Latin square through the use of the addition operation.In addition, any two rows in a difference matrix can be used to generate a pair of orthogonal Latin squares.
First, by utilizing Theorem 2 to generate the multiplication table of F 4 , we can obtain a (4,4;1)-difference matrix M t with M t (i, j) = g i × g j .Subsequently, this matrix can be converted into digital format: By selecting two nonzero rows from the difference matrix M t , namely, row 1 = 2 and row 2 = 3, we can form two Latin squares Lm 1 and Lm 2 using the addition operation in F 4 : We use Lm 1 and Lm 2 to construct the juxtaposition array Lm 12 , where each ordered pair occurs only once.Thus, it can be inferred that Lm 1 and Lm 2 are orthogonal: 23

Logistic Map
The logistic map signal, which is one of the most well-known signals exhibiting chaotic behavior, can be described as follows (1): where x n is a real number between [0, 1] and µ is a system parameter.When 3.573815 < µ ⩽ 4, the sequence {x n | n = 0, 1, 2, ...} has chaotic properties.Sensitivity to initial values and non-periodicity are the characteristics required by cryptography for keys and chaotic sequences.

Genetic Algorithm (GA)
Based on the principle of natural selection, John Holland first proposed GA as an optimization algorithm utilizing random search techniques in 1975.By selecting the most fit individuals and recombining their genetic information via crossover and mutation operations, a GA evolves a population of candidate solutions to generate new individuals.This process continues until satisfactory solutions are obtained or the algorithm reaches a predetermined stopping criterion.Thanks to their robustness, flexibility.and effectiveness in finding optimal solutions, GAs have been widely used in multiple optimization problems across different domains [38,39].

Selection
A GA mainly evaluates individuals according to their fitness, with commonly employed methods including sorting selection, roulette wheel selection, etc. Occasionally, to prevent the loss of the best individuals, a strategy of optimal preservation is implemented whereby the fittest members of the population are directly carried over into the next generation without undergoing selection, crossover, or mutation.

Crossover Operation
The crossover operation is a fundamental genetic operator in a GA that combines the genetic material of two or more parent individuals to generate new offspring.This process mimics the sexual reproduction found in nature, in which genes are inherited from parents.Various types of crossover operators exist within genetic algorithms, such as single-point, double-point, and multi-point crossovers, uniform crossover, arithmetical crossover, and many others.The crossover operation formula used in our proposed cryptosystem is presented below (2): where c denotes a crossover point, which is the index at which the genetic material of the two parent solutions is swapped; ps1 and ps2 represent two parent solutions, usually expressed as integers; ns1 and ns2 indicate two offspring solutions; and f loor and mod represent the down round and module integer functions, respectively.We use (2) to formulate the crossover function (ns1, ns2) = crossover(ps1, ps2, c), which can be directly applied later.An illustrative example of the crossover operation is presented in Table 1.

Mutation Operation
Mutation is another crucial genetic operator in GAs, introducing random changes to an individual's genetic material to create new candidate solutions.This operator plays a vital role in maintaining population diversity, preventing premature convergence, and enhancing the algorithm's local search capability.Various mutation operators are utilized in genetic algorithms, such as basic bit mutation, uniform mutation, Gaussian mutation, and others.In this paper, we define the rule of the mutation operation as follows (3): where c is a mutation point, pm denotes a parent solution, and gm represents a newly generated solution.We use (3) to formulate the mutation function gm=mutation(pm, c) for direct application in subsequent steps.An illustrative example of the mutation operation is presented in Table 2.

The Proposed Cryptosystem
We now introduce several symbols that are utilized in the rest of this paper.The symbol n represents a prime power, Q denotes an n × n grayscale image, C signifies the corresponding ciphertext image, and K 1 refers to the initial encryption key.This cryptosystem is comprised of the following three parts.In Algorithm I, a difference matrix M defined on a finite field is generated using K 1 .Algorithm II is utilized to perform the initial encryption, which consists of three layers: large-scale mutation, scrambling, and diffusion.This results in the formation of the initial encrypted image C ini .In Algorithm III, both crossover and mutation operations are applied block-by-block to C ini , and the final ciphertext image C is obtained over multiple iterations through the optimal preservation strategy.The encryption diagram of this cryptosystem is shown in Figure 1.

Generation of a Difference Matrix M
We generate a difference matrix M on a finite field.Initially, K 1 is utilized to produce an n-length chaotic sequence, which is employed to construct a finite field of order n.Subsequently, the difference matrix M is generated.
Step 1: Generate a logistic sequence of length 1000 + n using (1) with system parameter µ 0 and initial value x 0 = key 0 .The sequence obtained by excluding the initial 1000 values is denoted as to sort X in ascending order and obtain a new sequence f x, and corresponding index subscript vector lx.

Generation of the Initial Ciphertext Image
This section describes the generation of the initial ciphertext image C ini .First, a new encryption key is generated by adopting the information of the plaintext image.Then, a new n-length chaotic sequence is generated to construct the second finite field according to the method of generating a finite field from a sequence, as described in Algorithm I. Subsequently, a pair of orthogonal Latin squares is generated by selecting two nonzero rows from M. Finally, C ini is generated through three steps: large-scale mutation, scrambling, and diffusion.
Algorithm II: Generate the initial ciphertext image C ini .
Output: The initial ciphertext image C ini .
Step 1: Read Q and calculate the sum of all the pixel values, denoted as sumQ.Letting compute key 1_new = (key 1 + s)/2.Using µ 0 as the system parameter and key 1_new as the initial value, generate the second n-length chaotic sequence, then form the second finite field F 2 using the method in Algorithm I.
Step 2: Obtain an (n, n − 1; 1)-difference matrix by removing the zero row of matrix M. Select rows mod(sumQ, n − 1) and mod(sumQ + a, n − 1) to generate two n × n orthogonal Latin squares L m1 and L m2 via F 2 .By transforming these squares into row vectors, denoted as L 1 and L 2 , respectively, two index indicators ind 1 and ind 2 can be constructed based on their uniformity using the following formula: Step 3: Large-scale mutation.Transform Q into a row vector P 1 .Based on the parity of sumQ, distinct index indicators can be selected to sequentially mutate each element of P 1 and generate a new row vector P 2 using the mutation formula provided below.
Step 4: Image scrambling.Utilize the orthogonality of L 1 and L 2 to scramble P 2 and L t (The row vector formed by the transposition of M), resulting in the scrambled row vector P 3 and an approximately uniform vector L T .
Step 5: Image diffusion.The initial ciphertext image C ini is formed using L 1 , L 2 and L T as pseudo-random sequences for auxiliary diffusion.
where temp represents a temporary variable, C ini (−1) = 0 and ⊕ represents an XOR operation.

Optimization Process Using GA
In this section, we use a GA to optimize C ini in order to enhance the randomness of the final encrypted image.First, owing to the inherent randomness of GAs, multiple indexes are determined in order to restore the original plaintext image.Then, local crossover and mutation operations on C ini blocks are used to construct a large number of encrypted images, which significantly increases the level of randomness.Finally, after multiple rounds of genetic operations and using the optimal preservation strategy, the final encrypted image C and secondary key K 2 are generated.
Algorithm III: The optimization process using GA.Input: C ini , ind 1 , ind 2 , L T , the number of crossover blocks N c , the number of mutation blocks N m , and the number of iterations Num.
Output: The final encrypted image C and the secondary key K 2 .
Step 1: Process L T as follows to acquire the third index indicator ind 3 : Step 2: Crossover operation.Divide C ini into N c parts from left to right and intersect each part according to ind 1 and ind 2 to form 2 × N c new individuals.These individuals are then stored in the matrix CM 1 .Using entropy as the fitness function, select the best individual, denoted as C 1 , through the optimal preservation strategy.Simultaneously, record the corresponding index value Ind cbest in the first row component of K 2 .The Algorithm 1 is presented below, where crossover represents the compiled crossover function (2).
end for 6: end for 7: C 2 = CM 2 (Ind mbest , :); 8: return C 2 Step 4: Let C ini = C 2 .Continue with Steps 2 and 3 until the number of iterations Num or Ind cbest and Ind mbest match that of the previous column in K 2 , then terminate the calculation and record final iteration number as Ind best .
Step 5: Transpose C 2 , the vector obtained after the iteration, into an n × n matrix in order to obtain C and output K 2 .

Image Decryption Process
The proposed cryptosystem employs asymmetric processes for both encryption and decryption.To decrypt C, the receiver requires K 1 and K 2 along with the characteristic value sumQ and the public parameter a.The decryption diagram of this cryptosystem is illustrated in Figure 2.
The steps are described in detail below.
Step 1: First, K 1 is utilized to generate M following Algorithm I.Then, three row vectors L 1 , L 2 , and L T are generated using sumQ and a.
Step 2: Cis transformed into a row vector R 1 and the pre-optimized image R 2 is decrypted using K 2 .This step is asymmetric with regard to the optimization process, and can be decrypted directly by using K 2 .Initially, mutation is performed according to the second index block of the last column of K 2 , then crossover is conducted according to the first index block, iterating Ind best times to obtain R 2 .
Step 3: The original image R is recovered from R 2 .First, reverse diffusion is performed on R 2 to obtain R 3 , then reverse scrambling to obtain R 4 , followed by reverse large-scale mutation to acquire R 5 .Finally, the result is transposed into an n × n matrix in order to obtain the decrypted image R.This step is a complete reversal of the initial encryption process, and is not repeated.
Step 1：Generate M Step 2：Reverse optimization Step 3： Reverse initial encryption Crossover

Simulation Results and Safety Analyses
To validate the security and efficacy of the cryptosystem proposed in this paper, a set of 256 × 256 grayscale images from the USC-SIPI2 image set were selected as test samples.The initial key K 1 was set to µ 0 = 3.99999, key 0 = 0.123456 and key 1 = 0.234567, whilehe public parameters were set to a = 31, N c = 16, N m = 32, and Num = 20.
In the process of utilizing GAs for image encryption, fitness functions such as entropy and correlation coefficients are commonly employed for assessing the quality of ciphertext images.However, due to the stochastic nature of correlation coefficients, in this paper we have instead adopted the information entropy of the encrypted image as the fitness function.
We evaluated our proposed cryptosystem through simulation experiments from various aspects, including key space and sensitivity analyses, statistical analyses, resistance to differential attacks, and more.To demonstrate its superiority over recent algorithms, a comparison is provided in terms of security and efficiency.

Simulation Results
Our cryptosystem is highly effective in converting a grayscale image into a meaningless encrypted image, thereby ensuring the confidentiality and privacy of the original.Additionally, the decrypted image remains unchanged, with no loss or distortion, guaranteeing its integrity and authenticity.Figure 3a shows the several plaintext images, Figure 3c depicts the corresponding ciphertext images, and Figure 3e illustrates the lossless decrypted images.In this cryptosystem, the initial encryption process ensures that any image meets the requirements for encryption, while the optimization stage further enhances the overall randomness.The second keys and the iteration numbers required for optimization are displayed in Table 3.For a majority of the images, the optimization process can be completed within 20 generations, resulting in relatively higher-quality ciphertext images.The key space of a cryptosystem is a metric describing its resistance against brute-force attacks.A larger key space results in increased resistance to such attacks, making it more difficult for attackers to determine the correct key.The initial key K 1 = (µ 0 , key 0 , key 1 ) has a precision of 10 −15 for each real number.Therefore, the key space can reach at least 10 45 ≈ 2 149 , which is significantly larger than 2 128 [40,41].In addition, each image has a unique K 2 value during decryption, and there is a public parameter that can be selected.Therefore, the key space of the proposed cryptosystem is of sufficient size to defend against brute-force attacks.

Key Sensitivity Analyses
Key sensitivity is a crucial property of an image cryptosystem, ensuring that even the slightest alteration in the encryption or decryption key will result in two entirely distinct datasets.In regard to the proposed cryptosystem, the key sensitivity can be analyzed from two perspectives: during the encryption stage and during the decryption stage.
To analyze the key sensitivities of the proposed cryptosystem, we selected Lena as the test image.The resulting ciphertext image when encrypting Lena with the initial key K 1 = (3.99999,0.123456, 0.234567) is denoted as cipher1.A minute value of 10 −15 was subsequently added to each element of K 1 , resulting in cipher2 as the ciphertext image obtained by encrypting Lena with the altered key.A comparison of the results of two encrypted images under three sets of parameters is shown in Figure 4, revealing that while both images contain noise, they differ significantly from each other.Table 4 calculates the percentages of different pixels in the two contrasting images after encryption, with the results surpassing 99.6%.This fully demonstrates the exceptional sensitivity of the proposed cryptosystem during encryption.
For the sensitivity analysis performed during decryption, we again used Lena as the test image.Utilizing K 1 = (3.99999,0.123456, 0.234567) and K 2 to decrypt C, the original image can be obtained; however, even a slight alteration of 10 −15 in each value of K 1 results in a meaningless and completely different decryption compared to the original image.The contrasting results are presented in Figure 5. Further, Table 4 lists the percentages of different pixels between Q and the decryption using the modified key, reaching more than 99.52%.This fully demonstrates that the proposed cryptosystem is highly sensitive to K 1 .Additionally, there is an equally strong sensitivity to K 2 , which need not be reiterated here.

Histogram Analyses
In the context of image encryption algorithms, the randomness and uniformity of the encrypted image are important for protecting against statistical attacks.The more random and uniform the ciphertext image is, the more challenging it becomes for attackers to identify correlations or patterns that can be exploited to break the encryption [40].Typically, the variance S is employed as to describe the uniformity of the pixel distribution.Its calculation formula is where hist i (i = 0, 1, ..., 255) represents the occurrence of the ith grayscale value in the image and aver denotes the mean value of hist i .A smaller value of S implies a more homogeneous distribution of grayscale pixels in the encrypted image, posing a challenge for attackers to exploit any statistical patterns and break the encryption.Figure 3 illustrates the changes in the histograms of multiple images pre-and postencryption.The histograms of the ciphertext images display a more homogeneous distribution in comparison to that of the original image, indicating an approximately equal frequency of occurrence for each grayscale value.Table 5 presents the variance values of multiple images pre-and post-encryption.The data indicate that after encryption, the variance values decrease significantly and are all smaller than the standard value χ 2 0.05 = 293.25,which meets the encryption requirement.Notably, the variance of the encrypted Lena image is as low as 101.133,indicating the effectiveness of our proposed cryptosystem in resisting histogram analyses.

Correlation Coefficient Analyses
In a plaintext image, adjacent pixels exhibit a strong correlation, which can be exploited by attackers to break the encryption using statistical patterns or correlations.Therefore, an effective encryption algorithm should eliminate the correlation of adjacent pixels in order to increase resistance against statistical analyses.Typically, correlation coefficients are commonly computed to assess the strength of correlations using the formula where u and v represent the gray values of two adjacent pixels, E(u) denotes the expected value of u, D(u) represents its variance, and N denotes the quantity of samples randomly selected from the image.
In this study, we selected 4000 pairs of adjacent pixels in a stochastic manner from the vertical, horizontal, and diagonal directions in the image.The coefficients in the three directions x, y, and z were then calculated according to Equations ( 12) and ( 13) and the average coefficients were obtained using Equation (14).
The resulting coefficients are presented in Table 5.In the table, the correlation coefficient of each plaintext image is highly proximate to 1 in three distinct directions, indicating a strong correlation between adjacent pixels.Conversely, the correlation coefficient of every ciphertext image approaches 0, signifying a weakened correlation.To demonstrate the optimization effect of our cryptosystem, we compared the correlation coefficients of the encrypted Lena image with those obtained from several recently proposed algorithms.The contrasting results of the coefficients are displayed in Table 6.As can be seen, the average correlation coefficient when using our cryptosystem is larger than the results for those in [29,42], but smaller than those in the other seven papers.This indicates that our approach can effectively mitigate the pixel correlation.
To obtain a more intuitive visual comparison, Figure 6 displays the pre-and postencryption distribution of neighboring pixels in three directions for three different images when using our proposed cryptosystem.The midpoint of the original grayscale image is effectively scattered along the diagonal line, whereas that of the corresponding ciphertext image is more uniformly distributed within the entire scope.This demonstrates that the proposed cryptosystem is capable of achieving superior confounding effects and successfully passing the correlation test.

Entropy Analyses
Information entropy is another crucial measure for testing the uncertainty or randomness of ciphertext images, and can also be used to assess the efficacy of encryption algorithms.Its symbolic representation is H, and the calculation formula can be expressed as follows: where l is the number of gray values and m i and p(m i ) are the gray values and their occurrence probabilities, respectively.In cryptography, a secure cryptosystem should produce ciphertext images with uniform gray values in order to increase randomness and security.The ideal value of information entropy for an image with 256 gray levels is 8 [46].Following Equation ( 15), we calculated the information entropy values of multiple encrypted images.Table 5 displays the results, while Table 6 lists the contrasting results obtained for Lena with different algorithms.As can be seen, all entropy values are very close to 8; the information entropy for the encrypted Lena image reaches 7.99888, which is a larger value than most of the other algorithms.Therefore, the proposed image cryptosystem is capable of generating ciphertext images with a more random and uniform distribution of pixel values, resulting in increased security and confidentiality.

Differential Attack Analyses
In order to be resistant to differential attacks, a secure cryptosystem should guarantee that even minor alterations to the plaintext will lead to large changes in the encrypted image.In general, two criteria, NPCR and UACI, are used to evaluate resistance to differential attacks.The respective formulas are provided below. where In the above formulas, C 1 and C 2 are two ciphertext images that correspond to plaintext images with only one different pixel, while M and N represent the width and height of the encrypted image, respectively.For each plaintext image, 100 pixels at different positions are randomly selected and increased by 1. Table 7 displays the maximum, lowest, and average values of NPCR and UACI.The significance level was set to 0.05, and the ideal expected values of NPCR and UACI for grayscale images with a size of 256 × 256 were obtained from [47].The average NPCR values in Table 7 exceed the ideal values.Moreover, the average values of UACI are found to fall within the interval [U * − 0.05 , U * + 0.05 ].This testifies that the proposed image cryptosystem exhibits high resistance to differential attacks with respect to pixel modifications.Signal loss or noise pollution can compromise the security and confidentiality of transmitted ciphertext images.To test a ciphertext image's resilience against data loss and noise attacks, experiments can simulate such conditions to assess the encryption algorithm's ability to maintain data integrity [48].
Cutting parts of the ciphertext image can cause information loss and hinder the successful recovery of the original plaintext message.Taking the Plane image as an example, the corresponding decryptions are shown in Figure 7 when cutting 1/16, 1/8, 1/4, and 1/2 at the upper left corner of the encrypted image.As can be seen, even when up to 50% of the encrypted image is cut, the proposed cryptosystem is still able to recover a visually recognizable image of the original message using the correct key.In addition, it demonstrates strong robustness against various types of noise attacks, including salt and pepper noise (SPN) with densities of 0.05 and 0.1 and Gaussian noise (GN) with a mean value of 0 and variances of 0.01 and 0.1.Despite the introduction of such noise types into the ciphertext image, the deciphering process utilizing the correct encryption key remains discernible, as demonstrated in Figure 8. Overall, these results demonstrate the good robustness of our cryptosystem against both cutting attacks and different types of noise attacks.Additionally, the PSNR index is usually employed for assessing the quality of decrypted images after attacks.The formula is where P and P 1 denote the original decrypted image of size M × N and the decrypted image after attacks, respectively.A higher PSNR value indicates better image quality.Table 8 displays the PSNR values of various images that have undergone cutting and noise attacks using the proposed encryption cryptosystem.The data in the table suggest that the PSNR values under these cutting attacks are greater than 7.7 dB, while those for the noise attack are greater than 7.2 dB.These findings suggest that the decrypted images exhibit relatively low levels of distortion compared to their original counterparts even after being attacked, and continue to maintain a high level of visual quality.Therefore, these results indicate that our cryptosystem is robust against both cutting and noise attacks.are three layers of encryption structure: large-scale mutation, scrambling, and diffusion; thus, the CC is O(3n 2 ).Algorithm III is an optimization process, including crossover and mutation operations, meaning that the CC is also O(4n 2 ).Therefore, the CC of our cryptosystem is O(n 2 ).
The experimental environment was MATLAB R2019b, Microsoft Windows 10, Intel i5-1135G7, a 2.40 GHz processor, and 16 GB RAM.Based on 100 calculations, Table 9 presents the average time taken to perform encryption and decryption of six representative images.The results indicate that each image takes approximately 5.86 s to encrypt and about 0.43 s to decrypt, suggesting the effectiveness of our image cryptosystem for instant encryption.The proposed cryptosystem employs an asymmetric process for encryption and decryption that involves multi-segment and multi-round crossover and mutation operations during encryption, which can be computationally expensive and result in longer optimization and encryption times compared to other algorithms.However, the decryption time is significantly shorter when using the secondary secret key to decrypt the ciphertext image directly.The comparison results reported in Table 9 demonstrate that our GA-based encryption cryptosystem is faster in both encryption and decryption compared to other contrasting algorithms, with the exception of the algorithm presented in [29], reflecting the efficient optimization process of the proposed cryptosystem.10.9 -Encrypted Lena in [50] 14.1 -Encrypted Lena in [51] 6.9 -Encrypted Lena in [52] 7.07 -Encrypted Lena in [29] 0.88 -

Analysis of Resistance to Chosen-Plaintext Attacks
Chosen-plaintext attacks are a potent method of attacking encryption schemes.In such an attack, the attacker has access to the encryption scheme, and can select plaintext images and encrypt them to obtain the key's information.If a cryptosystem is able to withstand chosen-plaintext attacks, this usually indicates that the encryption approach is secure against three other classical attacks as well: ciphertext-only attacks, known-plaintext attacks and chosen-ciphertext attacks [21,53].
In the proposed cryptosystem, the same difference matrix is used for all images in image encryption.This matrix only needs to be generated once, and can be reused to encrypt multiple images.However, employing the information of plaintext images in the key ensures that the encrypted data remain unique and secure for every individual image even if the difference matrix is identical.Specifically, the entire cryptosystem is extremely sensitive to both K 1 = (µ 0 , key 0 , key 1 ) and to the plaintext image.If even a single pixel is altered, the resulting L 1 , L 2 , and L T will be completely distinct.Additionally, our encryption cryptosystem utilizes two Latin squares and leverages the approximate uniformity of the difference matrix during diffusion.With just one round of encryption processing required to achieve a secure result, our cryptosystem is resistant to chosen-plaintext attacks, as well as other forms of intrusion.
Additionally, all-black or all-white images are frequently utilized by hackers to launch attacks on encryption algorithms.These special images were also subjected to experiments.Table 5 shows the resulting correlation coefficients of approximately 0, variance values of approximately 100, and entropies of approximately 8 for two encrypted ciphertext images.These results fully demonstrate that the proposed cryptosystem can resist statistical attacks.Table 7 shows that both of the encrypted images pass the differential attack tests successfully.Table 8 displays that all PSNR values related to both encrypted images exceed 7.2 dB, demonstrating our cryptosystem's robustness.Moreover, our cryptosystem exhibits resistance against chosen-plaintext attacks as well as other classical attack methods.

Conclusions
In this paper, an efficient image cryptosystem utilizing a difference matrix and a genetic algorithm is put forward.The discreteness and approximate uniformity of the difference matrix satisfy the characteristics of a pseudo-random sequence, enabling a variety of scrambling methods while occupying a very small storage space.Additionally, the GA's crossover and mutation operations can generate numerous new individuals, and the optimal preservation strategy can then select the best one.The proposed cryptosystem first generates a difference matrix using the initial secret key; then, the difference matrix is used to perform image encryption.The resulting initial ciphertext image already has relatively good randomness.A large number of ciphertext images are then obtained through local genetic operations in order to generate better-quality ciphertext images through multiple iterations using the optimal preservation strategy, which strengthens the randomness of the final ciphertext image.We used this cryptosystem to effectively encrypt test images, and it successfully passed all tests.Furthermore, it offers a number of advantages over other existing algorithms.
Finally, the use of a combined structure consisting of a difference matrix and a genetic algorithm to generate more secure ciphertext images showcases interdisciplinary advantages that can serve as a reference for future research.
Funding: This research was funded by the National Natural Science Foundation of China under Grant Numbers 11871019.
Institutional Review Board Statement: Not applicable.

Figure 1 .
Figure 1.Encryption diagram of the proposed cryptosystem.

Algorithm 1
Local crossover operation 1: for all k = 1 : N c do 2:

7 : 1 Step 3 :Algorithm 2
C 1 = CM 1 (Ind cbest , :); 8: return C Mutation operation.Divide C 1 into N m parts from left to right; each part undergoes mutation according to ind 2 and ind 3 , resulting in the formation of 2 × N m new individuals that are stored in the matrix CM 2 .Use the optimal preservation strategy to select the best individual as C 2 and record the corresponding index value Ind mbest in the second row component of K 2 .The Algorithm 2 is presented below, where mutation represents the compiled mutation function (3).Local mutation operation 1: for all k = 1 : N m do 2:

Figure 2 .
Figure 2. Decryption diagram of the proposed cryptosystem.

Figure 3 .
Figure 3. Histograms of different plaintext images and ciphertext images.The plaintext images from top to bottom are as follows: Lena, Cameraman, Plane, Allblack, Allwhite.(a) Plaintext images; (b) the corresponding histograms of (a); (c) ciphertext images; (d) the corresponding histograms of (c); (e) the decryption of (c).

Figure 6 .
Figure 6.Distribution of adjacent pixels of Lena, Pepper, and 5.1.09:(a) Plaintext images; (b) Distribution of adjacent pixels of (a); (c) ciphertext images; (d) Distribution of adjacent pixels of (c).

Table 1 .
An example of a crossover operation with c = 3.

Table 2 .
An example mutation operation with c = 6.

Table 3 .
The final results of the iteration numbers and K 2 required for optimization.

Table 5 .
Complete results of several images pre-and post-encryption.

Table 6 .
Contrasting results for Lena.

Table 7 .
NPCR and UACI results for several test images.

Table 8 .
All PSNR values for robustness analyses of multiple images.

Table 9 .
Time efficiency results for several images.