Pseudo-random number generation method and device
Through multiple iterations and symmetric encryption algorithms, the shortcomings in pseudo-random number generation in the prior art are solved in terms of performance and security considerations, and pseudo-random number generation with high performance and side channel security are realized.
Patent Information
- Application Number
- CN202411556738.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2044-11-01
AI Technical Summary
The prior art cannot take into account performance and security in high-speed pseudo-random number generation, especially in privacy computing scenarios, and lacks consideration for the side channel security of pseudo-random number generators.
Using a pseudo-random number generation method with multiple iterations, a symmetric encryption algorithm is used to process the counter count value and the values determined by preset constants, to generate high-performance pseudo-random numbers, and update the seeds in each iteration to ensure side channel security. .
It realizes high-performance generation of pseudo-random numbers in privacy computing, and provides effective protection for contralateral channel leakage, avoids performance and resource losses, and has high performance and side channel security.
Smart Images

Figure CN119496609A_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of computers, and more particularly, to a method and apparatus for generating pseudo-random numbers. Background Art
[0002] Secure multi-party computation (MPC) is a cryptographic technology. The core idea is to allow participants to jointly calculate a result without revealing their respective inputs, ensuring that the input of each participant is protected.
[0003] In privacy computing scenarios such as MPC, secret computing needs to rely on a series of security parameters. For example, two-party secure multiplication can use a trusted third party to generate the pseudo-random number stream required for the calculation. The security of products based on this type of algorithm technology depends on the security of the trusted third party, so effective security protection measures are needed, and in actual application scenarios, it is hoped that the impact of protection measures on computing performance will be minimized.
[0004] In the prior art, the commonly used methods for generating high-speed pseudo-random numbers cannot take into account both performance and security. Some of these algorithms have comprehensive security designs but low performance, while others have high performance but lack security considerations for pseudo-random numbers. For example, the side channel security of the pseudo-random number generator is not considered. Summary of the invention
[0005] One or more embodiments of this specification describe a method and apparatus for generating pseudo-random numbers with high performance and side-channel security.
[0006] In a first aspect, a pseudo-random number generation method is provided, the method comprising multiple rounds of iterations corresponding to count values of a counter, wherein any t-th round of iterations comprises:
[0007] Get the seed output in the previous round as the current seed;
[0008] Using a symmetric encryption algorithm, the current seed and the first value are processed to obtain a random number for this round, wherein the first value is determined according to the current count value of the counter and a preset first constant;
[0009] The symmetric encryption algorithm is used to process the current seed and the second value to obtain the seed for the next round of iteration, wherein the second value is determined according to the current count value and a preset second constant.
[0010] In a possible implementation, the tth round of iteration is a first round of iteration, and the current seed is an initialized seed.
[0011] In a possible implementation, the process of using a symmetric encryption algorithm to process the current seed and the first value to obtain a random number for this round includes:
[0012] Using the current seed as a key and the first value as plaintext to be encrypted, encrypting the plaintext using a symmetric encryption algorithm to obtain a first ciphertext;
[0013] A random number for this round is determined based on the first ciphertext.
[0014] In a possible implementation manner, the first value is determined in the following manner:
[0015] The current count value of the first bit number and the first constant of the second bit number are concatenated to obtain a first value of the target bit number.
[0016] Furthermore, each bit of the first constant of the second bit number is 1.
[0017] In a possible implementation, the using the symmetric encryption algorithm to process the current seed and the second value to obtain the seed for this round includes:
[0018] Using the current seed as a key and the second value as plaintext to be encrypted, encrypting the plaintext using a symmetric encryption algorithm to obtain a second ciphertext;
[0019] A seed for this round is determined based on the second ciphertext.
[0020] In a possible implementation manner, the second value is determined in the following manner:
[0021] The current count value of the first bit number and the second constant of the second bit number are concatenated to obtain a second value of the target bit number.
[0022] Furthermore, each bit of the second constant of the second bit number is 0.
[0023] Furthermore, the first bit number is 120, and the second bit number is 8.
[0024] In a second aspect, a pseudo-random number generating device is provided, the device being used to perform multiple rounds of iterations corresponding to the count value of a counter, wherein the device comprises the following unit for performing any t-th round of iterations:
[0025] An acquisition unit, used to acquire the seed output in the previous round as the current seed;
[0026] a first processing unit, configured to process the current seed and the first value obtained by the obtaining unit by using a symmetric encryption algorithm to obtain a random number of this round, wherein the first value is determined according to a current count value of the counter and a preset first constant;
[0027] The second processing unit is used to use the symmetric encryption algorithm to process the current seed and the second value obtained by the acquisition unit to obtain the seed of this round for the next round of iteration, wherein the second value is determined according to the current count value and a preset second constant.
[0028] According to a third aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to execute the method of the first aspect.
[0029] According to a fourth aspect, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method of the first aspect is implemented.
[0030] Through the method and device provided in the embodiments of this specification, in any t-th round of iteration, first obtain the seed output in the previous round as the current seed; then use the symmetric encryption algorithm to process the current seed and the first value to obtain the random number of this round, wherein the first value is determined according to the current count value of the counter and the preset first constant; finally, use the symmetric encryption algorithm to process the current seed and the second value to obtain the seed of this round for the next round of iteration, wherein the second value is determined according to the current count value and the preset second constant. As can be seen from the above, the embodiments of this specification, based on the existing symmetric encryption algorithm, can generate the relevant pseudo-random number parameters required for privacy computing with high performance. At the same time, side channel security is considered in the scheme for generating pseudo-random numbers. Even if the underlying symmetric encryption algorithm does not adopt the implementation of anti-side channel leakage, it can provide effective protection against side channel leakage, thereby avoiding the performance and resource loss caused by the implementation of side channel leakage protection, thereby having high performance and side channel security. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0032] Figure 1 A schematic diagram of an implementation scenario of an embodiment disclosed in this specification;
[0033] Figure 2 A flow chart of a pseudo-random number generation method according to an embodiment is shown;
[0034] Figure 3 A schematic diagram showing a calculation process of pseudo-random number generation according to an embodiment;
[0035] Figure 4 A schematic block diagram of a pseudo-random number generating device according to an embodiment is shown. DETAILED DESCRIPTION
[0036] The solution provided in this specification is described below in conjunction with the accompanying drawings.
[0037] Figure 1 The following is a schematic diagram of an implementation scenario of an embodiment disclosed in this specification. The implementation scenario involves pseudo-random number generation. It is understandable that pseudo-random numbers are not truly random. Random numbers play an important role in fields such as computer science and cryptography. In many applications, such as simulation, encryption, games, etc., high-quality random numbers need to be generated. However, since computers work based on deterministic algorithms, they cannot truly generate completely random numbers. Therefore, computers use pseudo-random number generators (PRNGs) to simulate randomness and generate approximately random numerical sequences.
[0038] Reference Figure 1 A pseudo-random number generator is an algorithm that takes an initial value called a seed as input and generates a numerical sequence through a series of mathematical operations. This numerical sequence can be called a pseudo-random number sequence, including multiple pseudo-random numbers, such as word 1 is the first pseudo-random number in the sequence, word 2 is the second pseudo-random number in the sequence, …word n is the nth pseudo-random number in the sequence. This sequence exhibits statistically similar characteristics to true random numbers and has a longer period. The main goal of a PRNG is to generate a sequence of numerical values that looks random while being able to reproduce the same sequence with the same seed value.
[0039] The seed is the starting point for generating a sequence. The same seed will generate the same random number sequence. Common seeds include the current timestamp, process ID, hardware status, etc. If a weak seed or the same seed is used, the sequence may be predictable.
[0040] Unlike pseudo-random number generators, true random number generators use randomness in physical processes to generate random numbers. For example, by measuring atmospheric noise, radioactive decay, or noise in electronic devices. The unpredictability of these physical processes ensures that the generated values are truly random.
[0041] Common methods for generating high-speed pseudo-random numbers include DRBG based on AES / SM4, hash-based, and stream cipher-based. Among them, the DRBG algorithm has a more comprehensive security design, but the performance is relatively low. The hash-based and stream cipher-based designs have relatively high performance, but lack protocol-level security considerations for pseudo-random numbers. The above-mentioned various pseudo-random number algorithms usually mainly consider the security of pseudo-random numbers in terms of randomness in their design, but do not consider the side channel security of the pseudo-random number generator.
[0042] The embodiments of this specification provide a pseudo-random number generation scheme that has high performance and side-channel security.
[0043] Figure 2 A flowchart of a pseudo-random number generation method according to an embodiment is shown. The method can be based on Figure 1 The implementation scenario shown in Figure 1 is as follows. Figure 2 As shown, the pseudo-random number generation method in this embodiment includes multiple rounds of iterations corresponding to the count value of the counter, wherein any t-th round of iteration includes the following steps: Step 21, obtaining the seed outputted in the previous round as the current seed; Step 22, using a symmetric encryption algorithm, processing the current seed and the first value to obtain the random number of this round, wherein the first value is determined according to the current count value of the counter and a preset first constant; Step 23, using the symmetric encryption algorithm, processing the current seed and the second value to obtain the seed of this round for the next round of iteration, wherein the second value is determined according to the current count value and a preset second constant. The specific execution method of each of the above steps is described below.
[0044] First, in step 21, the seed output in the previous round is obtained as the current seed. It can be understood that in each round of iteration, not only the random number of the current round is generated, but also the seed used in the next round of iteration is generated.
[0045] In the embodiment of this specification, the seed length may be 128 bits, that is, 16 bytes.
[0046] For example, two variables can be defined by the following code to represent the current seed and the count value of the counter respectively.
[0047] “Variable:S∈{0,1} 128 / / 128 bits (16 bytes) internal state
[0048] cnt∈{0,1,…,2 120 -1} / / 120-bit (15-byte) counter"
[0049] From the above code, we can see that S is the internal state, which represents the current seed, and cnt is the counter, which represents the count value of the counter.
[0050] In one example, the tth round of iteration is the first round of iteration, and the current seed is an initialized seed.
[0051] For example, you can use the following code to initialize it.
[0052] "AlgorithmInit(seed)
[0053] / / Initialize the PRG with a 128-bit seed, similar to the C++ standard srand function
[0054] S←seed
[0055] cnt←0
[0056] ”
[0057] From the above code, we can see that the value of S after initialization is seed, the value of cnt after initialization is 0, and PRG represents the pseudo-random number generation algorithm.
[0058] Then, in step 22, the current seed and the first value are processed by a symmetric encryption algorithm to obtain a random number for this round, wherein the first value is determined according to the current count value of the counter and a preset first constant. It can be understood that in each round of iteration, the count value of the counter will increase relative to the previous round of iteration, and in each round of iteration, a random number for this round will be obtained.
[0059] The embodiments of this specification can be implemented based on the symmetric encryption algorithm SM4. The pseudo-random number generation algorithm can be recorded as AlgorithmLRPRG-SM4 (seed), referred to as PRG. It should be noted that SM4 can be replaced by other symmetric encryption algorithms to achieve similar effects.
[0060] In one example, the process of using a symmetric encryption algorithm to process the current seed and the first value to obtain a random number for this round includes:
[0061] Using the current seed as a key and the first value as plaintext to be encrypted, encrypting the plaintext using a symmetric encryption algorithm to obtain a first ciphertext;
[0062] A random number for this round is determined based on the first ciphertext.
[0063] In this example, the first ciphertext may be directly used as the random number of this round, or the first ciphertext may be processed and used as the random number of this round.
[0064] In one example, the first value is determined in the following manner:
[0065] The current count value of the first bit number and the first constant of the second bit number are concatenated to obtain a first value of the target bit number.
[0066] Furthermore, each bit of the first constant of the second bit number is 1.
[0067] Furthermore, the first bit number is 120, and the second bit number is 8.
[0068] For example, the random number of this round can be obtained by the following code.
[0069] “word←SM4(S,cnt||[1] 8 ) / / Generate 128 bits (16 bytes) pseudo-random word with one SM4 call"
[0070] From the above code, we can see that S is the current seed, cnt is the current count value, [1] 8 is the first constant, and word is the random number of this round.
[0071] Finally, in step 23, the current seed and the second value are processed by the symmetric encryption algorithm to obtain the seed for the next round of iteration, wherein the second value is determined according to the current count value and a preset second constant. It can be understood that in each round of iteration, the count value of the counter will increase relative to the previous round of iteration, and in each round of iteration, the seed for the current round will be obtained.
[0072] In one example, using the symmetric encryption algorithm to process the current seed and the second value to obtain the seed for this round includes:
[0073] Using the current seed as a key and the second value as plaintext to be encrypted, encrypting the plaintext using a symmetric encryption algorithm to obtain a second ciphertext;
[0074] A seed for this round is determined based on the second ciphertext.
[0075] In this example, the second ciphertext may be directly used as the seed for this round, or the second ciphertext may be processed and used as the seed for this round.
[0076] In one example, the second value is determined in the following manner:
[0077] The current count value of the first bit number and the second constant of the second bit number are concatenated to obtain a second value of the target bit number.
[0078] Furthermore, each bit of the second constant of the second bit number is 0.
[0079] Furthermore, the first bit number is 120, and the second bit number is 8.
[0080] For example, the seed for this round can be obtained through the following code.
[0081] “S←SM4(S,cnt||[0] 8 ) / / Use SM4 to update the status"
[0082] From the above code, we can see that the input S of SM4 is the current seed, cnt is the current count value, [0] 8 is the second constant, and the output S of SM4 is the seed of this round.
[0083] Figure 3 FIG. 1 is a schematic diagram showing a calculation process of generating a pseudo-random number according to an embodiment. Figure 3 , the calculation process includes a total of 4 rounds of iterations including the first round of iterations, where seed is the initialized seed, the two SM4s in the first column correspond to the first round of iterations, the two SM4s in the second column correspond to the second round of iterations, the two SM4s in the third column correspond to the third round of iterations, and the two SM4s in the fourth column correspond to the fourth round of iterations. The output of the SM4 in the first row of each column is the seed for this round, which is used for the next round of iterations, and the output of the SM4 in the second row is the random number for this round. For example, [0] 120 Indicates that the current count value is 0, the number of bits is 120 bits, [0] 8 is the second constant, [1] 8 is the first constant, word 1 The random number of this round obtained when the current count value is 0; [1] 120 Indicates that the current count value is 1, the number of bits is 120 bits, [0] 8 is the second constant, [1] 8 is the first constant, word 2 The random number of this round obtained when the current count value is 1; [2] 120 Indicates that the current count value is 2, the number of bits is 120 bits, [0] 8 is the second constant, [1] 8 is the first constant, word 3 The random number of this round obtained when the current count value is 2; [3] 120 Indicates that the current count value is 3, the number of bits is 120 bits, [0] 8 is the second constant, [1] 8 is the first constant, word 4 The random number of this round is obtained when the current count value is 3.
[0084] For example, each round of iteration can be implemented by the following code.
[0085]
[0086] From the above code, we can see that in each round of iteration, the SM4 algorithm is used twice, once to generate word, that is, the random number of this round, also called pseudo-random word, and the other time to generate S, that is, the seed of this round. After generating the random data and seed of this round, the count value of the counter must be updated.
[0087] Regarding the security of the embodiments of this specification in a non-leakage scenario, assuming that the attacker's computational complexity is T and the number of pseudo-random words extracted is D, it can be seen from the existing conclusions that the attacker's success probability of cracking the pseudo-randomness of the extracted word is no higher than
[0088]
[0089] This shows that the generator can generate about 2 121 128-bit (16-byte) pseudo-random word, and the amount of calculation can not exceed 2 121 attack.
[0090] The following is a proof of the anti-leakage security of the aforementioned algorithm LRPRG-SM4:
[0091] Using the existing conclusions, it can be proved that if the attacker's computational complexity is T and the number of pseudo-random words extracted is D, then it can be seen that the attacker's success probability of cracking the pseudo-randomness of the extracted word is no higher than
[0092]
[0093] The proof is as follows: first replace SM4 with the ideal cipher E:{0,1} n ×{0,1} n →{0,1} n , we get the idealized model LRPRG-E, where the block length and key length are replaced by the general parameter n.
[0094] Introducing stream ciphers based on ideal ciphers With the completely random stream cipher IStream, the algorithm is described as follows:
[0095] “Al gor ithm (D)
[0096] Fori=1,…,Ddo
[0097] y i ←E(k i-1 ,[i-1] n-8 ∥[1] 8 ),ki ←E(k i-1 ,[i-1] n-8 ∥[0] 8 )
[0098] The side channel leakage is
[0099] EndFor
[0100] Return(y 1 ,…,y D )”
[0101] The above algorithm describes a stream cipher Side channel leakage during the calculation process.
[0102] “Algorithm IStream(D):
[0103] B← $ {0,1} κ
[0104] S ′ 0 ←B||IV,S 1 ← $ {0,1} b . The side channel leakage is
[0105] Fori=1,…,Ddo
[0106] y i ← $ {0,1} n ,k i ← $ {0,1} n
[0107] The side channel leakage is
[0108] EndFor
[0109] Return(y 1 ,…,y D )”
[0110] The above algorithm describes the side channel leakage generated during the calculation of the stream cipher IStream.
[0111] It can be seen from the above algorithm that a call The output key stream (y 1 ,…,y D) and the corresponding side channel leakage are the D pseudo-random outputs and observable side channel leakages that can be obtained after calling LRPRG-E D times NextWord, and the output (y 1 ,…,y D ) is a true random number. Therefore, The difference from IStream reflects the security of LRPRG-π. It can be proved that if the attacker asks the ideal password E for T times, then The upper bound of the difference between IStream and
[0112]
[0113] Therefore, the success probability of an attacker with the same complexity attacking the idealized scheme LRPRG-E is also
[0114]
[0115] When attacking the idealized scheme LRPRG-E, the number of queries T for the ideal password E actually reflects the attacker's offline computational complexity. Finally, the actual parameter of LRPRG-SM4 is n = 128, which is used to obtain the claimed security boundary. The leakage-resistant security bound of LRPRG-SM4 is inferior to the corresponding leakage-free security bound, but this security loss is inevitable since side-channel leakage enhances the attacker's capabilities.
[0116] Through the method provided in the embodiment of this specification, in any t-th round of iteration, first obtain the seed output in the previous round as the current seed; then use the symmetric encryption algorithm to process the current seed and the first value to obtain the random number of this round, wherein the first value is determined according to the current count value of the counter and the preset first constant; finally, use the symmetric encryption algorithm to process the current seed and the second value to obtain the seed of this round for the next round of iteration, wherein the second value is determined according to the current count value and the preset second constant. As can be seen from the above, the embodiment of this specification, based on the existing symmetric encryption algorithm, can generate the relevant pseudo-random number parameters required for privacy computing with high performance. At the same time, side channel security is taken into account in the scheme for generating pseudo-random numbers. Even if the underlying symmetric encryption algorithm does not adopt the implementation of anti-side channel leakage, it can provide effective protection against side channel leakage, thereby avoiding the performance and resource loss caused by the implementation of side channel leakage protection, thereby having high performance and side channel security.
[0117] According to another aspect of the embodiment, a pseudo-random number generating device is also provided, and the device is used to execute the method provided in the embodiment of this specification. Figure 4FIG. 1 is a schematic block diagram of a pseudo-random number generating device according to an embodiment. Figure 4 As shown, the device 400 is used to perform multiple rounds of iterations corresponding to the count value of the counter, wherein the device 400 includes the following units for performing any t-th round of iterations:
[0118] An acquisition unit 41 is used to acquire the seed output in the previous round as the current seed;
[0119] A first processing unit 42 is used to process the current seed and the first value obtained by the obtaining unit 41 using a symmetric encryption algorithm to obtain a random number of this round, wherein the first value is determined according to the current count value of the counter and a preset first constant;
[0120] The second processing unit 43 is used to use the symmetric encryption algorithm to process the current seed and the second value obtained by the obtaining unit 41 to obtain the seed of this round for the next round of iteration, wherein the second value is determined according to the current count value and a preset second constant.
[0121] Optionally, as an embodiment, the tth round of iteration is a first round of iteration, and the current seed is an initialized seed.
[0122] Optionally, as an embodiment, the first processing unit 42 includes:
[0123] A first encryption subunit is configured to use the current seed as a key and the first value as plaintext to be encrypted, and to encrypt the plaintext using a symmetric encryption algorithm to obtain a first ciphertext;
[0124] The first determination subunit is used to determine the random number of this round based on the first ciphertext obtained by the first encryption subunit.
[0125] Optionally, as an embodiment, the first value is determined in the following manner:
[0126] The current count value of the first bit number and the first constant of the second bit number are concatenated to obtain a first value of the target bit number.
[0127] Furthermore, each bit of the first constant of the second bit number is 1.
[0128] Optionally, as an embodiment, the second processing unit 43 includes:
[0129] A second encryption subunit is used to use the current seed as a key and the second value as a plaintext to be encrypted, and use a symmetric encryption algorithm to encrypt the plaintext to obtain a second ciphertext;
[0130] The second determination subunit is used to determine the seed of this round based on the second ciphertext obtained by the second encryption subunit.
[0131] Optionally, as an embodiment, the second value is determined in the following manner:
[0132] The current count value of the first bit number and the second constant of the second bit number are concatenated to obtain a second value of the target bit number.
[0133] Furthermore, each bit of the second constant of the second bit number is 0.
[0134] Furthermore, the first bit number is 120, and the second bit number is 8.
[0135] Through the device provided by the embodiment of this specification, in any t-th round of iteration, the acquisition unit 41 first obtains the seed output in the previous round as the current seed; then the first processing unit 42 uses the symmetric encryption algorithm to process the current seed and the first value to obtain the random number of this round, wherein the first value is determined according to the current count value of the counter and the preset first constant; finally, the second processing unit 43 uses the symmetric encryption algorithm to process the current seed and the second value to obtain the seed of this round for the next round of iteration, wherein the second value is determined according to the current count value and the preset second constant. As can be seen from the above, the embodiment of this specification, based on the existing symmetric encryption algorithm, can generate the relevant pseudo-random number parameters required for privacy computing with high performance. At the same time, side channel security is considered in the scheme for generating pseudo-random numbers. Even if the underlying symmetric encryption algorithm does not adopt the implementation of anti-side channel leakage, it can provide effective protection against side channel leakage, thereby avoiding the performance and resource loss caused by the implementation of side channel leakage protection, thereby having high performance and side channel security.
[0136] According to another embodiment, there is also provided a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute a combination of Figure 2 The method described.
[0137] According to another embodiment of the present invention, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the Figure 2 The method described.
[0138] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the present invention can be implemented by hardware, software, firmware or any combination thereof. When implemented by software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium.
[0139] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solution of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for generating a pseudo-random number, the method comprising a plurality of rounds of iterations corresponding to the count value of a counter, wherein: Any t-th iteration includes: Get the seed output in the previous round as the current seed; Using a symmetric encryption algorithm, the current seed and the first value are processed to obtain a random number for this round, wherein the first value is determined according to the current count value of the counter and a preset first constant; The symmetric encryption algorithm is used to process the current seed and the second value to obtain the seed for the next round of iteration, wherein the second value is determined according to the current count value and a preset second constant.
2. The method of claim 1, wherein: The tth round of iteration is the first round of iteration, and the current seed is an initialized seed.
3. The method of claim 1, wherein: The method of using a symmetric encryption algorithm to process the current seed and the first value to obtain a random number for this round includes: Using the current seed as a key and the first value as plaintext to be encrypted, encrypting the plaintext using a symmetric encryption algorithm to obtain a first ciphertext; A random number for this round is determined based on the first ciphertext.
4. The method of claim 1, wherein: The first value is determined in the following manner: The current count value of the first bit number and the first constant of the second bit number are concatenated to obtain a first value of the target bit number.
5. The method of claim 4, wherein: All bits of the first constant of the second bit number are 1.
6. The method of claim 1, wherein: The method of using the symmetric encryption algorithm to process the current seed and the second value to obtain the seed for this round includes: Using the current seed as a key and the second value as plaintext to be encrypted, encrypting the plaintext using a symmetric encryption algorithm to obtain a second ciphertext; A seed for this round is determined based on the second ciphertext.
7. The method of claim 1, wherein: The second value is determined in the following manner: The current count value of the first bit number and the second constant of the second bit number are concatenated to obtain a second value of the target bit number.
8. The method of claim 7, wherein: All bits of the second constant of the second bit number are 0.
9. The method according to claim 4 or 7, wherein: The first bit number is 120, and the second bit number is 8.
10. A pseudo-random number generating device, the device being used to perform multiple rounds of iterations corresponding to the count value of a counter, wherein: Contains the following units for executing any t-th iteration: An acquisition unit, used to acquire the seed output in the previous round as the current seed; a first processing unit, configured to process the current seed and the first value obtained by the obtaining unit by using a symmetric encryption algorithm to obtain a random number of this round, wherein the first value is determined according to a current count value of the counter and a preset first constant; The second processing unit is used to use the symmetric encryption algorithm to process the current seed and the second value obtained by the acquisition unit to obtain the seed of this round for the next round of iteration, wherein the second value is determined according to the current count value and a preset second constant.
11. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 9.
12. A computing device comprising a memory and a processor, wherein the memory stores executable codes, and when the processor executes the executable codes, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Implementation method and device of SM4 algorithm
CN115442031A
Split random number generator
CN116670641A
Random number generation method and device, electronic equipment and readable storage medium
CN116931875A
Pseudo-random number generation method and device, equipment and storage medium
CN117573073A
Method and apparatus for improved pseudo-random number generation
US20020172359A1
Cited By
Pseudo-random sequence generation method and device, equipment and storage medium
CN120528584A