# How a VRF proof is verified on-chain

A VRF coordinator accepts a random number only when the oracle's proof passes one check. The proof must show that the number came from the oracle's registered key and an input fixed by the request. For that key and input exactly one number passes, so the oracle cannot pick another. On Randoo, Chainlink VRF v2.5 and native Ronin VRF, that check is Chainlink's `VRF.sol`, an ECVRF verifier on the secp256k1 curve. On 75 Randoo mainnet fulfilments it cost from 23,195 to 72,448 gas, 28,678 at the median.

The cost depends on one step. Before checking anything, the verifier must hash the input onto the curve, and it tries candidate points until one lands on it. Each extra try costs about 5,460 gas. Half of all inputs need one try, and about 2 in 1,000 need ten or more. Below: what each step checks, the gas measured on Ronin, Base and Robinhood, the proof edits each check catches, how to re-derive a real proof with `cast`, and what Pyth Entropy, D20DAO and Gelato VRF check instead.

## What the contract checks

The oracle sends the coordinator its proof: its public key `pk`, the point `gamma`, two numbers `c` and `s`, the input `seed`, and four helper values (`uWitness`, `cGammaWitness`, `sHashWitness`, `zInv`). The helpers let the contract check curve arithmetic without doing it in full. `fulfill(requestId, proof)` on Randoo's coordinator then runs these steps:

1. **The key is registered, and its oracle is on turn.** `keccak256(abi.encode(pk))` must be a registered key hash, the transaction must come from that key's wallet, and the request's turn must belong to that key.
2. **The input is the request's.** `proof.seed` must equal `keccak256(abi.encode(blockHash, requestId, consumer, keyHash))`, where `blockHash` is the hash of the block that holds the request. Nobody knows that hash until the block is sealed, so the oracle cannot choose an input in advance.
3. **The proof verifies.** `VRF._randomValueFromVRFProof(proof, proof.seed)` checks that `pk`, `gamma` and the two witness points are on the curve, then recomputes the challenge from the proof and compares it with `c`. A proof made without the secret key, or for another input, fails.
4. **The number is the hash of `gamma`.** The seed is `keccak256(abi.encode(3, gamma))`. Only one `gamma` passes step 3 for a given key and input, so only one seed can come out.

Chainlink VRF v2.5 runs the same steps 3 and 4. Only its input is different: `keccak256(abi.encodePacked(preSeed, blockHash))`, where `preSeed` hashes the key hash, the consumer, the subscription and a nonce (`VRFCoordinatorV2_5.sol` lines 325 and 395). Its coordinator also checks a stored commitment of the request's parameters. Native Ronin VRF verifies with the same `VRF.sol` ([contracts](/docs/contracts#how-a-seed-is-proven)).

## Gas measured on 75 mainnet proofs

We took the 40 latest Randoo fulfilments on Ronin (39 of their transactions were read) and every fulfilment so far on Base (23) and Robinhood (13). Each transaction's input was replayed against `VRF.sol` in a harness built with the coordinator's compiler settings: Solidity 0.8.38, via-IR, 200 optimizer runs. All 75 proofs verified, and each gave the seed the coordinator had recorded. We then ran the harness on each live chain through `eth_call` with a code override. The gas matched the local run for every proof, so Ronin, Base and Robinhood price the verifier's precompile calls the same way.

| Hash-to-curve tries | Proofs | Verification gas |
| --- | --- | --- |
| 1 | 34 | 23,195 – 23,239 |
| 2 | 18 | 28,658 – 28,722 |
| 3 | 12 | 34,133 – 34,193 |
| 4 | 3 | 39,625 – 39,669 |
| 5 | 2 | 45,089 – 45,141 |
| 6 | 1 | 50,593 |
| 7 | 3 | 55,990 – 56,042 |
| 9 | 1 | 67,013 |
| 10 | 1 | 72,448 |

Across all 75, the median was 28,678 gas and the mean 30,441. The verifier was 4.1% to 17.8% of the whole fulfil transaction, 6.7% at the median. The rest is the callback, storage and payment.

On 10,000 random inputs under the Base oracle's key, the number of tries fell by about half at each step: 5,049 needed one, 2,485 two, 1,210 three, 630 four, 311 five, and 12 needed eleven or more. Hash-to-curve alone ran from 6,194 to 77,307 gas, 11,630 on average. A coordinator therefore has to budget for a verification several times its median. Chainlink's wrapper on Base budgets 128,500 gas (`coordinatorGasOverheadNative`) for its coordinator's own work in each fulfilment, the verification included ([subscription vs direct funding](/docs/subscription-vs-direct-funding)).

With one try, the steps cost roughly this much:

| Step | Gas |
| --- | --- |
| `pk`, `gamma`, `cGammaWitness`, `sHashWitness` on the curve | 2,437 |
| `c·pk + s·G` matches `uWitness` (one `ecrecover`) | 4,023 – 4,035 |
| Hash the input to a curve point (one square root through the `modexp` precompile per try) | 6,216 – 6,236 |
| `c·gamma + s·H` from the witnesses, checked with two `ecrecover` calls | 10,711 – 10,729 |
| Recompute the challenge and compare it with `c` | 2,073 – 2,080 |
| Output: `keccak256(abi.encode(3, gamma))` | 220 |

The steps were timed one by one, so they add up to a little more than the 23,195 to 23,239 the full check costs.

## What a changed proof fails on

We took one real Base proof, changed one field at a time, and called the verifier. Every change was rejected, and the revert message says which check caught it:

| Change | Rejected by |
| --- | --- |
| `seed + 1`, as if the proof were reused for another request | `Second mul check failed` |
| `gamma` from another Base proof, to deliver a different number | `First mul check failed` |
| `c + 1` | `addr(c*pk+s*g)!=_uWitness` |
| `s + 1` | `addr(c*pk+s*g)!=_uWitness` |
| The Ronin oracle's `pk` | `addr(c*pk+s*g)!=_uWitness` |
| `gamma`'s y-coordinate + 1 | `gamma is not on curve` |
| `zInv + 1` | `invZ must be inverse of z` |

The second row is why a VRF number can be trusted. An oracle that dislikes a result cannot send a different `gamma` for the same request, because no other `gamma` passes. It can only refuse to answer, and how a game should handle that is in [VRF security considerations](/docs/vrf-security#4-no-retry-cancel-or-refund-that-depends-on-the-seed).

## Re-derive a real proof with cast

This is Randoo's request 23 on Base: the playground's race contract asked for a seed in block 66,371,884, and the oracle fulfilled it in block 66,371,897.

```bash
RPC=https://base-rpc.publicnode.com
COORD=0xC66eB2e7EE91145875000Ad46B55600000000001

# 0. Find the fulfil transaction and the consumer from the coordinator's events
TX=$(cast logs --from-block 66371897 --to-block 66371897 --address $COORD \
  'FulfilledBy(uint256 indexed,bytes32 indexed,uint256)' --rpc-url $RPC --json | jq -r '.[0].transactionHash')
CONSUMER=$(cast parse-bytes32-address "$(cast logs --from-block 66371884 --to-block 66371884 --address $COORD \
  'RandomSeedRequested(bytes32 indexed,uint256 indexed,address indexed,uint256,uint256,address,uint256)' \
  --rpc-url $RPC --json | jq -r '.[0].topics[3]')")

# 1. Decode the fulfil: request id and proof
cast calldata-decode 'fulfill(uint256,(uint256[2],uint256[2],uint256,uint256,uint256,address,uint256[2],uint256[2],uint256))' \
  "$(cast tx $TX input --rpc-url $RPC)"

# 2. Key hash of the proof's public key
PK='[89617326799109392770940164273926794054020202648011985922217592726354162839822,81892543751159606250916719839983533990340410521998089908744591458443450508479]'
KH=$(cast keccak "$(cast abi-encode 'f(uint256[2])' "$PK")")

# 3. The input: request block hash, request id, consumer, key hash
BH=$(cast block 66371884 -f hash --rpc-url $RPC)
cast to-dec "$(cast keccak "$(cast abi-encode 'f(bytes32,uint256,address,bytes32)' $BH 23 $CONSUMER $KH)")"
# 3817087998478631088345055632926607592035703197981559317189228290078746463807 = proof.seed

# 4. The number: hash of gamma
GAMMA='[11277775985892243523133337796407532862714003695930700964093653790573793250587,26037750228314252570173039557179518513201158469911637476996934262261421206055]'
cast to-dec "$(cast keccak "$(cast abi-encode 'f(uint256,uint256[2])' 3 "$GAMMA")")"
# 18272803124032535962177286808579380610236015823155931066001167410771913050569 = the seed delivered
```

Steps 3 and 4 tie the number to the request. Step 3 of the contract's checks, the curve math, is the part `cast` cannot do. [/verify](/verify) runs all of it in your browser for any Randoo request, from a request hash or a transaction hash.

## What other providers check

Not every on-chain random number comes with a proof the chain checks. Here is what each provider's contract verifies before it calls you:

| Provider | Checked on-chain before the callback | The number depends on |
| --- | --- | --- |
| Randoo | ECVRF proof with `VRF.sol`, against a registered key on its turn | Oracle key, request block hash, request id, consumer |
| Chainlink VRF v2.5 | ECVRF proof with `VRF.sol`, a registered key, and the stored request commitment | Oracle key, request block hash, key hash, consumer, subscription, nonce |
| Native Ronin VRF | ECVRF proof with `VRF.sol` | Oracle key and the request |
| D20DAO on Robinhood | The drand round's BLS signature, the first time a request of that round is served, then a secp256k1 VRF proof against a seed that binds the round ([architecture](https://d20dao.org/docs/architecture)) | D20DAO's key and a drand round |
| Pyth Entropy | No elliptic-curve proof. The provider's revealed value, hashed forward `numHashes` times, must equal its last stored commitment, and the user's value must hash to the user commitment (`Entropy.sol` `revealHelper`) | `keccak256(userRandom, providerRandom, blockHash)`; `requestV2()` without a user value makes one from `block.timestamp`, `block.prevrandao`, the requester and a stored seed, and sets the block hash to zero |
| Gelato VRF | No randomness proof: "verifiable off-chain but not on-chain", per its archived security page ([Gelato VRF status](/docs/gelato-vrf)) | A drand round |

Pyth's check is a handful of `keccak256` calls, cheaper than an ECVRF check, and it needs no curve math. Its guarantee comes from the provider committing to its whole chain of values in advance, not from a per-request proof. D20DAO adds a public beacon, so its numbers depend on more than one party's key. In every design here, the party that answers can compute the number before it publishes it, and can refuse to publish it ([Randoo vs Pyth Entropy](/docs/pyth-entropy#where-pyth-entropy-is-the-better-pick)).

## Tests we ran

In a scratch Foundry project (forge 1.10.0, Solidity 0.8.38 via-IR with 200 runs, EVM version osaka), with Chainlink's `VRF.sol` as Randoo vendors it from tag contracts-v1.3.0, these 4 tests pass:

- All 75 mainnet fulfil inputs verify, and each returns the seed the subgraph recorded. Gas per proof and per step is in the tables above.
- One Base proof with one field changed at a time: 7 of 7 changes rejected, with the messages in the table above.
- A proof replayed with the next request's input is rejected.
- 10,000 inputs hashed onto the curve under the Base oracle's key: the tries table above.

The live-chain check called the same harness through `eth_call` with a code override on `api.roninchain.com/rpc`, `base-rpc.publicnode.com` and a Robinhood RPC. It returned the same seed and the same gas as the local run for all 75 proofs.

## Try it

Roll a free seed on Base Sepolia in the [playground](/playground?network=base-sepolia), without a wallet, then paste its transaction into [/verify](/verify) to watch each check run. To request seeds from your own contract, start with the [quickstart](/docs/quickstart). If you come from Chainlink's wrapper, [one line changes](/docs/chainlink-wrapper). Your proofs are then checked by the same `VRF.sol` as before.

Sources (read 2026-12-06): Randoo's mainnet fulfil transactions and subgraphs on Ronin, Base and Robinhood; `VRF.sol` from smartcontractkit/chainlink tag contracts-v1.3.0, as vendored by Randoo; `VRFCoordinatorV2_5.sol` in `@chainlink/contracts` 1.5.0 from npm; pyth-crosschain `Entropy.sol` at commit f06628c (2026-09-18); D20DAO's [architecture page](https://d20dao.org/docs/architecture); Gelato's archived [VRF security considerations](https://web.archive.org/web/20250621084028/https://docs.gelato.cloud/web3-services/vrf/security-considerations).

_Updated 2026-12-06._
