Sunday, September 29, 2013

USB Random Number Generator

This project is about USB port base true hardware random number generator and it is design around the avalanche noise which occurred in reversed biased P-N junction.

This random number generator is design using commonly available electronic components. The core component of this system is Microchip’s PIC18F2550 microcontroller. The noise source is 2N3904 (Q1) transistor and LM386 low voltage power amplifier is used to amplify the incoming noise signals. This peripheral is design to work as a self-powered USB HID device.

Cumulative distribution graph of random number sample

In this design we use 2N3904 as a noise source because it give more noise amplitude than any another transistors which we tested. Theoretically this transistor (Q1) can be replaced with any other suitable NPN transistor like BC548, BC107, 2SC945, etc.

The control software of this system is available for Linux and it’s compiled as x86 - 32bit binary file. This controller application required libusb driver and it can be obtain from This application is working with command line parameters (e.g: sudo ./randgen 500) or through interactive user inputs (e.g: sudo ./randgen).

The valid output range of this random number generator is around 10000 to 41000. This output range is fixed and its linear distribution graph is available with the project package.

This USB random number generator is design as an open hardware project and its schematics, software source codes and detail documentation are available at google drive.


Ben Alabaster said...

Commendable effort. No doubt you will have received a ton of mixed responses to this. I'm not sure how secure this iteration is, but I think that an open source/open hardware project is much needed. This is a good start.

Robin Leffmann said...

As part of my interest in electronic music and building analog synthesizers, I came up with this exact same solution in 1999 when designing a circuit for producing frequency-tunable noise (in contrast to the usual solution of having just white and pink noise) - a simple reverse-fed transistor feeding a sample-and-hold circuit whose sample rate was controlled by a timer in order to get stepless control of the noise frequency, from white noise all the way down to a rumbling "black" noise.

Anonymous said...

Hi, any chance you could add an image of the schematic to your blog post? Thanks

Dilshan Jayakody said...

Sorry, right now schematic is not available in image format. You can find PDF version of schematic at

Anonymous said...

(schematic). Fair enough, but I don't have 7z (or windows for 7-zip), so I guess I won't be looking at it (hence asking).

Anonymous said...

7zip is available for windows/Mac/linux, see

Nice work Dilshan, I wonder how/if I could use this as an additional source of entropy for /dev/random.