Reducing bias in hardware generated random numbers
View Patent ↗A random number generator of a processor comprises a whitener for reducing the bias in random numbers generated by the random number generator. The whitener receives a random number of a first length read by an array of latches with inputs from an array of oscillators. The whitener dynamically creates a mask of the first length based on a parity of at least one previous random number read from the array of latches during at least one cycle prior to reading the random number. The whitener applies a compare operation between the random number and the mask to generate a whitened random number of the first length, with reduced bias, without reducing randomness.
1. A method for managing a random number generator, comprising:
receiving, by a whitener executing on a processor, a random number of a first length read by a plurality of latches with inputs from a plurality of oscillators;
dynamically creating, by the whitener, a mask of the first length based on a parity of at least one previous random number read from the plurality of latches during at least one cycle prior to reading the random number; and
applying, by the whitener, a compare operation between the random number and the mask to generate a whitened random number of the first length.
2. The method of claim 1 , further comprising:
providing the plurality of oscillators of a same number as the first length, wherein each oscillator operates at a different frequency and wherein the operating frequencies of each oscillator are not harmonically related; and
providing the plurality of latches of a same number as the first length, wherein each latch receives an input from a separate oscillator, receives a sample signal, and produces an output signal of the oscillator in response to the sample signal.
3. The method of claim 1 , further comprising:
dynamically creating the mask comprising a base mask of the first length by initially setting the base mask to a random number;
left shifting the plurality of bits of the base mask;
calculating the parity bit of said at least one previous random number; and
inserting the parity bit into the last position of the plurality of bits of the base mask.
4. The method of claim 3 , further comprising:
inverting every other bit of the plurality of bits of the base mask.
5. The method of claim 4 , further comprising:
inverting the parity bit for every other iteration; and
inserting the parity bit into the last position of the plurality of bits of the base mask.
6. The method of claim 4 , further comprising:
setting an applied mask to the base mask;
flipping the plurality of bits of the applied mask every other iteration; and
applying the applied mask as the mask in the compare operation between the random number and the mask.
7. The method of claim 1 , further comprising:
reading a separate binary data output from each of the plurality of latches at a rate of one sixty-fifth of the sample rate applied to sample the random number;
calculating a separate parity value of each separate binary data output for each separate binary data output read at the rate of one sixty-fifth of the sample rate;
setting a next empty bit of the mask to each separate parity value for each separate parity value calculated; and
responsive to completing a sixty-fourth read, applying the mask.
8. The method of claim 1 , wherein applying, by the whitener, a compare operation between the random number and the mask to generate a whitened random number of the first length further comprises:
applying, by the whitener, the compare operation comprising at least one of an exclusive or operation and an exclusive nor operation.