Genetic Algorithm Using Feistel and Genetic Operator Acting at the Bit Level for Images Encryption

ABSTRACT


INTRODUCTION
In today's digital age, the security of sensitive data, especially medical images, is of paramount importance.Safeguarding the integrity and the confidentiality of images is crucial in a digital world where the exchange and the storage of visual information are commonplace.Images may contain private, confidential, or strategic data, and unauthorized exposure can lead to several consequences for individuals and organizations.To address this growing concern, numerous image encryption methods have been developed, yet some still exhibit vulnerabilities to sophisticated attacks.
With the rapid advancement of chaos theory, we are witnessing several improvements in these classical techniques.Additionally, some of the currently highly recommended solutions are genetic algorithms.In fact, genetic algorithms are among the most frequently used optimization methods, with numerous applications in various scientific fields [17][18][19][20].The genetic algorithm, first proposed by John Holland in 1975, is one of the most renowned evolutionary algorithms, inspired by the evolutionary process of living species.The genetic algorithm is widely used to solve a variety of optimization problems, starting with the initial random generation of individuals, followed by selection for reproduction of the new tribes, according to the value of their evaluation function.In other words, the best-performing individuals have the opportunity to be selected for the reproduction of future generations.The selected individuals will be subjected to genetic operators such as mutation, crossover, insertion and reversion (Figure 1).With this in mind, most researchers have developed encryption methods based on adaptation of genetic algorithm to image encryption.Ghazvini et al. [21] proposed an image encryption method based on genetic and chaos algorithms.The method consists of three main steps: a confusion phase using the Chen map, a second phase performed by the logistic-sine map, and the final phase involves selecting the encrypted image that yields the highest entropy and the lowest correlation.Mahmud et al. [22] had developed a novel cryptosystem based on the hybridization of Ribonucleic Acid (RNA) and Genetic Algorithm (GA).Initially, the logistic map and RNA codons are used to create initial populations for GA.Finally, GA optimizes the images using the fitness function based on entropy to find the optimized encrypted image.Ferdush et al. [23] proposed a new hybrid encryption system using PSO and GA with a chaotic map.An image is initially encrypted using a chaotic function, then PSO and GA are applied to select the best encrypted image that exhibits the highest entropy and the lowest correlation coefficient between adjacent pixels.
Our contribution in this work is to develop a robust encryption system based on genetic algorithms using chaos and an enhanced Feistel scheme employing a circular shift for the right bloc and a pseudo-random permutation for the left bloc.Followed by the two most widely used genetic operators in cryptography, namely crossover and genetic mutation adapted to image encryption.

PROPOSED METHOD
Based on chaos [24], this new technology describes the construction of a genetic algorithm operating at the bit level.The implementation of this new system is based on the following axes:

Chaotic sequences development
The choice of chaotic maps is crucial for an encryption system.Therefore, our algorithm utilizes the two most used chaotic maps in cryptography, the logistic map, and the skewed tent map.This choice is due to the ease of implementation of both maps and their high sensitivity to initial conditions.

The logistics map
The logistic map is a recurrent sequence defined by Eq. ( 1).
0 is the initial value and  is the control parameter.
The Lyapunov exponent λ of the logistic map is λ= log(2)>0, which proves that this sequence is highly sensitive to initial conditions.

The skew tente map
The Skew tent map is defined by Eq. ( 2).
0 is the initial value and v is the control parameter.The combination of these two chaotic maps will be used to generate all the parameters necessary for the proper functioning and operation of our new technique.

Chaotic table design
Our approach requires the use of a pseudo-random table (WC) of size (13nm, 3) constructed from the chaotic maps used with coefficients in  256 to ensure multiple confusions (Algorithm 1), and a table (WB) of the same size for system action control (Algorithm 2).

Image vectorization
Before starting the encryption process, an extraction of the 3RGB color channels is performed, followed by vectorization (Wr), (Wg), and (Wb), each of size (nm), and then concatenation to obtain a vector (W) of size (3nm).This process is illustrated in Figure 2 and described by Algorithm 3.

Pseudo random transformation into binary
The vector (W) of size (3nm) will be converted into a binary vector (XB) of size (24nm) using 4 conversion tables (Figure 3).The choice of the conversion table is controlled by the control table (WB).The binary conversion process is described by Algorithm 4.An example of conversion is illustrated by Figure 4.
After the pseudo random binary conversion, the vector (XB) of size (24nm) will be resized into a matrix (MB) of size (4n, 6m), this process is illustrated in Figure 5.

Fitness function definition
The matrix (MB) will be considered as a population, where each row represents an individual.A fitness function will be applied to assess the population's integrity for future categorization into two groups: strong population and weak population.This evaluation function is defined by the Hamming distance between the original image (MB) and the pseudo-random image (CB) defined by Eq. ( 3).An example of hamming distance calculation is given in Figure 6.

ENCRYPTION PROCESS
Our encryption technique consists of coupling the rows of (MG) and (MD) matrices using an enhanced Feistel laps followed by a crossover and mutation operations.

Feistel laps
The two matrices (MG) and (MD) will undergo coupling through an enhanced Feistel TF circuit defined by Eq. (4).

𝑇𝐹(𝐺
where, ℎ  is a binary permutation constructed by the binary vector ((: , 3)) and   is a circular shift function determined by the coefficient WC (i, 3).The coupling process is described by Algorithm 5.  =  ⊕ D 6.
end For 20. end Using VIG and VID are obtained by applying the XOR operation on all the rows of the MG matrix and MD natrix, excluding the first row.The enhanced Feistel round is illustrated in Figure 8.
At the end of the Feistel round.The two matrices (GM) and (DM) of size (2n, 6m+16) are combined into a single matrix (M') of size (2n, 12m+32).This matrix will be transformed into a vector (BX) of size (24 nm+64n).

Genetic crossover
The second encryption phase involves a genetic crossover adapted for image encryption.For this reason, a pseudorandom transformation at the DNA level is necessary.This operation is described by the following steps:

Transition to 𝐺 4
Transition to 4 the binary vector (BX) of size (24nm+64 n) will be converted into a vector (BY) of size (12nm+32n) taking values in  4 using Algorithm 6. end For 5. end

Transition to DNA notation
The transition to DNA notation involves writing the vector (BY) into (YB) vector using the symbols {A, C, T, G}.For this, we will use two conversion tables T1 and T2 defined in Figure 9.The choice of the conversion table is determined by the control vector (WB(:, 3)).The process of converting to DNA notation is illustrated by Algorithm 7. If WB(i,3)=0 then 5.

Genetic crossover function
The vector (YB) will be genetically crossed with a pseudorandom vector (R) of size (12nm+32n) defined by Algorithm 8.For i=1 to 12nm+32n 3.
end For

end
The genetic crossover operation is controlled by a crossover table TC of size (12nm+32n, 3) where each column is defined as follows: • The first column: a permutation P obtained by sorting the 12nm+32n values of the sequence s, indicating the index of the pixel to be processed.
• The second column: a permutation Q obtained by sorting the 12nm+32n values of the sequence t, indicating the index of the factor of R to be used.
• The third column: the QoP permutation indicating the index of the pixel obtained through genetic crossover.
The process of genetic crossover is illustrated by Algorithm 9.With ⊕ and ⊗ are crossover operators defined at DNA level defined by Figure 10.

Genetic mutation
The third encryption phase involves establishing a diffusion operation ensured by a genetic mutation adapted for medical image encryption.This step will be described by the following axes:

Transition to 𝐺 4
The vector (WQ) written in DNA notation of size (12nm+32n) will be reconverted into a vector (QW) with coefficients in  4 using conversion tables defined in Figure 11.The choice of the conversion table is determined by the control vector (WB(:, 2)).The process of conversion to  4 is illustrated by Algorithm 10.If WB(i,2)=0 then 5.
end For 9. end

Transition to gray level (𝑮 𝟐𝟓𝟔 )
The vector (QW) of size (12nm+32n) will be converted into a vector (QZ) of size (3nm+8n) with values in ( 256 ).This conversion is illustrated by Algorithm 11.The vector (QZ) of size (3nm+8 n) will undergo a genetic mutation function, defined by an inversion operation, and controlled by a mutation table of size (3nm+8n, 3).Each column of the mutation table is defined as follows: • The first column: a permutation P obtained by sorting the 3nm+8n values of the sequence s+t, indicating the index of the pixel to be processed.
• The second column: a permutation Q obtained by sorting the 3nm+8n values of the sequence t+2s, indicating the index of the pixel obtained through genetic crossover.
• The third column: is a pseudo-random control vector used to control genetic mutation.This vector is defined by Algorithm 13.
The diffusion process is illustrated by Algorithm 14.
end For 12. end The vector (Z) constitutes the encrypted image by our algorithm and the entire encryption process is presented in Figure 12.

DECRYPTION PROCESS
Our algorithm is a symmetric encryption algorithm.By applying the inverse encryption functions, in reverse order and using the same encryption key, we can restore the original image.

The inverse of the genetic mutation
The inverse function of genetic mutation is described by Algorithm 15.

End If 20. end 4.2 The inverse of the genetic crossover
The genetic crossover operation acts on the image at the DNA level, a transition from the vector (QZ) to notation is necessary.First, the vector will be converted to the vector (QW) of size (12nm+32n) with coefficients in  4 .This conversion is described by Algorithm 16. end For 10. end The vector (QW) will be converted to the vector (WQ) in DNA notation using inverse conversion tables: TI3 (inverse of T3) and TI4 (inverse of T4) described in Figure 13.The conversion process is illustrated by Algorithm 17.If WB(i)=0 then 5.
end For

end
The inverse genetic crossover process is illustrated by Algorithm 18.
end For 10. End

Feistel lap inverse
Before applying the inverse Feistel network, a conversion to the binary level is crucial.For this, the vector (YB) will be converted to a vector (BY) with values in  4 using the inverse tables TI1 (inverse of T1) and TI2 (inverse of T2) described in Figure 14.The conversion process is illustrated by Algorithm 19.If WB(i,2)=0 then 5.
end For 9. end The vector (BY) will then be converted to a binary vector (BX) using Algorithm 20.After that, the vector (BX) will be resized into a matrix (M') of size (2n, 12m+32).This matrix will be subdivided into two sub-matrices (GM) and (DM) each of size (2n, 6 m+16).The inverse Feistel network is applied to each row of (GM) and (DM).This process is described by Algorithm 21.For i=2n to 2 3.
end For

end
The two matrices (MG) and (MD) will be combined into a single matrix (MBE) of size (4n, 6 m+16).

Reconstruction of the clear image
The matrix (MBE) will be sorted based on the last 16 bits of each row, and then extraction of the matrix (MB) from (MBE) by removing the last 16 columns to construct the decrypted image.The binary matrix (MB) of size (4n, 6m) will be transformed into a vector (XB) of size (24nm).The vector (XB) will be converted to grayscale to recover the encrypted image (W) using Algorithm 22. end For

end
The tables TCI1, TCI2, TCI3, and TCI4 are the inverse conversion tables described in Figure 15.The vector (W) represents the decrypted image.

SIMULATION RESULTS
To evaluate the performance of our encryption system, we randomly select many reference images and then subject them to our encryption method.In this section, all experiments are conducted using the Python programming language on a personal computer based on i5, with 8GB of RAM and a 500GB hard drive, running Ubuntu 20.04.

Brutal attacks
Brutal attacks consist of reconstructing the encryption keys in a random manner by exploring all the key-space values.

Key-space analysis
To ensure the robustness of a good image encryption algorithm, the key space should have at least 2100 possibilities.If the key space is not sufficiently large, the algorithm could be vulnerable to brute-force attacks.In this algorithm, the key space encompasses the initial condition and control parameters of the chaotic maps.The secret key of our system consists of: •  0 = 0.79878796,  = 0.755654 logistique map.•  0 = 0.6789654,  = 0.98788755 skew tente map.In our case, we consider the precision to be of the order of 1016.Therefore, the total key space reaches 1064.Thus, our algorithm is capable of resisting brute-force attacks due to the sufficiently large size of its key space.

Secret key's sensitivity analysis
The high sensitivity of our encryption key is manifested by an amplified reaction following a slight modification of a single parameter, resulting in a significant difference from the original image.This assertion is visually confirmed by Figure 16.

Visual test
The visual test is the first test which aims to detect a certain resemblance between the original image and the image encrypted by the new crypto system.In our simulations, visually the encrypted image is totally different from the original image and does not reflect any information or resemblance, this initially ensures the robustness of our system is illustrated by the result of the Table 1.

Histogram analysis
The histogram represents the distribution of pixels in an image.In the case of an encrypted image, the histogram should be uniformly distributed to prevent attackers from guessing information about the image.Furthermore, the histogram of the encrypted image should not resemble that of the original image.Table 2 shows the histograms of some encrypted images.As can be seen, the histograms of the encrypted images obtained with our algorithm are uniform.

Correlation analysis
In the original image, neighboring pixels demonstrate a pronounced correlation due to their closely similar values.The efficacy of the encryption algorithm resides in generating an encrypted image characterized by minimal correlation among adjacent pixels.Mathematically, the correlation coefficient between two neighboring pixels is calculated employing the Eq. ( 5). With: • "x" and "y" represent adjacent pixels.
•"cov (x, y)": covariance between the random variables x and y.
•V(x): variance of x.The Table 3 shows the correlation coefficients of some images encrypted by our method.All the images have a correlation close to zero.

Entropy analysis
Entropy is the measure of the disorder diffused by a source without memory.The entropy expression is determined by the Eq.(6).The maximum value of entropy is 8; the higher the entropy, the more randomness is present in the encrypted image.The Table 3 presents the entropy values obtained for different images encrypted by our algorithm.All the obtained values are close to the maximum value of 8.

Differential analysis
Differential attack is based on deducing information about an image by introducing a slight modification to the plaintext image and then encrypting both images using the same algorithm.A comparison between the two encrypted images is made to determine any correlation between the original image and its encrypted version.It is expected that a robust algorithm produces distinctly different encrypted images, even for the slightest modifications made to the plaintext image.The parameters used to measure the effectiveness of our method against differential attacks are: NPCR (Number of Pixel Change Rate) and UACI (Unified Average Changing Intensity).
NPCR (Number of Pixel Change Rate) is a measure that quantifies the percentage of different pixel values between two encrypted images, when the corresponding plaintext images differ by only one pixel.A high NPCR value indicates better resistance of the algorithm against differential attacks.NPCR can be calculated using Eq. ( 7).

Table 2. Histogram
The UACI mathematical analysis of an image is given by Eq. ( 8).
) * 100 The avalanche effect refers to the number of bits that change when a single bit in the original image is modified [24].The mathematical representation of the avalanche effect is expressed by Eq. ( 9).   4 presents some results of the calculation of differential parameters for images encrypted using our method.All calculated NPCR values are greater than the threshold of 99.60%, UACI is greater than 33.46%, and AE is greater than 50%.This demonstrates that our algorithm can resist differential attacks.

Encryption time
The encryption time is a crucial benchmark for assessing the efficiency of an image encryption algorithm.Effectively encrypting substantial data, such as images, within a reasonable timeframe has become a challenging aspect of algorithm development.In our study, we present the encryption times for images of sizes 256×256 and 512×512 in (Table 5), along with a comparison to other recent works.Furthermore, the time complexity of our method for an image of size (N, M) is O(NM).[25] 0.65 -----Ref.[26] 8.22 -----Ref.[27] 0.156 0.406

Comparison to other techniques
Table 6 shows that our technique gives satisfactory results compared to other method in the literature.The entropy of the tow images gives values extremely close to the ideal value of 8 and higher than the values obtained by most other methods.For the NPCR and UACI, the values of the proposed scheme are very close to the values of NPCR (99.6%) and UACI (33.4%) expected.Accordingly, from Table 6, we can conclude that the suggested method outperforms many recently published studies in terms of entropy, NPCR and UACI values.

CONCLUSIONS
Converting the image to be encrypted into binary notation and applying a discrimination function in our genetic algorithm resulted in the generation of two tribes of individuals with different properties.The implementation of a Feistel round and the integration of a diffusion function in the first round, for the mating of two individuals, made it possible to reproduce a new generation, inheriting the genes of each tribe in order to cope with any unforeseen attack.While crossover and mutation in the second round reinforced our encryption system.A wide range of images tested by our algorithm proved the robustness of our cryptosystem.Reformulating the fitness function and increasing the number of operations at the DNA level may add further performance to our system.

Algorithm 8 :
Generation of the vector R 1. Begin 2.

Table 1 .
Visual test

Table 3 .
Correlation and entropy

Table 5 .
Encryption time

Table 6 .
Comparison to other technique