Project 118: True Random Number Generator

The goal of this project is to create a true Random Number Generator, with a USB connector, that can be easily used with any computer. I don't expect it to match up to the many very expensive commercial RNG's out there, but I believe a product like this could have a niche.

In online games, for example, there are many applications for random numbers. One could use the same pseudorandom algorithms that you would use on any other game, but if the online game proves popular, or features any kind of subscription or paid content, users could try to exploit the RNG system to gain an unfair advantage, or profit from the game. If, for example, a rare item is spawned at a random location, and that random algorithm is hacked, the exact position of the rare item can be determined. However, a true random number generater would not have this problem, and if one could be build cheaply, it could appeal to developers with smaller budgets.

My idea for the RNG was this. First, use a Zener diode operating in "zener breakdown" mode to produce white noise, then, capture that white noise using an arduino for now, and in the finished project, and Attiny85 or similiar. Then connect a Serial to USB adapter to the Attiny, and I can feed the RNG noise into a computer, where I can analyse it, and determine if it is in fact truly random, using the "Die Hard" Tests.


I tried several different circuit in order to generate reliable white noise, and none worked properly. These next two screenshots show the closest I could get, but this is an intermittent "burst" of noise, not a continuous stream like it should be.

 
 

 

 
 
I then captured the data from the circuit using an arduino and the analogRead() function, and copied it to a text file using putty:
 
 
That seemed to work ok, so I used a program called ENT to do some random number testing. The results were very poor, the data was not random at all, it failed every test:
 
 
In order to figure out what went wrong, I tried graphing the data from the text file I obtained from putty (the numbers sent over the serial from the circuit) using gnuPlot:
 
 
This showed that I was not getting the random noise output that I should have been getting. Possibly because the noise was not strong enough to be detected? I tried various variations of the RNG circuit, including connecting an opamp to amplify the noise, but I couldn't get random noise output.

I did however figure out how to use the arduino and processing to create a simple oscilloscope, so that I could see what the arduino is seeing. This is the link to the tutorial.

 

Postponing the electronic side of things for a while, I wrote a program to create two kinds of bitmap images. One generates a bitmap image where each pixel is set to a random colour chosen by a pseudorandom algorithm, and the other does the ame thing with the supposedly true random data that I obtained from the circuit I build. The output generated from the pseudorandom algorithm is below, it looks random enough. The output based on my program was certainly not random however, and this program served as a convenient way to tell that.


In concluson, I am pretty sure I can get this project to work. I did some more research on random number generation, and I have a few new circuits that I can try, I am just waiting on some parts. I am confident that they will give me white noise. The trick then will be to sample that at the correct rate by the arduino/attiny for it to be unbiased true random data.

I have learned several new skills from this project so far, not only in the field of true random number generation and circuit design, but I also learned several other skills. I had wanted to use the processing IDE for some time, I had heard a lot about it, and I got to do that. I also got to use gnuPlot, which is a far superior graphic package than openoffice Calc's built in solution which I was using. I also got to use several random number generator testing tools, such as ENT, and I generated a bitmap image in C++, populating the pixel values with data I provided in the program, I had never done that before. Having complete programmatic control over the pixels in an image is a great thing to be able to do, and there are lots of ways I could use that information in the future, such as in fractal algorithms, which I also have an interest in.
 
I will post more on this project in the future.

You must be a member of this blog to see the comments. Log in now!