Peter Bierhorst’s machine is no pinnacle of design. Nestled in the Rocky Mountains inside a facility for the National Institute of Standards and Technology, the photon-generating behemoth spans an entire building. Its lasers, mirrors, and lenses are split among three laboratories, two of them at opposite ends of the L-shaped building. The whole thing is strung together with almost 900 feet of optical fiber. “It’s a prototype system,” the mathematician explains. “Something might drift out of alignment, and the whole thing stops working. It might take a few days to figure out what went wrong.”

On a good day, the machine produces 1,024 bits of data every 10 minutes, equivalent to typing 13 letters per minute. But it promises what even monkeys on typewriters can’t: completely random text.

Which is much more important than you might think. Cryptography protocols, like the ones that secure your credit card info online and your encrypted e-mails, rely on long strings of random numbers. The less guessable the number, the higher the security.

But the numbers often aren’t as random as you’d hope. “There are a number of papers that show weaknesses in cryptography because keys don’t have enough randomness,” says Grégoire Ribordy, the CEO of ID Quantique, a Swiss company that makes commercial random number generators. Some devices actually encrypt information using algorithm-generated numbers—which means that if you guess the algorithm, the numbers are entirely predictable. Other random number generators might convert electrical noise, like small fluctuations in voltage, into strings of numbers. But over time, these generators deteriorate and end up producing numbers that exhibit patterns. (Typing monkeys would exhibit patterns too, dictated by the relative lengths of their fingers and the layout of the QWERTY keyboard.) Any discernible pattern is a security risk.

Which is why, a couple years ago, Bierhorst’s team decided to develop a number generator that was perfectly, provably random. In the cryptography world, that means “numbers that cannot be predicted,” says Ribordy. And what’s random? Quantum mechanics.

It’s like this: Even if you repeat a quantum experiment by preparing a quantum particle in exactly the same initial state, subjecting it to the exact same conditions, measuring its orientation after the same amount of time, you can still end up with totally different results. This is unlike flipping a quarter, where its initial conditions—the force of your thumb, the direction of the winds—determine the outcome before it lands. The outcome of “flipping” a tiny quantum particle only exists as probabilities until the moment it “lands.” Electrons, photons, and atoms are really, actually random.

For several years now, companies like Ribordy’s have sold quantum random number generators based on photons. The encoding scheme can get complicated, but more or less, photons oriented in one direction represent 1, while ones oriented in another direction represent 0. However, these products still have a potential vulnerability. Someone—or something, like environmental noise—could have infiltrated the machine and inserted bias into the photons’ states, a blemish on their perfect randomness. A user can’t prove that these generators are random, says Ribordy.

So Bierhorst’s team set out to design a machine that could prove its own randomness. This involved a lot of math. Using a quantum mechanics theorem known as Bell’s inequality, Bierhorst designed a test that could show whether anything could have tampered with the photons to introduce patterns or bias. You can apply this test every time you generate a number, and it spits out a number that tells you, for sure, whether anyone has messed with its representative photon.