While working towards his Computing and Information Systems degree at the University of London, [Jason Fenech] submitted an interesting proposal for generating random numbers using nothing more exotic than an aquarium and a sufficiently high resolution camera. Not only does his BubbleRNG make a rather relaxing sound while in operation, but according to tools such as ENT, NIST-STS, and DieHard, appears to be a source of true randomness.
If you want to build your own BubbleRNG, all you need is a tank of water and some air pumps to generate the bubbles. A webcam looking down on the surface of the water captures the chaos that ensues when the columns of bubbles generated by each pump collide. In the video after the break [Jason] uses two pumps, but considering they’re cheaper than lava lamps, we’d probably chuck a few more into the mix. To be on the safe side, he mentions that the placement and number of pumps should be arbitrary and not repeated on subsequent installations.
To turn this tiny maelstrom into a source of random numbers, OpenCV is first used to identify the bubbles in the video stream that are between a user-supplied minimum and maximum radius. The software then captures the X and Y coordinates of each bubble, and the resulting values are shuffled around and XOR’d until a stream of random numbers comes out the other end. What you do with this cheap source of infinite improbability is, of course, up to you.
While this project has been floating around (no pun intended) the Internet for a few years now, it seems to have gone largely overlooked, and was only just brought to our attention thanks to a tip from one of our illustrious readers. An excellent reminder that if you see something interesting out there, we’d love to hear about it.
[Thanks to David for the tip.]
I wonder how many bits per second of randomness this pumps out.
Why go through all the trouble of bubble recognition when you can also hash the raw image data?
I was wondering that myself.
I would love to see the face of Jason reading this post…. no worries Jason, we all have been there ;-)
I was wondering why one couldn’t shine a lamp through it to a larger area photocell, (Or use lens system so it samples a decent area through it) and source the noise from that. Or even audio sample from the fizz of the bubbles popping on surface.
However, he’s meant to be studying it in detail, and doing a computing degree so had to make the problem a nail for his particular hammer.
Actually it’s not that random; it’s just hard to calculate. Each bubble’s move has some impulse caused by the previous ones. If you can capture 2 subsequent frames of the tank in 3d, you can compute the vectorial representation of the all bubbles and It turns out to be just a complex physics question to calculate the next bubble’s move. Lol.
I call physics!
My guess is that the water is also moving (has momentum) and that you’d need to know a lot more about the invisible water flows than you might think. Two frames of just bubbles will _certainly_ not suffice. I have no clue how many you’d need. And there’s a good chance that the process ends up chaotic in the physics sense: infinitessimal differences in initial conditions make large changes in the overall.
Still, I think that you’re right that it’s not random. It may be in principle work-outable.
I think you mean it’s chaotic in the maths sense, which it almost certainly is, as due to the flows, it will share a number of properties with weather patterns, the classic chaos example.
His nicely routed wires don’t look physically chaotic.
Apparently a container of water isn’t “still” until it’s been sitting a couple of days. Therefore seemingly random motion is already imparted by the method of filling it.
I would be more worried that there might be a 50 or 60Hz variation of bubble density that might come out with extensive analysis.
As long you haven’t solved the [Navier–Stokes existence and smoothness problem] there is no way to tell whether is assembly creates true randomness.
If you have, congrats to your $ 1M ;)
BTW:
You can calculate the dynamics of one bubble via the [Rayleigh–Plesset equation] if you make a plethora of assumptions (i.e. infinite body of water), but this is just a fish tank, so…
Furthermore every pump creates a sh!t-ton of bubbles, so you have to take bubble-bubble interaction into consideration – and you have 3 pumps…
So even if the resulting bubble-pattern isn’t truly random, good luck calculating it XD
I presume whatever sink is consuming this source of randomness won’t have any visibility of the tank of video feed. So, in my opinion, the output of this rig is suitably random.
You’re definitly right.
Every real random number is hard to calculate, by an agreed definition of ‘random’.
‘True’ random isn’t possible unless you’re able to compute the universe including yourself. That’s how deep the rabbithole of random goes.
This guy actually achieves a relatively high approximation of random with cheap stuff.
How to predict the image sensor’s statistical quantum fluctuations?
It just needs some fish….
+1
Adding organic motion into the equation would increase the randomness by a huge factor!
In the “Hitchiker’s Guide to the Galaxy”, the “Infinite Improbability Generator” used brownian motion from a really nice hot cup of tea as a source of randomness. Perhaps this should be considered for your next version.
But then, what do I know? I never get invited to those parties… :/
Someone else beat him to it – with lava lamps.
https://www.atlasobscura.com/videos/these-lava-lamps-help-encrypt-the-internet
And Cloudflare didn’t start using it until 2016 – after the original patent term had expired:
SGI did it first, way back in ’96:
https://en.wikipedia.org/wiki/Lavarand
Good job!
“What you do with this cheap source of infinite improbability is, of course, up to you”
Obviously, you use some of the bits to select which of the n>2 pumps will be active for the next batch of random bits. Or maybe toggle servos to tweak the pump nozzle output directions.
It’d be interesting if this could be miniaturized into a portable form factor. Maybe using colored water and clear mineral oil.
Doesn’t anyone use avalanche noise from a reverse biased p-n junction any more? Smaller, portable, lower maintenance, etc…
How do you know that the NSA doesn’t have a quantum entangled copy of your junction though?
…because it was hand soldered.
Or just use an avalanche diode noise generator with the A/D converter on any half-dollar uC…
The bubbles displace the water and changes the resistance. If you were to place the bubble stones between two electrodes and measure the resistance with a current source and ADC. This simplifies the measurement to something a cheap microcontroller can do.
Use deionized water and limit the voltage across so that you are not performing an electrolysis.
Since simpler RNGs are still random enough that we can’t quantify their randomness through observation….
How can we tell if this more complicated version produces better results?
For the Arduino platform, I have found that this code using the watchdog timer to extract the least significant bit from Timer1 as a source of entropy produces reasonably good numbers.
https://gist.github.com/endolith/2568571
A slightly modified version is used to get a unique RC4 initialization vector on this project:
https://hackaday.io/project/168713/gallery#fcb64ce26a9c697b13530ebbc603d746