Overview
How hash-based fairness checks work
Many online game services describe their games as verifiable. This page explains the commit-reveal scheme behind that claim, computes one complete example, and is clear about its limits.
The problem the scheme solves
When a game runs on someone else's computer, a player cannot see the random number generator. The operator could, in principle, look at the bet and then choose an unfavourable result. A commit-reveal scheme removes that option. The operator commits to a secret before the bet, in a form that cannot be changed later, and reveals the secret afterwards so the player can check that the result followed from it.
The four ingredients
- Server seed
- A random secret string chosen by the operator. It stays hidden while it is in use.
- Commitment
- The SHA-256 hash of the server seed, shown to the player before any bet. SHA-256 maps any input to a 256-bit value (64 hex digits). Nobody knows how to find a second input with the same hash, so the operator cannot swap the seed later.
- Client seed
- A string the player can choose or change. Because it is mixed in, the operator cannot pre-compute a seed that is bad for one particular player's input.
- Nonce
- A counter that goes up by one for each bet made with the same pair of seeds, so every bet gets a different result from the same seeds.
A complete worked example
The table below uses the construction found in many public descriptions: compute HMAC-SHA256 with the server seed as the key and client:nonce:round as the message, read the first four bytes as a whole number, and divide by 232 to get a value between 0 and 1. That value is then mapped to a game result, here a dice roll. Every line was computed with Python's hashlib and hmac modules.
| Server seed (revealed later) | reference-server-seed-0001 |
|---|---|
| Commitment shown before play: SHA-256(server seed) | b56f5b12f442b80067cb1ce12c8197e8b8cec4161d0ed88ac1fb0379c829cc93 |
| Client seed : nonce : round | my-own-client-seed:3:0 |
| HMAC-SHA256(server seed, message) | 849c312a165a209a24acacba375217af03e7d899b812ec958bedf685079fe138 |
| First 4 bytes (8 hex digits) | 849c312a = 2,224,828,714 |
| Float = value / 2^32 | 0.5180083015 |
| Dice roll = floor(float x 10,000) / 100 | 51.80 |
| Bet 'under 49.50' | loss |
One common construction, shown for teaching. Real services document their own message format; check theirs before verifying.
To check this yourself you need only a SHA-256 tool. First hash the revealed server seed and compare it with the commitment that was shown before play. If even one character differs, the check fails. Then compute the HMAC with the same message format and follow the same mapping. If your result matches the result you were given, the round was decided by the committed seed.
Why four bytes and a division
Four bytes give 232 = 4,294,967,296 equally likely values. Dividing by 232 turns them into a fraction from 0 up to, but not including, 1. Mapping that fraction to a result with a floor function is very close to uniform. For a dice roll with 10,000 outcomes, each outcome receives either 429,496 or 429,497 of the possible byte values, so the largest bias is about 0.0002% of one outcome's share, far too small to matter. Games that need several values, such as keno or plinko, read further bytes or increase the round counter in the message.
What a successful check proves
- The result of that bet followed from a server seed that was fixed before the bet was placed.
- The operator did not change that result after seeing the stake or the player's choice.
- If the client seed was the player's own, the operator could not have tuned the server seed against it in advance.
What it does not prove
- It says nothing about the payout. A perfectly verifiable game can still have a large house edge. The edge comes from the pay table, which you should read separately (see the house edge guide).
- It does not show that the server seed was chosen randomly, only that it was fixed. A seed that is fixed but chosen with care cannot target a client seed the operator has not seen, which is why changing your client seed matters.
- It does not cover anything outside the published scheme, such as how balances, withdrawals or disputes are handled.
- It only works if you actually run the check. A badge that says "verifiable" is not itself evidence.
Seed rotation
A server seed is usually used for a series of bets and then retired, at which point it is revealed and a new commitment is shown. While a seed is active, it must stay secret: anyone who knew it could predict every future result for that seed pair. That is why the reveal comes only after rotation, and why verification is something done afterwards rather than during play.
Each game guide on this site that contains a hash table uses its own seeds and nonce, and maps the value to that game's result: a crash point, a card rank, a set of keno numbers, mine positions, plinko bounces or a wheel segment. The guide index lists them by type.