Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Lava Lamp Random Number Generator

Lava Lamp Random Number Generator

(extracted from the now defunct SGI project at via the magical Internet Archive Wayback Machine)

Lava Lamps can be used as a source of randomness, which can be used to establish a random number generator. The output of the RNG can then be consumed by various computer applications.

Step 1: Establish a chaotic system

(Set up Lava Lite® lamps in a machine room.)

Lava Lite lamps are very good chaotic sources when operated under conditions recommended by the manufacturer. We use the Eleck-trickTM Lava Lite lamp model, in part because it works well in colder conditions found in machine rooms but more importantly, it comes in rad colors!

Step 2: Digitize the chaotic system

(Take digital images of the Lava Lite lamps.)

An O2cam TM digital camera is set up in front of six Lava Lite lamps. The digital camera takes a picture of the Lava Lite lamps every once in a while:

Digital cameras are "noisy" by nature. Taking two pictures of the same object will more likely than not produce two different images. Digital cameras add digital noise to the visual signal that they process.

Step 3: Cryptographically hash the digitization of the chaotic system

(Feed the digital output through a number munger.)

The digital output of the image is then munged by an algorithm, which compresses and scrambles it. Thus the 921,600-byte image is transmogrified into an 140-byte "seed."

The technogeek explanation:

We use NIST's Secure Hash Standard rev 1 (SHS-1, sometimes called the Secure Hash Algorithm or SHA-1) to cryptographically hash the digitized image of the chaotic system (Lava Lite lamps) produced in step 2.

Our implementation of SHS-1 allows for the production of an n-way hash. An n-way hash produces n hash values, each of which is a hash of a every nth octet. In this example we use a 7-way hash, each of which produces a 160 bit value from every 7th byte of the digitized image. By hashing every 7th byte we avoid hashing the same byte of each pixel.

The 7-way SHA-1 hash of the above digitized image yields the following 140-byte base 16 value:


Step 4: Seed a pseudo-random number generator

(Feed the 140-byte value through another number munger.)

The 140-byte value gets fed through the Blum Blum Shub - one of the best available number generators, its quality endorsed by respectable mathematicians everywhere. Think of a roulette game as an analogy - the pseudo-random number generator is the roulette wheel, the seed is how long the roulette wheel spins before it begins to slow down. The slot the ball falls into at the end is the resulting random number. Voila! You have a random number! Here is a sample 128-byte random number (in base 16):


NOTE: This random data is provided 'as is'. Obviously the random data generated by these demos is not secure since anyone can see this same data. See our standard disclaimer.

The technogeek explanation:

We use the Blum Blum Shub pseudo-random number generator, which takes the product of two prime numbers and generates a very long, cryptographically strong sequence of pseudo-random bits.

The Blum Blum Shub is based on the low order bits of quadratic residues of a product of two Blum primes. Blum primes are primes that are 3 mod 4. A quadratic residue is the square of a value modulo some value, in this case, modulo a product of two Blum primes. In this example we are using the following 1062-bit product of two Blum primes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment