Tools and worked checks · 02 / 23
How to verify a provably fair bet by hand
You need one value saved before play, three values from the bet record and the operator's written rule. With those, any tool that computes SHA-256 and HMAC can check the bet.

What to collect
| Value | Where it comes from | When you can have it |
|---|---|---|
| Server seed hash | Shown by the game before any bet under that seed | Before play. Save it yourself, outside the game's pages. |
| Client seed | Set by you, or suggested by the page and accepted by you | Before play |
| Nonce | The bet record | With each bet |
| Server seed | Revealed by the game after you ask for a new seed pair | After play under that seed has ended |
| Conversion rule | The operator's documentation | At any time |
The six steps
- Before you play, copy the server seed hash and your client seed to a place the operator cannot edit. A text file or a screenshot will do.
- Play. For the bet you want to check, note the nonce and the result the game displayed.
- Ask the game for a new seed pair. In the usual design the old server seed is revealed at that moment.
- Compute SHA-256 of the revealed seed and compare it with the hash from step 1. If they differ, the revealed seed is not the one that was committed to, and the remaining steps prove nothing.
- Compute HMAC-SHA256 with the server seed as the key and the message built from your client seed and the nonce, in the format the operator documents.
- Convert the bytes of the digest to a number by the documented rule and compare it with the displayed result.
One example, four ways
The example is test vector V1 under the scheme defined on the verifier page: the key is the server seed as text, the message is reference-client:0:0, and the result is floor(u × 10000 / 2^32). Each set of commands below prints the same four values.

| Value | Expected |
|---|---|
| SHA-256 of the server seed | 9088b0a58305a44b0ec72f1af9ef3e2e4927d17a516fdbf805707fdebdf69107 |
| HMAC-SHA256 digest | fd3f9c652643592c1de6a9a56228cc866eda7f2d26d95c2ee38e1d1e5d3378a3 |
| Integer from the first four bytes | 4248804453 |
| Result | 9892 |
const enc = new TextEncoder();
const hex = (b) => [...new Uint8Array(b)].map((x) => x.toString(16).padStart(2, '0')).join('');
const serverSeed = 'reference-test-server-seed-0001';
const clientSeed = 'reference-client';
const nonce = 0;
const commitment = hex(await crypto.subtle.digest('SHA-256', enc.encode(serverSeed)));
const key = await crypto.subtle.importKey('raw', enc.encode(serverSeed), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
const mac = new Uint8Array(await crypto.subtle.sign('HMAC', key, enc.encode(`${clientSeed}:${nonce}:0`)));
const u = new DataView(mac.buffer).getUint32(0);
const result = Number((BigInt(u) * 10000n) >> 32n);
[commitment, hex(mac), u, result];import hashlib, hmac
server_seed = b'reference-test-server-seed-0001'
client_seed = 'reference-client'
nonce = 0
print(hashlib.sha256(server_seed).hexdigest())
mac = hmac.new(server_seed, f'{client_seed}:{nonce}:0'.encode(), hashlib.sha256).digest()
print(mac.hex())
u = int.from_bytes(mac[:4], 'big')
print(u, u * 10000 // 2**32)printf '%s' 'reference-test-server-seed-0001' | openssl dgst -sha256
printf '%s' 'reference-client:0:0' | openssl dgst -sha256 -hmac 'reference-test-server-seed-0001'
echo $(( 0xfd3f9c65 * 10000 / 4294967296 ))const crypto = require('crypto');
const serverSeed = 'reference-test-server-seed-0001';
console.log(crypto.createHash('sha256').update(serverSeed).digest('hex'));
const mac = crypto.createHmac('sha256', serverSeed).update('reference-client:0:0').digest();
const u = mac.readUInt32BE(0);
console.log(mac.toString('hex'), u, Number((BigInt(u) * 10000n) >> 32n));A shell keeps a history of commands, and a seed typed into a command stays in that history. For a revealed server seed this is harmless. It is one more reason never to type a wallet secret phrase or a private key into a command, a script or a web page in order to verify anything.
What a mismatch means
| What differs | Likely cause | What to do |
|---|---|---|
| The hash in step 4 | The saved hash belongs to another seed pair, the seed was copied with an extra space or line break, or the seed is hex that the operator hashes as bytes | Try the readings in the hash checker. If none matches, keep the saved hash and the revealed seed as evidence. |
| The digest in step 5 | The message format or the key reading differs from the one you used | Read the operator's description again and compare it with the scheme table. |
| Only the final number | A different byte-to-number rule | See the rules and their differences. |
A digest or a number that will not match while the commitment holds is usually a question of format. A revealed seed that does not hash to the commitment you saved is the serious case, because catching that is the only purpose a commitment has.
What you have shown at the end
You have shown that one result was computed by the published rule from a server seed that matches the hash you saved. That the result was out of the operator's hands before you bet follows only if you also set your own client seed after the hash was shown and the nonce continued your own count. You have not checked the payout table, the stated return or whether wins are paid. Those limits are set out on the page about what provably fair leaves open. An explanation of the three inputs is on the page about seeds and the nonce.
Questions people ask
Do I have to check every bet?
No. The operator cannot know in advance which bets you will check, so checking a few chosen afterwards already has value. Each seed pair needs its own commitment check, since each has its own hash.
Why does my hash differ when I use echo?
On most systems echo adds a line break to its output, and the line break is hashed with the seed. Use printf '%s' as in the example.
Can I check a bet without the hash I should have saved?
You can still recompute the result from the revealed seed. What you lose is the evidence that this seed was fixed before you bet, and without it the recomputation shows only that the arithmetic is consistent.
Sources
- RFC 2104, HMAC: Keyed-Hashing for Message Authentication (IETF, February 1997). Defines HMAC as
H(K XOR opad, H(K XOR ipad, text))and says that keys longer than the hash block are hashed first. Checked . - RFC 4231, Identifiers and Test Vectors for HMAC-SHA-224, HMAC-SHA-256, HMAC-SHA-384 and HMAC-SHA-512 (IETF, December 2005). Source of the two published HMAC-SHA-256 test cases that our tools must reproduce. Checked .
- 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 .
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.