This Random Number Generator Does It With Neon

The quest for true randomness has roots in cryptography and is a rabbit hole that gets surprisingly deep with alarmingly rapidity. Still, the generation of random-enough numbers is a popular hacker project. Part of the appeal is the way these devices strive to incorporate physical phenomena, and in [Joshua Coleman]’s case, his Neon Entropy (Pseudo) Random Number Generator uses a trio of vintage neon lamps.

Neon lamps discharge at rates that vary unpredictably. They’re also pretty to look at.

[Joshua] chose neon lamps in part because the discharge rate of an energized lamp is a variable, physical process that makes a good source of entropy. They also have an attractive visual appeal that fits the concept [Joshua] had in mind. Unlike random number generators that kick off by measuring radiation or some other imperceptible thing, it’s possible — at least in a sense — to see this one working.

The small variations in the three neon lamps are measured optically by three TEPT4400 ambient light sensors (isolated from the neon lamps themselves) and turned into analog signals. A Raspberry Pi Pico W reads these signals, then uses them in a process that culminates in SHA-256 64-bit values that can be used as random seeds.

There’s also a web dashboard that shows everything live, furthering the “watch it work” concept [Joshua] is aiming for. The video below shows the project in action if you want to see how the sausage gets made.

Earlier we mentioned how random number generators are popular projects among hackers, and here are a few selected ones. Don’t miss the stylish glow and slick enclosure of this Nixie tube RNG, or the lava lamp RNG which is in fact not a gimmick. And while it is commonly understood that meaningful randomness must come from outside a digital chip, uninitialized internal volatile RAM — if accessed correctly — can be a remarkably good source of entropy.

16 thoughts on “This Random Number Generator Does It With Neon

  1. When I was a teen, I bought a kit of parts and built an 8-neon random oscillator project. Each bulb was an individual oscillator, stuck through a gromment so it showed through the front panel. I painted the housing flat black and had it in my bedroom. I think it was powered by 9V.

      1. Well what’s is the rule for when something is or isn’t random?

        Conditioning the output is always valuable so I think this articles saying pseudo random because of the hashing.

        Of course id I put 1 random bit in then churned out 128 bits and then put another random bit in we might say that’s only pseudorandom.

        If all bits are from a truly random source that is of course random.

        Still when does the transition happen?

        I imagine this is what the entropy tracker on my OS is doing.

        I shall investigate and might reply if I find a nice answer.

        1. Most arithmetic methods are Pseudo because they repeat at some boundary. A true RNG is not predictable, however a PRNG is imminently more likely to be predictable. Its just a mathematics things, but its important to be sufficiently random in say a Monte Carlo simulation being used to derive PI for example

    1. Yes, I wanted to create insurance against detractors with the parenthetical because it cannot be qualified as true RNG without a crazy amount of vetting. At the hobby level there’s all sorts of things like noise on the ADC channels, stray capacitance on any and all of the leads (again noise), channel cross-talk, etc. It takes a HEAP of validation to call something truly Random. Which I respect. I did however add one level of validation of the results with the temperature recording to assure the output wasnt affected by thermal drift which is one of the premiere concerns in such systems. So far, even varying ambient air temps across a day do not affect the quality of the outputs.

      1. Bah! It’s certainly truly random.

        Whether or not your 256-bit output has 256 bits worth of entropy is what I think you’re getting at, and that’s what the cryptographic nerds would be worrying about if all 256 bits were relevant to some brute-force attack, for instance.

        As [kuliphex] suggests, you might very well have a chaotic system, and that’ll eat up some of your entropy by providing a degree of predictability.

        But don’t think that a number with 128 bits of entropy instead of 256 isn’t random. It’s just less random. :) But for many purposes, that could be random enough.

        Pseudorandom is another can of worms entirely — that’s deterministic under the hood. You’re certainly not there because you have no way of getting the same sequence of numbers out. You can’t put the neons in a given initial state and replay the system, can you? It’s truly random. You can sleep well at night.

      2. It is random enough that a simple whitening algorithm will be sufficient, although you really do need to have more than just one or two of em feeding into your sampler (yes, it’s possible to end up with coupled behavior, but the coupling is itself random and variable. You simply won’t get as many bits of randomness as a naive reading would suggest. But, whiten it a bit, feed it into an aes hash, and it will pass any entropy test for randomness. And, you can make this self-tuning. the entropy score feeds back on the whitener and the aes loop count. The result is guaranteed to be high entropy, but the rate of random bits produced per second will be a bit variable.

        Oh. If you add a geiger tube and a radiation source, you may observe some interesting correlations, if the neon tubes are too close to the radiation source, depending on exactly which source you’re using. This is cool, but usually not helpful if the goal is greater entropy (any ioniziation flashover across multiple lamps is likely to be correlated, not entropic, at least some of the time)

  2. To weigh in. This is indeed not a PRNG, a pseudorandom number generator. That term already has a meaning, which is a stream generated by a some fixed seed. It is a proper physical random number generator. What it is not is well-characterized. So rather than using the wrong term, it would be fully appropriate to call it an ill-characterized random number generator.

    Building hardware is the easy part and characterizing it is the hard part. This is a first small step on not a short path.

    A couple of comments specifically on implementation details. The Von Neumann-style debiasing step is probably useless, and conceivably harmful. The problem is, of course, in characterization. That debiasing algorithm operates on Bernoulli sequences, which have the requirement that the bits in the stream are uncorrelated. Because these bits are taken from an oscillatory system, that assumption is almost certainly false. Since the bits are hashed afterwards, and hashing destroys the feasible computation of priors, it may be effective to drop the same percentage of bits after hashing as before. But without characterizing the underlying sampled stream, it’s difficult to say which is better.

    Another faulty assumption is that having three oscillators is significantly better than one. At the very least it’s less than three times better, exactly how much less subject to characterization. The problem here is that the three oscillators are not independent, but coupled. If I’m seeing the pictures right, they’re coupled through the finite impedance of a common power supply. The easiest figure of merit would be the CMRR, common-mode rejection ratio, a measure that gives an idea how much the behavior of one oscillator affects another on the same rail. And because the optical pairs are not potted, there will be some optical coupling in addition.

    If there’s a lesson here, is that the design of the circuit and its mechanical embodiment should be made in full conjunction with its characterization. Issues with characterization should feed back into the design process. If a design is hard to analyze, it is good to change the design until analysis is tractable.

    All that said, there’s real merit in the idea that such a generator should be auditable. I’m not at all convinced that the particular audit as present in the current project is all that valuable, but the concept is laudable and worth pursuing.

    Lastly. In an ill-characterized RNG, it would be better to add a “quality” argument to the interface for obtaining values. This would be something like a multiplier for the amount of raw data that will feed into the returned value. Given how the state space of this class of device works, this should probably be a logarithmic-scaled value (e.g. the exponent in floating point) than a linear-scaled one.

    1. This is extremely wonderful insight. I am a mere learner but I am picking up what you’re putting down. I appreciate the lauding of the audit process and I will seek to refine it given your comment. And I understand the questionability of the same power supply. I agree there are too many points actually to ever call this pseudo or real randomness, but as a dude in his lab with some neons I do believe it can be ‘characterized’ :) as a start. Thanks for the feedback and it’s very helpful in understanding.

  3. It seems overly complex using three neon lights and a reader to detect slight variations in light output just to generate a random number using the stochastics of an inert gas.

    Ditch the neon for room air (continuously varying mixture of nitrogen, oxygen, argon, H2O, CO2, etc), and use a thermocouple to measure the continuously-varying temperature in the room (entropy is heat). Take as many readings as you want to set whatever number of bits you want. Less pretty but extremely cheap, and simple to read with a DAC.

    “Everything should be made as simple as possible, but not simpler” – Simplified version of Albert Einstein Quote

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.