Skip to main content

This site is for educational purposes only. Nothing here constitutes financial advice.

Topic 47 of 189

Verifiable Random Functions

How VRFs produce randomness that's both unpredictable before commitment and cryptographically verifiable after — enabling fair lotteries, leader election, and on-chain randomness without trusted parties.

Beginner
8 min readUpdated November 2026Block Clarity Hub Editorial Team

The basics

Why On-Chain Randomness Is Hard

Blockchains are deterministic — every node has to compute the same answer given the same inputs. Real randomness doesn't fit. But many applications need randomness: NFT trait reveals, lottery winners, game outcomes, validator selection for the next block. Using `block.timestamp` or `blockhash` is unsafe because miners can manipulate them within their slot. Every chain needs a credible answer.

What a VRF Does

A Verifiable Random Function takes an input (e.g., a block hash, a seed) and a private key, and produces two things: a pseudo-random output, and a proof that the output was correctly computed from the input and key. The output looks random to anyone who doesn't hold the private key, but anyone can verify the proof matches. So you get: unpredictable before computation, verifiable after.

Chainlink VRF — A Widely Used Option

Chainlink VRF is a widely used on-chain randomness service. A smart contract requests randomness, paying in LINK or the chain's native token. A Chainlink oracle computes a VRF using its private key and the contract's request, and posts the output plus proof on-chain; the proof is verified on-chain before the contract can use the value. Used by major NFT projects, on-chain games, and DAO lottery mechanisms.

  • Block hashes are unsafe — miners can manipulate them
  • VRFs give unpredictable output + verifiable proof
  • Chainlink VRF is a widely used production option on EVM chains
  • Used by: NFT trait reveals, lotteries, on-chain games, DAO leader election

Key Takeaways

  • On-chain randomness without VRFs is unsafe — block fields are manipulable
  • VRFs produce unpredictable output + verifiable proof of correctness
  • Chainlink VRF is a widely used production solution
  • Common uses: NFT reveals, lotteries, games, validator selection

Going deeper

VRF Construction

The simplest VRF uses elliptic curves. The private key is a scalar x, the public key is xG (G is the curve generator). To compute the VRF on input m: hash m to a curve point H(m), multiply by x to get xH(m), and produce a Schnorr-style proof that xH(m) was computed from the public key. The output is the hash of xH(m). The proof can be verified by anyone with the public key without learning x. RFC 9381 standardises ECVRF on multiple curves.

Why Block Hashes Aren't Enough

Using `block.prevrandao` (formerly `block.difficulty`) on Ethereum looks tempting — it's a fresh value per block. But block proposers can choose to skip blocks if the prevrandao is unfavourable for their interests, biasing the value. This is fine for low-stakes randomness but inadequate for high-value applications. Chainlink VRF, drand (a distributed beacon), and committee-based randomness avoid this by using cryptography that the proposer can't simply skip.

VRFs in Consensus

Algorand is a well-known chain that uses VRFs in consensus: each block, validators compute a VRF on the current seed; the validator with the lowest VRF output (a 'committee selection') proposes the next block. Because the VRF is private and unpredictable, an attacker can't know in advance who'll be chosen, defeating denial-of-service attempts against the future proposer. Many post-Algorand consensus protocols use similar VRF-based leader selection.

Don't Confuse VRF With General Randomness

A VRF requires a specific private key and produces deterministic output for that key. It's not a source of fresh randomness — it transforms unpredictability of the key into unpredictability of the output. To get genuinely fresh randomness, you still need a beacon (drand, NIST randomness beacon) or a commit-reveal scheme. VRFs are best understood as 'committed pseudo-randomness with verifiable evaluation.'

Key Takeaways

  • Standard ECVRF uses elliptic-curve math — private key x, public key xG, output is hash of x times hash-to-curve
  • Block-field randomness is unsafe in high-stakes settings because proposers can skip unfavourable values
  • Algorand and many modern consensus protocols use VRFs for unbiased leader selection
  • VRFs transform key unpredictability into output unpredictability — they're not a source of fresh randomness

Under the hood

Bias-Resistance and Composability

A VRF holder still has some control: they can choose whether to publish the output or stay silent. If they don't like the value, they could refuse to participate, biasing the system toward 'whoever-likes-the-output.' Defences include: requiring deposits that get slashed for non-participation, using committees so any one party can't unilaterally suppress output, and using verifiable delay functions (VDFs) layered on top so the output cannot be computed in time to decide whether to withhold it.

drand and Distributed Randomness Beacons

drand is a public randomness beacon run by a network of independent organisations (including Cloudflare, EPFL, Protocol Labs). On its default chain it produces a fresh random value every 30 seconds (its newer quicknet chain every 3 seconds) via threshold BLS signatures. Outputs are verifiable, and nobody can predict or bias them without controlling a threshold of the nodes' key shares. drand is used within the Filecoin network, and its documentation lists leader election in consensus mechanisms and randomness for smart contracts among its uses.

VRFs vs VDFs vs Commit-Reveal

Three primitives for on-chain randomness. VRF: fast, requires trusted operator(s), output computable instantly. VDF (Verifiable Delay Function): takes a fixed minimum time to compute (e.g., 10 seconds), unbiasable, but currently slow and energy-intensive. Commit-reveal: parties commit to values in one transaction, reveal in the next; the XOR of reveals is the output. Each has tradeoffs in trust assumption, freshness, and latency. Many production systems combine them — e.g., commit-reveal seed feeding into a VRF for the actual output.

Real Attacks and Pitfalls

Several documented attacks on naive on-chain randomness: early lottery contracts manipulated by mining a block at the right time; multiple NFT mints rigged by attackers who reverted transactions when the random output was unfavourable. The pattern is: an attacker who can observe the random output before committing can choose not to commit. The defence requires either Chainlink VRF (the attacker can't predict the output) or commit-reveal where the commit is irrevocable. Naive PRNGs derived from block fields aren't enough.

If You're Building, Use Chainlink VRF v2.5 or drand

Don't roll your own randomness. Chainlink VRF v2.5 is the version in Chainlink's current docs and lets you pay for requests in LINK or native tokens. drand randomness is published by the League of Entropy and can be consumed over HTTP, gRPC or libp2p PubSub, with Go and JS client libraries. The cost of getting on-chain randomness wrong is high — exploited lotteries, rigged mints, biased validator selection. Use vetted infrastructure.

Key Takeaways

  • VRF holders can bias by refusing to publish — defences include slashing deposits and committee diversification
  • drand provides a distributed beacon with threshold BLS, used by Filecoin
  • Three primitives in production: VRF (fast + trusted), VDF (slow + trustless), commit-reveal (flexible + multi-tx)
  • Naive block-field randomness has been exploited many times — lotteries and NFT mints rigged
  • Use Chainlink VRF or drand for production randomness needs; don't roll your own

Related Content

State Pruning and Expiry

Why Ethereum's node storage needs have grown to terabytes, what 'archive,' 'full,' and 'light' nodes actually store, and how proposals like EIP-4444 and new state-tree designs (verkle or binary) aim to keep node hardware accessible for years to come.

ECDSA vs EdDSA vs BLS

The three signature schemes you'll meet across the crypto stack — what each does well, what tradeoffs they impose, and why Ethereum uses three of them simultaneously.

zk-SNARK vs zk-STARK vs PLONK

How the three major proof-system families compare on trusted setup, proof size, prover cost, and quantum resistance — and which production rollups picked which.

Threshold Signatures and MPC

How t-of-n threshold signatures and multi-party computation let multiple parties sign together without any one holding the full key — the cryptography behind Fireblocks and modern institutional custody.

Hash Functions Compared

SHA-256, Keccak-256, Blake3, and Poseidon — which one each chain uses, why ZK systems needed a new family of 'arithmetic-friendly' hashes, and what tradeoffs each makes.

Stealth Addresses and Confidential Transactions

Privacy primitives that hide who's receiving what — from Monero's foundational stealth addresses to Ethereum's ERC-5564 and the legal context post-Tornado-Cash.

CDP Lifecycle

How collateralized debt positions work end-to-end — minting DAI against ETH, paying stability fees, surviving liquidations, and the structural lessons from MakerDAO's Black Thursday and Liquity's no-fee model.

Perpetual Swap Mechanics

How perp futures actually work — funding rates that keep them pegged to spot, mark vs index price, insurance funds that backstop losses, and the liquidation cascades that wreck overleveraged accounts in seconds.

References & further reading