Skip to the article
Crypto Talk

Opinion and debate across crypto

Commit-Reveal Schemes in Smart Contracts: Two Steps, Real Costs

A commit-reveal scheme hides a choice behind a hash, then checks it when revealed; it can curb front-running, but costs another transaction and time.

Crypto Talk Editorial3 min read

Commit-Reveal Schemes in Smart Contracts: Two Steps, Real Costs

A commit-reveal scheme in smart contracts lets someone submit a choice without showing it immediately. The contract first receives a hash of the choice and a secret salt, then checks the choice when the user reveals both. Since transactions are public, this can stop someone from copying an open choice before it is recorded.

A hash keeps a choice hidden until reveal

Picture a sealed-bid auction. You want to bid 2 ETH, but if you post that bid while bidding is open, another bidder could react to it. Instead, you submit a commitment: typically keccak256 of your bid and a salt, which is a secret random value.

The contract follows two steps:

  1. Commit: Submit the hash while bidding is open. The bid and salt stay private.
  2. Reveal: After bidding closes, submit the bid and salt. The contract hashes them and checks that the result matches your commitment.

The salt matters because a guessable bid could otherwise be tested against the hash. After reveal, the bid is public. This pattern hides a choice temporarily; it does not encrypt it forever.

The Solidity documentation uses commit-reveal in its Blind Auction example. ENS also uses it for .eth registrations: a user commits, waits, then registers. The wait helps prevent someone from seeing a name registration in progress and front-running it.

A deposit makes non-reveal costly

A commit-reveal design needs a forfeitable deposit because a bidder who dislikes the outcome could simply refuse to reveal. Without a penalty, the bidder gets a free option: they can wait to see how the auction went, reveal if it suits them, and skip it otherwise. A deposit forfeited on non-reveal gives each commitment a cost for that choice.

  • Hidden choices: The commitment keeps bids or registrations out of view until the reveal stage.
  • Extra transactions: Users make a commitment and later reveal it, paying gas for both.
  • Waiting time: The contract must leave time for commitments to close before revealing begins.

Flashbots is an MEV research and infrastructure organization. Its Flashbots Protect service routes transactions away from the public mempool, where they could otherwise be seen before inclusion. The flashbots mempool topic adds background on this approach to reducing front-running exposure while a transaction is pending.

Commit-reveal is useful when a choice needs to stay hidden until a defined point, such as an auction close or name registration. It adds coordination, time, and cost, so it suits cases where that temporary secrecy matters and the contract can enforce a real consequence for not revealing.