---
title: "Commit-Reveal Scheme — definition | Nuri Glossary"
description: "Publish a hash first, reveal the value later, so nobody can adapt after seeing your choice."
lang: "en"
type: "glossary-term"
canonical: "https://nuri.com/glossary/commit-reveal-scheme"
---

# Commit-Reveal Scheme

Publish a hash first, reveal the value later, so nobody can adapt after seeing your choice.

## Basically

You lock in a choice without showing it. Later, you reveal it so others can check that you did not change it.

## Key Takeaways

- A commit-reveal scheme has two phases: you publish a hash of your secret data as the commitment, then reveal the original data for verification.
- Commit-reveal prevents front-running by hiding your transaction intent until the commitment is recorded on-chain, so observers cannot copy or preempt your pending action.
- Commit-reveal supports ENS domain registration, sealed-bid auctions, on-chain voting and random number generation. Hash time-locked contracts use the same core mechanism for Lightning Network payments.

## What Is a Commit-Reveal Scheme?

A commit-reveal scheme is a fundamental cryptographic protocol that lets you lock in a choice without disclosing it, then prove that choice later. It works like placing a sealed bid in an envelope: you cannot change your bid after submitting it, but nobody can read it until the envelopes are opened. On a blockchain, the envelope is a cryptographic hash, and opening it means publishing the original data, or preimage, that produces that hash.
The scheme solves a core problem on transparent blockchains: all pending transactions are visible in the mempool before confirmation. Without commit-reveal, an adversary watching the mempool can see your intended action and submit a competing transaction with higher fees to get ahead of you. The two steps hide your intent during the critical window when front-running would otherwise be possible.
The concept comes from the broader family of commitment schemes in cryptography, which were formalised in the 1980s. Commitment schemes have since become essential building blocks in zero-knowledge proofs, secure multi-party computation and blockchain protocol design.

## How It Works

A commit-reveal scheme operates in two distinct phases. The protocol enforces a time boundary between commitment and revelation.

## Phase 1: Commit

The participant takes their secret value, such as a vote, a bid or a name they want to register, and combines it with a random secret called a nonce or salt. They compute a cryptographic hash of this combined input and publish only the hash on-chain. The hash acts as a binding fingerprint that uniquely identifies the underlying data without revealing it.
The salt is critical because an attacker could otherwise hash every possible value in a brute-force or dictionary attack to discover the commitment. A commitment hiding a vote that can only be "yes" or "no" would take an attacker only two hash computations to break. A random 256-bit salt makes this attack infeasible.

## Phase 2: Reveal

The participant publishes their original value and salt after the commit window closes, preventing any new commitments. The smart contract recomputes the hash from these inputs and checks it against the stored commitment. Matching hashes mean the reveal is accepted, while different hashes mean the participant is trying to change their answer and the reveal is rejected.

## Security Properties

A properly constructed commit-reveal scheme provides two guarantees. Both guarantees derive from the properties of the underlying hash function.

## ENS Domain Registration

The Ethereum Name Service (ENS) uses commit-reveal to prevent front-running of .eth domain registrations. A single-transaction registration would let a bot watching the mempool see someone trying to register "valuable-name.eth" and submit the same registration with a higher gas price to claim it first.
ENS splits registration into two steps. A mandatory 60-second waiting period separates them.
No observer can determine which name is being registered during the waiting period. The commitment is already recorded on-chain when the name is revealed, so front-running the second transaction would be pointless because the original committer has priority.

## Sealed-Bid Auctions

On-chain auctions benefit from commit-reveal because it enables sealed bidding. Every participant can see every other bid in a standard open auction on a transparent blockchain, encouraging last-second sniping and discouraging honest price discovery.
All bidders submit hashed bids during the commit window, then reveal their actual amounts after the window closes. Participants are incentivised to bid their true valuation because no one can see competing bids before committing. This structure is commonly used for high-value NFT sales and domain name auctions.

## On-Chain Voting

Transparent on-chain voting suffers from "herding": early voters influence later voters, and whale wallets can signal their preference to sway outcomes. Commit-reveal voting hides individual votes until the voting period ends.
Each voter commits a hash of their vote during the voting window. Voters publish their actual choices after the window closes, and the contract verifies each reveal against its commitment. This prevents vote-buying because the buyer cannot verify how someone voted during the commit phase, and eliminates tactical voting based on partial results.

## On-Chain Random Number Generation

Fair random numbers are notoriously difficult to generate on a deterministic blockchain. Commit-reveal offers one approach: multiple participants each commit a random value and reveal them after all commitments are recorded, with the final random number derived by combining all revealed values, typically through XORing or hashing them together.
No single participant can predict the final output because it depends on everyone else's secret values. The approach remains vulnerable to the "last-revealer" problem: the final participant can see all other values and choose between revealing for a favourable outcome or forfeiting their deposit for an unfavourable one. Protocols like Chainlink VRF address this limitation with verifiable random functions.

## Relationship to Hash Time-Locked Contracts

Hash time-locked contracts (HTLCs) share the same core mechanism as commit-reveal: a hash locks a payment, and revealing the preimage unlocks it. In Lightning Network payments, the receiver generates a preimage and shares its hash in a BOLT 11 invoice. The receiver reveals the preimage to claim funds when the sender routes a payment locked to that hash, and this reveal propagates back through every hop in the route.
The key difference is purpose: commit-reveal schemes hide information to ensure fairness by preventing front-running and enabling sealed bids, while HTLCs use the hash-preimage pair to enforce atomic conditionality, meaning the payment either completes everywhere or nowhere. Both rely on the one-way property of hash functions, which makes it easy to verify a preimage but impossible to compute one from the hash.
Atomic swaps, submarine swaps and discreet log contracts all extend this commit-then-reveal pattern. They use it to coordinate trustless exchanges across different chains and layers.

## Why It Matters

Information asymmetry on transparent blockchains creates opportunities for exploitation. Miners and validators can reorder transactions for profit (MEV), bots can front-run DEX trades, and observers can preempt domain registrations or auction bids. Commit-reveal is one of the simplest and most effective countermeasures because it removes the information advantage entirely during the critical decision window.
The commit-reveal pattern appears in the HTLC-based payment routing that enables trustless multi-hop transfers for Bitcoin layer-2 protocols like Spark. The hash commitment explains why Lightning payments are atomic: revealing the preimage at any point in the route guarantees settlement across all hops.

## Griefing by Non-Revelation

A participant can commit but never reveal, disrupting protocols that require all commitments to be opened. Missing reveals mean missing votes in voting schemes and prevent the final result from being computed in random number generation. Protocols mitigate this by requiring deposits that are forfeited if the reveal phase is skipped, but this introduces its own economic tradeoffs: the cost of griefing must exceed the potential benefit of withholding information.

## Last-Revealer Advantage

The last participant to reveal in multi-party commit-reveal protocols, such as on-chain RNG, has an asymmetric advantage. They can see all other revealed values, compute the final outcome and decide whether revealing benefits them. Rational actors will choose to grief if the stake exceeds the deposit, while more sophisticated constructions like threshold commitment schemes or verifiable delay functions address this but add complexity.

## Front-Running the Reveal

The reveal transaction itself is visible in the mempool even though the commit phase is protected, so an adversary who sees it can extract useful information before it confirms in some protocols. A validator seeing a reveal in the mempool during a sealed-bid auction could theoretically censor or reorder it. Protocol designs must ensure that observing the reveal provides no actionable advantage, or use private mempools and encrypted mempool solutions to hide reveal transactions.

## Gas Cost and User Experience

Commit-reveal requires two separate on-chain transactions instead of one, roughly doubling the gas cost and adding a mandatory waiting period. ENS registration involves a 60-second delay and two transaction fees, which can create significant friction for applications targeting mainstream users. Some protocols batch commits or use off-chain commit phases to reduce overhead.

## Salt Management

A user who loses their salt before the reveal phase cannot prove their commitment and effectively forfeits their participation. ENS stores the salt in browser local storage, which can be lost if the user clears their browser data between the commit and reveal steps. Applications must carefully manage salt storage and communicate the importance of completing both phases in sequence.
The glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.
Part of the [Nuri glossary](https://nuri.com/glossary), which defines 1876 Bitcoin, Lightning, wallet, stablecoin and payment terms.
