inicasino.netContents

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.

Sequence diagram with the columns Player; House and the steps Commit; Bet; Reveal; Combine.
Two parties commit, reveal and combine. Includes what refusing to reveal is worth.

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.

Any text. In a real protocol it must be long and random.

Any text. The house must not be able to change it after committing.

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.

0 is the honest protocol.

More rounds bring the count closer to the exact value.

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.

One round with the numbers of our known-answer test
StepPlayerHouseWhat an observer can check
1. CommitPublishes 62053a03a7161d7d59c2c559a2fb2feb2f69d080352cb64338c11578a841919fPublishes eefa823197117acaa329323f9e7541035f38d750ce34d4970e2bfc6bf3c4154dBoth hashes exist before the bet
2. BetStake and choice are recordedAccepts the betThe terms were fixed while both secrets were hidden
3. RevealReveals player secret 0001Reveals house secret 0001SHA-256 of each secret equals its commitment
4. CombineSHA-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

Bar chart. Chance that the house wins an even round when it may drop a losing round and have it replayed 0 to 5 times: 0 = 50.0 %; 1 = 75.0 %; 2 = 87.5 %; 3 = 93.8 %; 4 = 96.9 %; 5 = 98.4 %.
Chance that the house wins an even round when it may drop a losing round and have it replayed 0 to 5 times.

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

Measures against a party that will not reveal
MeasureWhat it doesWhat remains
Deadline with forfeitA party that has not revealed in time loses the round, or the other side is refundedA refund still lets the refusing party cancel a result it dislikes, so only a forfeit at least as costly as losing removes the incentive
DepositRefusing costs a sum put up in advanceIt deters only when the deposit exceeds what refusing can gain
A third input fixed laterThe result also depends on a value neither party knows at commit time, such as data from a later blockWhoever produces that value gains influence; see on-chain randomness
Committing to many rounds at onceThe operator cannot choose a secret per betThe operator may still decline to settle individual rounds
Public count of unsettled roundsRefusals become visible to everyoneNothing 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.

Two ways to make a number others can verify
PropertyCommit-revealVRF
PartiesTwo or more, each with a secretOne key holder
Who can verifyAnyone who has the commitments and the revealsAnyone 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 beforehandEvery commitment, before the betThe key, and an input that the key holder does not choose
Who learns the result firstThe last party to revealThe key holder, as soon as it knows the input
Added dependencyNone beyond the hash functionThe party that runs the key, often an oracle service

Checking a commit-reveal round yourself

  1. 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.
  2. Hash the revealed secret and compare it with the commitment.
  3. Combine the inputs by the documented formula and convert the bytes to a result.
  4. 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

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.