Build your own True Random Number Generator

ATTENTION: VERSION 2 IS OUT.

Below is version 1

Intro

This generator uses avalanche noise, and is based on a design by Will Ware. Herein are instructions as to how you can use a pic chip to analyze a noise source and output random data serially. I've included circuit diagrams as well as links to instructions for fabricating your own board.

There are two types of random numbers: true and pseudo. Pseudo random numbers are created by an algorithm. The problem with this is that if someone knows what algorithm you use, it is theoretically possible predict what numbers you will create. True random number generators create sequences that are impossible to predict. They use random physical phenomenon as their source or randomness. They are used for encryption and micro psychokinesis research.

 

How it Works

 

 

From Will Ware:

"This circuit uses avalanche noise in a reverse-biased PN junction, the emitter-base junction of the first transistor. The second transistor amplifies it. The first two ALS04 inverters are biased into a linear region where they act like op amps, and they amplify it further. The third inverter amplifies it some more..."

The Max232 chip has two pins across which we can get 20V. That's the only reason it's there.

The Pic chip is for analyzing the noise and sending out random bits. I used a 16F648A because it has a comparator. The signal going into the pic has fuzz between 1 and 2 volts and spikes that go up to 3 volts. It's these spikes we want to measure. The comparator will cut out the fuzz and interrupt the pic whenever there is a spike. (I tried the pic's ADC but the comparator seemed more responsive).

The pic code works like this: the pic records the number of spikes it detects in a short time interval. If there are an even number of spikes it outputs a 1, an odd number a zero.

Also, the board has input for two switches. These control the output mode and the XOR mask. The mode switch sets the generator to output either random bytes or ascii 1's and 0's. The XOR mask XOR's the output of the generator with a string of alternating 0's and 1's. This reduces bias. The switch turns the mask on or off.

 

Code

 

Fabricating the board

To create the board I used a laser-printer transfer technique. I intend to write my own instructions, but until then I refer you to these already existing guides: Concise, Verbose, and Mine.

Read Concise first to get an overview of the process. If you are going to make your own board, read Verbose in detail, especially the ironing section. Surprisingly, ironing is the trickyest part. If it is not done correctly the toner will not transfer completely to the copper.

Also, what is not mentioned in these guides is that when creating a board, you should fill in open areas with shapes. As you can see in my board, I have filled in most of the open space including the area around the circuit. The benifit of this is that less copper is exposed during etching, and therefore less etchant and *a lot* less time is needed to etch the board.

 

 

 

Parts List

Component Quantity
PIC16F648A 1
MAX232 1
74ALSO4 Inverter 1
20mHz Crystal 1
D-Subminiature Connector 1
7805 5V voltage regulator 1
2N3904 Transistor 2
LED 1
1µF Polarized Capacitor 4
0.1µF Capacitor 2
10µF Polarized Capacitor 2
22pF Capacitor 2
15K Resistor 1
10K Resistor 4
2.7K Resistor 2
220ohm Resistor 1
switches 2
DC Power Jack Inline Male 1
Heat Sink (small) for 7805 1


Assembling the Board

Here is the components diagram. Put the components through the holes on the side of the board without the copper. Solder them. My board requires a 12V power supply, and I wire it to +12V and GND holes. It should also work with a 9V battery.

 

This is how mine looks:

 

Output Analysis

As of 12/14/05 I haven't had the chance to extensively analyze the output. I have produced a historgram of the random bytes and it looks good. The ratio of zero's to one's also seems in check. I ran about a million bits without the XOR mask through the NIST test suite, and it appeared to pass about 75% of the tests. I'm going to try again with the XOR mask and see if it makes an improvement.

 

Contact me:

rob (at) robseward (dot) com

robseward.com


Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License.