Monday, 21 January 2013

True RNG?

I was inspired the other day by a post on

I had all the bits lying around so I thought I'd have a go as well.  I have wanted to build a high quality entropy source to put on my network for a long time now (actually it was the main reason I took up electronics as a hobby a couple of years ago :)

I'm using a servo with an egg-timer hot-glued to it - swingint it through 180 degrees is really easy and fast and requires no bearings.  The low-precision nature of the cheap servo will only help the randomness over time.

The laser is a £5 1mW purple laser pointer I scored off Ebay last year (it's the same one I was using to power an ATTiny5 microcontroller:

I'm using the laser to illuminate the white sand grains as they fall through the egg timer's lower bulb.  The sensor is mounted on the servo housing and is not in the direct "firing line" of the laser - this is to allow a much wider range of light levels hitting the sensor.

The sensor is an LED connected directly between GND and the base of a 2n3904 NPN transistor to gain up the signal a little before it's sampled by the arduino's ADC pin.

It seems to work very well indeed, values between 200 and 1024 (the ADC's maximum) are frequently attained.  The oscilloscope suggests a very chaotic signal but will the data generated by this simplistic system actually be of any use as a viable entropy source?

This remains to be seen, I'll log a few hundred megabytes of data (assuming the servo doesn't wear out) and use the "Diehard" randomness test kit to measure just how good this system is.

It's not secure in it's present state of course, all you'd have to do to force it to output 1111111111111111...... forever would be to leave it in the sunshine!  I'll have to build a light-tight enclosure for it before I use it properly. :)

Have a look at the video and then skip on over to PART 2...

1 comment:

  1. As clever as this is, I doubt you'll be able to attain a High Quality Stream this way.

    Your best bet would be to setup up one or more entropy pools which accumulates all output, then use that to seed a Secure RNG.

    There is always noise present in the real world. The problem with a Hardware RNG is separating the random noise from the ordered motion. An entropy pool allows you to overcome this problem, by allowing the noise to build up, so that as long as you have a source that you know is subject to random noise, and your able to observe and measure that noise, you'll always have a high quality, true RNG.

    Keep us informed if you have any improvements!