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
| Component | Who provides it | Role | Property relied on |
|---|---|---|---|
| Server seed | Operator | Secret random value that drives all results in a seed period. | Must be unpredictable; stays hidden until the period ends. |
| Hash commitment | Operator, before play | SHA-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 seed | Player (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. |
| Nonce | Both, by convention | Counter incremented each round so the same seeds yield a fresh result every time. | Must advance monotonically and be visible to the player. |
| Result function | Published by the operator | Deterministic 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
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
| Nonce | Message | HMAC-SHA-256 digest (key = server seed) | First 8 hex | Integer | ÷ 2³² | Result |
|---|---|---|---|---|---|---|
| 0 | lab-client-2026:0 | 08da7e8d2829b55daa8e0ca1693e516bc5876da9e38c9b4479cff2d92a2c027d | 08da7e8d | 148,536,973 | 0.03458396 | 3 |
| 1 | lab-client-2026:1 | c1f59f78e2e711724788b12985b36db5ce0372a6cabe6e193d01629ce809be2f | c1f59f78 | 3,254,099,832 | 0.75765416 | 75 |
| 2 | lab-client-2026:2 | 02d3bae34e87da75812a53bc688e10eb75ef8f941f21422514767a4a76e5e255 | 02d3bae3 | 47,430,371 | 0.01104324 | 1 |
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.
Step 2 — the hash of the seed is published before play
SHA-256 is a one-way function: the commitment reveals nothing useful about the seed, and no other seed is expected to produce the same commitment.
Step 3 — the player contributes a client seed; a nonce counts rounds
Because the commitment already exists, the operator cannot adapt the server seed to whatever client seed is chosen. The nonce ensures each round has a distinct message.
Step 4 — the result is derived from all three inputs
HMAC-SHA-256 keyed with the server seed is applied to client seed : nonce. The first 32 bits of the digest are scaled to the game range — here an integer from 0 to 99.
An illustrative outcome in the range 0–99. In a real game a published rule maps this number to a game event; the mapping — not the randomness — is where the house edge lives.
Step 5 — after the seed period, the server seed is revealed and checked
Hash the revealed seed and compare with the commitment from step 2. Then recompute the result. Try the “tamper” button to change one character of the revealed seed.
Verification after the event
A complete verification has four checks, and all four are needed:
- Commitment check. SHA-256 of the revealed server seed equals the commitment displayed before play.
- 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.
- Recomputation. Applying the published result function to (server seed, client seed, nonce) yields the result that was displayed, for every round in the period.
- 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
- NIST, FIPS 180-4: Secure Hash Standard (SHS). csrc.nist.gov
- IETF, RFC 2104: HMAC: Keyed-Hashing for Message Authentication. rfc-editor.org
- IETF, RFC 6234: US Secure Hash Algorithms (SHA and SHA-based HMAC and HKDF). rfc-editor.org
- W3C, Web Cryptography API — the browser interface used by the explorer on this page. w3.org
- M. Blum, “Coin flipping by telephone: a protocol for solving impossible problems”, 1981 — the original description of a bit-commitment protocol.