A commit-reveal scheme is a two-phase cryptographic protocol designed to hide a participant's initial input (the secret) while committing to it irrevocably, only revealing it in a subsequent phase. In the commit phase, a user generates a cryptographic hash, known as a commitment, from their secret combined with a random value (a salt or nonce) and broadcasts this hash to the network. This commitment acts as a sealed, tamper-proof envelope—it binds the user to their secret without disclosing it. The core properties enforced are hiding (the secret cannot be deduced from the commitment) and binding (the user cannot later reveal a different secret that produces the same commitment hash).
Commit-Reveal Scheme
What is a Commit-Reveal Scheme?
A foundational cryptographic technique used in blockchain protocols to ensure fairness and privacy in scenarios where information must be submitted without being prematurely known.
The reveal phase occurs later, after all participants have submitted their commitments. Here, users publicly disclose their original secret and the random salt. The network can then verify the revelation by re-hashing the provided data and checking it matches the earlier commitment. This mechanism is critical for preventing front-running and manipulation in decentralized applications. For example, in a blockchain voting system or a random number generation protocol like RANDAO, participants commit to their votes or random numbers in one block and reveal them in a later block, ensuring no one can change their input after seeing others' choices.
Within smart contract platforms like Ethereum, commit-reveal schemes are implemented to handle operations where on-chain transparency is a disadvantage. A common use case is in sealed-bid auctions, where bidders submit hashed bids with a deposit. After the commitment period ends, they reveal their actual bid amounts; the contract verifies each reveal against its hash and awards the item to the highest valid bidder. This process prevents bidders from being influenced by others' bids in real-time. The random salt is essential here, as without it, a simple hash of a common bid (e.g., "100 ETH") could be easily guessed, breaking the hiding property.
The security of the scheme relies on the cryptographic strength of the hash function (e.g., SHA-256 or Keccak-256) and the proper generation of a sufficiently random salt. If the hash function is preimage-resistant, the commitment is effectively hiding. If it is collision-resistant, it is binding. Developers must also carefully manage timing and incentives between phases, often using deposit slashing to penalize participants who commit but fail to reveal, which would otherwise stall the protocol. This pattern elegantly trades off immediate transparency for procedural fairness, making it a cornerstone for decentralized coordination.
How a Commit-Reveal Scheme Works
A commit-reveal scheme is a two-phase cryptographic protocol that prevents front-running and ensures fairness in decentralized systems by separating the submission of information from its disclosure.
A commit-reveal scheme is a two-phase cryptographic protocol designed to ensure fairness and prevent front-running in decentralized applications. In the commit phase, a participant generates a cryptographic commitment—typically a hash—of their secret data (like a bid, vote, or random number) and broadcasts this commitment to the network. This hash acts as a sealed envelope, binding the participant to their choice without revealing it. The commitment is secured using a one-way hash function, making it computationally infeasible to deduce the original data or find a different input that produces the same hash output.
Following a predetermined time period, the reveal phase begins. Participants must then broadcast their original secret data, allowing anyone to verify that it matches the previously submitted hash commitment. If the revealed data hashes to the committed value, the action is considered valid. This mechanism is crucial for applications like blind auctions, fair random number generation (e.g., in blockchain gaming), and on-chain governance voting, where the order or timing of transactions could otherwise be manipulated. The scheme's security relies on the hiding and binding properties of the cryptographic commitment.
In practice, a commit-reveal transaction on a blockchain like Ethereum involves two separate transactions, which introduces challenges. Participants must pay gas fees twice and must remain online to submit the reveal transaction, creating a risk of losing their deposit or stake if they fail to reveal. To mitigate this, schemes often incorporate deposits or slashing conditions. More advanced implementations, such as threshold reveal schemes or the use of verifiable delay functions (VDFs), can enhance scalability and participant experience. This primitive is a foundational building block for achieving transaction ordering fairness and commitment secrecy in transparent, adversarial environments.
Key Features of Commit-Reveal
A commit-reveal scheme is a cryptographic protocol that allows participants to submit information in two phases, preventing front-running and ensuring fairness in decentralized systems.
Two-Phase Submission
The core mechanism consists of two distinct phases:
- Commit Phase: Participants submit a cryptographic hash (the commitment) of their secret data (e.g., a vote, bid, or random number). This hash locks in their choice without revealing it.
- Reveal Phase: After the commit period ends, participants must submit their original secret data. The system verifies it matches the earlier hash. Submissions without a valid prior commitment are rejected.
Prevention of Front-Running
This is a primary use case in blockchain applications. By hiding the actual data in the first phase, the scheme prevents malicious actors from observing pending transactions in the mempool and copying or undermining them. For example, in an on-chain auction, bidders cannot see others' bids during the commit phase, eliminating the advantage of last-moment bid sniping.
Cryptographic Binding & Hiding
The scheme relies on two key properties of cryptographic hash functions:
- Binding: Once committed, a participant cannot change the revealed data to something different than what was originally hashed.
- Hiding: The commitment hash should not leak any information about the secret data. Salts (random nonces) are often added before hashing to prevent brute-force revelation of simple secrets.
Temporal Separation & Finality
The enforced delay between commit and reveal creates a temporal commitment. All participants must decide and commit before anyone can reveal. This ensures all actions are based on the same information state. The reveal phase provides finality, as the on-chain state is only updated with the verified, revealed data.
Use Case: On-Chain Voting
Used in DAO governance to prevent vote buying and coercion. A voter commits a hash of their choice (e.g., hash(vote + salt)). They can prove how they voted with the salt later, but during the voting period, their choice is secret. This allows for more honest voting without fear of social pressure.
Use Case: Random Number Generation (RNG)
A common method for generating provably fair random numbers on-chain. Multiple participants commit to a random seed. After all commitments are received, they reveal their seeds. The final random number is derived from the combination of all revealed seeds. If any participant refuses to reveal, they are penalized, ensuring the process completes.
Visualizing the Commit-Reveal Process
A step-by-step breakdown of how a commit-reveal scheme functions to conceal sensitive information on a public blockchain until a predetermined time.
The commit-reveal scheme is a cryptographic protocol executed in two distinct phases to enable fair and private submissions on a transparent ledger. In the commit phase, a participant generates a secret value, such as a vote, bid, or random number, and submits only a cryptographic hash of it—the commitment—to the blockchain. This hash acts as a sealed, tamper-proof envelope, binding the participant to their secret without revealing it. The commitment is publicly recorded, providing cryptographic proof that the information existed at that time and cannot be altered later.
After a predefined deadline for commitments passes, the reveal phase begins. Participants must then publicly submit their original secret value. The network, or a smart contract, verifies each reveal by hashing the submitted value and checking that it matches the earlier commitment stored on-chain. This ensures the participant is revealing the exact information they originally committed to. Any participant who fails to reveal, or submits a value that doesn't match their commitment, forfeits their stake or their submission is invalidated, which is a key mechanism to prevent griefing or last-mover advantage.
This two-step process is crucial for applications requiring secrecy and fairness in a public environment. Common use cases include blind auctions, where bidders' amounts must remain hidden until the auction closes to prevent strategic bidding; fair randomness generation, where multiple parties commit random seeds later revealed to create a provably unbiased result; and governance voting, where votes can be cast privately to prevent coercion, with results only tallied after the reveal period. The scheme elegantly solves the problem of how to keep information secret on a system where all data is inherently public.
From a technical perspective, the commitment is typically created using a cryptographic hash function like SHA-256. To prevent brute-force attacks where an attacker guesses the secret by hashing common values, the secret is often combined with a random salt or nonce before hashing. The salt is revealed alongside the secret, allowing for verification. Smart contracts on platforms like Ethereum automate this entire process, holding funds in escrow during the commit phase and automatically executing settlements or penalties based on the validity of the reveals, making the protocol trustless and self-enforcing.
While powerful, commit-reveal schemes have limitations. They require participants to be online and proactive in both phases, which can be a hurdle for user experience. There is also a inherent time delay, as the process cannot be completed instantaneously. Furthermore, if the secret is very low-entropy (easy to guess), a powerful adversary might still precompute possible hashes. Despite these trade-offs, the commit-reveal scheme remains a foundational cryptographic primitive in blockchain design, enabling a class of applications that would otherwise be impossible on a transparent ledger.
Primary Use Cases in Blockchain
A commit-reveal scheme is a cryptographic two-phase protocol that prevents front-running and ensures fairness by hiding sensitive information (like bids or votes) in a first commitment phase before revealing it in a second phase.
Random Number Generation (RNG)
Creates provably fair random numbers for on-chain applications like gaming or lotteries. Multiple participants commit a hash of their secret number. After all commitments are locked in, they reveal their numbers. The final random value is derived from the combination of all revealed secrets, making it unpredictable and tamper-proof until the moment of revelation.
Privacy-Preserving Voting
Enables anonymous voting with public verifiability. Voters commit to a hash of their encrypted vote. After the voting period, they reveal the vote and decryption key. This allows the tally to be computed publicly while keeping individual votes secret until the reveal, preventing coercion and vote buying based on interim results.
Anti-Front-Running in DEXs
Mitigates Maximal Extractable Value (MEV) by hiding transaction details. Traders submit a commitment to their trade intent. In a later block, they reveal the exact transaction. This prevents bots from seeing pending trades in the mempool and front-running them, creating a more equitable trading environment.
The Commitment: Hashing
The first phase where users generate and submit a commitment, typically a cryptographic hash like keccak256 or SHA-256. The input is the sensitive data (e.g., a bid of 100) concatenated with a cryptographically random salt. This creates a fixed-length digest that reveals nothing about the original data, binding the user to their secret.
The Reveal & Verification
The second phase where users publicly disclose their original data and salt. The smart contract recalculates the hash from the revealed inputs and checks it against the stored commitment. If they match, the data is accepted as valid and originally committed. This ensures binding (can't change the data) and hiding (data was secret).
Ecosystem Usage & Protocols
A cryptographic two-phase protocol used to conceal information during a decision-making process, then later prove its authenticity. It is a foundational mechanism for privacy, randomness, and fair ordering in decentralized systems.
Core Cryptographic Mechanism
The scheme operates in two distinct phases to hide and later prove a secret value.
- Commit Phase: A user generates a secret (e.g., a vote, bid, or random number) and publishes a cryptographic commitment, typically a hash like
keccak256(secret, salt). This binds the user to their secret without revealing it. - Reveal Phase: After all commitments are submitted, users publish their original
secretandsalt. The network verifies each reveal by hashing the provided data and checking it matches the earlier commitment.
This ensures the secret was predetermined and cannot be changed after seeing others' commits.
On-Chain Voting & Governance
Used in DAOs and governance protocols to prevent voting bias and manipulation.
- Concealed Voting: Voters commit hashes of their choices. This prevents later voters from being influenced by early vote tallies.
- Fair Tallying: After the commit phase ends, voters reveal their votes. The final result is calculated from all valid reveals.
- Example: Snapshot and on-chain DAOs use commit-reveal to ensure vote privacy and integrity during sensitive proposals, preventing strategic last-minute swings.
Random Number Generation (RNG)
A critical application for creating provably fair randomness in smart contracts, where all participants contribute.
- Process: Each participant commits a random number. After all commits are locked in, they reveal their numbers.
- Final Random Seed: The revealed numbers are combined (e.g., XOR'd) to generate a final, unpredictable random value that no single party could manipulate.
- Use Case: This method secures NFT minting lotteries, gaming outcomes, and validator selection in proof-of-stake networks, replacing insecure
blockhashreliance.
Sealed-Bid Auctions
Enables fair, front-running-resistant auctions on blockchain by keeping bids secret until a deadline.
- Bid Submission: Bidders commit a hash of their bid amount and a nonce.
- Bid Reveal: After the bidding period, winners reveal their actual bid to claim assets. Non-revealed bids forfeit their deposit.
- Advantage: Prevents participants from adjusting bids based on competitors' actions. Used in NFT platforms like Zora and decentralized domain name auctions to ensure optimal price discovery.
MEV Resistance & Transaction Ordering
Mitigates Maximal Extractable Value (MEV) by obscuring transaction content from block builders until inclusion.
- Commit: Users submit a commitment to their transaction bundle.
- Reveal: The full transaction details are revealed only after the bundle is included in a block.
- Protocol Example: Flashbots SUAVE and other MEV mitigation systems employ commit-reveal schemes to create a fair, opaque mempool, preventing searchers and validators from front-running or sandwiching trades based on visible intent.
Implementation Risks & Considerations
While powerful, the scheme introduces specific engineering challenges that must be addressed.
- Liveness Requirement: Participants must be online to reveal their secrets; failure results in lost funds or broken processes.
- Collusion Resistance: Schemes can be vulnerable if a majority of participants collude before the reveal phase.
- Gas & Cost: Requires two transactions (commit and reveal), doubling gas fees and user effort.
- Salt Security: A cryptographically secure random salt is mandatory; predictable salts allow brute-force attacks to uncover the secret before the reveal.
Security Considerations & Limitations
While a powerful tool for privacy and fairness, the commit-reveal pattern introduces specific security trade-offs and operational constraints that developers must account for.
Front-Running & Timing Attacks
The inherent delay between the commit and reveal phases creates a vulnerability window. Malicious actors can monitor the mempool for commits, deduce their content (e.g., a high-value bid), and front-run with their own transaction. Mitigations include using cryptographic commitments (hashes) that hide the data and employing submarine sends or private mempools to obscure transaction visibility until reveal.
Data Availability & Storage Costs
The scheme requires storing both the commitment (hash) and the later revealed data on-chain, effectively doubling the storage footprint for that operation. This increases gas costs and blockchain bloat. For applications with high-frequency commits (e.g., per-block voting), this can become prohibitively expensive, necessitating layer-2 solutions or alternative cryptographic primitives like zk-SNARKs.
Commitment Non-Repudiation
A critical limitation is ensuring a participant cannot back out of a revealed value that doesn't benefit them. The system must enforce that the revealed plaintext hashes to the committed value. If the reveal fails this check, the transaction must revert, and the participant's stake (often in the form of a bond or deposit) can be slashed. Without economic penalties, the scheme lacks cryptographic fairness.
Collusion & Sybil Attacks
In voting or random number generation contexts, participants may collude to manipulate the outcome after seeing commits but before the reveal. An attacker could also create many fake identities (Sybil attacks) to submit commits, influencing the result. Defenses include participant whitelisting, proof-of-personhood systems, and using verifiable delay functions (VDFs) to enforce a mandatory wait time between commit and reveal.
Blockchain Finality & Reorgs
A commit transaction included in one block could be orphaned by a chain reorganization. If the reveal transaction is mined in a different canonical chain, the original commitment may not exist, causing the reveal to fail. Applications must design for this uncertainty, potentially by only considering commits after a sufficient number of confirmations or using consensus mechanisms with fast finality.
Implementation Complexity & Gas Limits
Correctly implementing the commit-reveal state machine adds significant smart contract complexity. Errors in state transitions or hash verification can lead to locked funds. Furthermore, the reveal transaction must include the original data, which can hit block gas limits if the data is large (e.g., a complex bid). This often limits the scheme to concise inputs like integers or short strings.
Commit-Reveal vs. Alternative Schemes
A comparison of cryptographic schemes for hiding sensitive data, like votes or random numbers, on a public blockchain until a predetermined reveal phase.
| Feature / Metric | Commit-Reveal Scheme | Zero-Knowledge Proofs (ZKPs) | Trusted Execution Environments (TEEs) |
|---|---|---|---|
Core Mechanism | Hash then reveal plaintext | Prove statement validity without revealing data | Compute within secure, isolated hardware |
On-Chain Data Privacy | |||
Off-Chain Trust Assumptions | Requires trusted setup for some systems | Requires trust in hardware manufacturer | |
Computational Overhead | Low (hashing) | High (proof generation/verification) | Medium (secure enclave ops) |
Typical Latency | 2+ blocks (commit + reveal phases) | Proof generation time (seconds-minutes) | Near-instant computation |
Data Finality | After reveal, data is public forever | Only proof is public; data remains private | Data remains private inside enclave; output is public |
Primary Use Cases | Simple auctions, random number generation | Private transactions (zkRollups), identity verification | Confidential smart contracts, decentralized oracles |
Common Misconceptions About Commit-Reveal
The commit-reveal scheme is a fundamental cryptographic pattern for achieving fairness and privacy in blockchain transactions, yet it is often misunderstood. This section clarifies prevalent inaccuracies about its security, cost, and application.
No, a commit-reveal scheme provides conditional privacy, not absolute anonymity. The initial commit phase hides the actual data using a cryptographic hash, but the final reveal phase broadcasts the plaintext data on-chain for verification. Once revealed, the data is permanently public. The scheme's privacy is temporal, protecting information only during the commitment window. For true, persistent privacy, other techniques like zero-knowledge proofs or secure multi-party computation are required. Commit-reveal is best for scenarios like hiding a bid in an auction until the bidding closes, not for permanently concealing sensitive information.
Frequently Asked Questions (FAQ)
A commit-reveal scheme is a cryptographic two-phase protocol used in blockchain systems to conceal information during a voting or bidding period before it is disclosed. This section answers the most common technical questions about its mechanics and applications.
A commit-reveal scheme is a two-phase cryptographic protocol designed to keep information secret during a submission period before it is later publicly disclosed. It works by having participants first submit a cryptographic commitment—typically the hash of their secret data plus a random nonce or salt. After the commitment phase closes, participants enter the reveal phase, where they must publish the original secret data and the salt. The system then hashes the revealed values and checks that they match the initial commitment, ensuring the data was not altered after the commitment was made. This process prevents later submissions from being influenced by earlier ones, enabling fair voting, random number generation, and sealed-bid auctions on transparent blockchains.
Get In Touch
today.
Our experts will offer a free quote and a 30min call to discuss your project.