Open-Source Random Numbers

Whether it’s a game of D&D or encrypting top-secret information, a wide array of methods are available for generating the needed random numbers with high enough entropy for their use case. For a tabletop game this might be a single die but for more sensitive applications a more robust method of generating random numbers is needed. Programmers might reach for a rand() function of some sort, but these pseudorandom numbers don’t cut the mustard for encryption. For that you’ll need a true random number generator (RNG), and this open-source hardware RNG uses one of the better methods we’ve seen.

The device, called RAVA, is based on a property found in many electronic devices called avalanche breakdown. Avalanche breakdown occurs when a high voltage (in this case approximately 25V) is applied in the reverse bias direction, with this device using a pair of Zener diodes. When this high voltage is applied, an “avalanche” of electrons occurs which allows the diodes conduct in the opposite direction that they would when they are forward biased. This isn’t a constant current flow, though; there are slight variations over time which can be amplified and used as the random number generator. The noise is amplified over a series of op amps and then fed to an ATmega32U4 microcontroller which can provide the user with 136.0 Kbit/s of random data.

Unlike other random number generators, this device is based on a method generally accepted to be truly random. Not only that, but since it’s based on discrete hardware it can be accessed directly for monitoring and replacement in case of faults, unlike other methods which are more “black boxes” and are more opaque in their processes which are thus harder to audit. We also appreciate it’s open-source nature as well, and for some more information on it be sure to check out the paper on it in IEEE. If you’re looking for something to generate random numbers but will also bring some extra flair to the next game night, take a look at this radioactive dice replacement.

23 thoughts on “Open-Source Random Numbers

  1. @Bryan Cockfield said: “Whether it’s a game of D&D or encrypting top-secret information, a wide array of methods are available for generating the needed random numbers with high enough entropy for their use case. For a tabletop game this might be a single die but for more sensitive applications a more robust method of generating random numbers is needed. Programmers might reach for a rand() function of some sort, but these pseudorandom numbers don’t cut the mustard for encryption. For that you’ll need a true random number generator (RNG)…”

    A reliable pedant said: “RAVA is a True Random Number Generator (TRNG) – not an RNG.”

      1. I could be wrong, it has been a while since I last looked at diehard tests, I think that you need about 1GiB to 10GiB of random goodness for a full set of tests. At 136.0 Kbit/s that would take about 749 days to around 21 years for one RAVA device to generate.

        1. I get wildly different numbers to you. 1Gigabyte is 8.59 Million kilobits. At 136kilobits per second that takes 63162 seconds. So 1GiB of random data from this device takes less than 18 hours, but 10GiB takes just over a week.

          1. You are totally right I must have multiplied by an extra 1024 and screwed up my calculations.

            For 1 GiB I get approximately 17.5 hours, so for 10 GIB that would be about 7.3 days.

  2. Hardware randomness rules. The deep dive i did on PRNGs ultimately made me more interested in circuits and other novel approsches to true random. However the cyclic nature of PRNG is rather appealing, I see the chain of a state space as something like a musical part.

    1. One advantage to PRNG is that you can rerun a deterministic program with the same seed it’ll generate the same sequence of random numbers.

      This is an advantage in, for example, debugging where you want to reproduce the sequence of events exactly.

  3. no need to go to a separate board – you can use a esp32 to generate real random numbers (based on the noise of the WiFi / Bluetooth RF subsystem – so genuinely random) that would be goo enough for any use I can think of..

    I have one permanently set up that spits random bytes up the usb when I plug it in, in 0x format that I can use in anything.. Great for password creation…

      1. It’s hard to test for randomness, but the esp32 one went through quite a few of the available tests, and was the subject of a number of papers.. I can’t see why anyone would need more random than that – ie it was certainly beyond what almost anyone would need for either simulation or encryption..

  4. I think it’s a poor design.

    Everything depends on the quality of USB power provided by host.

    And if You ever delt with it You know it’s a crap and will vary a lot.

    And everything in the design will vary (can be modulated by changing 5V from USB host).
    2.5 Vref will change (TL431 could fix it), “high voltage” BV will change. This is far from random.

    1. Yeah, and probably could be affected from far away using high power RF source. Of course this is irrelevant for the hobbyist purposes this is meant for, but for those PC built-in randomness sources are good enough.

    2. That’s why a differential design is used: the avalanche noise from two similar Zener diodes is compared (subtracted) to generate random pulses. This ensures that any variations in the circuit affect both channels equally. Studies have shown that this design also mitigates electromagnetic noise; see Section IV.B of the IEEE publication for details.

    3. Indeed, I think V5 would be better to have an LDO on it to knock it down to, say, 4.5V.
      Also the bias voltage for the zeners has a massive decoupling (Cbb) – feeding the zeners themselves. This probably reduces the bandwidth of the noise significantly. Better off adding some inductors in series, to increase the noise frequency distribution, then you can get more bits per second out of it.

      1. Thanks for the helpful comments. Regarding the bandwidth, I’d like to understand how the circuit would look after your proposed changes. Do you mean removing Cbb or keeping it? Also, where should the inductors be placed, and what values do you recommend? Currently, the CMPs operate at ~3 MHz. With your suggestion, can this be improved?

  5. Very nice I still have my truerng V2 somewhere but randomness is much more available these days.

    The easiest true RNG I ever built was a webcam and a smoke detectors ionisation source. It seemed to work nicely for several years before I ditched it. It’s supply was fairly limited and could be patchy(only emitted when it was certain there was multiple events).

    I am sure it’s been featured in had before.

  6. I’ve built something quite similar, using an MC34063 to boost the USB voltage to ~15V for 12V zeners. I used 16 of them and 8 comparators, so the µC can fetch a whole byte at once and spit it out via RS232-to-USB. It manages around 70 kB/s at 921600 baud (that’s kilobytes, not kilobit).

  7. You could use a bit of radioactive material to generate random numbers

    Get an old smoke detector and a Geiger tube, or solar panel, and use the radioactive source as a way to generate random noise, which would be a seed for a random number generator

    Use like 128bits and get a really large and random number

    Then Use that as a seed for a keypair

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.