Diffusion Model-Based Key Generation Method, Device, Electronic Device, and Medium

Through the diffusion model, the key generation security problem under the threat of quantum computing is solved, and the key generation with high randomness and high security is achieved, adapting to the needs of different application scenarios.

CN119182525BActive Publication Date: 2025-07-25ELECTRIC POWER RESEARCH INSTITUTE OF STATE GRID SHANDONG ELECTRIC POWER COMPANY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411304783.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-19
Publication Date
2025-07-25
Estimated Expiration
2044-09-19

AI Technical Summary

Technical Problem

The existing key generation methods are less secure when facing quantum computing threats and cannot effectively resist quantum computing attacks.

Method used

The diffusion model is used to generate the key. By constructing the initial noise distribution and diffusion model, secret information and the initial noise distribution are input to the diffusion model for denoising, generating high randomness and high security initial keys, and performing multi-level verification and optimization.

Benefits of technology

The generated key can effectively resist quantum computing attacks, improve the security of key generation, adapt to the needs of different application scenarios, and has high randomness and high security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119182525B_ABST
    Figure CN119182525B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention discloses a key generation method, device, electronic device, and storage medium based on a diffusion model. The method includes: constructing an initial noise distribution and a diffusion model; inputting the secret information and the initial noise distribution into the diffusion model to obtain noisy data, and using the diffusion model to perform denoising processing on the noisy data to obtain a target distribution; determining a target random sample from the target distribution, and using the target random sample as an initial key; performing multi-level verification and optimization on the initial key to generate a target key. By using the technical solution of the embodiment of the present invention, a key with high randomness and high security is generated by using a diffusion model, effectively resisting attacks of quantum computing, and improving the security of key generation; the flexibility and scalability of the diffusion model enable it to adapt to the requirements of different application scenarios, and it has high application value and broad application prospects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the technical fields of information security and cryptography, and particularly to a key generation method, device, electronic device, and medium based on a diffusion model. Background Art

[0002] Traditional key generation methods usually rely on deterministic algorithms, such as generating keys based on mathematical problems. These methods are secure on classical computers because the time and computing resources required for classical computers to solve these mathematical problems are very high. However, with the development of quantum computing, these algorithms based on mathematical problems are facing unprecedented threats. Quantum computing can effectively crack many existing encryption algorithms through algorithms such as Shor's algorithm, greatly reducing the security of traditional key generation methods.

[0003] Shor's algorithm is a quantum algorithm that can solve the problems of large integer factorization and discrete logarithm in polynomial time, and these two are the basis of many traditional public key encryption algorithms. This means that once quantum computers reach sufficient scale and stability, existing public key encryption algorithms will no longer be able to provide security guarantees.

[0004] Therefore, there is an urgent need to develop new key generation methods to ensure communication and data security in the era of quantum computing. Summary of the Invention

[0005] The purpose of the present invention is to overcome the defects in the prior art, and provide a key generation method, device, electronic device, and storage medium based on a diffusion model, so as to generate keys with high randomness and high security through the diffusion model, effectively resist attacks of quantum computing, and improve the security of key generation.

[0006] In a first aspect, embodiments of the present invention provide a key generation method based on a diffusion model, including:

[0007] Construct an initial noise distribution and a diffusion model;

[0008] Input the secret information and the initial noise distribution into the diffusion model to obtain noisy data, and use the diffusion model to denoise the noisy data to obtain a target distribution;

[0009] Determine a target random sample from the target distribution, and use the target random sample as the initial key;

[0010] Perform multi-level verification and optimization on the initial key to generate a target key.

[0011] In a second aspect, embodiments of the present invention further provide a key generation device based on a diffusion model, including:

[0012] A noise and model generation module, configured to construct an initial noise distribution and a diffusion model;

[0013] A diffusion model application module, configured to input the secret information and the initial noise distribution into the diffusion model to obtain noisy data, and use the diffusion model to denoise the noisy data to obtain a target distribution;

[0014] A key extraction module, configured to determine a target random sample from the target distribution and use the target random sample as an initial key;

[0015] A verification and optimization module, configured to perform multi-level verification and optimization on the initial key to generate a target key.

[0016] In a third aspect, an embodiment of the present invention further provides an electronic device, which includes:

[0017] One or more processors;

[0018] A storage device, configured to store one or more programs;

[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement the key generation method based on a diffusion model according to any embodiment of the present invention.

[0020] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements the key generation method based on a diffusion model according to any embodiment of the present invention.

[0021] To achieve the above object, the beneficial effects of the present invention are as follows: By using a diffusion model to generate keys with high randomness and high security, it effectively resists attacks by quantum computing and improves the security of key generation; The flexibility and scalability of the diffusion model enable it to adapt to the requirements of different application scenarios, and it has high application value and broad application prospects. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] By reading the detailed description of the non-limiting embodiments with reference to the following drawings, other features, objects, and advantages of the present invention will become more apparent. The drawings are only for the purpose of showing the preferred embodiments and are not considered to limit the present invention. Moreover, throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:

[0023] Figure 1 is a flowchart of a key generation method based on a diffusion model provided by Embodiment 1 of the present invention;

[0024] Figure 2It is a schematic diagram of a diffusion model construction provided in the first embodiment of the present invention;

[0025] Figure 3 It is a flowchart of a key generation method based on a diffusion model provided in the second embodiment of the present invention;

[0026] Figure 4 It is a schematic diagram of a modular system structure provided in the embodiments of the present invention;

[0027] Figure 5 It is a schematic diagram of the structure of a key generation device based on a diffusion model provided in the third embodiment of the present invention;

[0028] Figure 6 It is a schematic diagram of the structure of an electronic device provided in the fourth embodiment of the present invention. Detailed implementation manners

[0029] The present invention will be further described in detail below with reference to the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the present invention, rather than limiting the present invention. In addition, it should be noted that, for the sake of convenience of description, only parts related to the present invention are shown in the drawings, rather than all the structures.

[0030] Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the operations (or steps) as sequential processes, many of the operations (or steps) can be implemented in parallel, concurrently, or simultaneously. In addition, the order of the operations can be rearranged. The process can be terminated when its operations are completed, but it can also have additional steps not included in the drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.

[0031] Among them, the acquisition, storage, use, and processing of data in the technical solution of the present application all comply with the relevant regulations of national laws and regulations. It should be noted that in the embodiments of the present application, some industry-existing solutions such as certain software, components, or models may be mentioned. They should be regarded as exemplary, and their purpose is only to illustrate the feasibility in the implementation of the technical solution of the present application, but it does not mean that the applicant has already or necessarily used this solution.

[0032] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above drawings are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present invention described here can be implemented in an order other than those illustrated or described here.

[0033] Example 1

[0034] Figure 1 FIG. 4 is a flowchart of a key generation method based on a diffusion model provided in Example 1 of the present invention. This example is applicable to the case of key generation based on a diffusion model. The method of this example can be executed by a key generation device based on a diffusion model, and this device can be implemented in a hardware and / or software manner. This device can be configured in a server for key generation based on a diffusion model. The method specifically includes the following steps:

[0035] S110. Construct an initial noise distribution and a diffusion model.

[0036] Among them, the initial noise distribution can refer to the starting point of the diffusion process, which is an initial noise distribution generated by a high-quality pseudo-random number generator. The generation of the initial noise is crucial and requires sufficient randomness and unpredictability to ensure that the diffusion model can generate high-quality keys from it.

[0037] The diffusion model is a type of probability model for generating data, especially excellent in generating images. The working principle of this type of model is to gradually add noise to disrupt the data distribution and gradually remove the noise through an inverse process to generate new data. The core idea of the diffusion model is to gradually add noise to the data through a forward process model to make it more and more random until it becomes a pure Gaussian noise; then, through a reverse process, gradually denoise from the pure noise to restore to the original data. This step-by-step adjustment method can ensure the stability and diversity of the generation process and avoid the generation result falling into a local optimum.

[0038] Optionally, the diffusion model also has high flexibility and scalability. By adjusting the parameters of the diffusion process, keys of different lengths and different security levels can be generated to meet the requirements of various application scenarios; the parameters include the number of time steps, noise intensity, and denoising algorithm. For example, in scenarios that require high security, a longer number of time steps and a more complex denoising algorithm can be selected to generate long keys with high entropy; while in resource-constrained environments, a shorter number of time steps and a simpler denoising algorithm can be selected to generate short keys.

[0039] S120. Input the secret information and the initial noise distribution into the diffusion model to obtain noisy data, and use the diffusion model to perform denoising processing on the noisy data to obtain a target distribution.

[0040] Among them, in the embodiments of the present invention, the diffusion model is applied to key generation. By introducing randomness and complexity, keys with high randomness and high security are generated, thereby effectively resisting attacks of quantum computing. The core of the diffusion model lies in the iterative process of gradually denoising. In each step, an appropriate amount of noise is introduced to maintain the diversity of samples, and at the same time, the target distribution is gradually approximated through the denoising operation.

[0041] Among them, the diffusion model is a class of probability models for generating data, especially excellent in generating images. The working principle of this type of model is to gradually add noise to disrupt the data distribution, and generate new data by gradually removing the noise through the inverse process. In the embodiments of the present invention, the diffusion model is used to gradually add noise to the secret information to obtain noisy data, and the target distribution is obtained by gradually removing the noise through the inverse process.

[0042] Specifically, first prepare a training data set, such as an image data set. Define a forward process model for adding noise, and generate noisy data by gradually adding noise. Use a neural network (usually a U-Net) to fit the reverse process and learn how to recover from the noisy data to the original data. Train the reverse process model by maximizing the likelihood estimation (Maximum Likelihood Estimation, MLE). Start from Gaussian noise and gradually denoise using the trained reverse process model to generate new data. Refer to Figure 2 , SECRET KEY PROMPT is an input part of a secret key prompt, including secret information provided by user input or other means. τ (Tau) is a transformation module for processing the input secret information to generate a certain form of encoding or feature representation. Latent space, in this space, the data undergoes a series of processes to generate multiple latent representations (such as Zt). The figure shows multiple layers of latent representations, indicating a deep neural network structure. Each layer will process the latent representation and add noise Nt. KEY is a secret key module, which is used in each layer of the latent space. The secret key module may be used to add or remove specific information so that the data is properly encrypted or decrypted in the latent space. D (Decoder) represents the decoder for decoding the representation in the latent space back to the original information; for example, converting the last layer representation Zt-1 in the latent space back to the key.

[0043] Optionally, the working principle of the diffusion model is to start from the initial noise distribution and gradually reduce the noise through a series of iterative steps. Each step introduces appropriate randomness to the generated samples. This gradually optimized process makes the generated samples have high entropy and high randomness, and are difficult to be predicted and cracked. In the key generation process, these characteristics of the diffusion model are particularly important because they ensure the unpredictability and security of the key.

[0044] S130. Determine a target random sample from the target distribution and use the target random sample as the initial key.

[0045] Among them, select the most representative and secure sample from the target distribution as the target random sample, and use the target random sample as the initial key. The selection methods of the target random sample include but are not limited to entropy value calculation and frequency detection. For example, determine the entropy values of each sample in the target distribution, and use the sample with the highest entropy value as the initial key.

[0046] S140. Perform multi-level verification and optimization on the initial key to generate a target key.

[0047] Among them, perform multiple verifications and optimizations on the initial key to ensure that the generated target key has high randomness and high entropy. The verification and optimization methods include but are not limited to frequency detection, sequence detection, and entropy calculation. Among them, frequency detection can refer to detecting the frequency of occurrence of each symbol in the initial key; sequence detection can refer to determining the sequence length of the initial key; entropy calculation can refer to determining the entropy value of the initial key.

[0048] Optionally, if the verification fails when verifying the initial key, the parameters of the diffusion model for constructing the initial key need to be dynamically adjusted. For example, adjust the time step or the initial noise distribution of the diffusion model to make the initial key pass the verification, so as to improve the security and reliability of key generation.

[0049] The embodiment of the present invention provides a key generation method based on a diffusion model. By constructing an initial noise distribution and a diffusion model; inputting the secret information and the initial noise distribution into the diffusion model to obtain noisy data, and using the diffusion model to denoise the noisy data to obtain a target distribution; determining a target random sample from the target distribution and using the target random sample as the initial key; performing multi-level verification and optimization on the initial key to generate a target key. By adopting the technical solution of the embodiment of the present invention, keys with high randomness and high security are generated by using a diffusion model, effectively resisting attacks of quantum computing, and improving the security of key generation; the flexibility and scalability of the diffusion model enable it to adapt to the requirements of different application scenarios, and it has high application value and broad application prospects.

[0050] Embodiment 2

[0051] Figure 3 This is a flowchart of a key generation method based on a diffusion model provided by the second embodiment of the present invention. The second embodiment of the present invention further optimizes the foregoing embodiment on the basis of the above embodiment, and the second embodiment of the present invention can be combined with each optional solution in one or more of the above embodiments. Such as Figure 3As shown in the figure, the key generation method based on the diffusion model provided in the embodiment of the present invention may include the following steps:

[0052] S310. Construct an initial noise distribution and a diffusion model.

[0053] Among them, the initial noise distribution is crucial as the starting point of the diffusion process. The initial noise distribution needs to have sufficient randomness and unpredictability to ensure that the diffusion model can generate high-quality keys from it.

[0054] As an optional but non-limiting implementation manner, the constructing of the initial noise distribution includes:

[0055] Use a pseudo-random number generator to generate a pseudo-random number sequence through a given seed, and use the pseudo-random number sequence as the initial noise distribution.

[0056] Among them, the embodiment of the present invention provides a modular system structure, including a noise generation module, a diffusion model module, a key extraction module, and a verification and optimization module. Each module interacts through standard interfaces, having high flexibility and scalability.

[0057] The noise generation module is the basis of the key generation system. Its main task is to generate an initial noise distribution with high entropy and high randomness. To achieve this goal, the noise generation module relies on a high-quality pseudo-random number generator (PRNG). The pseudo-random number generator generates a pseudo-random number sequence through a given seed (seed), expressed as:

[0058] N0 = PRNG(seed)

[0059] Among them, N0 is the initial noise distribution, and seed is the seed of the pseudo-random number generator. To ensure the high entropy of the noise, the following entropy calculation formula is used to measure the quality of the generated noise:

[0060]

[0061] Among them, H(N0) represents the noise quality, and P(N0 = i) represents the probability of the i-th value in the noise distribution.

[0062] Optionally, the pseudo-random number generator can provide high-quality randomness to ensure high entropy of the initial noise. The pseudo-random number generator includes, but is not limited to, the Mersenne Twister, Xorshift, and Cryptographically Secure PRNG. Among them, xorshift is a pseudo-random number generator algorithm that uses bit operations and exclusive-or operations to generate random numbers. Cryptographically Secure PRNG is a cryptographically secure pseudo-random number generator, which is a special type of pseudo-random number generator, and the generated random number sequence is unpredictable in cryptographic applications. This type of pseudo-random number generator must be able to resist various cryptographic attacks to ensure that the generated random values are secure in environments with high security requirements.

[0063] The initial noise distribution will directly affect the performance of the subsequent diffusion model, so it is crucial to ensure the quality of the initial noise. To further enhance security, the seed of the PRNG can be changed regularly, or a hardware random number generator (such as a quantum random number generator) can be used to enhance the randomness and unpredictability of noise generation.

[0064] In an alternative embodiment of the present invention, the entropy value of the initial noise distribution can be verified and enhanced through various methods. For example, multiple independent noise distributions can be generated, and their entropy values can be calculated, and the distribution with the highest entropy value can be selected as the final initial noise distribution. In addition, the randomness and entropy value of the noise can be further enhanced by combining the outputs of multiple PRNGs.

[0065] The diffusion model can refer to a generative model that is widely used to generate data samples with complex distributions. The basic idea is to simulate the diffusion process of data and gradually transform the initial random noise into the target data distribution. The diffusion model is based on the idea of a Markov chain and simulates a process of gradually transforming from a simple noise distribution to a complex data distribution through multiple steps of iteration. Each step of the iteration can be regarded as making a small adjustment to the current state to make it closer to the target distribution. This method of gradual adjustment can ensure the stability and diversity of the generation process and prevent the generation result from falling into a local optimum.

[0066] As an alternative but non-limiting implementation, the construction of the diffusion model includes, but is not limited to, steps A1 - A3:

[0067] Step A1: Determine the training dataset for the diffusion model; wherein, the diffusion model includes a forward process model and a reverse process.

[0068] Step A2: Construct the forward process model, and gradually add the initial noise distribution to the training dataset through the forward process model to generate noisy data.

[0069] Among them, the forward process model is a set of Markov chains, and these chains add some small Gaussian noise at each time step. Suppose there is a data point \(X_0\), the forward process model can be defined as:

[0070]

[0071] This formula represents that at time step \(t\), given the sample \(X\) at the previous time step t-1 , the conditional probability distribution of the sample \(X\) at the current time step t is a Gaussian distribution with a mean of and a covariance of \(\beta\) t \(I\). Among them, \(\beta\) t is the noise intensity at time step \(t\), and \(I\) is the identity matrix.

[0072]

[0073] denotes that the joint distribution from \(X_0\) to \(X\) t is the product of the conditional probability distributions at each time step. This is because the forward process model is a Markov chain, so the sample at each time step only depends on the sample at the previous time step.

[0074] Generally speaking, each step of the forward process model generates the sample at the current time step by adding Gaussian noise to the sample at the previous time step. The whole process starts from the initial data point \(X_0\) and is repeated by applying the conditional probability distribution \(q(x\) t |x t-1 ) until the final time step \(X\) t .

[0075] Step A3: Construct the reverse process model and train the reverse process model using maximum likelihood estimation until the loss function converges; among them, the reverse process model is used to denoise the noisy data to obtain the original data.

[0076] Among them, the reverse process is a training denoising process, and its purpose is to generate data from pure noise. This process can also be defined as a Markov chain, and the joint probability distribution of the reverse process can be expressed as:

[0077]

[0078] Among them, \(p(x\) T ) is the prior distribution at time step \(T\), usually the standard normal distribution; \(p\) θ (x t-1 |x t is the conditional probability distribution from time step \(t\) to \(t - 1\).

[0079] The conditional probability distribution of each step of the reverse process can be expressed as:

[0080]

[0081] wherein, represents a Gaussian distribution with mean μ θ (x t , t), and covariance Σ θ (x t , t). μ θ (x t , t) and Σ θ (x t , t) are parameterized functions, usually learned by a neural network. During training, the model learns the parameters θ in the reverse process such that the data generated by the reverse process matches the original data as closely as possible. This process is usually achieved by maximizing the log-likelihood or minimizing the KL divergence.

[0082] Optionally, the loss function used during training is usually the Variational Lower Bound (VLB):

[0083]

[0084] where Eq represents the expectation symbol, indicating the expectation over samples of the forward process model q(x 1:T |x0). represents the KL divergence term, where q(x t-1 |x t , x0 represents the inverse conditional distribution in the forward process model, considering the real data X0 and the data X at the current time step t ; p θ (x t-1 |x t ) represents the conditional distribution of the reverse process, parameterized by the model parameters θ. The KL divergence measures the difference between two distributions, and minimizing this term means hoping that the reverse process can well approximate the inverse conditional distribution in the forward process model.

[0085] -logp θ (x0|x1) represents the log-likelihood term, indicating the log-likelihood of generating the original data X0 at the first step (from X1 to X0). Maximizing the log-likelihood is equivalent to minimizing its negative value, thereby enhancing the model's ability to generate data. By minimizing this defined loss function, the model can learn how to generate real data from noisy data.

[0086] S320. Input the secret information into the forward process model of the diffusion model, and add an initial noise distribution to the secret information at the current time step based on the secret information at the previous time step to obtain noisy data.

[0087] Among them, before adding noise to the secret information, the initial parameters of the diffusion model are set. The initial parameters include the time step and the initial noise distribution. The setting of the initial parameters will directly affect the quality and security of the finally generated key. By precisely controlling the initial parameters, the stability and efficiency of the generation process can be ensured. After determining the initial parameters, the secret information is input into the diffusion model, and the initial noise distribution is introduced at each time step to obtain the noisy data, so as to ensure the randomness and security of the generation process.

[0088] The main goal of the diffusion model is to transform the initial noise distribution N0 into a high-quality target distribution N through a series of iterative steps T .

[0089] The basic iterative formula of the diffusion model is as follows:

[0090] N t+1 = f(N t , θ)

[0091] where N t is the noise distribution at the t-th step, f is the update function of the diffusion model, and θ is the model parameter. The noise distribution at the (t + 1)-th step is obtained based on the noise distribution at the t-th step.

[0092] S330. During the reverse process of inputting the noisy data into the diffusion model, iterative and denoising processing are performed on the noisy data to obtain the target distribution.

[0093] Among them, iterative and denoising processing are performed on the noisy data, so that the noise gradually decreases to obtain the target distribution. In each iterative step, the diffusion model performs denoising processing according to the current noise state and the preset diffusion rules. The more the number of iterations, the closer the generated sample is to the target distribution, and the higher the quality of the key. For example, a specific denoising algorithm, variational autoencoder, is used to gradually reduce the influence of noise and generate samples closer to the target distribution.

[0094] As an optional but non-limiting implementation manner, during the reverse process of inputting the noisy data into the diffusion model, iterative and denoising processing are performed on the noisy data to obtain the target distribution, including:

[0095] Denoising processing is performed during the reverse process of inputting the noisy data into the diffusion model. The denoising processing can be expressed as:

[0096] N t+1 = D(N t , η)

[0097] where D is the denoising function, η is the denoising parameter, and N t represents the noisy data before denoising, Nt+1 Denote the noisy data after denoising;

[0098] The noisy data is processed through multiple iterations and denoising to finally generate a target distribution, which can be expressed as:

[0099] N T = D T (N0, η)

[0100] where N T represents the target distribution, and N0 represents the initial noise distribution.

[0101] Optionally, the diffusion model module is the core part of the key generation process. Based on the set diffusion process parameters, the diffusion model module performs multiple iterations and step-by-step denoising to finally generate a target distribution. To optimize the effect of the diffusion model, an adaptive time step is used to dynamically adjust the step size according to the change of the noise distribution; a multi-scale modeling method is adopted to perform diffusion and denoising at different scales to capture the multi-level structure of the noise distribution. In addition, overfitting of the model can be prevented by introducing a regularization term to improve the generalization ability of the generated distribution. The parameters of the diffusion model need to be adjusted according to the specific application scenario to achieve the best key generation effect. The generation effect under different parameter configurations can be evaluated through experiments and simulations, and the optimal parameter combination can be selected.

[0102] S340. Determine the target random sample from the target distribution and use the target random sample as the initial key.

[0103] Among them, at the end of the diffusion process, samples with high randomness are extracted from the generated target distribution as the final key. These samples should have high entropy and high unpredictability to ensure the security of the key. The samples are usually selected randomly directly from the target distribution or generated as keys through a specific transformation function. According to security requirements, keys of different lengths are generated, such as 128 bits, 256 bits, and 512 bits, etc.

[0104] As an optional but non-limiting implementation, determining the target random sample from the target distribution and using the target random sample as the initial key includes:

[0105] Determine the target random sample from the target distribution according to the preset sample extraction standard; the preset sample extraction standard can be expressed as:

[0106]

[0107] where K is the target random sample, and N T is the target distribution; R(k) is the randomness measurement function of sample k, and the randomness measurement methods include entropy calculation and frequency detection.

[0108] Optionally, the key extraction module extracts samples with high randomness from the generated target distribution to generate the final key. The key extraction module analyzes the target distribution and selects the most representative and secure samples as the key.

[0109] Assume the target distribution is N T , from which it is necessary to extract the target random sample K, which can be expressed as:

[0110] K = E(N T )

[0111] where E is the extraction function.

[0112] S350. Perform multi-level verification and optimization on the initial key to generate the target key.

[0113] Among them, after generating the initial key, perform security verification on the generated initial key, and adjust the diffusion model parameters for optimization if necessary. Through multi-level security verification, ensure that the generated target key has high randomness and high entropy. The parameters of the diffusion model can also be dynamically adjusted according to the verification results to improve the security and reliability of the target key generation process.

[0114] As an optional but non-limiting implementation, the performing multi-level verification and optimization on the initial key to generate the target key includes, but is not limited to, steps B1 - B2:

[0115] Step B1: Perform multi-level verification on the initial key and determine whether the verification result meets the preset verification conditions.

[0116] Step B2: If the initial key does not meet the preset verification conditions, dynamically adjust the parameters of the diffusion model until the initial key meets the preset verification conditions to obtain the target key.

[0117] Among them, the multi-level verification includes frequency detection, sequence detection, and entropy calculation; the preset verification conditions include that the symbol occurrence frequency is less than the preset frequency threshold, the sequence length is less than the preset length threshold, and the entropy value is greater than the preset entropy threshold.

[0118] Among them, the frequency detection is used to detect the frequency of each symbol in the initial key to ensure its uniform distribution.

[0119]

[0120] where n k is the number of times the symbol k appears in the key, and N is the total length of the key.

[0121] Sequence detection prevents the emergence of sequences with low randomness by detecting the presence of long sequences in the initial key. For example, run length detection is used to evaluate the presence of long sequences in the initial key. If a long sequence is detected, the key is reselected or regenerated.

[0122] Entropy calculation is used to calculate the entropy value of the initial key to ensure high entropy of the initial key.

[0123]

[0124] According to the verification results, the parameters of the diffusion model are dynamically adjusted, such as the number of time steps, the type of noise distribution, and the denoising algorithm, etc., to improve the security and reliability of the target key generation process. For example, the number of time steps can be increased to improve the detail of the diffusion process; a more suitable type of noise distribution can be selected to better simulate the noise characteristics in actual applications; the denoising algorithm can be optimized to improve the denoising effect, thereby generating a higher-quality target distribution.

[0125] In an alternative solution of the embodiment of the present invention, refer to Figure 4 , the embodiment of the present invention designs a modular system structure, including a noise generation module, a diffusion model module, a key extraction module, and a verification and optimization module. By designing a modular system structure, the entire process of noise generation, diffusion model, key extraction, and verification and optimization is realized. Each module interacts through standard interfaces, having high flexibility and scalability. Through multi-level security verification and dynamic optimization, it is ensured that the generated key has high randomness and high entropy, greatly improving the security and reliability of the key generation process.

[0126] The embodiment of the present invention provides a key generation method based on a diffusion model. By inputting secret information into the forward process model of the diffusion model and adding an initial noise distribution to the secret information at the current time step according to the secret information at the previous time step at each time step, noisy data is obtained; the noisy data is input into the reverse process of the diffusion model, and the noisy data is iteratively denoised to obtain a target distribution. A target random sample is determined from the target distribution, and the target random sample is used as the initial key; the initial key is subjected to multi-level verification and optimization to generate a target key. By adopting the technical solution of the embodiment of the present invention, a diffusion model is used to generate an initial key with high randomness and high security, which can effectively resist attacks by quantum computing, has high application value and broad application prospects. The flexibility and scalability of the diffusion model enable it to adapt to the requirements of different application scenarios and generate keys of different lengths and security levels. Verifying and optimizing the initial key makes the generated target key more unpredictable and secure.

[0127] Embodiment III

[0128] Figure 5 FIG. Figure 5 is a schematic structural diagram of a key generation device based on a diffusion model provided in Embodiment 3 of the present invention. The technical solution of this embodiment is applicable to the case of key generation based on a diffusion model. The device can be implemented by software and / or hardware and is generally integrated into any electronic device with network communication functions, including but not limited to: servers, computers, personal digital assistants, and other devices. As Figure 5 shown, the key generation device based on a diffusion model provided in this embodiment may include: a noise and model generation module 510, a diffusion model application module 520, a key extraction module 530, and a verification and optimization module 540; wherein,

[0129] The noise and model generation module 510 is configured to construct an initial noise distribution and a diffusion model;

[0130] The diffusion model application module 520 is configured to input the secret information and the initial noise distribution into the diffusion model to obtain noisy data, and use the diffusion model to perform denoising processing on the noisy data to obtain a target distribution;

[0131] The key extraction module 530 is configured to determine a target random sample from the target distribution and use the target random sample as an initial key;

[0132] The verification and optimization module 540 is configured to perform multi-level verification and optimization on the initial key to generate a target key.

[0133] Based on the above embodiment, optionally, the noise and model generation module is specifically configured to:

[0134] Use a pseudo-random number generator to generate a pseudo-random number sequence through a given seed, and use the pseudo-random number sequence as the initial noise distribution.

[0135] Based on the above embodiment, optionally, the noise and model generation module is specifically configured to:

[0136] Determine a diffusion model training data set; wherein, the diffusion model includes a forward process model and a reverse process;

[0137] Construct a forward process model, and gradually add the initial noise distribution to the training data set through the forward process model to generate noisy data;

[0138] Construct a reverse process model, and use maximum likelihood estimation to train the reverse process model until the loss function converges; wherein, the reverse process model is used to denoise the noisy data to obtain the original data.

[0139] Based on the above embodiment, optionally, the diffusion model application module is specifically configured to:

[0140] Input the secret information into the forward process model of the diffusion model, and add an initial noise distribution to the secret information at the current time step based on the secret information at the previous time step to obtain noisy data;

[0141] Input the noisy data into the reverse process of the diffusion model, and perform iterative and denoising processing on the noisy data to obtain the target distribution.

[0142] Based on the above embodiments, optionally, the diffusion model application module is further specifically configured to:

[0143] Input the noisy data into the reverse process of the diffusion model for denoising processing, and the denoising processing can be expressed as:

[0144] N t+1 = D(N t , η)

[0145] where D is the denoising function, η is the denoising parameter, N t represents the noisy data before denoising, and N t+1 represents the noisy data after denoising;

[0146] Generate the target distribution by repeatedly iterating and denoising the noisy data, and the target distribution can be expressed as:

[0147] N T = D T (N0, η)

[0148] where N T represents the target distribution, and N0 represents the initial noise distribution.

[0149] Based on the above embodiments, optionally, the key extraction module is specifically configured to:

[0150] Determine the target random sample from the target distribution according to the preset sample extraction criterion; the preset sample extraction criterion can be expressed as:

[0151]

[0152] where K is the target random sample, N T is the target distribution; R(k) is the randomness measurement function of sample k, and the randomness measurement methods include entropy calculation and frequency detection.

[0153] Based on the above embodiments, optionally, the verification and optimization module is specifically configured to:

[0154] Perform multi-level verification on the initial key and determine whether the verification result meets the preset verification conditions;

[0155] If the initial key does not meet the preset verification conditions, the parameters of the diffusion model are dynamically adjusted until the initial key meets the preset verification conditions to obtain the target key;

[0156] Among them, the multi-level verification includes frequency detection, sequence detection, and entropy calculation; the frequency detection is used to detect the frequency of occurrence of each symbol in the initial key; the sequence detection is used to determine the sequence length of the initial key; the entropy calculation is used to determine the entropy value of the initial key; the preset verification conditions include that the symbol occurrence frequency is less than the preset frequency threshold, the sequence length is less than the preset length threshold, and the entropy value is greater than the preset entropy value threshold.

[0157] The key generation device based on the diffusion model provided in the embodiments of the present invention can execute the key generation method based on the diffusion model provided in any of the above embodiments of the present invention, and has the corresponding functions and beneficial effects for executing the key generation method based on the diffusion model. For the detailed process, refer to the related operations of the key generation method based on the diffusion model in the foregoing embodiments.

[0158] Embodiment Four

[0159] Figure 6 It is a schematic structural diagram of an electronic device provided in Embodiment Four of the present invention. The electronic device 10 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are only examples and are not intended to limit the implementation of the present invention described and / or claimed herein.

[0160] As Figure 6 shown, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. Among them, the memory stores a computer program executable by at least one processor. The processor 11 can execute various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.

[0161] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disc, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0162] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include but are not limited to a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the key generation method based on the diffusion model.

[0163] In some embodiments, the key generation method based on the diffusion model can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the key generation method based on the diffusion model described above can be executed. Alternatively, in other embodiments, the processor 11 can be configured to execute the key generation method based on the diffusion model by any other suitable means (e.g., by means of firmware).

[0164] The various embodiments of the systems and technologies described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special or general programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.

[0165] A computer program for implementing the method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, a special purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowchart and / or block diagram to be implemented. The computer programs can be executed entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine, or entirely on a remote machine or server.

[0166] In the context of the present invention, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0167] In order to provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, speech input, or tactile input).

[0168] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected with each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), blockchain network, and the Internet.

[0169] A computing system can include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The client-server relationship is created by computer programs running on respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system, solving the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.

[0170] It should be understood that various forms of the processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in the present invention can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved, and no limitation is imposed herein.

[0171] The above embodiments are merely examples given for clear illustration and are not limitations on the implementation manners. For those of ordinary skill in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to enumerate all implementation manners here. And the obvious changes or modifications derived therefrom still fall within the protection scope of the present invention.

Claims

1. A key generation method based on a diffusion model, characterized in that The method includes: Constructing an initial noise distribution and a diffusion model; Input the secret information into the forward process model of the diffusion model, and add the initial noise distribution to the secret information at the current time step based on the secret information at the previous time step at each time step to obtain the noisy data; input the noisy data into the reverse process of the diffusion model, and perform iteration and denoising processing on the noisy data to obtain the target distribution; where the denoising processing can be expressed as: N t+1 = D(N t , η), where t represents the time step, D is the denoising function, η is the denoising parameter, N t represents the noisy data before denoising, and N t+1 represents the noisy data after denoising; the target distribution can be expressed as: N T = D T (N0, η), where N T represents the target distribution, and N0 represents the initial noise distribution; Determining a target random sample from the target distribution and using the target random sample as an initial key; Performing multi-level verification and optimization on the initial key to generate a target key.

2. The method according to claim 1, wherein The constructing of the initial noise distribution includes: Using a pseudo-random number generator to generate a pseudo-random number sequence through a given seed and using the pseudo-random number sequence as the initial noise distribution.

3. The method according to claim 1, characterized in that, Constructing the diffusion model includes: Determining a diffusion model training data set; wherein, the diffusion model includes a forward process model and a reverse process; Constructing a forward process model and gradually adding the initial noise distribution to the training data set through the forward process model to generate noisy data; Constructing a reverse process model and training the reverse process model using maximum likelihood estimation until the loss function converges; wherein, the reverse process model is used to denoise the noisy data to obtain the original data.

4. The method according to claim 1, wherein The determining of the target random sample from the target distribution and using the target random sample as the initial key includes: Determining a target random sample from the target distribution according to a preset sample extraction criterion; the preset sample extraction criterion can be expressed as: Among them, K is the target random sample, and N T is the target distribution; R(k) is the randomness measurement function of sample k, and the randomness measurement methods include entropy calculation and frequency detection.

5. The method according to claim 1, characterized in that The performing of multi-level verification and optimization on the initial key to generate a target key includes: Performing multi-level verification on the initial key and determining whether the verification result meets the preset verification conditions; If the initial key does not meet the preset verification conditions, dynamically adjusting the parameters of the diffusion model until the initial key meets the preset verification conditions to obtain the target key; Wherein, the multi-level verification includes frequency detection, sequence detection, and entropy calculation; the frequency detection is used to detect the frequency of occurrence of each symbol in the initial key; the sequence detection is used to determine the sequence length of the initial key; the entropy calculation is used to determine the entropy value of the initial key; the preset verification conditions include that the symbol occurrence frequency is less than a preset frequency threshold, the sequence length is less than a preset length threshold, and the entropy value is greater than a preset entropy value threshold.

6. A key generation device based on a diffusion model, characterized in that, The device includes: A noise and model generation module for constructing an initial noise distribution and a diffusion model; Diffusion model application module, which is used to input secret information into the forward process model of the diffusion model, and add an initial noise distribution to the secret information at the current time step based on the secret information at the previous time step at each time step to obtain noisy data; input the noisy data into the reverse process of the diffusion model, and perform iteration and denoising processing on the noisy data to obtain a target distribution; where the denoising processing can be expressed as: N t+1 = D(N t , η), where t represents the time step, D is the denoising function, η is the denoising parameter, N t represents the noisy data before denoising, and N t+1 represents the noisy data after denoising; the target distribution can be expressed as: N T = D T (N0, η), where N T represents the target distribution, and N0 represents the initial noise distribution; A key extraction module for determining a target random sample from the target distribution and using the target random sample as the initial key; A verification and optimization module for performing multi-level verification and optimization on the initial key to generate a target key.

7. The device according to claim 6, characterized in that, The noise and model generation module is specifically used for: Using a pseudo-random number generator to generate a pseudo-random number sequence through a given seed and using the pseudo-random number sequence as the initial noise distribution.

8. The device according to claim 6, characterized in that, The noise and model generation module is specifically used for: Determining a diffusion model training data set; wherein, the diffusion model includes a forward process model and a reverse process; Constructing a forward process model and gradually adding the initial noise distribution to the training data set through the forward process model to generate noisy data; Constructing a reverse process model and training the reverse process model using maximum likelihood estimation until the loss function converges; wherein, the reverse process model is used to denoise the noisy data to obtain the original data.

9. The device according to claim 6, characterized in that, The key extraction module is specifically used for: Determine a target random sample from the target distribution according to a preset sample extraction criterion; the preset sample extraction criterion can be expressed as: Among them, K is the target random sample, and N T is the target distribution; R(k) is the randomness measurement function of sample k, and the randomness measurement methods include entropy calculation and frequency detection.

10. The device according to claim 6, characterized in that, The verification and optimization module is specifically configured to: Perform multi-level verification on the initial key and determine whether the verification result meets a preset verification condition; If the initial key does not meet the preset verification condition, dynamically adjust the parameters of the diffusion model until the initial key meets the preset verification condition to obtain a target key; Among them, the multi-level verification includes frequency detection, sequence detection, and entropy calculation; the frequency detection is used to detect the frequency of occurrence of each symbol in the initial key; the sequence detection is used to determine the sequence length of the initial key; the entropy calculation is used to determine the entropy value of the initial key; the preset verification conditions include that the symbol occurrence frequency is less than a preset frequency threshold, the sequence length is less than a preset length threshold, and the entropy value is greater than a preset entropy value threshold.

11. An electronic device, characterized in that, Comprising: At least one processor; A storage device for storing at least one computer program; When the at least one computer program is executed by the at least one processor, the at least one processor implements the key generation method based on the diffusion model according to any one of claims 1-5.

12. A storage medium containing computer-executable instructions, characterized in that, The computer-executable instructions are used to execute the key generation method based on the diffusion model according to any one of claims 1-5 when executed by a computer processor.

Citation Information

Patent Citations

  • Voice watermark injection and right confirmation method and system based on diffusion model

    CN117894323A

  • Data encryption storage and transmission method, device and system

    CN118175539A