Image encryption transmission method and system based on shared key and knight cruise algorithm
By generating scrambling and diffusion parameters using a shared key and the Knight's Roaming algorithm, and combining a multi-scale scrambling model and a bidirectional feedback diffusion structure, the problems of key space reduction and nonlinearity in existing technologies are solved, achieving efficient and secure encrypted image transmission.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUILIN TOURISM UNIV
- Filing Date
- 2026-01-30
- Publication Date
- 2026-04-24
AI Technical Summary
Existing image encryption transmission schemes suffer from key space reduction, degraded dynamic characteristics, and insufficient nonlinearity in the diffusion process due to limited precision digital implementation and parameter discretization, making them difficult to resist advanced cryptanalysis.
Using a shared key and the Knight's Roaming algorithm, scrambling and diffusion parameters are generated through the HKDF algorithm. A multi-scale scrambling model is constructed by combining the Knight's Roaming algorithm with the model. A bidirectional feedback diffusion structure is designed using finite field multiplication and modulo 256 addition to realize image scrambling and diffusion.
It improves the reliability and security of encrypted image transmission, enhances the ability to resist differential attacks and chosen-plaintext attacks, while maintaining low time overhead and implementation efficiency.
Smart Images

Figure CN121924221A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of information security, specifically relating to an image encryption transmission method and system based on shared keys and the Knight's Roaming algorithm. Background Technology
[0002] Currently, with the rapid development of digital technology, various types of digital information are being widely collected, transmitted, and shared. Digital images are also being used extensively in scenarios such as social media, video surveillance, telemedicine, industrial inspection, and military reconnaissance.
[0003] However, digital images may carry sensitive and security information in many applications, such as personal privacy and trade secrets. Therefore, if digital images are illegally stolen during transmission or cloud storage, it can cause security risks and economic losses; if they are tampered with or forged, it will also affect the authenticity and credibility of the image. Therefore, ensuring the confidentiality and integrity of digital images during transmission is of great importance.
[0004] To ensure the security of image storage and transmission in network environments, researchers have proposed several image encryption methods based on the "scrambling-diffusion" framework. In existing technologies, commonly used encryption transmission schemes typically utilize pseudo-random sequences generated by chaotic systems to construct keystreams, scrambling image pixel positions and diffusing pixel values. However, under the influence of factors such as finite-precision digital implementation and parameter discretization, keystream generation schemes based on chaotic systems may suffer from problems such as reduced effective key space, degraded dynamic characteristics, and short sequence periods. Furthermore, the diffusion process in existing schemes often employs bitwise XOR or simple modular addition operations, lacking sufficient nonlinearity and offering limited resistance to advanced cryptanalysis such as differential attacks and chosen-plaintext attacks. Summary of the Invention
[0005] One of the objectives of this invention is to provide a highly reliable and secure image encryption transmission method based on shared key and knight's roaming algorithm.
[0006] The second objective of this invention is to provide a system for implementing the image encryption transmission method based on shared key and knight's roaming algorithm.
[0007] The image encryption transmission method based on shared key and knight's roaming algorithm provided by this invention includes the following steps:
[0008] S1. The sender preprocesses the target image;
[0009] S2. The sender and receiver negotiate to obtain a shared key, and based on the shared key and the HKDF algorithm, obtain the image scrambling parameters and image diffusion parameters;
[0010] S3. Construct an image scrambling model based on the Knight's Roaming algorithm;
[0011] S4. Based on the image scrambling parameters obtained in step S2 and the model constructed in step S3, perform image scrambling on the preprocessed target image;
[0012] S5. Based on the image diffusion parameters obtained in step S2, perform image diffusion on the scrambled image obtained in step S4 to obtain the final encrypted image;
[0013] S6. The sender transmits the encrypted image to the receiver; the receiver decrypts the image, completing the encrypted transmission of the target image.
[0014] Step S1, where the sender preprocesses the target image, specifically includes the following steps:
[0015] The sender fills the height and width of the target image to integer multiples of 16 to obtain the corresponding filled image and records the filling parameters.
[0016] Step S2, obtaining the image scrambling parameters, specifically includes the following steps:
[0017] The sender and receiver negotiate and obtain a shared key Z;
[0018] Based on the shared key Z, a one-time salt is used in the Extract phase of the HKDF algorithm to calculate the pseudo-random key PRK through HMAC-SHA256, which is then used as the input for the subsequent Expand phase.
[0019] Based on the field separation mechanism, in the Expand phase of the HKDF algorithm, selection bytes for scrambling are generated respectively. and shift bytes , is represented as:
[0020] In the formula This refers to the Expand process of the HKDF algorithm. Select a domain label for the knight path; For row and column circular field labels; For shifted bytes The length, and , To fill the height of the image, To fill the width of the image;
[0021] Based on the selected bytes The path selection parameters of the Knight's Patrol algorithm are calculated using the following formula:
[0022] In the formula Select parameters for the first path; Select parameters for the second path; Select parameters for the third path; Let be the modulo operation function, and , This is the floor function; To convert the data into a double-precision floating-point function; To select bytes The first byte in; To select bytes The second byte in; To select bytes The third byte in;
[0023] The generated shift byte Interpreted as a 16-bit word u16, the shift parameters are calculated using the following formula:
[0024] In the formula This is the row shift parameter; For column shift parameters; Represents a 16-bit word sequence The first to the second A subsequence consisting of elements; Represents a 16-bit word sequence The Middle The first to the second A subsequence consisting of elements;
[0025] Ultimately, the obtained image scrambling parameters include , , , and .
[0026] Step S2, which involves obtaining the image diffusion parameters, specifically includes the following steps:
[0027] Based on the field separation mechanism, a mapped byte sequence is generated in the Expand phase of the HKDF algorithm. , is represented as:
[0028] In the formula For diffusion domain labels; For mapped byte sequences The length, and ;
[0029] Based on the generated mapping byte sequence The image diffusion parameters are obtained by mapping using the following formula:
[0030] In the formula The first image diffusion parameter; express The first to the second A subsequence consisting of elements; This is the second image diffusion parameter; express The Middle The first to the second A subsequence consisting of elements; For the third image diffusion parameter; To indicate The last element in;
[0031] Step S3, which involves constructing an image scrambling model based on the Knight's Roaming algorithm, specifically includes the following steps:
[0032] set up Grid patrol path:
[0033] exist On the grid, using the four vertices of the outermost square as candidate starting points, construct... An open patrol path is created; during patrol, the knight first performs an "L"-shaped jump to generate candidate landing points, thus obtaining a patrol path that covers all grids; if a landing point goes out of bounds during a jump, the algorithm is applied... and Return the landing point to within the boundary, among which The coordinates of the landing point after crossing the boundary. To return to the coordinates of the landing point within the boundary, It is a return function and , Let be the grid side length. This is the modulo operation function;
[0034] Completed After establishing an open cruise path, by using D4 symmetry and reversing the path, we obtain... Image tour path;
[0035] set up Grid patrol path:
[0036] exist On the grid, starting from the four vertices of the outermost square, construct... An open knight patrol path; during the patrol, the knight performs "L"-shaped jumps to obtain a patrol path that covers all grids;
[0037] Completed After establishing an open knight's patrol path, by using D4 symmetry and reversing the path, we obtain... Image tour path;
[0038] set up Grid patrol path:
[0039] exist On the grid, starting from the four vertices of the outermost square, construct... An open knight patrol path; during the patrol, the knight performs "L"-shaped jumps to obtain a patrol path that covers all grids;
[0040] Completed After establishing an open knight's patrol path, by using D4 symmetry and reversing the path, we obtain... A single image tour path.
[0041] Step S4, which involves scrambling the preprocessed target image based on the image scrambling parameters obtained in step S2 and the model constructed in step S3, specifically includes the following steps:
[0042] First disruption:
[0043] The preprocessed target image is divided into... The grid area; parameters are selected based on the first path. ,from Select the corresponding tour path from the image tour path, and scramble the preprocessed target image according to the selected tour path to obtain the first scrambled image;
[0044] Second disruption:
[0045] Divide the first scrambled image into: The grid area; parameters are selected based on the second path. ,from Select the corresponding scrambled path from the image scrambled path, and scramble the first scrambled image according to the selected scrambled path to obtain the second scrambled image;
[0046] The third disruption:
[0047] Divide the second scrambled image into The grid area; parameters are selected based on the third path. ,from Select the corresponding scrambled path from the image scrambled path, and scramble the second scrambled image according to the selected scrambled path to obtain the third scrambled image;
[0048] During the first to third scrambling process, the pixel positions within the grid area remain unchanged;
[0049] Disorderly conduct:
[0050] The third scrambled image Row, according to row shift parameters The i-th element value in the image is cyclically shifted to obtain a row scrambled image; where The value is , The total number of rows in the third scrambled image;
[0051] Column shuffling:
[0052] For the obtained row scrambling image, the first Columns, according to column shift parameters The j-th element value in the image is cyclically shifted to obtain a scrambled column image; where The value is , The total number of columns for the third scrambled image;
[0053] The resulting scrambled image is used as the scrambled image. .
[0054] Step S5, which involves performing image diffusion on the scrambled image obtained in step S4 based on the image diffusion parameters obtained in step S2 to obtain the final encrypted image, specifically includes the following steps:
[0055] The scrambled image obtained in step S4 Flattening the images according to a predetermined order yields a one-dimensional image sequence. for ,in One-dimensional image sequence The Middle The pixel value of each pixel. , The length of the image sequence and ;
[0056] Forward diffusion process:
[0057] Initialize the first diffusion state variable For the third image diffusion parameter ;
[0058] The following formula is used for one-dimensional image sequences. The Middle input pixels Perform a diffusion transformation to obtain the output pixels. and will As the first The first diffusion output pixel value and the first diffusion state variable for the next round:
[0059] In the formula The coefficients are non-zero to avoid diffusion degradation in finite field multiplication due to coefficients being zero. ; Indicates in Multiplication on (using a pre-defined irreducible polynomial) ); This is a bitwise XOR operation; First image diffusion parameter The One element; For modulo operation; ;
[0060] Obtain the updated one-dimensional image sequence ;
[0061] Backward diffusion process:
[0062] Initialize the second diffusion state variable For the third image diffusion parameter ;
[0063] The following formula is used for one-dimensional image sequences. The first in element values After updating again, we get and will As the first The first diffusion output pixel value and the second diffusion state variable for the next round:
[0064] In the formula The coefficients are non-zero to avoid diffusion degradation in finite field multiplication due to coefficients being zero. ; First image diffusion parameter The One element; ;
[0065] After forward and backward diffusion are completed, a one-dimensional ciphertext byte sequence C is obtained;
[0066] Reshape the one-dimensional ciphertext byte sequence C as follows: The image was used to obtain an encrypted image. .
[0067] Step S6 involves the sender transmitting the encrypted image to the receiver; the receiver decrypts the image to complete the encrypted transmission of the target image, specifically including the following steps:
[0068] The sender transmits the encrypted image and session assistance information to the receiver. The session assistance information includes one-time salting and domain-separated context information. , , ) and the parameters for filling (including the original image size and the specific parameters for filling);
[0069] The receiver decrypts the image according to the image encryption process, thus completing the encrypted transmission of the target image.
[0070] This invention also provides a system for implementing the image encrypted transmission method based on shared key and the Knight's Roaming algorithm, comprising an image preprocessing module, a parameter calculation module, a scrambling construction module, an image scrambling module, an image diffusion module, and an encrypted transmission module; the image preprocessing module, parameter calculation module, scrambling construction module, image scrambling module, image diffusion module, and encrypted transmission module are connected in series; the image preprocessing module is used by the sender to preprocess the target image and upload the data information to the parameter calculation module; the parameter calculation module is used by the sender and receiver to negotiate a shared key based on the received data information, and based on the shared key and the HKDF algorithm, to obtain image scrambling parameters and image diffusion parameters, and upload the data information to the scrambling construction module. The scrambling construction module constructs an image scrambling model based on the received data and the Knight's Roaming algorithm, and uploads the data to the image scrambling module. The image scrambling module scrambles the preprocessed target image based on the received data, obtained image scrambling parameters, and the constructed model, and uploads the data to the image diffusion module. The image diffusion module diffuses the scrambled image based on the received data and obtained image diffusion parameters to obtain the final encrypted image, and uploads the data to the encryption transmission module. The encryption transmission module transmits the encrypted image from the sender to the receiver based on the received data; the receiver decrypts the image, completing the encrypted transmission of the target image.
[0071] The image encryption transmission method and system based on shared key and knight's roaming algorithm provided by this invention generates scrambling and diffusion parameters through shared key and HKDF algorithm, and then realizes image scrambling and diffusion based on knight's roaming algorithm. In the end, it not only realizes the encrypted transmission of images, but also has higher reliability and better security. Attached Figure Description
[0072] Figure 1 This is a schematic diagram of the method flow of the present invention.
[0073] Figure 2 An extension of the method of the present invention Map showing the route of the knights' procession.
[0074] Figure 3 The method of the present invention Map showing the route of the knights' procession.
[0075] Figure 4 The method of the present invention Map showing the route of the knights' procession.
[0076] Figure 5 This is a schematic diagram of the functional modules of the system of the present invention. Detailed Implementation
[0077] like Figure 1 The diagram shown is a flowchart of the method of the present invention: The image encryption transmission method based on shared key and knight's roaming algorithm disclosed in this invention includes the following steps:
[0078] S1. The sender preprocesses the target image; specifically, this includes the following steps:
[0079] The sender pads the height and width of the target image to multiples of 16 to obtain the corresponding padded image and records the padded parameters.
[0080] S2. The sender and receiver negotiate to obtain a shared key, and based on the shared key and the HKDF algorithm, obtain the image scrambling parameters and image diffusion parameters;
[0081] The process of obtaining image scrambling parameters specifically includes the following steps:
[0082] The sender and receiver negotiate to obtain a shared key Z; in specific implementations, the X25519 algorithm is preferred to generate a 32-byte shared key Z.
[0083] Based on the shared key Z, a one-time salt is used in the Extract phase of the HKDF algorithm to calculate the pseudo-random key PRK through HMAC-SHA256, which is then used as the input for the subsequent Expand phase.
[0084] Based on the field separation mechanism, in the Expand phase of the HKDF algorithm, selection bytes for scrambling are generated respectively. and shift bytes , is represented as:
[0085] In the formula This refers to the Expand process of the HKDF algorithm. Select a domain label for the knight path; For row and column circular field labels; For shifted bytes The length, and , To fill the height of the image, To fill the width of the image;
[0086] Based on the selected bytes The path selection parameters of the Knight's Patrol algorithm are calculated using the following formula:
[0087] In the formula Select parameters for the first path; Select parameters for the second path; Select parameters for the third path; Let be the modulo operation function, and , This is the floor function; To convert the data into a double-precision floating-point function; To select bytes The first byte in; To select bytes The second byte in; To select bytes The third byte in;
[0088] The generated shift byte Interpreted as a 16-bit word u16, the shift parameters are calculated using the following formula:
[0089] In the formula This is the row shift parameter; For column shift parameters; Represents a 16-bit word sequence The first to the second A subsequence consisting of elements; Represents a 16-bit word sequence The Middle The first to the second A subsequence consisting of elements;
[0090] Ultimately, the obtained image scrambling parameters include , , , and ;
[0091] The process of obtaining image diffusion parameters specifically includes the following steps:
[0092] Based on the field separation mechanism, a mapped byte sequence is generated in the Expand phase of the HKDF algorithm. , is represented as:
[0093] In the formula For diffusion domain labels; For mapped byte sequences The length, and ;
[0094] Based on the generated mapping byte sequence The image diffusion parameters are obtained by mapping using the following formula:
[0095] In the formula The first image diffusion parameter; express The first to the second A subsequence consisting of elements; This is the second image diffusion parameter; express The Middle The first to the second A subsequence consisting of elements; For the third image diffusion parameter; To indicate The last element in;
[0096] S3. Construct an image scrambling model based on the Knight's Roaming algorithm; specifically including the following steps:
[0097] set up Grid patrol path, such as Figure 2 As shown:
[0098] exist On the grid, using the four vertices of the outermost square as candidate starting points, construct... An open patrol path is created; during patrol, the knight first performs an "L"-shaped jump to generate candidate landing points, thus obtaining a patrol path that covers all grids; if a landing point goes out of bounds during a jump, the algorithm is applied... and Return the landing point to within the boundary, among which The coordinates of the landing point after crossing the boundary. To return to the coordinates of the landing point within the boundary, It is a return function and , Let be the grid side length. This is the modulo operation function;
[0099] Completed After establishing an open cruise path, by using D4 symmetry and reversing the path, we obtain... Image tour path; in specific implementation, When the value is 8, The value is 128;
[0100] set up Grid patrol path, such as Figure 3 As shown:
[0101] exist On the grid, starting from the four vertices of the outermost square, construct... An open knight patrol path; during the patrol, the knight performs "L"-shaped jumps to obtain a patrol path that covers all grids; in practice, The preferred value is 4;
[0102] Completed After establishing an open knight's patrol path, by using D4 symmetry and reversing the path, we obtain... Image tour path; in specific implementation, When the value is 4, The value is 64;
[0103] set up Grid patrol path, such as Figure 4 As shown:
[0104] exist On the grid, starting from the four vertices of the outermost square, construct... An open knight patrol path; during the patrol, the knight performs "L"-shaped jumps to obtain a patrol path that covers all grids; in practice, The preferred value is 4;
[0105] Completed After establishing an open knight's patrol path, by using D4 symmetry and reversing the path, we obtain... Image tour path; in specific implementation, When the value is 4, The value is 64;
[0106] In practice, the D4 symmetry includes identity transformation I, R90, R180, R270 rotation, horizontal / vertical flip, and main / secondary diagonal flip.
[0107] S4. Based on the image scrambling parameters obtained in step S2 and the model constructed in step S3, perform image scrambling on the preprocessed target image; specifically, this includes the following steps:
[0108] First disruption:
[0109] The preprocessed target image is divided into... The grid area; parameters are selected based on the first path. ,from Select the corresponding tour path from the image tour path, and scramble the preprocessed target image according to the selected tour path to obtain the first scrambled image;
[0110] Second disruption:
[0111] Divide the first scrambled image into: The grid area; parameters are selected based on the second path. ,from Select the corresponding scrambled path from the image scrambled path, and scramble the first scrambled image according to the selected scrambled path to obtain the second scrambled image;
[0112] The third disruption:
[0113] Divide the second scrambled image into The grid area; parameters are selected based on the third path. ,from Select the corresponding scrambled path from the image scrambled path, and scramble the second scrambled image according to the selected scrambled path to obtain the third scrambled image;
[0114] Through the first to third scrambling, multi-scale, hierarchical block-level scrambling is achieved;
[0115] During the first to third scrambling process, the pixel positions within the grid area remain unchanged;
[0116] Disorderly conduct:
[0117] The third scrambled image Row, according to row shift parameters The i-th element value in the image is cyclically shifted to obtain a row scrambled image; where The value is , The total number of rows in the third scrambled image; in specific implementation, when A positive value indicates that the row is shifted cyclically to the right. 1 pixel, when A negative value indicates that the row is shifted to the left in a circular fashion. 1 pixel, when A value of zero indicates that the row will not be moved;
[0118] Column shuffling:
[0119] For the obtained row scrambling image, the first Columns, according to column shift parameters The j-th element value in the image is cyclically shifted to obtain a scrambled column image; where The value is , The total number of columns for the third scrambled image; in specific implementation, when A positive value indicates that the column is shifted downwards in a circular fashion. 1 pixel, when A negative value indicates that the column has been shifted upwards in a circular fashion. 1 pixel, when A value of zero indicates that the column is not moved;
[0120] The resulting scrambled image is used as the scrambled image. ;
[0121] S5. Based on the image diffusion parameters obtained in step S2, perform image diffusion on the scrambled image obtained in step S4 to obtain the final encrypted image; specifically including the following steps:
[0122] The scrambled image obtained in step S4 Flattening the images according to a predetermined order yields a one-dimensional image sequence. for ,in One-dimensional image sequence The Middle The pixel value of each pixel. , The length of the image sequence and ;
[0123] Forward diffusion process:
[0124] Initialize the first diffusion state variable For the third image diffusion parameter ;
[0125] The following formula is used for one-dimensional image sequences. The Middle input pixels Perform a diffusion transformation to obtain the output pixels. and will As the first The first diffusion output pixel value and the first diffusion state variable for the next round:
[0126] In the formula The coefficients are non-zero to avoid diffusion degradation in finite field multiplication due to coefficients being zero. ; Indicates in Multiplication on (using a pre-defined irreducible polynomial) ); This is a bitwise XOR operation; First image diffusion parameter The One element; For modulo operation; ;
[0127] Obtain the updated one-dimensional image sequence ;
[0128] Backward diffusion process:
[0129] Initialize the second diffusion state variable For the third image diffusion parameter ;
[0130] The following formula is used for one-dimensional image sequences. The first in element values After updating again, we get and will As the first The first diffusion output pixel value and the second diffusion state variable for the next round:
[0131] In the formula The coefficients are non-zero to avoid diffusion degradation in finite field multiplication due to coefficients being zero. ; First image diffusion parameter The One element; ;
[0132] After forward and backward diffusion are completed, a one-dimensional ciphertext byte sequence C is obtained;
[0133] During the diffusion process, The function maps any product that is 0 to 1, while leaving non-zero values unchanged; therefore, The function can guarantee and All of them are non-zero coefficients, so the inversion operation during the decryption process is well-defined and safe, which in turn can also guarantee the reliability of this scheme;
[0134] Reshape the one-dimensional ciphertext byte sequence C as follows: The image was used to obtain an encrypted image. ;
[0135] S6. The sender transmits the encrypted image to the receiver; the receiver decrypts the image, completing the encrypted transmission of the target image; specifically, this includes the following steps:
[0136] The sender transmits the encrypted image and session assistance information to the receiver, the session assistance information including one-time salt and domain-separated context information. , , ) and the parameters for filling (including the original image size and the specific parameters for filling);
[0137] The receiver decrypts the image according to the image encryption process, thus completing the encrypted transmission of the target image.
[0138] This invention's method, through standardized X25519 key exchange and a tagged HKDF derivation mechanism, achieves end-to-end secure session key negotiation and domain-separated key generation. This avoids the distribution risks of traditional pre-shared key methods and facilitates integration with existing security protocols such as TLS, significantly improving the security and scalability of key negotiation. At the scrambling level, this invention's method is based on... , , A multi-scale open knight's roaming path is constructed to create a block-level scrambling model. A large-scale high-entropy path pool is obtained using D4 group symmetric transformation and path backward expansion. Combined with row-by-row and column-by-column cyclic shift operations, the spatial correlation of image pixels is effectively broken. Compared with traditional fixed-pattern scrambling methods such as Zigzag, this significantly improves scrambling entropy and resistance to exhaustive analysis. At the diffusion level, this invention designs a finite-field-based... A bidirectional feedback diffusion structure combining multiplication and modulo 256 addition achieves rapid global diffusion of minute changes in plaintext and key through forward and backward chained feedback, enhancing the algorithm's nonlinearity and resistance to cryptanalysis techniques such as differential attacks and chosen-plaintext attacks. Experimental results show that the method of this invention maintains high encryption security while having low time overhead and good implementation efficiency, making it suitable for the security protection of digital images in network transmission and cloud storage scenarios.
[0139] like Figure 5The diagram shows the functional modules of the system of this invention: The system disclosed in this invention, which implements the image encryption transmission method based on shared key and the Knight's Roaming algorithm, includes an image preprocessing module, a parameter calculation module, a scrambling construction module, an image scrambling module, an image diffusion module, and an encryption transmission module; these modules are connected in series. The image preprocessing module is used by the sender to preprocess the target image and upload the data information to the parameter calculation module. The parameter calculation module is used by the sender and receiver to generate a shared key based on the received data information, and obtain image scrambling parameters and image diffusion parameters based on the generated shared key and the HKDF algorithm, and then transmit the data information... The image scrambling module is used to construct an image scrambling model based on the received data and the Knight's Roaming algorithm, and then uploads the data to the image scrambling module. The image scrambling module, based on the received data, the obtained image scrambling parameters, and the constructed model, scrambles the preprocessed target image and uploads the data to the image diffusion module. The image diffusion module, based on the received data and the obtained image diffusion parameters, diffuses the scrambled image to obtain the final encrypted image and uploads the data to the encryption transmission module. The encryption transmission module, based on the received data, transmits the encrypted image from the sender to the receiver. The receiver decrypts the image, completing the encrypted transmission of the target image.
Claims
1. An image encryption transmission method based on shared key and knight's roaming algorithm, comprising the following steps: S1. The sender preprocesses the target image; S2. The sender and receiver negotiate to obtain a shared key, and based on the shared key and the HKDF algorithm, obtain the image scrambling parameters and image diffusion parameters; S3. Construct an image scrambling model based on the Knight's Roaming algorithm; S4. Based on the image scrambling parameters obtained in step S2 and the model constructed in step S3, perform image scrambling on the preprocessed target image; S5. Based on the image diffusion parameters obtained in step S2, perform image diffusion on the scrambled image obtained in step S4 to obtain the final encrypted image; S6. The sender transmits the encrypted image to the receiver; the receiver decrypts the image, completing the encrypted transmission of the target image.
2. The image encryption transmission method based on shared key and knight's roaming algorithm according to claim 1, characterized in that... Step S1, where the sender preprocesses the target image, specifically includes the following steps: The sender fills the height and width of the target image to integer multiples of 16 to obtain the corresponding filled image and records the filling parameters.
3. The image encryption transmission method based on shared key and knight's roaming algorithm according to claim 2, characterized in that... Step S2, obtaining the image scrambling parameters, specifically includes the following steps: The sender and receiver negotiate and obtain a shared key Z; Based on the shared key Z, a one-time salt is used in the Extract phase of the HKDF algorithm to calculate the pseudo-random key PRK through HMAC-SHA256, which is then used as the input for the subsequent Expand phase. Based on the field separation mechanism, in the Expand phase of the HKDF algorithm, selection bytes for scrambling are generated respectively. and shift bytes , is represented as: In the formula This refers to the Expand process of the HKDF algorithm. Select a domain label for the knight path; For row and column circular field labels; For shifted bytes The length, and , To fill the height of the image, To fill the width of the image; Based on the selected bytes The path selection parameters of the Knight's Patrol algorithm are calculated using the following formula: In the formula Select parameters for the first path; Select parameters for the second path; Select parameters for the third path; Let be the modulo operation function, and , This is the floor function; To convert the data into a double-precision floating-point function; To select bytes The first byte in; To select bytes The second byte in; To select bytes The third byte in; The generated shift byte Interpreted as a 16-bit word u16, the shift parameters are calculated using the following formula: In the formula This is the row shift parameter; For column shift parameters; Represents a 16-bit word sequence The first to the second A subsequence consisting of elements; Represents a 16-bit word sequence The Middle The first to the second A subsequence consisting of elements; Ultimately, the obtained image scrambling parameters include , , , and .
4. The image encryption transmission method based on shared key and knight's roaming algorithm according to claim 3, characterized in that... Step S2, which involves obtaining the image diffusion parameters, specifically includes the following steps: Based on the field separation mechanism, a mapped byte sequence is generated in the Expand phase of the HKDF algorithm. , is represented as: In the formula For diffusion domain labels; For mapped byte sequences The length, and ; Based on the generated mapping byte sequence The image diffusion parameters are obtained by mapping using the following formula: In the formula The first image diffusion parameter; express The first to the second A subsequence consisting of elements; This is the second image diffusion parameter; express The Middle The first to the second A subsequence consisting of elements; For the third image diffusion parameter; To indicate The last element in the middle.
5. The image encryption transmission method based on shared key and knight's roaming algorithm according to claim 4, characterized in that... Step S3, which involves constructing an image scrambling model based on the Knight's Roaming algorithm, specifically includes the following steps: set up Grid patrol path: exist On the grid, using the four vertices of the outermost square as candidate starting points, construct... An open patrol path is created; during patrol, the knight first performs an "L"-shaped jump to generate candidate landing points, thus obtaining a patrol path that covers all grids; if a landing point goes out of bounds during a jump, the algorithm is applied... and Return the landing point to within the boundary, among which The coordinates of the landing point after crossing the boundary. To return to the coordinates of the landing point within the boundary, It is a return function and , Let be the grid side length. This is the modulo operation function; Completed After establishing an open cruise path, by using D4 symmetry and reversing the path, we obtain... Image tour path; set up Grid patrol path: exist On the grid, starting from the four vertices of the outermost square, construct... An open knight patrol path; during patrol, the knight performs "L"-shaped jumps to obtain a patrol path that covers all grids; once constructed... After establishing an open knight's patrol path, by using D4 symmetry and reversing the path, we obtain... Image tour path; set up Grid patrol path: exist On the grid, starting from the four vertices of the outermost square, construct... An open knight patrol path; during the patrol, the knight performs "L"-shaped jumps to obtain a patrol path that covers all grids; Completed After establishing an open knight's patrol path, by using D4 symmetry and reversing the path, we obtain... A single image tour path.
6. The image encryption transmission method based on shared key and knight's roaming algorithm according to claim 5, characterized in that... Step S4, which involves scrambling the preprocessed target image based on the image scrambling parameters obtained in step S2 and the model constructed in step S3, specifically includes the following steps: First disruption: The preprocessed target image is divided into... The grid area; parameters are selected based on the first path. ,from Select the corresponding tour path from the image tour path, and scramble the preprocessed target image according to the selected tour path to obtain the first scrambled image; Second disruption: Divide the first scrambled image into: The grid area; parameters are selected based on the second path. ,from Select the corresponding scrambled path from the image scrambled path, and scramble the first scrambled image according to the selected scrambled path to obtain the second scrambled image; The third disruption: Divide the second scrambled image into Grid area; Select parameters based on the third path. ,from Select the corresponding scrambled path from the image scrambled path, and scramble the second scrambled image according to the selected scrambled path to obtain the third scrambled image; During the first to third scrambling process, the pixel positions within the grid area remain unchanged; Disorderly conduct: The third scrambled image Row, according to row shift parameters The i-th element value in the image is cyclically shifted to obtain a row scrambled image; where The value is , The total number of rows in the third scrambled image; Column shuffling: For the obtained row scrambling image, the first Columns, according to column shift parameters The j-th element value in the image is cyclically shifted to obtain a scrambled column image; where The value is , The total number of columns for the third scrambled image; The resulting scrambled image is used as the scrambled image. .
7. The image encryption transmission method based on shared key and knight's roaming algorithm according to claim 6, characterized in that... Step S5, which involves performing image diffusion on the scrambled image obtained in step S4 based on the image diffusion parameters obtained in step S2 to obtain the final encrypted image, specifically includes the following steps: The scrambled image obtained in step S4 Flattening the images according to a predetermined order yields a one-dimensional image sequence. for ,in One-dimensional image sequence The Middle The pixel value of each pixel. , The length of the image sequence and ; Forward diffusion process: Initialize the first diffusion state variable For the third image diffusion parameter ; The following formula is used for one-dimensional image sequences. The Middle input pixels Perform a diffusion transformation to obtain the output pixels. and will As the first The first diffusion output pixel value and the first diffusion state variable for the next round: In the formula The coefficients are non-zero to avoid diffusion degradation in finite field multiplication due to coefficients being zero. ; Indicates in Multiplication on top; This is a bitwise XOR operation; The first image diffusion parameter The One element; For modulo operation; ; Obtain the updated one-dimensional image sequence ; Backward diffusion process: Initialize the second diffusion state variable For the third image diffusion parameter ; The following formula is used for one-dimensional image sequences. The first in element values After updating again, we get and will As the first The first diffusion output pixel value and the second diffusion state variable for the next round: In the formula The coefficients are non-zero to avoid diffusion degradation in finite field multiplication due to coefficients being zero. ; The first image diffusion parameter The One element; ; After forward and backward diffusion are completed, a one-dimensional ciphertext byte sequence C is obtained; Reshape the one-dimensional ciphertext byte sequence C as follows: The image was used to obtain an encrypted image. .
8. The image encryption transmission method based on shared key and knight's roaming algorithm according to claim 7, characterized in that... Step S6 involves the sender transmitting the encrypted image to the receiver; the receiver decrypts the image to complete the encrypted transmission of the target image, specifically including the following steps: The sender transmits the encrypted image and session assistance information to the receiver. The session assistance information includes a one-time salt, domain-separated context information, and padding parameters. The receiver decrypts the image according to the image encryption process, thus completing the encrypted transmission of the target image.
9. A system for implementing the image encryption transmission method based on shared key and knight's roaming algorithm as described in any one of claims 1 to 8, characterized in that... It includes an image preprocessing module, a parameter calculation module, a scrambling construction module, an image scrambling module, an image diffusion module, and an encrypted transmission module; the image preprocessing module, parameter calculation module, scrambling construction module, image scrambling module, image diffusion module, and encrypted transmission module are connected in series; the image preprocessing module is used by the sender to preprocess the target image and upload the data information to the parameter calculation module; The parameter calculation module is used to obtain a shared key through negotiation between the sender and receiver based on the received data information, and to obtain image scrambling parameters and image diffusion parameters based on the shared key and the HKDF algorithm, and then upload the data information to the scrambling construction module; the scrambling construction module is used to construct an image scrambling model based on the Knight's Roaming algorithm based on the received data information, and then upload the data information to the image scrambling module. The image scrambling module is used to scramble the preprocessed target image based on the received data information, the obtained image scrambling parameters, and the constructed model, and then upload the data information to the image diffusion module. The image diffusion module is used to diffuse the scrambled image according to the received data information and the obtained image diffusion parameters to obtain the final encrypted image, and then upload the data information to the encrypted transmission module. The encrypted transmission module is used to transmit an encrypted image from the sender to the receiver based on the received data information; the receiver decrypts the image to complete the encrypted transmission of the target image.