Why True Randomness Is Important in Web3
Randomness is a fundamental property of nature denoting the lack of pattern or predictability. While randomness underpins much of the activity on the Internet, true randomness is extremely difficult—perhaps even impossible—to achieve with computers since they are deterministic systems.
The term “randomness” refers to the lack of pattern or predictability. The outcome of a coin toss, the pattern of a fingerprint, and the shape of a snowflake are all considered to be unpredictable. While unpredictable outcomes are abundant in nature, the same can’t be said for randomness generated by computers. As computers are deterministic devices, it may not be possible to generate truly random numbers purely through a set of computer algorithms.
Furthermore, while individual random events are considered to be unpredictable, the frequency of different outcomes over repeated events can be predictable. For example, while the outcome of any individual dice roll is unpredictable, the probability of outcomes over 100 dice rolls can be calculated with high certainty.
With economic, social, and cultural interactions increasingly taking place on the Internet, there has been a growing demand over the last few decades to mimic the unpredictability of the natural world and create digital systems that incorporate unpredictable outcomes. Use cases for this unpredictability include introducing artificial scarcity, building more robust security mechanisms, and facilitating credibly neutral decision-making processes.
In this article, we’ll break down what randomness is, learn about types of randomness, and explore the challenges randomness presents when it comes to blockchains and the Web3 ecosystem.
Is Randomness Truly Random?
First, we need to define a set of principles that make a sequence random. If a sequence is to be identified as random, it has to possess the following qualities:
- Unpredictable—The result must be unknowable ahead of time.
- Unbiased—Each outcome must be equally possible.
- Provable—The result must be independently verifiable.
- Tamper-proof—The process of generating randomness must be resistant to manipulation by any entity.
- Non-reproducible—The process of generating randomness cannot be reproduced unless the original sequence is preserved.
A computer is a predictable device with preset circuits, components, and a defined set of code and algorithms, making the prediction of a random number output or sequence generated by a computer possible under fixed conditions. Just as a functioning calculator should always produce the output of 2+2 to be 4, a computer should always produce a given output given the same input. As such, computers may be unable to generate contingent conditions and true random numbers.
To circumvent this limitation, random number generators (RNGs) use a seed—the starting value (input) of the calculation that is used to generate the output. The seed can be generated based on anything that’s complicated to reproduce—data captured from a photograph, the time of day, the user’s mouse movement, or lava lamps.
However, even if the random number generation process is difficult to reproduce, that doesn’t mean reproducing it is technically impossible. If multiple hard-to-repeat seed generation methods are combined, the results can be considered relatively reliable, even if it’s a reasonable assumption that those seeds may eventually be revealed over time. But if the same mathematical method is used when generating different seeds, the results won’t be truly random. The question then becomes: What kind of randomness can be considered truly random?
Pseudorandom RNGs vs. True RNGs
Generally, we can divide random number generators into two categories: pseudorandom random number generators (PRNGs) and true random number generators (TRNGs). PRNGs use mathematical algorithms as a means of generating random values, while TRNGs use physical means such as atmospheric noise.
PRNGs are a set of algorithms that use mathematical formulas to generate a random sequence that mimics true random numbers. As computers are distinct systems, the numbers may appear random to human observers, but they may contain discernible patterns that can be revealed through extensive statistical analysis.
TRNGs utilize unpredictable physical sources such as cosmic noise, the radioactive decay of isotopes, or static in airwaves to generate random numbers based on naturally occurring phenomena. As TRNGs “extract” randomness from physical phenomena, they are considered to produce stronger (more unpredictable) randomness than computers do. Even so, the information TRNGs use may also be deterministic. If someone inserts themselves between the TRNG and the phenomenon it is scanning, they could pick up the same signal and know exactly what the sequence of numbers is.
While TRNGs can produce random sequences that have a lower chance of being revealed to contain discernible patterns, they are more cost-intensive than PRNGs, making them impractical for common use cases. PRNGs also have another key benefit compared to TRNGs—reproducibility. An observer can reproduce the same sequence of numbers if they know the starting point of the sequence, making the verification of the random number generation process possible—a helpful aspect for many Web3 applications that incorporate randomness.
Why Randomness Is Important for Blockchains
Secure randomness underpins the foundations of the cryptography used in blockchains. An essential ingredient in generating a private key for a cryptocurrency wallet, cryptographic hash functions ensure that it’s prohibitively difficult to guess what a particular wallet’s private key is. By some estimations, the number of possible private key combinations in SHA-256—the hash function used in the Bitcoin protocol—is close to the estimated number of atoms in the observable universe.
Distributed consensus is fundamentally constrained by the number of messages that can be sent within a period of time (throughput) and the time it takes for a message to be sent across the network (latency). In a public blockchain with thousands of distributed participants needing to come to agreement, every node needing to send messages to all other nodes wouldn’t be practical. To limit the number of messages that need to be sent to achieve consensus, Bitcoin uses Proof of Work (PoW) as a source of randomness that determines which block gets added to the blockchain. As the computational puzzle miners are competing to complete to successfully add a block to the blockchain is difficult to solve, the probability that multiple nodes will solve the puzzle at the same time is low, limiting the number of messages required for the network to reach consensus.
Randomness is also commonly used in Proof-of-Stake (PoS) systems to underpin the fair and unpredictable distribution of validator responsibilities. If a malicious actor can influence the source of randomness used in the selection process, they can increase their chance of being selected and compromise the security of the network.
Due to the transparency of blockchains, all inputs and outputs are exposed to system participants, potentially making randomly generated sequences predictable. For example, some methods for on-chain random number generation, such as block hashing, contain easily exploitable security loopholes. If the miner/validator has an interest in a particular outcome decided by a random value or sequence, the block producer can influence the generation of random sequences by not publishing blocks that would give it a disadvantage, essentially rerolling the dice until a favorable outcome for them appears.
On the other hand, off-chain RNG solutions are opaque, requiring users to trust that the centralized data provider won’t manipulate the results to their benefit, with no way for the user to tell the difference between true or manipulated randomness. Both solutions become increasingly concerning as the amount of value being secured by the RNG solution goes up.
Randomness in Web3
When people think of blockchain gaming, NFT projects, or digital art, they may not take into account the importance of randomness in determining outcomes. Whether it’s determining the location of in-game assets in a metaverse, adding variation to a generative art algorithm, generating the content of a loot box, minting NFTs, distributing prizes to winners, authenticating event tickets, or periodically determining which DAO participant gets selected for a particular governance role, Web3 applications require a secure source of randomness to create fair and unpredictable outcomes.
As these systems can amass a considerable amount of real-world value, exploitable outcomes from suboptimal randomness solutions can lead to information asymmetry and an unfair advantage for a subset of participants. These scenarios can often create negative feedback loops that lead to an imbalance of power in interactions and result in the complete failure of economic and game-theoretic mechanisms designed to facilitate economic activity and social coordination.
Accessing a source of randomness that is tamper-proof, unpredictable, and auditable by all participants is not an easy feat. However, the desire for fairness and transparency in the Web3 industry has unlocked many applications and protocols that stand out compared to their Web2 counterparts. The ability to access a fair and unbiased source of randomness in a verifiably secure manner opens up a plethora of new use cases in blockchain gaming, NFTs, decentralized governance, Web3 social media, fundraising and charity, social tokens, and beyond.
Chainlink Verifiable Random Function (VRF) is the industry-standard RNG solution, enabling smart contracts and off-chain systems to access a source of verifiable randomness using off-chain computation and cryptography. VRF combines block data that is still unknown when the request is made with the oracle node’s pre-committed private key to generate both a random number and a cryptographic proof. The consuming application will only accept the random number input if it has valid cryptographic proof, and the cryptographic proof can only be generated if the VRF process is tamper-proof.
Since its launch, Chainlink VRF has fulfilled more than 6.5 million requests for fair and unbiased random numbers and currently provides verifiable randomness to over 3,400 unique smart contracts across multiple blockchain networks, including Avalanche, BNB Chain, Ethereum, and Polygon.
Chainlink VRF provides a number of critical features that make it the industry standard, such as:
- Unpredictable—No one can predict the randomness generated by Chainlink VRF as block data is unknown at the time of the randomness request.
- Fair/unbiased—The random number generated is based on uniform distribution, meaning that all numbers in the range have an equal chance to be selected.
- Verifiable—Users can verify the integrity of an application relying on a random input from Chainlink VRF through the on-chain verification of the cryptographic proof.
- Tamper-proof—No one—not the oracle, external entities, or the development team—can tamper with the random number generation process. If the VRF process is tampered with, the node cannot produce a valid cryptographic proof, and the smart contract won’t accept the random number input.
- Transparent—Thanks to the code being open-source, users can verify the process of sourcing randomness.
With the aid of these unparalleled features, a multitude of baked-in security techniques, and continual enhancements based on user feedback, applications powered by Chainlink VRF can produce provably fair, unpredictable outcomes through a tamper-proof RNG and unlock meaningful and exciting features and experiences.
If you’re a developer and want to quickly get your application connected to Chainlink VRF, visit the developer documentation and join the technical discussion in Discord. If you want to schedule a call to discuss the integration more in-depth, reach out here.