Lossless video encryption method based on real value non-volume preserving transformation model
Through the lossless video encryption method based on RealNVP, multi-layer alternating encryption and coupling operations are performed on the video frame stream, which solves the problems of low efficiency and insufficient security of video encryption in the existing technology, realizes efficient lossless encryption and powerful key space, and ensures the security of video data.
Patent Information
- Application Number
- CN202511058169.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-30
- Publication Date
- 2025-10-17
AI Technical Summary
Existing neural network-based video encryption schemes suffer from high time complexity and are unable to fully restore video images without information loss. They are also vulnerable to statistical attacks and chosen ciphertext attacks.
A lossless video encryption method based on RealNVP is adopted. By dividing the video into digital image streams, the additively coupled RealNVP model is used to perform multi-layer alternating encryption and coupling operations on each frame of the image, generating a tailored sub-key, and combining the Fisher-Yates scrambling algorithm for initial scrambling and channel segmentation to achieve efficient lossless encryption.
It achieves efficient and lossless video encryption, can resist classic attacks, ensure the security of video data during transmission, and has key sensitivity and a strong key space to prevent information leakage.
Smart Images

Figure CN120812318A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of video security transmission, and particularly discloses a lossless video encryption method based on a real-valued non-volume preserving transformation model (RealNVP), which realizes efficient and lossless video encryption. BACKGROUND
[0002] Video encryption is a basic task in image data processing, aiming to ensure the security of video during transmission or storage. There are many different encryption video schemes in current research, such as compressed sensing and chaos theory. Taking the chaos-based image encryption scheme as an example, they usually use the unpredictability and key sensitivity of chaotic systems to complete the permutation and diffusion process. Although the efficiency of these schemes is relatively high, a small number of schemes are vulnerable to statistical attacks and chosen ciphertext attacks.
[0003] Compared with traditional cryptography image and video encryption schemes, neural network (NN) based encryption schemes show a significantly larger key space and have a strong ability to process image data in parallel. However, most existing neural network-based image encryption schemes have the problem of high time complexity when generating random keys, and their decryption process often cannot completely restore the video image without losing information. SUMMARY
[0004] The present application aims to overcome the shortcomings of the prior art and provide an encryption network based on a real-valued non-volume preserving transformation model (RealNVP) model, which aims to realize efficient and lossless video encryption.
[0005] To achieve the above-mentioned purpose, the technical scheme adopted by the present application is as follows:
[0006] A lossless video encryption method based on RealNVP includes the following steps:
[0007] Step one: process the video into a frame stream, and regard each frame as a digital image;
[0008] Step two: input the digital image stream into the encryption network, and apply the encryption process to each frame image;
[0009] Step three, based on the structure of the real-valued non-volume preserving transformation model (RealNVP), after recombining the pixel values, additive coupling is selected, and in each layer of the encryption network, the encryption function is used to encrypt and couple the selected image block with the key of the layer, and the final encrypted digital image is obtained through multiple alternating encryption and coupling operations.
[0010] In step one, the secret key required for encryption is generated, and the method for generating the secret key includes: selecting a random master key, and using a key generation algorithm to generate a sub-key used in each layer of the encryption network.
[0011] In the step 1, the video stream is segmented into digital image streams by frames using a video framing algorithm, and each frame is regarded as a digital image and used as input to the encryption network.
[0012] In step 1, the generated random master key is used to control the generation of multiple subsequences, extract multiple random binary sequences from the subsequences, and convert them into decimal numbers in the range of 0 to 255, and finally obtain the subkeys k1 to k2 required for each layer in the encryption process. n .
[0013] In step 2, the input digital image is converted into a pixel matrix, and initial scrambling and channel segmentation operations are performed; for the digital image, it is divided into three two-dimensional pixel matrices, and the Fisher-Yates scrambling algorithm is used to complete the initial scrambling.
[0014] Step 2 also includes: completing the three-channel segmentation operation on the three pixel matrices obtained after segmentation, and after the pixel values are reorganized, 12 image blocks of the same size are obtained; in the encryption process of each layer, two image blocks are randomly divided into a group, which is expressed as There are six groups in total, where n is the number of encryption layers of the current network, starting from n=1.
[0015] Step three includes selecting the image blocks in each group according to the number of layers of the current encryption network and performing encryption operations on the image blocks in the six groups.
[0016] When the encryption layer n is an odd number, select the block Elements in With the key k of this layer n Perform encryption operation, the encryption method is Get the encrypted result and another block Elements in Perform coupling operations and calculate coupling Get the encrypted output of this layer Keep The elements in remain unchanged Get the output
[0017] When the encryption layer n is an even number, the block is selected Elements in With the key k of this layer n Perform encryption operation, the encryption method is Get the encrypted result and another block Elements in Perform coupling operations and calculate coupling results. Get the encrypted output of this layer Keep The elements in remain unchanged Get the output
[0018] The coupling method selected in step three is additive coupling. Multiple rounds of encryption are repeated, and encryption and coupling operations are performed alternately. The output of the current network layer is used as the input of the subsequent layer. The operation is repeated until the last layer of encryption is completed, and six groups of alternately encrypted image blocks are obtained. After merging, an encrypted image of a frame of image is obtained. After all images in the frame stream are encrypted, the encrypted video is restored.
[0019] The advantage of this invention lies in its ability to achieve lossless encryption of video frame streams based on a RealNVP neural network coupling structure. Specifically, we decompose the video into image streams, apply encryption to each frame, and allow image blocks to be encrypted alternately during the forward propagation process. Furthermore, we design a key generation algorithm that generates customized subkeys for each layer of the encryption network. This invention effectively resists classical attacks, ensuring the security of video data during transmission, and has broad application prospects in the field of digital media information security. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The following is a brief description of the contents and symbols in the drawings of the present invention:
[0021] Figure 1 It is a schematic diagram of key generation of the present invention;
[0022] Figure 2 It is the encryption flow chart of the present invention;
[0023] Figure 3 (a) is a schematic diagram of the present invention before encrypting a frame of image, Figure 3 (b) is the encrypted image of a frame of image. Figure 3 (c) is the decrypted image of a ciphertext image;
[0024] Figure 4 (b)-(d) are histograms of the first three channels of the image frame encrypted by the present invention. Figure 4 (f)-(h) are the histograms of the three channels after image frame encryption;
[0025] Figure 5 (b)-(d) are the pixel correlation distribution diagrams before image frame encryption. Figure 5 (f)-(h) are pixel correlation distribution diagrams after image frame encryption
[0026] Figure 6 (a) is the effect diagram of the encrypted image frame. Figure 6 (b) is the image frame decrypted with the correct key. Figure 6(c) is a minutely changed error key decrypted image frame. DETAILED DESCRIPTION
[0027] The specific embodiments of the present application will be further described in detail below with reference to the accompanying drawings, by describing the optimal embodiments.
[0028] The encryption method provided by the embodiment is used for efficient lossless encryption of a video, and is a RealNVP-based video lossless encryption method, including the following steps.
[0029] Step one: process the video into a frame stream, and regard each frame as a digital image. Before encryption, the communication parties negotiate a secure session key according to an authentication key exchange protocol. On this basis, a randomly selected initial sequence is generated using a random salt and a random function. The initial sequence is a random master key, and a key generation algorithm is used to generate a sub-key used by each layer of the encryption network;
[0030] Step two: the digital image stream is used as the input of the encryption network, and the encryption process is applied to each frame. The input digital image is converted into a pixel matrix and subjected to an initial shuffling operation;
[0031] Step three: based on the RealNVP coupling structure, the inter-channel segmentation operation of the image frame is completed, and 12 image blocks of the same size are obtained after the pixel values are reorganized. In the encryption process of each layer, two image blocks are randomly selected as a group. In order to make the encryption more secure and efficient, the network structure of the RealNVP model is improved in the present application. The coupling mode of the coupling layer is selected as additive coupling. The designed network is composed of input, encryption coupling layer and output. These image blocks are used as the input of the encryption network, and the encryption and coupling operations are completed in the process of forward propagation. In each layer of the encryption network, the selected image blocks in the group are encrypted and coupled using the encryption function and the key of the layer. The encryption output of each layer is used as the input of the next layer encryption. The final encrypted digital image is obtained through the alternating encryption and coupling operations of multiple layers, and the final video is formed after merging.
[0032] As a further scheme of the present application: in the step one, the specific method for performing the video stream encryption processing is as follows:
[0033] The video stream is segmented into a digital image stream by a video frame segmentation algorithm, and each frame is regarded as a digital image, which is used as the input of the encryption network proposed in the present application. The encryption network is composed of input, coupling encryption layer and output. In order to more fully encrypt the image pixel information in the process of forward propagation, the number of encryption coupling layers is designed to be 40.
[0034] The generated random master key is used to control the generation of multiple subsequences. First, the master key is permuted using a predefined permutation table 1 to obtain a (km) bit sequence, where m represents the number of parity bits added. Next, the permuted sequence is divided into two parts, and a predefined cyclic left shift is performed on each part. The two parts are merged by the left shift and permuted again using the defined permutation table 2. Repeat the cyclic left shift and permutation of the sequence for multiple rounds to obtain the final subsequence. Multiple random binary sequences are extracted from these subsequences and converted into decimal numbers in the range of 0 to 255, and finally the subkeys k1 to k2 required for each layer in the encryption process are obtained. n ;
[0035] As a further solution of the present invention: in the step 2, the specific method of encrypting a frame of image is as follows:
[0036] For digital images, decompose them into three two-dimensional pixel matrices (corresponding to RGB channels respectively), each matrix represents a color channel, and use the Fisher-Yates scrambling algorithm to complete the initial scrambling;
[0037] The RealNVP flow model combines channel segmentation and squeezing to reorganize the input data. The inventive method proposed in this paper is based on the data reorganization method in the model, and only reorganizes the pixels of the scrambled image on the channel axis, that is, the reorganization and segmentation operations in the RealNVP model are performed on the elements in the pixel matrices of the three channels. Specifically, the pixel matrix of each original channel is further divided into 4 sub-matrices of the same size, so a total of 12 pixel matrices are obtained for the three channels. These sub-matrices are image blocks, which are used for modeling or transformation in subsequent processing. Randomly divide the image blocks into groups of two, represented as There are six groups in total, where n is the number of encryption layers in the current network, starting from n=1;
[0038] As a further solution of the present invention: In the step 3, the specific method of encryption is as follows:
[0039] When the encryption layer n is an odd number, select the block Elements in With the key k of this layer n Perform encryption operations, Here, E(x) is the encryption function, and mod is the remainder function. The encrypted result is obtained and the other block Elements in Perform coupling operations and calculate coupling Get the encrypted output of this layer Where, Indicates that a coupling operation is performed on the two parts of data, and the coupling mode is selected as additive coupling, that is, an exclusive-or addition operation is performed on the two parts of data.
[0040] Keep The elements in remain unchanged Get the output
[0041] When the encryption layer n is an even number, the block is selected Elements in With the key k of this layer n Perform encryption operations, Here, E(x) is the encryption function, and mod is the remainder function. The encrypted result is obtained and the other block Elements in Perform coupling operations and calculate coupling results. Get the encrypted output of this layer As mentioned above, here For the coupling operation, the selected coupling mode is additive coupling, and an XOR addition operation is performed on the two parts of data.
[0042] Keep The elements in remain unchanged Get the output
[0043] Each image frame is encrypted through n layers of an encryption network to produce the final encrypted output. Additive coupling is used, repeating multiple rounds of encryption, alternating between encryption and coupling. The output of each network layer is used as the input for the subsequent layer, and this process repeats until the final layer is encrypted. Six sets of alternately encrypted image blocks are generated, which are then merged to form the encrypted image of a single frame. Once all frames in the frame stream are encrypted, the encrypted video is restored.
[0044] The video encryption implemented by the present invention includes the following steps:
[0045] Step 1: Process the video into a frame stream and treat each frame as a digital image. Select a random master key, such as Figure 1 As shown, a key generation algorithm is used to generate subkeys used in each layer of the encryption network;
[0046] Step 2: The digital image stream is used as the input of the encryption network, and the encryption process is applied to each frame. The input digital image is converted into a pixel matrix, and the pixel matrix is initially scrambled by channel.
[0047] Step 3: Based on the RealNVP coupling structure, after pixel values are reorganized, the input image is encrypted. In each layer of the encryption network, the selected image block is encrypted and coupled using the encryption function and the key of that layer. Multiple layers of alternating encryption and coupling operations produce the final encrypted digital image, which is then combined to form the final video.
[0048] As a further solution of the present invention: in step 1, the specific method of executing the initialization service is as follows:
[0049] The video stream is divided into frames and processed into digital image streams through the video frame segmentation algorithm. Each frame is regarded as a digital image and used as the input of the encryption network.
[0050] The generated random master key is used to control the generation of multiple subsequences. Figure 1 As shown in the figure, multiple random binary sequences are extracted from the subsequence and converted into decimal numbers in the range of 0 to 255, and finally the subkeys k1 to k2 required for each layer in the encryption process are obtained. n ;
[0051] For digital images, they are divided into three two-dimensional pixel matrices and the Fisher-Yates scrambling algorithm is used to complete the initial scrambling.
[0052] Encryption operations such as Figure 2 As shown in the figure, the image frame is segmented between channels, and 12 image blocks of the same size are obtained after segmentation. In the encryption process of each layer, two image blocks are randomly divided into a group. They are represented as The number of encryption layers of the current network starts from n=1.
[0053] When the encryption layer n is an odd number, select the block Elements in With the key k of this layer n Perform encryption operations, Get the encrypted result and another block Elements in Perform coupling operations and calculate coupling Get the encrypted output of this layer
[0054] Keep The elements in remain unchanged Get the output
[0055] When the encryption layer n is an even number, the block is selected Elements in With the key k of this layer n Perform encryption operations, Get the encrypted result and another block elements in perform coupling operation, calculate coupling result, get the output of the layer after encryption
[0056] maintain elements in get the output
[0057] The selected coupling mode is additive coupling, and multiple rounds of encryption are repeated, and the encryption and coupling operations are alternately performed. The output of the current network layer is used as the input of the subsequent layer, and the operation is repeated until the encryption of the last layer is completed.
[0058] Six groups of alternately encrypted image blocks are obtained, and after merging, an encrypted image of a frame is obtained, and the encrypted picture is as shown in Figure 3 (b).
[0059] After the frame stream encryption is completed, it is restored to an encrypted video.
[0060] The security of the video encryption method of the present application is analyzed as follows,
[0061] 1. Histogram analysis
[0062] The histogram reflects the characteristics of the pixel value distribution, and the more stable the histogram, the more difficult it is for the attacker to obtain pixel information from the image. Figure 4 The histograms of a frame of plaintext image and ciphertext image are shown in Figures 1 and 2, respectively. As can be seen from the figures, the pixel value distribution of the histogram of the original image frame before encryption is uneven. After the image is encrypted by the present application, the histogram of the ciphertext image is uniformly distributed, and the pixel value information is well hidden, achieving the effect of secure encryption.
[0063] 2. Statistical analysis
[0064] 5000 pairs of plaintext and ciphertext images are randomly selected, and two groups of adjacent horizontal, vertical and diagonal pixel values are obtained, and the distribution graph of the pixel correlation is obtained. As shown in Figure 5 (b)-(d) show the relationship graph before encryption of the image frame, Figure 5 (f)-(h) show the relationship graph after encryption, and the correlation coefficient between the pixels is calculated according to formulas (1)-(4).
[0065]
[0066] cov(x, y) = E((x - E(x))(y - E(y))), (2)
[0067]
[0068] where x and y represent two adjacent pixels. E(x), D(x) and cov(x, y) represent expectation, variance and covariance, respectively. The results are shown in Table 1. The correlation coefficient after encryption is close to 0, and the correlation is low.
[0069] Table 1. Correlation coefficient table of adjacent pixels
[0070]
[0071] 3. Key sensitivity analysis
[0072] Key sensitivity means that when the key changes extremely slightly, the image frame cannot be successfully decrypted. As shown in Fig. 3, the original ciphertext image is decrypted after changing one bit of the original key, and the slightly changed key cannot obtain the correct plaintext image. Therefore, the encryption method proposed in the present application has key sensitivity. Figure 6
[0073] 4. Plaintext sensitivity analysis
[0074] Plaintext sensitivity means that when the pixel value in the image changes slightly, a completely different ciphertext image is obtained. Two parameters, namely, the NPCR (Number of Pixel Change Rate) and the UACI (Unified Average Change Intensity), are used to evaluate the plaintext sensitivity. The calculation formula is as follows:
[0075]
[0076] Some pixels in the plaintext image are modified, and then the same key encryption is performed to obtain two encrypted images. The information of the original encrypted image and the modified encrypted image is analyzed. The calculation shows that the NPCR is close to 99.64%, and the UACI is close to 33.78%, indicating that when the pixel value of the image changes slightly, the ciphertext image obtained by encryption has significant differences.
[0077] 5. Security analysis
[0078] In the encryption network proposed in the present application, the video is decomposed into frames, and all the image frames are encrypted. During encryption, the pixel diffusion is realized by combining the permutation operation, multiple rounds of encryption and coupling operation. The ciphertext-only attack means that the attacker only knows the ciphertext-related information, and needs to try to recover the plaintext from the statistical information in the ciphertext. The correlation analysis of the encrypted image frames in the present application shows that the correlation of the pixels after encryption is close to 0, and the attacker cannot extract any useful information from the ciphertext image. The present application can effectively resist the ciphertext-only attack.
[0079] The symmetric encryption network structure provided by the application has randomness of each generated sub-key when the plaintext image is consistent, and the same ciphertext cannot be returned twice after encryption.
[0080] In combination with the working mode of the block cipher, the application can resist the chosen plaintext attack.
[0081] In addition, the initial master key provided by the application is generated by the communication parties negotiating a random seed, and a random sequence with a length of 64 bits is generated. A plurality of sub-sequences are obtained through random calculation. The sub-sequences are extracted and converted into decimals to obtain the sub-key. Based on the process, the total size of the key space is about 2 512 , that is, the scheme provided by the application has strong resistance to brute force attack.
[0082] Obviously, the specific implementation of the application is not limited by the above mode, and various non-essential improvements using the method concept and technical scheme of the application are within the protection scope of the application.
Claims
1. A lossless video encryption method based on a real-valued non-volume preserving transformation model, characterized by: The steps include: Step 1: Process the video into a frame stream, and treat each frame as a digital image; Step 2: The digital image stream is used as the input of the encryption network, and the encryption process is applied to each frame of the image; Step 3: Based on the structure of the real-valued non-volume-preserving transformation model, after the pixel values are reorganized, additive coupling is selected. In each layer of the encryption network, the selected image blocks are encrypted and coupled using the encryption function and the key of that layer. Multiple layers of alternating encryption and coupling operations are performed to obtain the final encrypted digital image.
2. The lossless video encryption method based on a real-valued non-volume preserving transformation model according to claim 1, wherein: In step 1, the key required for encryption is generated. The method for generating the key includes: selecting a random master key and using a key generation algorithm to generate a subkey used in each layer of the encryption network.
3. The lossless video encryption method based on a real-valued non-volume preserving transformation model according to claim 1 or 2, characterized in that: In the step 1, the video stream is segmented into digital image streams by frames using a video framing algorithm, and each frame is regarded as a digital image and used as input to the encryption network.
4. The method for lossless video encryption based on a real-valued non-volume preserving transformation model according to claim 2, wherein: In step 1, the generated random master key is used to control the generation of multiple subsequences, extract multiple random binary sequences from the subsequences, and convert them into decimal numbers in the range of 0 to 255, and finally obtain the subkeys k1 to k2 required for each layer in the encryption process. n .
5. The lossless video encryption method based on a real-valued non-volume preserving transformation model according to claim 1 or 2, characterized in that: In step 2, the input digital image is converted into a pixel matrix, and initial scrambling and channel segmentation operations are performed; wherein, for the digital image, it is divided into three two-dimensional pixel matrices, and the Fisher-Yates scrambling algorithm is used to complete the initial scrambling.
6. The lossless video encryption method based on a real-valued non-volume preserving transformation model according to claim 5, characterized in that: Step 2 also includes: completing the three-channel segmentation operation on the three pixel matrices obtained after segmentation, and after the pixel values are reorganized, 12 image blocks of the same size are obtained; in the encryption process of each layer, two image blocks are randomly divided into a group, which is expressed as There are six groups in total, where n is the number of encryption layers of the current network, starting from n=1.
7. The lossless video encryption method based on a real-valued non-volume preserving transformation model according to claim 6, characterized in that: Step three includes selecting the image blocks in each group according to the number of layers of the current encryption network and performing encryption operations on the image blocks in the six groups.
8. The lossless video encryption method based on a real-valued non-volume preserving transformation model according to claim 7, characterized in that: When the encryption layer n is an odd number, select the block Elements in With the key k of this layer n Perform encryption operation, the encryption method is Get the encrypted result and another block Elements in Perform coupling operations and calculate coupling Get the encrypted output of this layer Keep The elements in remain unchanged Get the output When the encryption layer n is an even number, the block is selected Elements in With the key k of this layer n Perform encryption operation, the encryption method is Get the encrypted result and another block Elements in Perform coupling operations and calculate coupling results. Get the encrypted output of this layer Keep The elements in remain unchanged Get the output 9. The lossless video encryption method based on a real-valued non-volume preserving transformation model according to claim 8, characterized in that: The coupling method selected in step three is additive coupling. Multiple rounds of encryption are repeated, and encryption and coupling operations are performed alternately. The output of the current network layer is used as the input of the subsequent layer. The operation is repeated until the last layer of encryption is completed, and six groups of alternately encrypted image blocks are obtained. After merging, an encrypted image of a frame of image is obtained. After all images in the frame stream are encrypted, the encrypted video is restored.