Random number generator and method of operating a random number generator

By introducing repetition count test and adaptive scaling test into the random number generator, the noise source circuit is detected and reset, solving the problem of random number predictability caused by the characteristic bias of the noise source circuit, and realizing the generation of high-quality random numbers and enhanced security.

CN123157166APending Publication Date: 2026-11-24ARTERY TECH CO
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510671126.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-23
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

Existing true random number generators are susceptible to the specific characteristics of noise source circuits and the influence of the external environment, which leads to reduced predictability of random numbers and security vulnerabilities.

Method used

By employing a noise source circuit, an N-bit shift register, a repetition count test circuit, and an adaptive scaling test circuit, the control circuit resets the noise source circuit when an error signal is detected by detecting the repetition events and numerical scaling of random bits, thus ensuring the unpredictability of the random number generator.

Benefits of technology

It improves the quality of random numbers generated by the random number generator, enhances its unpredictability, avoids security vulnerabilities, increases hardware utilization, and reduces circuit area.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123157166A_ABST
    Figure CN123157166A_ABST
Patent Text Reader

Abstract

This application discloses a random number generator. The random number generator includes a noise source circuit, an N-bit shift register, a repetition count test circuit, an adaptive proportional test circuit, and a control circuit. The N-bit shift register receives and stores N random bits generated by the noise source circuit. The repetition count test circuit determines whether a repetition event has occurred based on all the random bits stored in the N-bit shift register, and issues an error signal when two repetition events occur within a predetermined time. The adaptive proportional test circuit issues an error signal when the number of random bits with specific values ​​among the multiple random bits generated by the noise source circuit is greater than a first predetermined value or less than a second predetermined value. After the noise source circuit is enabled, if the control circuit receives any error signal, it disables the noise source circuit and then re-enables it.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to a random number generator, and more particularly to a random number generator capable of detecting the quality of random numbers. Background Technology

[0002] Modern encryption techniques often utilize the random numbers generated by a True Random Number Generator (TRNG) to increase the unpredictability of their keys, thereby protecting data security. Generally, a TRNG includes a noise source circuit for generating random bits, and a randomness conditioning circuit for generating random numbers based on those random bits. The noise source circuit typically utilizes the unpredictability of physical phenomena, such as thermal noise or oscillator noise, to generate unpredictable random bits.

[0003] However, if the hardware components of the noise source circuit have specific characteristic biases, it may lead to a higher probability of generating bits with specific values ​​(e.g., a higher likelihood of generating bits with the value 1), making the random numbers generated by the true random number generator more predictable. Furthermore, the noise source circuit may also be affected by external environmental factors (e.g., attacks), resulting in specific characteristic biases. These situations can cause the random numbers to be distorted or lose their unpredictability, thus creating security vulnerabilities in encryption algorithms using these random numbers. Therefore, it is necessary to test the unpredictability of the random bits generated by the noise source circuit to ensure that the generated random numbers possess sufficient randomness and security. Summary of the Invention

[0004] One embodiment of this disclosure provides a random number generator. The random number generator includes a noise source circuit, an N-bit shift register, a repetition count test (RCT) circuit, an adaptive proportion test (APT) circuit, and a control circuit. The noise source circuit continuously generates multiple random bits. The N-bit shift register sequentially receives and stores N random bits, where N is an integer greater than 1. The repetition count test circuit determines whether a repetition event has occurred based on all the random bits stored in the N-bit shift register, and issues a first error signal when two repetition events occur within a predetermined time. The adaptive proportion test circuit issues a second error signal when the number of random bits with a specific value among a predetermined number of consecutively generated random bits is greater than a first predetermined value or less than a second predetermined value. The control circuit enables the noise source circuit in an initial stage, and disables and then re-enables the noise source circuit upon receiving the first or second error signal. In addition, the control circuit is used to make the noise source circuit continuously generate random bits during the processing stage, so that the random number generator generates at least one random number based on the random bits generated by the noise source circuit during the processing stage, and disables the noise source circuit and re-enters the initial stage when the first error signal or the second error signal is received.

[0005] Another embodiment of this disclosure provides a method for operating a random number generator. The random number generator includes a noise source circuit, an N-bit shift register, a repetition count test circuit, and an adaptive scaling test circuit, where N is an integer greater than 1. The method of operating the random number generator includes, in an initial stage, causing the noise source circuit to continuously generate multiple random bits; causing the N-bit shift register to sequentially receive and store N random bits; causing the repetition count test circuit to perform a repetition count test to determine whether a repetition event has occurred based on all the random bits stored in the N-bit shift register; when the repetition count test circuit experiences two repetition events within a predetermined time, it issues a first error signal; causing the adaptive scaling test circuit to perform an adaptive scaling test; and when the number of random bits with a specific value among the consecutively generated predetermined number of random bits is greater than a first predetermined value or less than a second predetermined value, it issues a second error signal; and when the repetition count test circuit issues the first error signal or the adaptive scaling test circuit issues the second error signal, the noise source circuit is disabled and then re-enabled. The operation method of the random number generator further includes a processing stage in which the noise source circuit continuously generates random bits, the repetition test circuit performs the repetition test, the adaptive scaling test circuit performs the adaptive scaling test, and when the first error signal or the second error signal is received, the noise source circuit is disabled and re-enters the initial stage. Attached Figure Description

[0006] Figure 1 This is a schematic diagram of a random number generator according to an embodiment of the present disclosure.

[0007] Figure 2A and Figure 2B This is a flowchart of the operation method of a random number generator according to an embodiment of the present invention.

[0008] Figure 3 This is a schematic diagram of a repetition test circuit according to an embodiment of the present disclosure.

[0009] Figure 4 This is a schematic diagram of an adaptive proportional test circuit according to an embodiment of the present disclosure. Detailed Implementation

[0010] Figure 1 This is a schematic diagram of a random number generator 100 according to an embodiment of the present disclosure. The random number generator 100 includes a noise source circuit 110, an N-bit shift register 120, a repetition count test (RCT) circuit 130, an adaptive proportion test (APT) circuit 140, and a control circuit 150.

[0011] The noise source circuit 110 can utilize the unpredictability of physical phenomena, such as thermal noise or oscillator noise, to generate multiple random bits. For example, the noise source circuit 110 may include a ring oscillator formed by multiple inverters connected in series. Because thermal noise, power supply noise, and other environmental factors in the circuit can cause jitter at signal transition edges, the period of the oscillation signal generated by the ring oscillator is unpredictable. In this case, the noise source circuit 110 can generate random bits by sampling the output of the ring oscillator. However, this disclosure does not limit the noise source circuit 110 to be implemented using a ring oscillator; in some other embodiments, the noise source circuit 110 may also be implemented using other structures.

[0012] The N-bit shift register 120 may contain N serially connected registers and can sequentially receive and store N random bits from the random bits generated by the noise source circuit 110, where N is an integer greater than 1. The repetition count test circuit 130 can determine whether the noise source circuit 110 repeatedly generates bits with the same value (e.g., generating N consecutive 1s or N consecutive 0s) based on the random bits stored in the N-bit shift register 120. If the noise source circuit 110 repeatedly generates bits with the same value, it indicates that the noise source circuit 110 may have a significant characteristic bias or be attacked, resulting in a decrease in its unpredictability. At this time, the repetition count test circuit 130 can issue a signal to warn the system.

[0013] The NIST SP800-90B standard document published by the National Institute of Standards and Technology (NIST) defines the relationship between the number of repetitions N in repetition testing and the entropy and acceptable false-positive probability. Therefore, users can set the value of N according to the entropy and acceptable false-positive probability required for their application.

[0014] Furthermore, each time the noise source circuit 110 continuously generates a predetermined number of random bits (e.g., but not limited to 1024), the adaptive proportional test circuit 140 can detect whether an excessive number of these predetermined number of random bits have the same value. If, among the predetermined number of random bits, the number of random bits with a specific value (e.g., 1 or 0) is greater than a first predetermined value (e.g., but not limited to 589) or less than a second predetermined value (e.g., but not limited to 435), it indicates that the noise source circuit 110 may exhibit a significant characteristic bias or be attacked, resulting in a decrease in its unpredictability. In this case, the adaptive proportional test circuit 140 can issue a signal to warn the system.

[0015] The NIST SP800-90B standard document published by the National Institute of Standards and Technology (NIST) defines the relationship between a predetermined quantity and a first specific value, a second specific value, randomness, and an acceptable false alarm probability in adaptive scaling tests. Therefore, users can set the predetermined quantity, the first specific value, and the second specific value according to the randomness and acceptable false alarm probability required for the application.

[0016] In some embodiments, when the control circuit 150 receives an error signal from the repetition test circuit 130 or the adaptive proportional test circuit 140, it can reset the noise source circuit 110 to attempt to remove the noise source circuit 110 from a state with obvious characteristic bias, and continuously monitor the random bits generated by the noise source circuit 110 to ensure that the random numbers generated by the random number generator 100 have a considerable degree of unpredictability. In some embodiments, the control circuit 150 may be a processor, microprocessor, or controller with general functions; however, this disclosure is not limited thereto. In some other embodiments, the control circuit 150 may also be an application-specific integrated circuit (ASIC) designed according to the application required by the random number generator 100.

[0017] Figure 2A and Figure 2BThis is a flowchart illustrating the operation method of a random number generator 100 according to an embodiment of the present invention. In this embodiment, the operation method M1 can be executed by the control circuit 150. Method M1 divides the operation of the random number generator 100 into two stages: an initial stage ST1 and a processing stage ST2. Upon entering the initial stage ST1, the control circuit 150 enables the noise source circuit 110 in step S111 and initializes the components in the noise source circuit 110, causing the noise source circuit 110 to start generating random bits. Next, in step S112, the control circuit 150 causes the N-bit shift register 120 to sequentially receive and store N random bits, and in step S113, the repetition test circuit 130 performs a repetition test. At this time, the repetition test circuit 130 can determine whether a repetition event has occurred based on the random bits stored in the N-bit shift register 120. Under natural conditions, the noise source circuit 110 has a certain probability of repeatedly generating N random bits with the same value. Therefore, in this embodiment, when the repetition count test circuit 130 determines that a repetition event has occurred for the first time, it will only issue a warning signal and will not directly reset the noise source circuit 110. In some embodiments, the control circuit 150 may convey a warning to the user based on the warning signal, but this disclosure is not limited to this. However, if the repetition count test circuit 130 determines that a second repetition event has occurred within a predetermined time after the first repetition event, it indicates that the frequency of the repetition event is too high, and the noise source circuit 110 may have shown obvious characteristic bias or been attacked. At this time, the repetition count test circuit 130 can issue a first error signal SE1, and the control circuit 150 will choose to continue executing step S116 in step S115, thereby disabling the noise source circuit 110 and clearing the registers and various warning flags in the random number generator 100, so as to enable the noise source circuit again by executing step S111.

[0018] Furthermore, in step S114, the control circuit 150 can also cause the adaptive proportional test circuit 140 to perform an adaptive proportional test to determine whether the proportion of random bits with specific values ​​in the random bits generated by the noise source circuit 110 is too high or too low. For example, when the number of random bits with specific values ​​in a predetermined number of random bits generated by the noise source circuit 110 is greater than a first predetermined value or less than a second predetermined value, it indicates that the noise source circuit 110 may have shown obvious characteristic bias or been attacked. At this time, the adaptive proportional test circuit 140 can issue a second error signal SE2, and the control circuit 150 will select to execute step S116 in step S115, thereby disabling the noise source circuit 110 and clearing the registers and various warning flags in the random number generator 100, so as to re-enable the noise source circuit by executing step S111 again.

[0019] It should be noted that, in Figure 2AThe sequence of steps shown is not intended to limit this disclosure. For example, although in Figure 2A Step S114 follows step S113, but this disclosure is not limited thereto. In some embodiments, steps S113 and S114 can be performed in parallel.

[0020] In this embodiment, if the random bits generated by the noise source circuit 110 fail the repetition test or the adaptive scaling test, the control circuit 150 can repeatedly disable and re-enable the noise source circuit 110, keeping the random number generator 100 in the initial stage ST1. This prevents the use of less unpredictable random bits to generate random numbers, which could lead to security vulnerabilities in subsequent applications (e.g., encryption algorithms). Conversely, if the control circuit 150 does not receive an error signal after the repetition test or the adaptive scaling test, the control circuit 150 can then enable the random number generator 100 to enter the processing stage ST2. In the processing stage ST2, the random number generator 100 can generate random number data based on the random bits generated by the noise source circuit 110 to facilitate subsequent applications.

[0021] In processing stage ST2, control circuit 150 can cause noise source circuit 110 to continuously generate random bits in step S121, and cause N-bit shift register 120 to sequentially receive and store N random bits in step S122, so that repetition test circuit 130 can perform repetition test in step S123. Similarly, repetition test circuit 130 can determine whether a second repetition event has occurred within a predetermined time after the first determination of the repetition event, and issue a first error signal SE1 when a second repetition event occurs within the predetermined time. In step S124, control circuit 150 can cause adaptive scaling test circuit 140 to perform adaptive scaling test, and issue a second error signal SE2 when the number of random bits with a specific value in the predetermined number of random bits generated by noise source circuit 110 is greater than a first predetermined value or less than a second predetermined value. Similar to the initial stage ST1, steps S123 and S124 can also be executed in parallel in processing stage ST2.

[0022] In step S125, when the control circuit 150 receives the first error signal SE1 generated by the repetition test circuit 130 or the second error signal SE2 generated by the adaptive scaling test circuit 140, step S126 is executed to disable the noise source circuit 110 and return the random number generator 100 to the initial stage ST1. In this way, the noise source circuit 110 can be re-enabled and tested again until the random bits it generates pass the repetition test and the adaptive scaling test. Conversely, in the processing stage ST2, if the random bits generated by the noise source circuit 110 pass the repetition test and the adaptive scaling test, the noise source circuit 110 will continue to generate random bits for the random number generator 100 to generate the random number data required for subsequent applications, and the test can be repeated to ensure the quality of the random number data.

[0023] In some embodiments, to further improve the quality of the random number (e.g., increase the randomness) and ensure that the bit length of each random number data meets the requirements of subsequent applications, the random number generator 100 may also include a randomness conditioning circuit 160 and an output circuit 170. In the processing stage ST2, the randomness conditioning circuit 160 can process the random bits generated by the noise source circuit 110 according to a specific randomness enhancement algorithm, thereby generating random number data with higher randomness and the required length, which is then output by the output circuit 170.

[0024] In some embodiments, depending on the algorithm requirements (e.g., CMAC or CBC-MAC with Advanced Encryption Standard (AES) algorithm), the scrambling circuit 160 may need to generate a random number of bits each time. Therefore, the random number generator 100 may also include a buffer storage circuit 180. The buffer storage circuit 180 may include a memory or register and may be implemented, for example, but not limited to, a First-In, First-Out (FIFO) data structure. In this embodiment, the buffer storage circuit 180 may store K random bits, and the scrambling circuit 160 may execute a scrambling enhancement algorithm based on the K random bits stored in the buffer storage circuit 180 to generate at least one random number of bits. Furthermore, in this embodiment, to improve hardware utilization, the buffer storage circuit 180 and the N-bit shift register 120 may cooperate with each other and transmit the K random bits to the buffer storage circuit 180 in a counting manner. In some embodiments, when the control circuit 150 receives an error signal from the repetition test circuit 130 or the adaptive proportional test circuit 140 during the processing stage ST2, it may also clear the data in the buffer storage circuit 180 to prevent the randomness conditioning circuit 160 from using the random bits therein to generate random numbers.

[0025] Figure 3 This is a schematic diagram of a repetition test circuit 130 according to an embodiment of this disclosure. Figure 3 As shown, the repetition test circuit 130 may include logic circuit 132, reset counter 134, and timer 136. When all random bits stored in the N-bit shift register 120 are either 1 or 0 (e.g., a first repetition event occurs), logic circuit 132 may issue a warning signal SW1. Upon receiving the warning signal SW1, reset counter 134 may cause logic circuit 132 to ignore the N random bits originally stored in the N-bit shift register 120 until the N-bit shift register 120 receives another N random bits. Furthermore, upon receiving the warning signal SW1, timer 136 may start counting down a predetermined time. In this case, after the warning signal SW1 is issued and the N-bit shift register 120 has received another N random bits, when all random bits stored in the N-bit shift register 120 are again either 1 or 0 (e.g., a second repetition event occurs), and timer 136 has not yet returned to zero, it indicates that the random bits generated by the noise source circuit 110 have experienced two repetition events within the predetermined time. At this time, logic circuit 132 may further issue a first error signal SE1. In some embodiments, the designer can determine the length of the predetermined countdown time for the timer 136 based on the rate at which the noise source circuit 110 generates random bits. For example, if, under ideal conditions, a repetition event may occur every million random bits generated by the noise source circuit 110, the designer can set the predetermined time to the time it takes for the noise source circuit 110 to generate one million random bits. In this case, if the noise source circuit 110 experiences more than one repetition event within the predetermined time, it indicates that the noise source circuit 110 may exhibit a specific characteristic bias, and the repetition count test circuit 130 can issue a first error signal SE1 to reset the noise source circuit 110.

[0026] In this embodiment, the N-bit shift register 120 may contain N unit registers 121 to 12N, and the N unit registers 121 to 12N and the sampling circuit of the noise source circuit 110 can receive the same clock signal CLK. Therefore, whenever the noise source circuit 110 generates a random bit, the N unit registers 121 to 12N will store a new random bit. In addition, the reset counter 134 and the timer 136 can also receive the same clock signal CLK as the N-bit shift register 120 and operate according to the clock signal CLK to synchronize the operation of each circuit.

[0027] Logic circuit 132 includes a first gate AND1, a second gate AND2, an OR gate OR1, and a third gate AND3. The first gate AND1 has N+1 inputs and one output. N inputs of the first gate AND1 can be coupled to the positive data input of a corresponding unit register among the N unit registers 121 to 12N of the N-bit shift register 120. For example, the first input of the first gate AND1 can be coupled to the positive data input of unit register 121, the second input of the first gate AND1 can be coupled to the positive data input of unit register 122, and the Nth input of the first gate AND1 can be coupled to the positive data input of unit register 12N. Furthermore, the N+1th input of the first gate AND1 can be coupled to a reset counter 134.

[0028] The second gate AND2 has N+1 inputs and one output. N inputs of the second gate AND2 can be coupled to the negative data terminal of a corresponding unit register from N unit registers 121 to 12N. For example, the first input of the second gate AND2 can be coupled to the negative data terminal of unit register 121, the second input of the second gate AND2 can be coupled to the negative data terminal of unit register 122, and the Nth input of the second gate AND2 can be coupled to the negative data terminal of unit register 12N. Furthermore, the N+1th input of the second gate AND2 can be coupled to the reset counter 134.

[0029] OR gate OR1 has a first input, a second input, and an output. The first input of OR gate OR1 can be coupled to the output of first AND gate AND1, and the second input of OR gate OR1 can be coupled to the output of second AND gate AND2. The output of OR gate OR1 can output a warning signal SW1. Before the repetition count test circuit 130 detects any repetition event, the output of reset counter 134 can be preset to "1" (i.e., logic high level). Therefore, when the random bit values ​​stored in N unit registers 121 to 12N are all "1", first AND gate AND1 will output a high level representing the value "1", and OR gate OR1 will also output a high level warning signal SW1. Similarly, when the random bit values ​​stored in N unit registers 121 to 12N are all "0", second AND gate AND2 will output a high level representing the value "1", and OR gate OR1 will also output a high level warning signal SW1.

[0030] When the repetition test circuit 130 determines that a repetition event has occurred and issues a warning signal SW1, the timer 136 will begin counting down for a predetermined time. In this embodiment, the timer 136 can continuously output a high-level Bollinger signal SB1 (representing the value "1") during the countdown, and output a low-level Bollinger signal (representing the value "0") during the countdown ends or during periods when no countdown is being performed. The reset counter 134 will continuously output N low-level signals representing the value "0" to cause the first gate, AND1, the second gate, and AND2 of the logic circuit 132 to ignore the N random bits originally stored in the N-bit shift register 120, until the N-bit shift register 120 receives another N random bits. In this way, after issuing the warning signal SW1 and the N-bit shift register 120 receives another N random bits, when all the random bits stored in the N-bit shift register 120 are again 1 or all are 0, the logic circuit 132 can issue the warning signal SW1 again.

[0031] In this embodiment, the third gate AND3 has a first input terminal, a second input terminal, and an output terminal. The first input terminal of the third gate AND3 is coupled to the output terminal of the OR gate OR1, and the second input terminal of the third gate AND3 can receive the Bollinger signal SB1. In this case, when the repetition count test circuit 130 determines that a repetition event has occurred and issues a warning signal SW1, if the predetermined time has not yet returned to zero, the timer 136 will output a high-level Bollinger signal SB1 (representing the value "1"), so that the output terminal of the third gate AND3 can issue a first error signal SE1 accordingly. Conversely, if the predetermined time has returned to zero, the timer 136 will output a low-level Bollinger signal SB1 (representing the value "0"), and the output terminal of the third gate AND3 will not issue the first error signal SE1.

[0032] Figure 4 This is a schematic diagram of an adaptive scaling test circuit 140 according to an embodiment of the present disclosure. The adaptive scaling test circuit 140 includes a P-shift register 141, an accumulator 142, a counter 143, an accumulation register 144, a comparator 145, an adder 146, and a subtractor 147. In this embodiment, the adaptive scaling test circuit 140 can accumulate a predetermined number of random bits generated by the noise source circuit 110. When the total value of the accumulated random bits is greater than a first predetermined value or less than a second predetermined value, it indicates that the number of random bits with the value "1" in the random bits generated by the noise source circuit 110 exceeds a certain proportion or is less than a certain proportion. In this case, the noise source circuit 110 may have a specific characteristic bias. Therefore, the adaptive scaling test circuit 140 will issue a second error signal SE2 to re-enable the noise source circuit 110, thereby attempting to escape the state with a significant characteristic bias.

[0033] In this embodiment, to reduce the hardware storage space required by the adaptive scaling test circuit 140 and the complexity of the adder, the adaptive scaling test circuit 140 can accumulate random bits in batches. Specifically, the predetermined number of random bits to be summed by the adaptive scaling test circuit 140 can be Q, and Q is equal to P and 2. (M-1) The product of Q, P, and M, where Q, P, and M are positive integers. In this case, accumulator 142 can continuously accumulate the random bits generated by noise source circuit 110, while counter 143 can increment by one each time noise source circuit 110 generates a random bit, and when accumulator 142 receives 2... (M-1) When there are 1 random bits, output the counting signal SC1 so that the accumulator 142 will be counted by 2 (M-1) The latest partial accumulated value A1 generated by accumulating 2 random bits is output to the P-shift register 141, while the counter 143 can return to zero after outputting the counting signal SC1. In this embodiment, in order to store 2 (M-1) The maximum accumulated value of random bits, P-bit shift register 141 can contain P M-bit registers 1411 to 141P, so each M-bit register 1411 to 141P can store a 2 (M-1) The accumulated value of random bits.

[0034] Furthermore, the accumulator register 144 can temporarily store the total accumulated value A2 of a predetermined number of Q random bits (e.g., the sum of the accumulated values ​​of all random bits currently stored in the shift register 141). In this case, when the counter 143 outputs the counting signal SC1, the accumulator 142 will count the newly received 2... (M-1) When the latest partial accumulated value A1 of random bits is transmitted to shift register 141 (P bits), adder 146 adds the latest partial accumulated value A1 from accumulator 142 to the total accumulated value A2 stored in accumulator register 144 to generate an intermediate accumulated value A3. At this time, the intermediate accumulated value A3 is equivalent to the most recent (P+1)×2 bits. (M-1) The subtractor 147 accumulates the value of 10 random bits, so it subtracts the previous accumulated value A4 stored in the last M-bit register 141P in the P-shift register 141 from the intermediate accumulated value A3 to generate the updated accumulated value A5, and then stores the updated accumulated value A5 in the accumulated register 144. In this way, the updated accumulated value A5 is the latest P×2. (M-1) The comparator 145 accumulates the value of K random bits, and compares the updated accumulated value A5 with the first predetermined value, i.e. the second predetermined value. If the updated accumulated value A5 is greater than the first predetermined value or less than the second predetermined value, the second error signal SE2 can be output.

[0035] In some embodiments, N may be greater than 2. (M-1) And K can be 2(M-1) The value must be an integer multiple of the value. In this way, the N-bit shift register 120 can also receive the counting signal SC1 generated by the counter 143, and use it to count every 2 bits stored. (M-1) When there are 2 random bits, take 2 of them. (M-1) 2 random bits (e.g., the first 2 received) (M-1) K random bits are output to the buffer storage circuit 180. In this case, after the buffer storage circuit 180 receives K random bits from the N-shift register 120 in several batches, it can pass the K random bits to the scrambling circuit 160, so that the scrambling circuit 160 can generate a random number. For example, N can be 40, M can be 6, and K can be 128. Therefore, when the counter 143 stores 32 random bits in the N-shift register 120, it outputs 32 random bits to the buffer storage circuit 180. In this case, the buffer storage circuit 180 will accumulate and store 128 random bits after receiving four batches of random bits from the N-shift register 120, thereby providing the scrambling circuit 160 with a random number to generate a random number. In other words, the repetition test circuit 130 and the adaptive proportional test circuit 140 in the random number generator 100 can share some circuitry, thus improving the overall hardware utilization.

[0036] Furthermore, in some embodiments, when the repetition count test circuit 130 determines that a repetition event has occurred, it indicates that the batch of random bits generated by the noise source circuit 110 may no longer have sufficient unpredictability, and therefore, the use of these random bits to generate random data should be avoided. In this case, when the adaptive scaling test circuit 140 receives the warning signal SW1 issued by the repetition count test circuit 130 when it determines that a repetition event has occurred, the adaptive scaling test circuit 140 can also be reset, including setting the accumulator 142 and counter 143 therein to zero, thereby performing adaptive scaling tests based on the newly generated random bits.

[0037] In summary, the random number generator and the method for operating the random number generator provided in the embodiments of this disclosure can perform repetition test and adaptive scaling test on the noise source circuit, thereby enabling the random number generator to operate in the initial or processing stage. This allows the noise source circuit to be reset to attempt to escape this state when it may exhibit significant characteristic bias or be attacked, avoiding the use of random bits with low unpredictability and improving the random number quality of the random number generator. Furthermore, during the repetition test, the random number generator and the method for operating the random number generator disclosed in this disclosure can only issue an error signal when two repetition events occur within a predetermined time, avoiding unnecessary restarts of the noise source circuit that would reduce the throughput of the random number generator. Moreover, the repetition test circuit and the adaptive scaling test circuit provided in the embodiments of this disclosure can share some circuitry, thus improving the overall hardware utilization of the random number generator and reducing the required circuit area.

[0038] Symbol Explanation

[0039] 100: Random Number Generator

[0040] 110: Noise source circuit

[0041] 120:N bit shift register

[0042] 130: Repetition Count Test Circuit

[0043] 140: Adaptive Proportional Test Circuit

[0044] 150: Control Circuit

[0045] 160: Disorder Conditioning Circuit

[0046] 170: Output Circuit

[0047] 180: Buffer storage circuit

[0048] SE1: First error signal

[0049] SE2: Second error signal

[0050] ST1: Initial Stage

[0051] ST2: Processing Stage

[0052] S111, S112, S113, S114, S115, S116: Steps

[0053] S121, S122, S123, S124, S125, S126: Steps

[0054] 121 to 12N: Unit Registers

[0055] CLK: Clock signal

[0056] 132: Logic Circuits

[0057] 134: Reset Counter

[0058] 136: Timer

[0059] SW1: Warning signal

[0060] AND1, AND2, AND3: and gates

[0061] OR1: OR gate

[0062] SB1: Boolean signal

[0063] 141: P bit shift register

[0064] 1411 to 141P: M-bit register

[0065] 142: Accumulator 142

[0066] 143: Counter

[0067] 144: Accumulator Register

[0068] 145: Comparator

[0069] 146: Adder

[0070] 147: Subtractor

[0071] A1: Latest partial cumulative value

[0072] A2: Overall Cumulative Value

[0073] A3: Intermediate Accumulated Value

[0074] A4: Previous partial accumulated value

[0075] A5: Update the accumulated value

Claims

1. A random number generator, comprising: A noise source circuit used to continuously generate multiple random bits; An N-bit shift register is used to sequentially receive and store N random bits from these random bits, where N is an integer greater than 1; A repetition test circuit is used to determine whether a repetition event has occurred based on all the random bits stored in the N-bit shift register, and to issue a first error signal when two repetition events occur within a predetermined time. An adaptive proportional test circuit is used to issue a second error signal when the number of random bits with a specific value in a predetermined number of consecutively generated random bits is greater than a first predetermined value or less than a second predetermined value; and A control circuit for use in an initial stage: Enable the noise source circuit; and When the first error signal or the second error signal is received, the noise source circuit is disabled and then re-enabled; and In the first processing stage: This causes the noise source circuit to continuously generate random bits; The random number generator generates at least one random number based on the random bits generated by the noise source circuit during the processing stage; and When the first error signal or the second error signal is received, the noise source circuit is disabled and re-enters the initial stage.

2. The random number generator as claimed in claim 1, wherein the control circuit is further configured to, in the initial stage, cause the random number generator to enter the processing stage when the first error signal or the second error signal is not received within the predetermined time.

3. The random number generator as described in claim 2, further comprising: A buffer storage circuit is used to store K random bits transmitted from the N-bit shift register in several steps, where K is an integer greater than N; A scrambling conditioning circuit is used to execute a scrambling enhancement algorithm based on the K random bits to generate the at least one random number of data; and An output circuit is used to output the at least one random number data during the processing stage.

4. The random number generator as claimed in claim 3, wherein the control circuit is further configured to clear the data in the buffer storage circuit upon receiving the first error signal or the second error signal.

5. The random number generator as claimed in claim 3, wherein the adaptive proportional test circuit comprises: A P-bit shift register contains P M-bit registers, where P and M are positive integers, and 2... M-1 The product of P and P equals the predetermined quantity; An accumulator is used to accumulate the random bits generated by the noise source circuit; and A counter is used to count the number of 2s each time the accumulator receives a value of 2. M-1 When there are 2 random bits, a counting signal is output so that the accumulator will be controlled by the 2 M-1 The latest partial accumulated value, which is the sum of the random bits, is output to the P-shift register. The counter is also used to reset to zero after the count signal is output.

6. The random number generator of claim 5, wherein the adaptive scaling test circuit comprises: An accumulator register is used to temporarily store the total accumulated value of the predetermined number of random bits; An adder is used to add the latest partial accumulated value to the overall accumulated value to produce an intermediate accumulated value; A subtractor is used to subtract a previously accumulated value stored in the last M-bit register of the P-shift register from the intermediate accumulated value to produce an updated accumulated value; and A comparator is used to output the second error signal when the updated accumulated value is greater than the first predetermined value or less than the second predetermined value.

7. The random number generator as claimed in claim 5, wherein when the adaptive proportional test circuit receives a warning signal issued by the repetition count test circuit when it determines that the repetition event has occurred, the adaptive proportional test circuit is reset.

8. The random number generator as described in claim 5, wherein K is 2. M-1 Integer multiples of N, where N is greater than 2 M-1 Furthermore, the N-bit shift register is also used to receive the counting signal, and upon receiving the counting signal, two bits of the N-bit shift register are shifted... M-1 A random bit is output to the buffer storage circuit.

9. The random number generator of claim 1, wherein the repetition count test circuit comprises: A logic circuit is used to issue a warning signal when all random bits stored in the N-bit shift register are either 1 or 0. A reset counter is used to cause the logic circuit to ignore the previously stored N random bits when the warning signal is received until the N-bit shift register receives another N random bits; and A timer is used to start counting down a predetermined time when the warning signal is received; The logic circuit is further configured to issue the first error signal after the warning signal is issued and the N-bit shift register receives the other N random bits, when all the random bits stored in the N-bit shift register are either 1 or 0 again, and the timer has not yet returned to zero.

10. The random number generator of claim 9, wherein the N-bit shift register comprises N unit registers, and the logic circuit comprises: A first gate has N+1 input terminals respectively coupled to a positive data terminal of a corresponding unit register in the N unit registers and the reset counter, and an output terminal; A second gate, having N+1 input terminals respectively coupled to a negative data terminal of a corresponding unit register in one of the N unit registers and the reset counter, and an output terminal; and A gate has a first input terminal coupled to the output terminal of the first gate, a second input terminal coupled to the output terminal of the second gate, and an output terminal for outputting the warning signal.

11. The random number generator of claim 10, wherein the reset counter outputs N zeros upon receiving the warning signal so that the logic circuit ignores the previously stored N random bits until the N shift register receives another N random bits.

12. The random number generator of claim 11, wherein the logic circuit is further configured to issue the warning signal again after the warning signal is issued and the N-bit shift register receives the other N random bits, when all the random bits stored in the N-bit shift register are again 1 or all are 0.

13. The random number generator of claim 12, wherein the logic circuit further includes a third OR gate having a first input terminal coupled to the output terminal of the OR gate, a second input terminal for receiving the Boolean signal, and an output terminal for outputting the first error signal.

14. A method for operating a random number generator, the random number generator comprising a noise source circuit, an N-bit shift register, a repetition count test circuit, and an adaptive scaling test circuit, wherein N is an integer greater than 1, the method comprising: In the initial stage: This causes the noise source circuit to continuously generate multiple random bits; The N-bit shift register receives and stores N random bits from these random bits in sequence. The repetition test circuit performs a repetition test to determine whether a repetition event has occurred based on all the random bits stored in the N-bit shift register. When the repetition test circuit experiences two repetition events within a predetermined time, it issues a first error signal. The adaptive proportional test circuit performs an adaptive proportional test to issue a second error signal when the number of random bits with a specific value in a predetermined number of consecutively generated random bits is greater than a first predetermined value or less than a second predetermined value; and When the repetition count test circuit issues the first error signal or the adaptive proportional test circuit issues the second error signal, the noise source circuit is disabled and then re-enabled; and In the first processing stage: This causes the noise source circuit to continuously generate random bits; The circuit for testing the number of repetitions shall perform the test for the number of repetitions. The adaptive proportional test circuit is then used to perform the adaptive proportional test. and When the first error signal or the second error signal is received, the noise source circuit is disabled and re-enters the initial stage.

15. The method of claim 14, wherein the method further includes, in the initial stage, causing the random number generator to enter the processing stage if neither the first error signal nor the second error signal is received within the predetermined time.

16. The method of claim 14, wherein the method further includes, in the processing phase, generating at least one random number based on random bits generated by the noise source circuit when neither the first error signal nor the second error signal is received within the predetermined time.

17. The method of claim 16, wherein the random number generator further comprises a buffer storage circuit and a randomness conditioning circuit, and in the processing stage, when no first error signal or second error signal is received within the predetermined time, the step of generating the at least one random number data based on the random bits generated by the noise source circuit comprises: The buffer storage circuit stores K random bits transmitted from the N-bit shift register in multiple steps. The scrambling circuit executes a scrambling algorithm based on the K random bits to generate the at least one random number of data; and Output at least one random number.

18. The method of claim 14, wherein the adaptive proportional test circuit comprises a P-bit shift register, an accumulator, a counter, and an accumulation register, the P-bit shift register comprising P M-bit registers, wherein P and M are positive integers, and 2 M-1 The product of P and P equals the predetermined quantity, and the method includes: This accumulates the random bits generated by the noise source circuit; Make the counter so that each time the accumulator receives 2 M-1 When there are 2 random bits, a counting signal is output so that the accumulator will be controlled by the 2 M-1 The latest partial accumulated value, which is formed by accumulating 1 random bits, is output to the P-bit shift register; The counter is reset to zero after the count signal is output; Add the latest partial accumulated value to the overall accumulated value and subtract a previous partial accumulated value stored in the last M-bit register in the P-shift register to produce an updated accumulated value; The adaptive proportional test circuit outputs the second error signal when the updated cumulative value is greater than the first predetermined value or less than the second predetermined value.

19. The method of claim 14, wherein the step of causing the repetition test circuit to perform the repetition test to determine whether the repetition event has occurred based on all the random bits stored in the N-bit shift register comprises: A warning signal is issued when all random bits stored in the N-bit shift register are either 1 or 0.

20. The method of claim 19, wherein the repetition test circuit includes a timer, and the step of issuing the first error signal when the repetition test circuit experiences two repetition events within the predetermined time period comprises: Upon receiving the warning signal, the timer begins counting down the predetermined time; and Upon receiving the warning signal, and after the N-bit shift register has received another N random bits, the first error signal is issued when all the random bits stored in the N-bit shift register are either 1 or 0 again, and the timer has not yet returned to zero.