Provably Fair: Commit, Reveal, Verify

How server seeds, client seeds, nonces and SHA-256 hash commitments let a result be checked after the event — with a worked example, an interactive flow explorer, and a plain account of what the term does not guarantee.

Updated Reading time 8 min By Editorial Team

The idea in one paragraph

A provably fair system lets a player confirm, after a round, that its result was determined before the player’s own input was known — so it could not have been altered in response to the bet.

It achieves this with a commit–reveal protocol built on a cryptographic hash function. The operator chooses a secret server seed and publishes its hash — a commitment — before play. The player supplies a client seed. Each round combines the server seed, the client seed and a counter (the nonce) to produce the result. Later the operator reveals the server seed; the player hashes it, confirms it matches the published commitment, and recomputes the results. If everything matches, the results were fixed by values committed in advance.

The components

ComponentWho provides itRoleProperty relied on
Server seedOperatorSecret random value that drives all results in a seed period.Must be unpredictable; stays hidden until the period ends.
Hash commitmentOperator, before playSHA-256 of the server seed, shown to the player in advance.Binding (cannot find a different seed with the same hash) and hiding (hash reveals nothing about the seed).
Client seedPlayer (or set by the client, editable by the player)Input the operator did not control at commitment time.Must be chosen or changeable after the commitment is shown.
NonceBoth, by conventionCounter incremented each round so the same seeds yield a fresh result every time.Must advance monotonically and be visible to the player.
Result functionPublished by the operatorDeterministic mapping from (server seed, client seed, nonce) to a game outcome.Must be specified exactly, including scaling, so anyone can reproduce it.

The hash functions involved are standard: SHA-256 as specified in FIPS 180-4, and HMAC-SHA-256 as specified in RFC 2104 for the keyed combination step. No proprietary cryptography is needed, and its presence in a scheme is a reason for suspicion rather than confidence.

Flow diagram

Provably fair commit–reveal flow Before play, the operator generates a server seed and publishes its SHA-256 hash as a commitment. The player supplies a client seed and a nonce counter. During play, an HMAC of the client seed and nonce, keyed with the server seed, produces a digest that is scaled to a result. After play, the server seed is revealed; the player hashes it, compares with the commitment, and recomputes the result. PHASE A · BEFORE PLAY (COMMIT) PHASE B · EACH ROUND (COMPUTE) PHASE C · AFTER PLAY (REVEAL & VERIFY) OPERATOR · SECRET Server seed (random, hidden) SHA-256 PUBLISHED TO PLAYER Hash commitment PLAYER · AFTER SEEING COMMITMENT Client seed (chosen / editable) COUNTER · VISIBLE Nonce = 0, 1, 2, … per round key message = client seed : nonce COMBINE digest = HMAC-SHA-256( key = server seed, message ) scale RESULT e.g. integer 0–99 Published result function: first 8 hex chars of digest → integer → ÷ 2³² → × range → floor. The same inputs always give the same digest, so anyone holding them can recompute the result. OPERATOR · REVEALS Server seed disclosed SHA-256 PLAYER · CHECK 1 Hash equals commitment? PLAYER · CHECK 2 Recompute results GOLD = SECRET / OPERATOR · CYAN = PUBLIC INPUTS & COMPUTATION · GREEN = OUTPUTS THE PLAYER CAN CHECK
Figure 1. Commit–reveal. The order of events is the whole protocol: the commitment must be shown before the client seed can be set, and the server seed must stay secret until the seed period ends. Break either ordering and the proof collapses.

Worked example (reproducible)

All values below are real outputs of SHA-256 and HMAC-SHA-256 on the stated inputs. They can be reproduced with any standard library, with the explorer further down this page, or in a terminal:

# Python 3 — reproduce every value in this section
import hashlib, hmac, math
server = "6f1c3b9a2e8d4c7f0a5b1e9d8c3f2a6b7e4d1c0f9a8b5e2d3c6f1a4b7e0d9c2f"
client = "lab-client-2026"
commit = hashlib.sha256(server.encode()).hexdigest()
for nonce in range(3):
    d = hmac.new(server.encode(), f"{client}:{nonce}".encode(), hashlib.sha256).hexdigest()
    result = math.floor(int(d[:8], 16) / 2**32 * 100)
    print(nonce, d, result)

Phase A — commitment

Server seed
(kept secret)
6f1c3b9a2e8d4c7f0a5b1e9d8c3f2a6b7e4d1c0f9a8b5e2d3c6f1a4b7e0d9c2f
Commitment
SHA-256(server seed), published
d22003ff476f81e2774580410c9b92800d2f30086a280f4941157e77f14fd75b
Client seed
set by player after seeing commitment
lab-client-2026

Phase B — three rounds

Result function: take the first 8 hex characters of the digest, read as an integer, divide by 232 to get a value in [0, 1), multiply by 100, floor. Output is an integer 0–99.
NonceMessageHMAC-SHA-256 digest (key = server seed)First 8 hexInteger÷ 2³²Result
0lab-client-2026:008da7e8d2829b55daa8e0ca1693e516bc5876da9e38c9b4479cff2d92a2c027d08da7e8d148,536,9730.034583963
1lab-client-2026:1c1f59f78e2e711724788b12985b36db5ce0372a6cabe6e193d01629ce809be2fc1f59f783,254,099,8320.7576541675
2lab-client-2026:202d3bae34e87da75812a53bc688e10eb75ef8f941f21422514767a4a76e5e25502d3bae347,430,3710.011043241

Phase C — reveal and verify

At the end of the seed period the operator reveals the server seed. The player computes SHA-256 of the revealed value and compares it with the commitment shown in Phase A:

SHA-256(6f1c…9c2f) = d22003ff476f81e2774580410c9b92800d2f30086a280f4941157e77f14fd75b   = commitment ✓

Suppose instead the operator had tried to substitute a seed that differs in a single character — the final f changed to 0:

SHA-256(6f1c…9c20) = 7ae7e620e89efa9bf9dea5a4ac11ff5f61e1ef0007d884ed09518322b6dc6ac9   ≠ commitment ✕

The hash bears no resemblance to the commitment. That is the hiding and binding property in practice: the operator cannot change the seed after the fact without the change being detected by anyone who kept the commitment.

Interactive flow explorer

The explorer below runs the same scheme in your browser using the Web Crypto API. Edit any input and watch the commitment, digest and result change; then alter the revealed seed by one character to see verification fail. Nothing is sent anywhere. It is an illustration of a protocol, not a game.

Provably Fair Flow Explorer

Step 1 — the operator picks a secret server seed

In production this is a random value from a cryptographic generator, kept secret for the whole seed period. Here you can type anything; the default reproduces the worked example above.

Verification after the event

A complete verification has four checks, and all four are needed:

  1. Commitment check. SHA-256 of the revealed server seed equals the commitment displayed before play.
  2. Input check. The client seed and nonce used in the recomputation are the ones the player actually saw and controlled. If the interface generated the client seed and the player could not change it, this check is weaker.
  3. Recomputation. Applying the published result function to (server seed, client seed, nonce) yields the result that was displayed, for every round in the period.
  4. Function check. The published result function is fully specified, uses standard primitives, and is the one actually implemented — ideally confirmed by a third-party verifier that does not depend on the operator’s own page.

What “provably fair” does and does not mean

A correct implementation proves

  • The result of each round was fixed by values committed before the player’s input.
  • The operator did not alter a specific outcome after seeing the bet.
  • Any player with the inputs can recompute any result without trusting the operator.
  • The server seed was not swapped after the fact (binding commitment).

It does not prove

  • That the game’s odds or RTP are favourable, or even what they are — the mapping from number to payout is a separate, published rule. See RTP Verification.
  • That the server seed was generated randomly rather than selected from a pre-screened set — commitment prevents post hoc changes, not biased ex ante choice, which is why RNG review still matters. See RNG Audit.
  • That the scaling step is unbiased; a result function can be published and still skewed.
  • Anything about third-party games on the same platform that do not use the scheme.
  • Anything about payouts, licensing, terms or solvency.

Implementation details that matter

  • Ordering. The commitment must be visible before the client seed is accepted. If a client seed can be set and then a new server seed committed, the proof is void.
  • Seed rotation. The server seed must be revealed only when it is retired. Revealing a seed that remains in use exposes future results.
  • Client seed control. The strongest schemes let the player type their own client seed; weaker ones generate it client-side. Weakest is a “client seed” the operator provides.
  • Nonce visibility. The player should see the nonce for each round, so that recomputation can be matched to the right result.
  • Specification completeness. Byte encoding of the message, separator characters, which digest bytes are used and how they are scaled must all be stated. The example above states each one; a specification that does not is not verifiable.
  • Scaling bias. The floor(u × 100) mapping used here has a negligible but non-zero bias because 232 is not divisible by 100. A production specification should either use rejection sampling or document why the residual bias is immaterial for the game in question.

Sources

  1. NIST, FIPS 180-4: Secure Hash Standard (SHS). csrc.nist.gov
  2. IETF, RFC 2104: HMAC: Keyed-Hashing for Message Authentication. rfc-editor.org
  3. IETF, RFC 6234: US Secure Hash Algorithms (SHA and SHA-based HMAC and HKDF). rfc-editor.org
  4. W3C, Web Cryptography API — the browser interface used by the explorer on this page. w3.org
  5. M. Blum, “Coin flipping by telephone: a protocol for solving impossible problems”, 1981 — the original description of a bit-commitment protocol.