Random number generation method, device, electronic device and storage medium
By dividing prime number bits and non-prime number bits according to the N-bit binary seed, merging and rotating them and performing logical operations, generating pseudo-random numbers evenly distributed in the interval [0, 2N-1], which solves the problem of memory chip security in Row Hammer attacks. Inadequate problem and improve the security of memory chips.
Patent Information
- Application Number
- CN202411005607.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-25
- Publication Date
- 2024-10-08
- Estimated Expiration
- 2044-07-25
AI Technical Summary
Existing technology is difficult to generate pseudo-random numbers uniformly distributed in the interval [0, 2N-1], resulting in insufficient security of memory chips in Row Hammer attacks.
By determining the arrays of prime and non-prime digits based on the N-bit binary seed, merging and rotating them, logical operations are performed to generate N-1-bit pseudo-random numbers, ensuring that they are evenly distributed in the interval [0, 2N-1].
It improves the security of the memory chip, reduces the risk of being cracked, and enhances the attack resistance of the memory chip by generating uniformly distributed pseudo-random numbers.
Smart Images

Figure CN118519614B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the computer field, and in particular, to a random number generation method, device, electronic device, and storage medium. Background Art
[0002] The data stored in Dynamic Random Access Memory (DRAM) is actually the electrons stored in the capacitor, and the electrons will escape over time, so they need to be refreshed regularly to maintain a stable voltage. Row Hammer refers to the use of the mutual influence of electrons between adjacent memory cells (the smallest storage unit) to change the value of a memory cell from 1 to 0 after a sufficient number of accesses, and vice versa.
[0003] In the field of DRAM security, hackers can use Row Hammer to generate erroneous data without accessing the target memory area, cracking the memory chip to attack the memory chip. Usually, random numbers are used to probabilistically refresh the memory chip, which can greatly reduce the risk of the memory chip being cracked and improve the security of the memory chip.
[0004] Therefore, it is necessary to propose a random number generation scheme to obtain uniformly distributed random numbers. Summary of the invention
[0005] The present disclosure provides a random number generation method, device, electronic device and storage medium, which can generate a random number in the interval [0, 2 N -1] Uniformly distributed pseudo-random numbers can improve the security of memory chips.
[0006] In a first aspect, the present disclosure provides a random number generation method, comprising:
[0007] According to an N-bit binary seed, a first array and a second array are determined; wherein N is a prime number greater than 4, the first array includes numbers on at least some of the prime bits of the seed, and the second array includes numbers on at least some of the non-prime bits of the seed; the first array and the second array are combined into a third array, wherein there is at least one pair of adjacent numbers in the third array, which are numbers in the first array and numbers in the second array; the numbers in the third array are rotated by at least 1 bit to obtain a fourth array; and the numbers in the third array and the numbers in the fourth array are logically operated bit by bit to generate N-1-bit pseudo-random numbers.
[0008] In some embodiments of the present disclosure, determining the first array and the second array according to the N-bit binary seed includes:
[0009] The numbers at the first position of the seed are divided into a first initial array; starting from the second position of the seed until the end of the Nth position of the seed and skipping the (N+1) / 2th position of the seed, the numbers at each of the prime positions of the seed are divided into the first initial array, and the numbers at each of the non-prime positions of the seed are divided into a second initial array; the seed prime positions corresponding to each number in the first initial array are arranged in order from large to small to obtain the first array, and the seed non-prime positions corresponding to each number in the second initial array are arranged in order from large to small to obtain the second array.
[0010] In some embodiments of the present disclosure, merging the first array and the second array into a third array includes:
[0011] Put the first number in the second array into the first position of the third array; starting from the second position of the third array until the end of the Nth position of the third array and skipping the (N+1) / 2th position of the third array, put the numbers in the first array into each non-prime position of the third array in sequence, and put the remaining numbers in the second array into each prime position of the third array in sequence, to obtain the N-bit third array.
[0012] In some embodiments of the present disclosure, rotating the numbers in the third array by at least 1 bit to obtain the fourth array includes:
[0013] The numbers in the third array are rotated right by M bits and the (N+1) / 2th bit of the third array is skipped to obtain the N-bit fourth array; or the numbers in the third array are rotated left by M bits and the (N+1) / 2th bit of the third array is skipped to obtain the N-bit fourth array. Wherein, M is an integer greater than or equal to 1 and less than (N+1) / 2.
[0014] In some embodiments of the present disclosure, performing bit-by-bit logical operations on the numbers in the third array and the numbers in the fourth array to generate an N-1-bit pseudo-random number includes:
[0015] Skip the (N+1) / 2th bit of the fourth array and the (N+1) / 2th bit of the third array, perform bit-wise XOR operation on the N-bit numbers in the third array and the N-bit numbers in the fourth array to obtain the N-1-bit pseudo-random number.
[0016] In some embodiments of the present disclosure, the method further includes:
[0017] The seed is updated according to the pseudo-random number, and the process is returned to execute according to the N-bit binary seed to determine the first array and the second array.
[0018] In some embodiments of the present disclosure, updating the seed according to the pseudo-random number includes:
[0019] The skipped number at the (N+1) / 2th position of the seed is combined with the pseudo-random number to obtain a new seed.
[0020] In a second aspect, an embodiment of the present disclosure provides a random number generating device, including:
[0021] A determination module is used to determine a first array and a second array according to an N-bit binary seed; wherein N is a prime number greater than 4, the first array includes numbers on at least some of the prime bits of the seed, and the second array includes numbers on at least some of the non-prime bits of the seed; the first array and the second array are combined into a third array, wherein there is at least one pair of adjacent numbers in the third array that are numbers in the first array and numbers in the second array; and the numbers in the third array are rotated by at least 1 bit to obtain a fourth array.
[0022] The logic operation module is used to perform bit-by-bit logic operation on the numbers in the third array and the numbers in the fourth array to generate an N-1-bit pseudo-random number.
[0023] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising a processor, wherein the processor is used to execute a computer program stored in a memory, wherein the computer program, when executed by the processor, implements the steps of any method provided in the first aspect.
[0024] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of any method provided in the first aspect are implemented.
[0025] In the technical solution provided by the present disclosure, a first array including at least part of the numbers on the prime number positions of the seed and a second array including at least part of the numbers on the non-prime number positions of the seed are determined according to an N-bit binary seed, the first array and the second array are merged into a third array, the numbers in the third array are rotated by at least 1 bit to obtain a fourth array, and the numbers in the third array and the numbers in the fourth array are logically operated bit by bit to generate an N-1-bit pseudo-random number, so that a pseudo-random number in the interval [0, 2 N -1] Uniformly distributed pseudo-random numbers can improve the security of memory chips.
[0026] The above description is only an overview of the technical solution of the embodiment of the present application. In order to more clearly understand the technical means of the embodiment of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiment of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present application, a brief introduction will be given below to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0028] Figure 1 A schematic diagram of the structure of an application scenario provided by an embodiment of the present disclosure;
[0029] Figure 2 A flowchart of a random number generation method provided by an embodiment of the present disclosure;
[0030] Figure 3 A schematic diagram of a random number generation process provided by an embodiment of the present disclosure;
[0031] Figure 4 A flowchart of another random number generation method provided by an embodiment of the present disclosure;
[0032] Figure 5 A schematic diagram of another distribution of pseudo-random numbers provided in an embodiment of the present disclosure;
[0033] Figure 6 A schematic diagram of the structure of a random number generating device provided by an embodiment of the present disclosure;
[0034] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0035] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution of the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the described embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative work also fall within the scope of protection of the present disclosure.
[0036] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by a person skilled in the art to which the subject matter of the present disclosure belongs. It will be further understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the specification and the relevant art, and will not be interpreted in an idealized or overly formal form unless otherwise explicitly defined herein. As used herein, a statement that two or more parts are "electrically connected" together shall mean that the parts are directly joined together or joined through one or more intermediate components.
[0037] Reference to "embodiments" in this disclosure means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase "embodiments" in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described in this disclosure may be combined with other embodiments.
[0038] In addition, the terms "first", "second", etc. in the specification and claims of the present disclosure or the above-mentioned drawings are used to distinguish different objects rather than to describe a specific order, and may explicitly or implicitly include one or more of the features.
[0039] The term "and / or" in this disclosure is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists, A and B exist at the same time, and B exists. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0040] In the description of the present disclosure, unless otherwise specified, "plurality" and "at least two" mean more than two (including two), and similarly, "multiple groups" and "at least two groups" mean more than two groups (including two).
[0041] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0042] Figure 1 A schematic diagram of an application scenario provided by an embodiment of the present disclosure, such as Figure 1 As shown, the application scenario includes a random number generator 10 and a memory chip 20, and the output end of the random number generator 10 is connected to the input end of the memory chip 20. The random number generator 10 includes a random number generating device, a clock module, a reset module and an input module.
[0043] Exemplarily, the input module includes an analog-to-digital converter, and the input module can randomly capture any analog signal in other circuits and convert it into a digital signal through the analog-to-digital converter to obtain a binary seed. The length of the seed can be flexibly set. If the length of the seed is set to N, the input module can convert the analog signal into an N-bit digital signal to obtain an N-bit binary seed.
[0044] A reset condition may be preset in the reset module, for example, the reset condition may be that the number of random number generation reaches a preset number and / or the memory chip 20 is attacked from the outside, etc. When the reset condition is reached, the reset module generates a reset signal, for example, the reset signal is a high level signal, or a low level signal.
[0045] In other embodiments, the reset module may include a unit for receiving a user reset operation, or the reset module may be provided with a reset condition and include a unit for receiving a user reset operation. When the user performs a reset operation, the reset module generates a reset signal.
[0046] The output end of the clock module, the output end of the reset module, and the output end of the input module are all connected to a random number generator, which can receive a reset signal generated by the reset module, a clock signal generated by the clock module, and a seed obtained by the input module. The random number generator can execute the steps of any random number generation method embodiment provided in the embodiments of the present disclosure to generate a pseudo-random number based on the seed. At the rising edge or falling edge of the clock signal, the random number generator can trigger the next step of the internal random number generation algorithm. When a reset signal is received, the input module reacquires the seed, and the random number generator generates a random number based on the reacquired seed. Before receiving the reset signal, the random number generator can update the seed based on the generated pseudo-random number and continue to generate pseudo-random numbers.
[0047] The memory chip 20 refreshes the memory unit according to the received random number to reduce the risk of the memory chip being cracked, thereby improving the security of the memory chip.
[0048] Usually, the square middle method, linear congruential method, Mersenne twister algorithm and shift register generator can be used to generate random numbers. Among them, the square middle method can generate random numbers with uniform distribution of [0,1]. The linear congruential method is also called linear congruential random number generator, including mixed congruential method and multiplication congruential method, which can also generate random numbers with uniform distribution of [0,1]. The Mersenne twister algorithm is a pseudo-random number generation algorithm based on matrix linear recursion on wired binary fields. The shift register generator, namely the Xorshift random number generator, is a pseudo-random number generator and a subset of the linear feedback shift register.
[0049] Since random numbers only exist in the real natural world, all random numbers generated by computers are not real random numbers, that is, all random numbers generated by computers are pseudo-random numbers. What is usually done is to try to make the distribution of the generated pseudo-random numbers closer to the random result. However, the distribution of random numbers generated by the above four methods is not uniform.
[0050] In view of this, the present disclosure provides a random number generation method, by determining a first array including numbers on at least some of the seed prime bits and a second array including numbers on at least some of the seed non-prime bits according to an N-bit binary seed, merging the first array and the second array into a third array, rotating the numbers in the third array by at least 1 bit to obtain a fourth array, performing a bitwise logical operation on the numbers in the third array and the numbers in the fourth array to generate an N-1-bit pseudo-random number, and being able to obtain a pseudo-random number in the interval [0, 2 N -1] Uniformly distributed pseudo-random numbers can improve the security of memory chips.
[0051] The technical solution of the present disclosure is described in detail below with several specific implementations.
[0052] Figure 2 A flow chart of a random number generation method provided by an embodiment of the present disclosure is shown as follows: Figure 2 As shown, the specific steps of the random number generation method include:
[0053] S101, determining a first array and a second array according to an N-bit binary seed.
[0054] Wherein, N is a prime number greater than 4, the first array includes numbers on at least some of the seed prime positions, and the second array includes numbers on at least some of the seed non-prime positions.
[0055] Exemplarily, the seed length N can be preset to any prime number greater than 4, and an N-bit binary seed can be obtained. For example, if N is 17, a 17-bit binary seed can be obtained. The embodiment of the present disclosure only uses a 17-bit seed as an example to illustrate the random number generation process, and does not limit the length N of the binary seed.
[0056] Figure 3 A schematic diagram of a random number generation process provided by an embodiment of the present disclosure is shown in FIG. Figure 3 As shown in part (a) of , the seed is 17 bits. Figure 3 As shown, 1 to 17 represent seed bits, where 1 represents the first seed bit, i.e., the least significant bit, and 17 represents the seventeenth seed bit, i.e., the most significant bit. For example, the seed is 10101010001010011.
[0057] Since the prime numbers from 1 to 17 are 2, 3, 5, 7, 11, 13 and 17, and the non-prime numbers are 4, 6, 8, 9, 10, 12, 14, 15 and 16, the seed prime positions are seed 2, seed 3, seed 5, seed 7, seed 11, seed 13 and seed 17, and the seed non-prime positions are seed 4, seed 6, seed 8, seed 9, seed 10, seed 12, seed 14, seed 15 and seed 16.
[0058] The first array includes at least two digits of the numbers at the second, third, fifth, seventh, eleventh, thirteenth and seventeenth seed positions, and the second array includes at least two digits of the numbers at the fourth, sixth, eighth, ninth, tenth, twelfth, fourteenth, fifteenth and sixteenth seed positions, and the number at the first seed position can be a number in the first array or a number in the second array.
[0059] A specific description of a possible implementation method when executing S101 is as follows:
[0060] The number at the first seed position is divided into a first initial array, starting from the second seed position until the end of the Nth seed position and skipping the (N+1) / 2th seed position, the numbers at various sub-prime positions are divided into the first initial array, and the numbers at various sub-non-prime positions are divided into the second initial array; the seed prime positions corresponding to the numbers in the first initial array are arranged in order from large to small to obtain a first array, and the seed non-prime positions corresponding to the numbers in the second initial array are arranged in order from large to small to obtain a second array.
[0061] Exemplarily, based on the above embodiment, the 9th seed position is skipped, and the numbers at the 1st seed position, the 2nd seed position, the 3rd seed position, the 5th seed position, the 7th seed position, the 11th seed position, the 13th seed position and the 17th seed position may be placed in the first initial array in sequence, and the numbers at the 4th seed position, the 6th seed position, the 8th seed position, the 10th seed position, the 12th seed position, the 14th seed position, the 15th seed position and the 16th seed position may be placed in the second initial array in sequence.
[0062] Therefore, the numbers in the first initial array are the numbers at seed 1, seed 2, seed 3, seed 5, seed 7, seed 11, seed 13 and seed 17, respectively, and the numbers in the second initial array are the numbers at seed 4, seed 6, seed 8, seed 10, seed 12, seed 14, seed 15 and seed 16, respectively.
[0063] Arrange the numbers in the first initial array in descending order according to the seed prime number to obtain the first array. The numbers in the first array are the numbers at the 17th seed, the 13th seed, the 11th seed, the 7th seed, the 5th seed, the 3rd seed, the 2nd seed and the 1st seed, respectively. Figure 3 As shown in part (b) of the second initial array, the numbers in the second initial array are arranged in descending order according to the non-prime number of the seed, and the numbers in the second array are the numbers at the 16th seed, the 15th seed, the 14th seed, the 12th seed, the 10th seed, the 8th seed, the 6th seed and the 4th seed, as shown in FIG. Figure 3 As shown in part (b) of .
[0064] For example, the seed is 10101010001010011, the first initial array is 10111111, the second initial number is 00000001, the first array is 11111101, and the second array is 10000000.
[0065] Another possible implementation method for executing S101 is described in detail as follows:
[0066] Starting from the Nth seed position until the 1st seed position and skipping the (N+1) / 2th seed position, the numbers on various sub-prime positions and the number on the 1st seed position are placed in the first array in sequence, and the numbers on various sub-non-prime positions are placed in the second array in sequence.
[0067] For example, based on the above embodiment, the 9th seed is skipped, and the numbers at the 17th seed, the 13th seed, the 11th seed, the 7th seed, the 5th seed, the 3rd seed, the 2nd seed and the 1st seed can be sequentially placed into the first array, such as Figure 3 As shown in part (b) of . Put the numbers at the 16th, 15th, 14th, 12th, 10th, 8th, 6th and 4th positions of the seed into the second array in sequence, as Figure 3 As shown in part (b) of .
[0068] S102: merge the first array and the second array into a third array.
[0069] Exemplarily, the third array includes all the numbers in the first array and all the numbers in the second array, and there is at least one pair of adjacent numbers in the third array that are numbers in the first array and numbers in the second array.
[0070] A specific description of a possible implementation method when executing S102 is as follows:
[0071] The second array is arranged after the first array, or the second array is arranged before the first array, to obtain an N-1-bit third array.
[0072] Exemplarily, all the numbers in the first array are sequentially placed into the third array starting from the first position of the third array, and all the numbers in the second array are sequentially placed into the third array starting from the position next to the last number in the first array, to obtain an N-1-bit third array. For example, based on the above embodiment, the third array is 1111110110000000.
[0073] Alternatively, all the numbers in the second array are sequentially placed into the third array starting from the first digit of the third array, and all the numbers in the first array are sequentially placed into the third array starting from the digit next to the last digit in the second array, to obtain an N-1 digit third array. For example, based on the above embodiment, the third array is 1000000011111101.
[0074] A specific description of a possible implementation method when executing S102 is as follows:
[0075] The numbers in the first array are spaced apart from the numbers in the second array to obtain a third array of N-1 digits.
[0076] Exemplarily, based on the above embodiment, each number in the first array and each number in the second array can be set at intervals to obtain a 16-bit third array. If the first bit of the third array is the first bit of the first array, the numbers in the 16-bit third array are the numbers at the 17th seed bit, the 16th seed bit, the 13th seed bit, the 15th seed bit, the 11th seed bit, the 14th seed bit, the 7th seed bit, the 12th seed bit, the 5th seed bit, the 10th seed bit, the 3rd seed bit, the 8th seed bit, the 2nd seed bit, the 6th seed bit, the 1st seed bit, and the 4th seed bit. For example, based on the above embodiment, the third array is 1110101010100010.
[0077] If the first bit of the third array is the first bit of the second array, the numbers in the 16-bit third array are the numbers at seed bit 16, seed bit 17, seed bit 15, seed bit 13, seed bit 14, seed bit 11, seed bit 12, seed bit 7, seed bit 10, seed bit 5, seed bit 8, seed bit 3, seed bit 6, seed bit 2, seed bit 4 and seed bit 1. For example, based on the above embodiment, the third array is 1101010101010001.
[0078] In some other implementations, each group of numbers in the first array and each group of numbers in the second array may be arranged at intervals to obtain a 16-bit third array. If the first bit of the third array is the first bit of the first array, the numbers in the 16-bit third array are the numbers at the 17th seed bit, the 13th seed bit, the 16th seed bit, the 15th seed bit, the 11th seed bit, the 7th seed bit, the 14th seed bit, the 12th seed bit, the 5th seed bit, the 3rd seed bit, the 10th seed bit, the 8th seed bit, the 2nd seed bit, the 1st seed bit, the 6th seed bit, and the 4th seed bit. For example, based on the above embodiment, the third array is 1110110011000100.
[0079] If the first bit of the third array is the first bit of the second array, the numbers in the 16-bit third array are the numbers at seed 16, seed 15, seed 17, seed 13, seed 14, seed 12, seed 11, seed 7, seed 10, seed 8, seed 5, seed 3, seed 6, seed 4, seed 2 and seed 1. For example, based on the above embodiment, the third array is 1011001100110001.
[0080] In some other embodiments, the first three numbers in the first array can be taken as a whole, the fourth to sixth numbers can be taken as a whole, and the seventh and eighth numbers can be taken as a whole, and inserted between any two adjacent numbers in the second array to obtain a 16-bit third array. Alternatively, the first four numbers in the first array can be taken as a whole, and the last four numbers can be taken as a whole, and inserted between any two adjacent numbers in the second array to obtain a 16-bit third array.
[0081] It should be noted that the embodiments of the present disclosure only provide an exemplary description of the interval setting between the numbers in the first array and the numbers in the second array, and are not intended to limit the number of seed non-prime bits between adjacent seed prime bits in the third array, nor are they intended to limit the number of seed prime bits between adjacent seed non-prime bits in the third array.
[0082] Another possible implementation method for executing S102 is described in detail as follows:
[0083] Put the first number in the second array into the first position of the third array, start from the second position of the third array until the end of the Nth position of the third array and skip the (N+1) / 2th position of the third array, put the numbers in the first array into each non-prime position of the third array in sequence, and put the remaining numbers in the second array into each prime position of the third array in sequence, to obtain an N-bit third array.
[0084] Exemplarily, based on the above embodiment, the number at the 16th position of the seed is placed in the 1st position of the third array, the number at the 15th position of the seed is placed in the 2nd position of the third array, the number at the 14th position of the seed is placed in the 3rd position of the third array, the number at the 17th position of the seed is placed in the 4th position of the third array, the number at the 12th position of the seed is placed in the 5th position of the third array, the number at the 13th position of the seed is placed in the 6th position of the third array, the number at the 10th position of the seed is placed in the 7th position of the third array, and the number at the 11th position of the seed is placed in the 8th position of the third array.
[0085] Skip the 9th position of the third array, put the number at the 7th position of the seed into the 10th position of the third array, put the number at the 8th position of the seed into the 11th position of the third array, put the number at the 5th position of the seed into the 12th position of the third array, put the number at the 6th position of the seed into the 13th position of the third array, put the number at the 3rd position of the seed into the 14th position of the third array, put the number at the 2nd position of the seed into the 15th position of the third array, put the number at the 1st position of the seed into the 16th position of the third array, and put the number at the 4th position of the seed into the 17th position of the third array, and get a 17-digit third array, such as Figure 3 As shown in part (c) of . The 9th bit of the third array can be the 9th bit of the seed, such as Figure 3 As shown in part (c), for example, based on the above embodiment, the third array is 10010101010101010.
[0086] S103, rotate the numbers in the third array by at least 1 bit to obtain a fourth array.
[0087] Exemplarily, the rotation may be a left rotation, in which case a rotation of 1 bit is a left rotation shift of 1 bit. The rotation may also be a right rotation, in which case a rotation of 1 bit is a right rotation shift of 1 bit.
[0088] Based on the above embodiment, a third array of N-1 bits is obtained, and a specific description of a possible implementation method when performing S103 is as follows:
[0089] The numbers in the third array are rotated right by i bits, or the numbers in the third array are rotated left by i bits, to obtain an N-1-bit fourth array, where i is an integer greater than or equal to 1 and less than N-1.
[0090] Exemplarily, based on the above embodiment, the numbers in the 16-bit third array are the numbers at the 16th seed, the 17th seed, the 15th seed, the 13th seed, the 14th seed, the 11th seed, the 12th seed, the 7th seed, the 10th seed, the 5th seed, the 8th seed, the 3rd seed, the 6th seed, the 2nd seed, the 4th seed and the 1st seed. If the numbers in the 16-bit third array are cyclically shifted right by 1 bit to obtain the 16-bit fourth array, the numbers in the 16-bit fourth array are the numbers at the 1st seed, the 16th seed, the 17th seed, the 15th seed, the 13th seed, the 14th seed, the 11th seed, the 12th seed, the 7th seed, the 10th seed, the 5th seed, the 8th seed, the 3rd seed, the 6th seed, the 2nd seed and the 4th seed. For example, if the third array is 1101010101010001, then the fourth array is 111010101010101000.
[0091] If the numbers in the 16-bit third array are cyclically shifted left by 1 bit to obtain the 16-bit fourth array, the numbers in the 16-bit fourth array are the numbers at seed position 17, seed position 15, seed position 13, seed position 14, seed position 11, seed position 12, seed position 7, seed position 10, seed position 5, seed position 8, seed position 3, seed position 6, seed position 2, seed position 4, seed position 1 and seed position 16. For example, based on the above embodiment, the fourth array is 1010101010100011.
[0092] In some other implementations, the numbers in the 16-bit third array may be cyclically right-shifted by 2 bits to obtain a 16-bit fourth array, and the numbers in the 16-bit fourth array are the numbers at seed position 4, seed position 1, seed position 16, seed position 17, seed position 15, seed position 13, seed position 14, seed position 11, seed position 12, seed position 7, seed position 10, seed position 5, seed position 8, seed position 3, seed position 6, and seed position 2. For example, based on the above embodiment, the fourth array is 0111010101010100.
[0093] Alternatively, the numbers in the 16-bit third array can be cyclically shifted left by 2 bits to obtain a 16-bit fourth array, and the numbers in the 16-bit fourth array are the numbers at seed position 15, seed position 13, seed position 14, seed position 11, seed position 12, seed position 7, seed position 10, seed position 5, seed position 8, seed position 3, seed position 6, seed position 2, seed position 4, seed position 1, seed position 16 and seed position 17. For example, based on the above embodiment, the fourth array is 0101010101000111.
[0094] In some other embodiments, the numbers in the 16-bit third array can be rotated right by 3 bits to any bit in the 15 bits, or rotated left by 3 bits to any bit in the 15 bits. The present disclosure does not impose any specific restrictions on the number of rotation bits i, but only limits the number of rotation bits i to be less than the number of bits in the third array, that is, i <N-1。
[0095] Based on the above embodiment, the N-bit third array is obtained, and as another possible implementation method when executing S103, a specific description is as follows:
[0096] The numbers in the third array are rotated right by M bits and the (N+1) / 2th bit of the third array is skipped to obtain an N-bit fourth array; or the numbers in the third array are rotated left by M bits and the (N+1) / 2th bit of the third array is skipped to obtain an N-bit fourth array. Where M is an integer greater than or equal to 1 and less than (N+1) / 2.
[0097] Exemplarily, based on the above embodiments, Figure 3 As shown in part (c), the numbers in the 17-digit third array are, respectively, the numbers at seed 16, seed 15, seed 14, seed 17, seed 12, seed 13, seed 10, seed 11, seed 9, seed 7, seed 8, seed 5, seed 6, seed 3, seed 2, seed 1 and seed 4. If the numbers in the 17-digit third array are cyclically shifted right by 1 bit and the 9th bit of the third array is skipped during the right shift, that is, the 9th bit of the third array does not participate in the cyclic right shift, and the 17-digit fourth array is obtained, then the numbers in the 17-digit fourth array are the numbers at the 4th seed bit, the 16th seed bit, the 15th seed bit, the 14th seed bit, the 17th seed bit, the 12th seed bit, the 13th seed bit, the 10th seed bit, the 9th seed bit, the 11th seed bit, the 7th seed bit, the 8th seed bit, the 5th seed bit, the 6th seed bit, the 3rd seed bit, the 2nd seed bit and the 1st seed bit, such as Figure 3 For example, the third array is 10010101010101010, and the fourth array is 01001010011010101.
[0098] If the numbers in the 17-bit third array are cyclically shifted left by 1 bit, and the 9th bit of the third array is skipped during the left shift, that is, the 9th bit of the third array does not participate in the cyclic left shift, the 17-bit fourth array is obtained, and the numbers in the 17-bit fourth array are the numbers on the numbers at the 15th seed bit, the 14th seed bit, the 17th seed bit, the 12th seed bit, the 13th seed bit, the 10th seed bit, the 11th seed bit, the 7th seed bit, the 9th seed bit, the 8th seed bit, the 5th seed bit, the 6th seed bit, the 3rd seed bit, the 2nd seed bit, the 1st seed bit, the 4th seed bit, and the 16th seed bit. For example, based on the above embodiment, the fourth array is 00101011001010101.
[0099] In other implementations, the numbers in the 17-bit third array can be cyclically right-shifted by 2 bits and the 9th bit of the third array can be skipped to obtain the 17-bit fourth array. Then, the numbers in the 17-bit fourth array are the numbers at the seed 1st bit, the seed 4th bit, the seed 16th bit, the seed 15th bit, the seed 14th bit, the seed 17th bit, the seed 12th bit, the seed 13th bit, the seed 9th bit, the seed 10th bit, the seed 11th bit, the seed 7th bit, the seed 8th bit, the seed 5th bit, the seed 6th bit, the seed 3rd bit and the seed 2nd bit. For example, based on the above embodiment, the fourth array is 10100101001101010.
[0100] Alternatively, the numbers in the 17-bit third array can be cyclically shifted left by 2 bits and the 9th bit of the third array can be skipped to obtain the 17-bit fourth array. Then the numbers in the 17-bit fourth array are the numbers at the 14th seed bit, the 17th seed bit, the 12th seed bit, the 13th seed bit, the 10th seed bit, the 11th seed bit, the 7th seed bit, the 8th seed bit, the 9th seed bit, the 5th seed bit, the 6th seed bit, the 3rd seed bit, the 2nd seed bit, the 1st seed bit, the 4th seed bit, the 16th seed bit and the 15th seed bit. For example, based on the above embodiment, the fourth array is 01010110010101010.
[0101] In another other embodiment, the numbers in the 17-bit third array can be rotated right by 3 bits to any position in the 8 bits, or rotated left by 3 bits to any position in the 8 bits. The present disclosure does not impose any specific restriction on the number of rotation bits M, but only limits the number of rotation bits M to less than (N+1) / 2.
[0102] S104, performing a bit-by-bit logical operation on the numbers in the third array and the numbers in the fourth array to generate an N-1-bit pseudo-random number.
[0103] Exemplarily, the logic operation may be any one of an AND operation, an OR operation, a NOT operation, a NAND operation, a NOR operation, an XOR operation, and an XNOR operation.
[0104] A specific description of a possible implementation method when executing S104 is as follows:
[0105] The numbers in the N-1-bit third array and the numbers in the N-1-bit fourth array are subjected to bit-by-bit XOR operation to obtain an N-1-bit pseudo-random number.
[0106] Exemplarily, the 16-bit numbers in the third array and the 16-bit numbers in the fourth array are XORed bit by bit to obtain a 16-bit pseudo-random number. For example, based on the above embodiment, the 16-bit third array is 1101010101010001, the 16-bit fourth array is 1110101010101000, and the 16-bit pseudo-random number obtained by XORing bit by bit is 0011111111111001.
[0107] Another possible implementation method for executing S104 is described in detail as follows:
[0108] Skip the (N+1) / 2th bit of the fourth array and the (N+1) / 2th bit of the third array, perform bit-wise XOR operation on the N-bit numbers in the third array and the N-bit numbers in the fourth array to obtain an N-1-bit pseudo-random number.
[0109] Exemplarily, the numbers from the 1st bit of the third array to the 8th bit of the third array and the numbers from the 1st bit of the fourth array to the 8th bit of the fourth array are subjected to bitwise XOR operation to obtain the first 8 bits of the 16-bit pseudo-random number, namely X0X1X2X3X4X5X6X7. The numbers from the 10th bit of the third array to the 17th bit of the third array and the numbers from the 10th bit of the fourth array to the 17th bit of the fourth array are subjected to bitwise XOR operation to obtain the last 8 bits of the 16-bit pseudo-random number, namely X8X9X 10 X 11 X 12 X 13 X 14 X 15 In this way, the 16-bit pseudo-random number is X0X1X2X3X4X5X6X7X8X9X 10 X 11 X 12 X 13 X 14 X 15 ,like Figure 3 As shown in part (e) of .
[0110] For example, based on the above embodiment, the 17-bit third array is 10010101010101010, and the 17-bit fourth array is 01001010011010101, and the numbers from the 1st bit of the third array to the 8th bit of the third array are XORed bit by bit with the numbers from the 1st bit of the fourth array to the 8th bit of the fourth array, and the first 8 bits of the 16-bit pseudo-random number are 11011111. The numbers from the 10th bit of the third array to the 17th bit of the third array are XORed bit by bit with the numbers from the 10th bit of the fourth array to the 17th bit of the fourth array, and the last 8 bits of the 16-bit pseudo-random number are 01111111, so the obtained 16-bit pseudo-random number is 1101111101111111.
[0111] As a specific description of another possible implementation method when executing S104, the following is provided:
[0112] The numbers in the N-1-bit third array and the numbers in the N-1-bit fourth array are subjected to bit-by-bit AND operation, OR operation, NOT operation, AND-NON operation, OR-NON operation or XENOR operation to obtain an N-1-bit pseudo-random number.
[0113] As a specific description of another possible implementation method when executing S104, the following is provided:
[0114] Skip the (N+1) / 2th bit of the fourth array and the (N+1) / 2th bit of the third array, and perform bit-by-bit AND operation, bit-by-bit OR operation, bit-by-bit NOT operation, bit-by-bit AND operation, bit-by-bit NOT operation, or bit-by-bit XNOR operation on the numbers in the N-bit third array and the numbers in the N-bit fourth array to obtain an N-1-bit pseudo-random number.
[0115] In the embodiment of the present disclosure, a first array including at least some of the numbers on the prime number positions of the seed and a second array including at least some of the numbers on the non-prime number positions of the seed are determined according to an N-bit binary seed, the first array and the second array are combined into a third array, the numbers in the third array are rotated by at least 1 bit to obtain a fourth array, and the numbers in the third array and the numbers in the fourth array are logically operated bit by bit to generate an N-1-bit pseudo-random number, so that a pseudo-random number in the interval [0, 2 N -1] Uniformly distributed pseudo-random numbers can improve the security of memory chips.
[0116] In some embodiments, Figure 4 A flowchart of another random number generation method provided by an embodiment of the present disclosure is provided. Figure 4 for Figure 2 Based on the embodiment shown, the specific steps of the random number generation method also include:
[0117] S105: Update the seed according to the pseudo-random number.
[0118] Return to execution S101.
[0119] Exemplarily, the generated pseudo-random number is N-1 bits, and the seed is N bits, so a digit can be added to the generated pseudo-random number to obtain a new seed, and the execution of S101 is returned based on the new seed until the reset condition is met.
[0120] A specific description of a possible implementation method when executing S105 is as follows:
[0121] Combine the skipped seed's (N+1) / 2th digit with the pseudo-random number to get a new seed.
[0122] For example, the number at the (N+1) / 2th digit of the skipped seed can be used as the first digit of the new seed, and the N-1-digit pseudo-random number can be used as the second digit to the Nth digit of the new seed to obtain an N-digit new seed, such as Figure 3 For example, if the number at the (N+1) / 2th position of the skipped seed is 0, the generated pseudo-random number is 1101111101111111, then the new seed is 01101111101111111.
[0123] In other implementations, an N-1-bit pseudo-random number can be used as the first bit of the new seed to the N-1-bit new seed, and the number on the skipped seed (N+1) / 2 bit is used as the N-bit new seed to obtain an N-bit new seed. For example, based on the above embodiment, the new seed is 11011111011111110.
[0124] In some other implementations, the number at the (N+1) / 2th digit of the skipped seed may be inserted between any two adjacent digits in the N-1-digit pseudo-random number to obtain an N-digit new seed.
[0125] Figure 5 A schematic diagram of the distribution of pseudo-random numbers provided in an embodiment of the present disclosure is shown in FIG. Figure 5 As shown, the horizontal axis represents the decimal number corresponding to the first (N-1) / 2 bits of the pseudo-random number, and the vertical axis represents the decimal number corresponding to the last (N-1) / 2 bits of the pseudo-random number.
[0126] Generate 4000 pseudo-random numbers based on a 17-bit binary seed, such as Figure 5 As shown in part (a) of , a 17-bit binary seed is used to generate 40,000 pseudo-random numbers, as Figure 5 As shown in part (b) of . Obviously, if Figure 5 As shown in the figure, the points formed by the horizontal and vertical coordinates are evenly distributed in the area where the horizontal coordinate is ≤ 255 and the vertical coordinate is ≤ 255, that is, the 16-bit pseudo-random number is in the interval [0,2 17 -1] uniform distribution.
[0127] The present disclosure also provides a random number generating device. Figure 6 A schematic diagram of a random number generation device provided in an embodiment of the present disclosure is shown in FIG. Figure 6 As shown, the random number generating device comprises:
[0128] The determination module 110 is used to determine a first array and a second array according to an N-bit binary seed; wherein N is a prime number greater than 4, the first array includes numbers on at least some of the prime bits of the seed, and the second array includes numbers on at least some of the non-prime bits of the seed; the first array and the second array are combined into a third array, wherein there is at least one pair of adjacent numbers in the third array that are numbers in the first array and numbers in the second array; and the numbers in the third array are rotated by at least 1 bit to obtain a fourth array.
[0129] The logic operation module 120 is used to perform a bit-by-bit logic operation on the numbers in the third array and the numbers in the fourth array to generate an N-1-bit pseudo-random number.
[0130] In some embodiments, the determination module 110 is further used to divide the number on the first position of the seed into a first initial array; starting from the second position of the seed until the end of the Nth position of the seed and skipping the (N+1) / 2th position of the seed, the numbers on each of the prime positions of the seed are divided into the first initial array, and the numbers on each of the non-prime positions of the seed are divided into a second initial array; the seed prime positions corresponding to each number in the first initial array are arranged in order from large to small to obtain the first array, and the seed non-prime positions corresponding to each number in the second initial array are arranged in order from large to small to obtain the second array.
[0131] In some embodiments, the determination module 110 is further used to place the first number in the second array into the first position of the third array; starting from the second position of the third array until the end of the Nth position of the third array and skipping the (N+1) / 2th position of the third array, the numbers in the first array are placed in each non-prime position of the third array in sequence, and the remaining numbers in the second array are placed in each prime position of the third array in sequence to obtain the N-bit third array.
[0132] In some embodiments, the determination module 110 is further used to rotate and right-shift the numbers in the third array by M bits and skip the (N+1) / 2th bit of the third array to obtain the N-bit fourth array; or, rotate and left-shift the numbers in the third array by M bits and skip the (N+1) / 2th bit of the third array to obtain the N-bit fourth array; wherein M is an integer greater than or equal to 1 and less than (N+1) / 2.
[0133] In some embodiments, the logic operation module 120 is further used to skip the (N+1) / 2th bit of the fourth array and the (N+1) / 2th bit of the third array, and perform a bit-by-bit XOR operation on the N-bit numbers in the third array and the N-bit numbers in the fourth array to obtain the N-1-bit pseudo-random number.
[0134] In some embodiments, the random number generating device further comprises:
[0135] An updating module is used to update the seed according to the pseudo-random number.
[0136] In some embodiments, the update module is further used to combine the skipped number at the (N+1) / 2th position of the seed with the pseudo-random number to obtain a new seed.
[0137] The random number generation device provided in the embodiment of the present disclosure is used to execute the steps provided in any of the above method embodiments, and has the functional modules and beneficial effects corresponding to the method embodiments, which will not be repeated here.
[0138] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure is provided. Figure 7 A block diagram of an exemplary electronic device suitable for implementing the embodiments of the present disclosure is shown. Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0139] like Figure 7 As shown, the electronic device 12 is in the form of a general purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processor 16).
[0140] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0141] The electronic device 12 typically includes a variety of computer system readable media. These media can be any media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0142] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media (commonly referred to as "hard drives"). A disk drive for reading and writing removable non-volatile disks (such as "floppy disks"), and an optical disk drive for reading and writing removable non-volatile optical disks (such as CD-ROMs, DVD-ROMs, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data media interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present disclosure.
[0143] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination thereof may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods of the embodiments described in the embodiments of the present disclosure.
[0144] The processor 16 executes various functional applications and data processing by running at least one program among a plurality of programs stored in the system memory 28 , such as implementing the method embodiment provided in the embodiment of the present disclosure.
[0145] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon, and the computer program implements the steps of the above method embodiment when executed by a processor.
[0146] Any combination of one or more computer-readable media can be used. Computer-readable media can be computer-readable signal media or computer-readable storage media. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this document, computer-readable storage media can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0147] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0148] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0149] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or wide area network (WAN) domain, or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0150] The present disclosure also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the steps of implementing the above method embodiments.
[0151] Unless the context clearly indicates otherwise, the singular form of the words used herein and in the appended claims includes the plural and vice versa. Thus, when referring to the singular, the plural form of the corresponding term is generally included. Similarly, the words "comprise" and "include" are to be interpreted as inclusive rather than exclusive. Likewise, the terms "include" and "or" should be interpreted as inclusive unless such interpretation is expressly prohibited herein. Where the term "example" is used herein, particularly when it is located after a group of terms, the "example" is merely exemplary and illustrative and should not be considered exclusive or comprehensive.
[0152] Further aspects and scopes of adaptability become apparent from the description provided herein. It should be understood that various aspects of the present application can be implemented individually or in combination with one or more other aspects. It should also be understood that the description and specific embodiments herein are intended for purposes of illustration only and are not intended to limit the scope of the present application.
[0153] Several embodiments of the present disclosure are described in detail above, but it is obvious that those skilled in the art can make various modifications and variations to the embodiments of the present disclosure without departing from the spirit and scope of the present disclosure. The protection scope of the present disclosure is defined by the attached claims.
Claims
1. A random number generation method, characterized in that: include: According to an N-bit binary seed, a first array and a second array are determined; wherein N is a prime number greater than 4, the first array includes numbers on at least some of the seed prime bits, the second array includes numbers on at least some of the seed non-prime bits, the seed prime bits are bits corresponding to all prime numbers from 1 to N, and the seed non-prime bits are bits corresponding to all non-prime numbers from 1 to N; Merge the first array and the second array into a third array, wherein there is at least one pair of adjacent numbers in the third array that are a number in the first array and a number in the second array; Rotate the numbers in the third array by at least 1 bit to obtain a fourth array; Performing a bit-by-bit logical operation on the numbers in the third array and the numbers in the fourth array to generate an N-1-bit pseudo-random number.
2. The method according to claim 1, characterized in that Determining the first array and the second array according to the N-bit binary seed includes: Divide the number at the first position of the seed into the first initial array; Starting from the second seed position until the end of the Nth seed position and skipping the (N+1) / 2th seed position, the numbers on the prime number positions of the seeds are divided into the first initial array, and the numbers on the non-prime number positions of the seeds are divided into the second initial array; The seed prime number bits corresponding to each number in the first initial array are arranged in order from large to small to obtain the first array, and the seed non-prime number bits corresponding to each number in the second initial array are arranged in order from large to small to obtain the second array.
3. The method according to claim 2, characterized in that The merging the first array and the second array into a third array comprises: Put the first number in the second array into the first position of the third array; Starting from the 2nd bit of the third array until the end of the Nth bit of the third array and skipping the (N+1) / 2th bit of the third array, the numbers in the first array are sequentially placed into the non-prime bits of the third array, and the remaining numbers in the second array are sequentially placed into the prime bits of the third array to obtain the N-bit third array.
4. The method according to claim 3, characterized in that The step of rotating the numbers in the third array by at least one bit to obtain a fourth array comprises: Rotate and right-shift the numbers in the third array by M bits and skip the (N+1) / 2th bit of the third array to obtain the N-bit fourth array; Alternatively, the numbers in the third array are rotated and left-shifted by M bits and the (N+1) / 2th bit of the third array is skipped to obtain the fourth array of N bits; Here, M is an integer greater than or equal to 1 and less than (N+1) / 2.
5. The method according to claim 3, characterized in that: The step of performing a bit-by-bit logical operation on the numbers in the third array and the numbers in the fourth array to generate an N-1-bit pseudo-random number comprises: Skip the (N+1) / 2th bit of the fourth array and the (N+1) / 2th bit of the third array, perform bit-wise XOR operation on the N-bit numbers in the third array and the N-bit numbers in the fourth array to obtain the N-1-bit pseudo-random number.
6. The method according to claim 2, characterized in that The method further comprises: The seed is updated according to the pseudo-random number, and the process is returned to execute according to the N-bit binary seed to determine the first array and the second array.
7. The method according to claim 6, characterized in that The updating of the seed according to the pseudo-random number comprises: The skipped number at the (N+1) / 2th position of the seed is combined with the pseudo-random number to obtain a new seed.
8. A random number generating device, characterized in that: include: A determination module is used to determine a first array and a second array according to an N-bit binary seed; wherein N is a prime number greater than 4, the first array includes numbers on at least some of the seed prime bits, the second array includes numbers on at least some of the seed non-prime bits, the seed prime bits are bits corresponding to all prime numbers from 1 to N, and the seed non-prime bits are bits corresponding to all non-prime numbers from 1 to N; the first array and the second array are combined into a third array, wherein there is at least one pair of adjacent numbers in the third array that are numbers in the first array and numbers in the second array; the numbers in the third array are rotated by at least 1 bit to obtain a fourth array; The logic operation module is used to perform bit-by-bit logic operation on the numbers in the third array and the numbers in the fourth array to generate an N-1-bit pseudo-random number.
9. An electronic device, characterized in that: include: A processor, wherein the processor is used to execute a computer program stored in a memory, wherein the computer program, when executed by the processor, implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
