How the schemes work · 05 / 23
Commit-reveal explained with a worked round
Commit-reveal lets two parties who do not rely on each other produce a number together. Each fixes a secret before seeing the other's, and the result depends on both.

Commit-reveal walk-through
This tool runs in your browser with the Web Crypto API. It sends nothing over the network and works offline once the page has loaded. Never paste a wallet secret phrase or a private key here or into any verifier. No check on this site needs one.
Free of charge, no account. Runs in any current web browser.
The result appears here.
What refusing to reveal is worth
Here the house wins a round when the die shows 1, 2 or 3. It reveals last, so it sees the result first. Suppose it may drop a losing round, for example by claiming an error, and have the round replayed. The simulation uses fresh random secrets for every attempt.
The result appears here.
The idea in one paragraph
Each party picks a secret and publishes its hash. That is the commit. When both hashes are public, both parties reveal their secrets. Anyone can then hash each secret, compare it with the commitment and combine the two secrets into the result. Since each party committed before it saw the other's secret, neither could choose its own secret in response.
| Step | Player | House | What an observer can check |
|---|---|---|---|
| 1. Commit | Publishes 62053a03a7161d7d59c2c559a2fb2feb2f69d080352cb64338c11578a841919f | Publishes eefa823197117acaa329323f9e7541035f38d750ce34d4970e2bfc6bf3c4154d | Both hashes exist before the bet |
| 2. Bet | Stake and choice are recorded | Accepts the bet | The terms were fixed while both secrets were hidden |
| 3. Reveal | Reveals player secret 0001 | Reveals house secret 0001 | SHA-256 of each secret equals its commitment |
| 4. Combine | SHA-256 of the player's secret followed by the house's secret is 3249712fc9ce2d0f0a7b352b7f2ebf19f0a01c1ff9a3c609cceb03ba6e2295ed. The first four bytes, 3249712f, are the integer 843673903, and floor(843673903 × 6 / 2^32) + 1 = 2. |
What the two hashes provide
A commitment has to bind and to hide. Binding means the committer cannot later present a different secret with the same hash. Hiding means the hash does not give the secret away. SHA-256 binds for any input. It hides only when the secret is long and random: a four-digit secret can be found by hashing all 10000 candidates and comparing. The walk-through joins the two secrets with nothing between them, so the pairs ab, c and a, bc would give the same combined hash. Real protocols use secrets of fixed length or put a length in front of each one. The hash checker performs the comparison in step 3 for a single commitment.
The last-revealer problem

Two reveals cannot happen at the same moment. Whoever reveals second knows the result before the other party does. It cannot change its secret, because the commitment binds it. It can refuse to reveal.
If refusing costs nothing and the round is simply replayed, the second revealer gets a fresh draw each time it dislikes the result. A party that wins a single honest round with probability p, and can force k replays, wins with probability 1 − (1 − p)^(k + 1). For p = 0.5 that is 75 % with one replay and 87.5 % with two. The simulation in the tool above reproduces these figures with real hashes.
How protocols limit refusal
| Measure | What it does | What remains |
|---|---|---|
| Deadline with forfeit | A party that has not revealed in time loses the round, or the other side is refunded | A refund still lets the refusing party cancel a result it dislikes, so only a forfeit at least as costly as losing removes the incentive |
| Deposit | Refusing costs a sum put up in advance | It deters only when the deposit exceeds what refusing can gain |
| A third input fixed later | The result also depends on a value neither party knows at commit time, such as data from a later block | Whoever produces that value gains influence; see on-chain randomness |
| Committing to many rounds at once | The operator cannot choose a secret per bet | The operator may still decline to settle individual rounds |
| Public count of unsettled rounds | Refusals become visible to everyone | Nothing is prevented, and someone has to look |
For any game in which the operator holds a secret, the question to ask is this: what happens to a bet whose secret is never revealed, and who decides? If the answer is a refund at the operator's discretion, without a time limit and without a public record, the operator holds a free option on every round. This is the gap called selective settlement on the page about what provably fair leaves open.
Commit-reveal and a VRF compared
A verifiable random function is described in RFC 9381 as the public-key version of a keyed hash: only the holder of the secret key can compute the output, and anyone with the public key can verify it.
| Property | Commit-reveal | VRF |
|---|---|---|
| Parties | Two or more, each with a secret | One key holder |
| Who can verify | Anyone who has the commitments and the reveals | Anyone who has the public key and the proof |
| Can the producer choose between outputs? | No, once it has committed. It can withhold its reveal. | No. For one key and one input there is one valid output, which RFC 9381 calls uniqueness. The document says its elliptic-curve VRF keeps this even for a maliciously generated key, and its RSA-based VRF only when the key was generated honestly. The producer can withhold or delay the output. |
| What must be fixed beforehand | Every commitment, before the bet | The key, and an input that the key holder does not choose |
| Who learns the result first | The last party to reveal | The key holder, as soon as it knows the input |
| Added dependency | None beyond the hash function | The party that runs the key, often an oracle service |
Checking a commit-reveal round yourself
- Find the commitment as it was recorded before the bet. Use your own copy or a public record, since a page the operator can edit is weak evidence.
- Hash the revealed secret and compare it with the commitment.
- Combine the inputs by the documented formula and convert the bytes to a result.
- Compare with the result you were shown, and note whether every round you played was settled.
The seed scheme used by many games is a form of commit-reveal in which only the operator commits. The page on seeds and the nonce explains that variant.
Questions people ask
Is commit-reveal the same as provably fair?
Provably fair is a label, and most games that carry it use a commit-reveal in which the operator commits to a server seed while the player's seed is public from the start.
Why do the parties not reveal at the same time?
Messages arrive in some order, on a network and on a blockchain alike. A protocol has to work when one party sees the other's reveal first, which is why deadlines and forfeits exist.
What makes a secret long enough?
It has to be drawn at random from so many possibilities that trying them all is out of reach. 32 random bytes is a common choice. A word, a date or a short number is not enough.
Sources
- FIPS 180-4, the NIST standard that specifies SHA-256. We link to the NIST publication page for the standard. The known answer for the input
abcin our test vectors is recomputed with Node on every build. Checked . - RFC 9381, Verifiable Random Functions (IRTF, August 2023). Describes a VRF as the public-key version of a keyed hash and defines its uniqueness and pseudorandomness properties. Checked .
- EIP-4399, Supplant DIFFICULTY opcode with PREVRANDAO (Ethereum Improvement Proposals). Its security section describes how much influence a block proposer has over the randomness value. Checked .
How we checked: statements about a named body link to that body's own page and carry the date we read it. Numbers in worked examples are computed by the site's build from the formulas shown, with routines covered by its test suite.