How to get truly random data, not random data fed into a PRNG seed like CSRNG’s do?

As you know, “truly random” means each of the bits is independent of everything else as well as uniformly distributed. However, this ideal is hard, if not impossible, to achieve in practice. In general, the closest way to get “truly random data” in practice is to gather hard-to-guess bits from nondeterministic sources, then condense those bits into a random block of data.

There are many issues involved with getting this close to “truly random data”, including the following:

  1. The sources must be nondeterministic, that is, their output cannot be determined by their inputs. Examples of nondeterministic sources include timings of input devices; thermal noise; and the noise registered by microphone and camera outputs.
  2. The sources’ output must be hard to guess. This is more formally known as entropy, such as 32 bits of entropy per 64 bits of output. However, measuring entropy is far from trivial. If you need 1 MB (8 million bits) of truly random data, you need to have data with at least 8 million bits of entropy (which in practice will be many times more than 1 MB long depending on the sources), then condense the data somehow into 1 MB of data while preserving that entropy.
  3. The sources must be independent of each other.
  4. There should be two or more independent sources. This is because it’s impossible to extract full randomness from just one source (see McInnes and Pinkas 1990). On the other hand, extracting randomness from three or more independent sources is relatively trivial, but there is still a matter of choosing an appropriate randomness extractor, and a survey of randomness extractors would be beyond the scope of this answer.

In general, for random number generation purposes, the more sources available, the better.

REFERENCES:

  • McInnes, J. L., & Pinkas, B. (1990, August). On the impossibility of private key cryptography with weakly random keys. In Conference on the Theory and Application of Cryptography (pp. 421-435).

Leave a Comment