Creating random numbers is really useful. Randomness underpins key elements of scientific study, ensures communications are secure and is the basis of popular forms of recreation like gambling and lotteries. It is also fundamental to the cryptography that secures Bitcoin and your funds on the NGRAVE Zero hardware wallet. The problem is that humans are rubbish at being random and enlisting the help of computers cannot generate true entropy because they can only do what predictable humans tell them. So how can you generate randomness and what is the secret to the NGRAVE ZERO’s Perfect Key?
For most of human existence, people have believed in higher powers controlling our destiny rather than accepting life as just a random sequence of events. The Greeks even had Destiny Godesses - the three Fates - said to assign our destinies at birth.
Games of chance evolved from dice being used as a conduit to understanding what the Gods had in store, along with much messier approaches like examining the entrails of sacrificed animals.
The first reference to dice was around 2,000 years ago in the Mahabharata, the ancient Sanskrit epic and actual dice have been excavated from Egyptian tombs around the same time.
Despite the belief that life was ordered, examples of the usefulness of random systems beyond gambling can be found in the Old Testament with Moses commanding the Israelites to apportion the land by lot and Athenians choosing civic administrators by sortition - a system of selecting representatives at random.
Our use of randomness has increased dramatically over the last century and as our understanding of it has improved so has our creativity in trying to generate randomness.
Subscribe To The NGRAVE Blog
Get the latest insights on crypto, security, blockchain, and more.
Randomness in games, lotteries & gambling
One of the most fascinating attempts to generate randomness came out of the creation of Premium Bonds in the United Kingdom in the 50s, a government-run Prize Linked Savings scheme set up to encourage saving in the post-war years which still runs today.
Savers deposit funds receiving proportionate entry into a monthly no-loss lottery for which Premium Bonds needed a robust system to randomly select the winners. Enter ERNIE.
ERNIE used neon tubes as the basis of its random draws. Electrons move chaotically through neon producing a random current which was extracted as a fair way to generate Premium Bond winners.
ERNIE has been iterated five times and now uses light-based quantum technology which takes 12 minutes to draw the required amount of random winners. The original machine took ten days and was the size of a truck.
Generating randomness for the sake of organised games of chance extends to our obsession with dice games which hasn’t diminished since the era of the Mahabharata. We’ve just refined the lengths we go to make sure the outcome is random.
As an example, the process for Casino grade dice used in games like Craps is very specific. Their straight edges and eyes are milled to within a tolerance of 0.0005 of an inch using cellulose acetate which doesn’t degrade with the finished product tested on a Balancing Caliper.
One gaming company took dice rolling to the next level building the Dice-O-Matic to machine roll dice at scale. It produced over a million random dice rolls a day from 200 dice all captured on camera to create a reliable store of random rolls.
ERNIE and the Dice-O-Matic are one of many creative solutions for what are essentially recreational purposes, but generating randomness has a very serious side.
The Serious Side of Random
Randomness plays a critical part in science, from helping generate random population samples for testing drugs, to identifying random signals from space. Randomness is also used to replicate unpredictable environmental factors in computer simulations and is an essential part of creating secure communications.
As with much of modern life, you’d expect the answer to ensuring the inputs for these critical pursuits are sufficiently random to come from a computer, but they are no better at generating random numbers than we are.
The answers on Stackoverflow.com to the question ‘Why is it hard for a program to generate random numbers?’ really nails the problem:
"Because computers just follow instructions, and random numbers are the opposite of following instructions. If you make a random number by following instructions, then it's not very random!”
Computers cannot generate random numbers, instead they generate pseudo-random numbers using algorithms. This is true of the random function in your calculator, in Microsoft Excel, secure password generators, encrypted communication and data encryption, which finally brings us round to how random generation relates to crypto.
Random numbers & public-key cryptography
Cryptocurrencies like Bitcoin use public-key cryptography, also known as asymmetric cryptography. Every Bitcoin address has a pair of public and private keys that are essentially large non-identical numbers hence the term asymmetric.
When we say large, we really mean it. The keys are 256-bit in binary, which means 256 one’s and zero’s.
Despite the mind-boggling odds of guessing a Bitcoin private key, the algorithm behind Bitcoin’s digital signatures is still just pseudo-random, so with enough time and computing power it could be theoretically broken. This is why, when we’re not obsessing about trillion-dollar market crashes, the subject of Quantum Computing gets so much airplay in the crypto community.
The security that Bitcoin private keys get from the algorithm creating them also generates a paradox. It is near mathematically impossible to crack the cryptography used to generate private keys, but if they are stolen or lost, there is no way back, and some estimates suggest that up to 20% of Bitcoin’s Total Supply are lost forever (amounting to more than 3 million BTC).
Entropy & Wallet Seed Generation
Self-custody of Bitcoin has always been a challenge but was simplified by the introduction of what are known as recovery Seeds and Hierarchically Deterministic wallets (HD for short). The concept was first introduced in 2011 in Bitcoin Improvement Proposal (BIP 0032), and later applied to other cryptocurrencies through BIP0044, three years later.
As part of an HD wallet set-up process, a root seed/key is generated from which all addresses generated by that wallet are derived. That root Seed is usually created in the form of a collection of mnemonics (memorable words), drawn from a standardised list of 2,048 phrases determined in another Bitcoin Improvement Proposal (BIP 0039).
Sometimes the seed uses 12 phrases, or for higher entropy (randomness), 24 phrases. These phrases are essentially a convenient and usable way to encode one massive pseudo-random number as a means to controlling any number of addresses which are also themselves massive pseudo-random numbers.
Next-Level Randomness: NGRAVE's Perfect Key
Given that a Seed gives the holder keys to the crypto castle, the process wallets use for generating them has to be as random as possible. NGRAVE takes entropy to the next level in generating what we call the Perfect Key for the ZERO hardware wallet. It uses something unique to you, your fingerprint, and combines this together with something random, inputs from a light sensor.
Using environmental inputs is a proven way of further optimising and increasing entropy because any data from real-life is predictable. This is illustrated by Benford’s Law which states that the leading digit in any real-world data set is likely to be small; 1 appears 30% of the time and 9 just 5%.
Cloudflare, which provides security for millions of websites, takes a unique approach to generating entropy using 100 lava lamps sat on the wall of their head office feeding random inputs to a camera constantly taking photos. The digital images are saved as numbers on Cloudflare servers based on the random pixel arrangement and are used as the salt for certificate encryption.
The Australian National University has looked skywards finding a unique way to generate random numbers inputs by listening to the quantum particles in the near-vacuum of space.
NGRAVE’s approach might not have Star Trek appeal but it generates a key truly personal to the user, and so random as to be collision resistant.
That doesn’t mean it has a built-in airbag, it just means that the chances of two personal keys being the same are 2256, which is equivalent to the total number of atoms in the universe.
Incorporating random inputs specific to the user and their environment, provided once the device has left the factory, reassures the user that key is known only to them. This is known as the User’s Eyes Only Principle.
In this way, NGRAVE creates a truly statistically unique, unbreakable and unpredictable key, what we call the NGRAVE Perfect Key.
As you should hopefully now appreciate, NGRAVE’s approach to generating genuine randomness works far better than conscious user inputs; no offence, but people are inherently predictable.