Since we had an Arduino lying around, we felt that it was incumbent on us to see if entropy condensation is really as simple as we think that it is. We set out to generate unbiased true random numbers using just the Arduino (nano). This is our set up:-

Proof of Concept 2 - The Flawed Condenser/nano-trng.jpg

There are no external hardware components other than the strong cryptographic foam substrate (which also stops the pins getting bent). We were successful, finally creating this image of true randomness condensed out of thin air and electromagnetic noise:-

Proof of Concept 2 - The Flawed Condenser/arduinoImage.png

with this histogram:-

Proof of Concept 2 - The Flawed Condenser/histogram.png

and the following ent output validating it's randomness. It may strike some as a suspicious caveat or proviso, but clearly an allowance has to be made for the small 65K sample size as it's typical to use a much larger test file for such a validation:-

Entropy = 7.997404 bits per byte.

Optimum compression would reduce the size
of this 65536 byte file by 0 percent.

Chi square distribution for 65536 samples is 236.99, and randomly
would exceed this value 78.44 percent of the times.

Arithmetic mean value of data bytes is 127.3377 (127.5 = random).
Monte Carlo value for Pi is 3.153268632 (error 0.37 percent).
Serial correlation coefficient is -0.001966 (totally uncorrelated = 0.0)

Pi and Chi both suggest statistically significant randomness. Whilst such statistical testing is fine in principle, true validation only comes from a visual inspection of the source code and an understanding of how the random numbers are actually produced. Any loop's counter passed through a cryptographic hash function like SHA1 will produce output that is statistically verifiable as random. That just confirms the efficient design of such functions. It also makes random number generators extremely susceptible to the Garbage in Garbage Out idiom, or what we specifically call the Cryptographic Function Extraction Fallacy (CFEF). We believe that even the venerable /dev/random might fall foul of this.

This image took 71 minutes to generate at a rate of 123 bits /s which is not quite as fast as a photon counter or beam splitter. But hey! This generation rate is somewhat throttled by the serial transfer to the PC at 57600 baud. This was chosen as it reminded Helen of using 56K modems when she was little. It may be tempting to up the baud rate. Doing so will speed up generation, but the Arduino's UART clock will begin to skew the analogue conversion as the input pin is floating with consequent reduction of entropy and non random numbers. The magic occurs within this code fragment where the internal analogue to digital converter is read with 8 bit resolution:-

byte nextSample() {
  byte reading = analogRead(A0) & 0xff;    // The source!
  return reading;

The nextSample()s are put through a basic Von Neumann extractor to remove potential bias, and the resultant bits sequentially hashed together with a Pearson hash. 52 bits hashed together produce one really really random byte. The entire Arduino (nano) code is available as an attachment. Needless to say that some receiving code is required at the other end of the USB cable to construct an actual image. That is left as an exercise for the readers. Unless they cheat and look at one of the other attachments, then use an image editor like GIMP.

There are those that would doubt that a floating analogue to digital converter pin can produce cryptographic strength random numbers so easily. A floating pin in our command centre will in all likelihood just pick up the 50Hz mains hum. They have a point. Somewhat. We are not saying that the pin directly picks up fully random values. The mains hum is indeed the principle component of the input. We performed a spectrographic analysis of the input readings, scaled down to eight bits. The analysis looks like this:-

Proof of Concept 2 - The Flawed Condenser/spectrum.png

The peak at 50Hz is glaringly apparent. But notice that the spectrum has other peaks. Those other peaks represent the true entropy we are seeking. They’re much less prominent at 40dB below the mains hum, but they are there, and if you capture enough of them you can produce a truly random byte. The following is a plot of a perfect sine wave (purple) superimposed over the actual pin readings (black). The actual readings are shall we say, rough around the edges. That’s entropy. It’s all the other electromagnetic random noise in the environment. We have measured the rate of this entropy at 1.9%, which you can interpret as meaning that 1.9 readings out of a 100 are truly random and therefore unpredictable by man or beast. It also means that if you take 52 single bit readings (post Von Neumann), you can assemble a truly random byte.

Proof of Concept 2 - The Flawed Condenser/waveform.png

And if it’s a waveform, what might it sound like? This(info) mp3 file has been rate adjusted so that it plays in equivalent real time. Also, the 50Hz component has been removed with a high pass filter, leaving behind the raw entropy. Sounds like a scene from some sci-fi film Dom thinks.

Whilst the output is very pretty confirming our entropy measurement and extraction methodology, this entropy condenser is flawed below the pcb. It is extremely susceptible to external influence by the capacitive effects of a closely waved hand or paw, and is very slow. It's principle use would be for introducing true randomness into Arduino sketches. Although in retrospect, is it still waay faster than /dev/random.

Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
LV-426.mp3 42.2 kB 1 11-May-2016 03:03 Helen
LV-426.png 5.9 kB 1 11-May-2016 03:03 Helen
arduino.txt 2.4 kB 1 10-May-2016 02:13 Helen Arduino (nano) source code
arduinoImage.png 66.7 kB 2 09-May-2016 11:04 Helen
histogram.png 9.0 kB 1 10-May-2016 02:19 Helen
nano-trng.jpg 33.6 kB 1 09-May-2016 01:21 Helen
pc-code.txt 1.5 kB 1 09-May-2016 13:53 Helen Receiving code at the pc end
spectrum.png 15.8 kB 1 11-May-2016 02:54 Helen
waveform.png 40.2 kB 2 13-May-2016 15:06 Helen
« This page (revision-) was last changed on 18-Jul-2016 14:08 by Helen
G’day (anonymous guest) User Preferences

Currently being read by 27 soul(s) or robot(s) like so:

Flag Counter