What is API3 QRNG and why is it good for Web3?

Tom Watson
Coinmonks
7 min readJul 12, 2022

--

Galaxy cluster SMACS 0723, brought to you by the Webb telescope… and the laws of physics.

The world’s top choice in Quantum Random Number Generators (QRNGs) is now available to Web3 as API3 QRNG. Since the method of randomization is new to the space, I’ll be deep-diving quantum random number generation and looking at how it fits in with Web3 alongside the most popular option: VRF.

  • Introducing QRNG
  • True vs pseudo-randomness — why quantum randomness is the gold standard for random number generation.
  • Trusting ANU — A look at incentives, and evaluate the long-term plausibility of manipulation at the source. (Hint: it’s not really plausible)
  • Cryptographic proof of randomness
  • Enriching the Web3 ecosystem — breaking a near-monopoly stimulates technological innovation and price competitiveness.

Introducing QRNG

There’s been a lot of excitement comparing API3’s QRNG to the incumbent RNG product for Web3, Chainlink’s VRF. I’ve had a front-row seat on our Twitter the last few months while eating a metric ton of popcorn.

The team behind the QRNG is the Quantum Optics Group of the Australian National University (ANU) in Canberra. On top of their world-class research into quantum physics, the scientists at the Australian National University have been providing random number generation to Web2 for the last ten years. However, the technical challenge of integrating a 3rd-party oracle node into the mix stopped them from being able to provide the same service to Web3 blockchain projects.

With API3’s first-party Airnode taking down barriers, ANU was able to easily expand their service base to Web3. Now smart contracts can make requests to their API and receive a truly random output in the forms of numbers, texts, colors, and so on.

As a non-mathematician, when I first heard that ANU utilizes the intrinsic probabilistic nature of quantum mechanics and entropy to set QRNG apart from traditional random number generators — I said “😯”.

Though we’ll go over the specifics a little later in the article the TLDR is that not everyone can build a QRNG. Barriers to entry include exorbitant maintenance costs and fiddly mechanics, but thankfully we can all access the benefits of QRNG through API3.

New to trading? Try crypto trading bots or copy trading

Compared to the incumbent VRF options, API3 QRNG has some cool pros:

  1. Free-to-use.
  2. Available on ten chains VRF isn’t, and three chains VRF is (full list here).
  3. True randomness thanks to entropy.
  4. Breaks up a near ecosystem-wide monopoly on random number generation, which can only benefit devs and dApp users in the long-run.

Why random?

Randomness is so important to humans that objects identified as dice have been found all over the globe dating back thousand of years and into pre-history. With all this time playing with randomness, we’ve found many uses for it.

Games and gambling frequently employ randomness in the form of selecting winners and losers (like in roulette, or straws), or in deciding the abilities of players like the dice in Monopoly that move players around the board.

The government in ancient Athens used random selection for its members. Various committees managing important affairs were formed and reformed regularly by drawing from the citizens at random, much like jury duty is assigned today. The idea of elections were seen by ancient Athenians as unaligned with the principle of equality.

Randomness is also critical to security, like in the generation of keys with the elliptic curve method as used in Bitcoin.

Without systems to generate randomness, we’re left with predictable outcomes or our own biases. These can have wide ranging effects from boredom to bankruptcy.

What is random?

True randomness requires that there be no pattern or predictability to events.

But when you use algorithms to generate randomness, their programmatic method inherently follows a structure that results in patterns given enough time; they more approximate randomness than really generate it.

What about flipping a coin? You would still need to manually flip the coin each time you needed a number to keep the outcome tied to the randomness of nature and have a true random number generator (TRNG).

If you were to take data for thousands of manual flips and pipe that data into an algorithm so that your service could be useful to many people, you’d then run into the same issue of programmatic selection:

  • input is a finite set
  • finite means repetition at some point
  • output is not truly random

Cryptographic proof of randomness

VRF stands for “Verifiable Random Function”. These functions are composed of three parts:

  1. A generator function which makes a public/secret key pair k bits in length.

GEN(1k) = (PK,SK)

2. A main function that outputs a variable about the randomness based on the secret key.

FSK(x) = (r,π)

3. A verifier function that verifies that the randomness was calculated correctly based on the public key.

VERPK(x,r,π) = True/False

Along with a number, VRFs also output a cryptographic proof about how that number was generated. The proof means the computation is reproducible, enabling trustless consensus verification.

However, VRFs are technically pseudo-random number generators (PRNGs) because of a mechanic that causes the numbers to start repeating after a long enough period of time. Also, PRNGs security is dependent on limitations in computational power, since they’re deterministic algorithms.

We must return to the natural world for true randomness.

Enter entropy

“The quantum theory basically tells us that in empty space, you still have… virtual particles forming and disappearing… And that’s what we’re seeing… I think that that’s why people are quite fascinated that from nothing comes this sequence of infinite random numbers” — Professor Koy Lam of the Quantum Optics Group of the Australian National University

Dr Aaron Tranter with the ANU Quantum Random Number Generator | Picture: Elesa Kurtz

At the ANU, they create this empty space by holding a vacuum inside a gold box, and then use a laser to detect the particles phasing in and out of existence. That measurement is turned into binary code used to generate random numbers.

Random input yields random output.

Trust in physics

The ANU Quantum Random Number Generator experiment used for API3 QRNG is specifically optimized to benefit cryptography, and is set up to be secure even in the presence of an adversary.

The QRNG looks for noise in a vacuum. Think of this noise as a kind of static, which is made up of electromatic, thermal and quantum information. The cool thing is that the ratio of what makes up the noise follows a predictable distribution known as the quantum-to-classical-noise ratio, which we’ll see is a key factor in the security of the data collected.

The thermal and electromagnetic signals are comparatively easy for an adversary to monitor or control. However in order to manipulate the quantum signal, humans would need to know how to accurately apparate matter remotely, which isn’t on the table at the moment.

Thus, the scientists are able to use the quantum-to-classical-noise ratio to cancel out what could possibly be predicted or controlled by an adversary, and generate numbers based only on the quantum data that their laser is detecting. Currently, this yields random bits of information at a rate of 5.7 Gbits/s — faster than the bandwidth available to broadcast the data.

Interestingly, there’s an experiment you can run to check the randomness of the data API3 QRNG delivers — just open this link in two separate windows. Put the two windows side by side and you’ll notice that each series of colors is completely unique. That would continue to be the case if you stacked more and more open windows for comparison.

The ANU API delivers new and unique random numbers for every call it receives, and has been doing just that for the last 10 years. There is a constant stream of data coming from the experiment that results in an answer unknown to anyone before a request is fielded.

A richer Web3 ecosystem

With API3 QRNG, developers on 10 new chains have access to random number generation. 3 others now have the choice between API3 QRNG and VRF.

Choice is the cornerstone of markets, and drives innovation through competition between service providers. In order to get the largest share of customer dollars, companies are incentivized to out-compete others by providing the product with the best market fit. This means that they have to constantly be looking to improve, both against what they have done in the past, but also against what their competitors are doing now or might do in the future.

Not only do services get better thanks to this mechanic, they also get less expensive. If customers don’t like the price of a good or service, they have the choice to move elsewhere. With competition, market forces can honestly balance cost against what is being offered.

Thanks Capitalism!

There will undoubtedly be critiques, but I’m excited to see how a new player entering the game changes the board. So pop some popcorn, and let’s watch randomness work its magic — innovation is unpredictable.

Thanks to Ry Leong for setting me down this rabbit hole.

Also, Read

--

--

Tom Watson
Coinmonks

I like to learn and help others do the same. Twitter: @omnomtomnom