Crypto gambling, explained. Verify, don't trust.

ChainChip Journal

· The ChainChip desk · Provably fair · 6 min read

Provably Fair Algorithm Explained: Server Seed, Client Seed, Nonce

The provably fair algorithm step by step: HMAC-SHA256 of server seed, client seed and nonce, bytes to a float, float to a dice roll. Real seeds you can rerun.

Most provably fair casino games run the same pipeline: take an HMAC-SHA256 of your client seed and a nonce, keyed with the casino’s server seed, turn the first bytes of that hash into a number between 0 and 1, then map that number onto a game result. Every step below uses real values, so you can copy the seeds into your own terminal and get the same output.

For the reference implementation we use Stake’s published documentation, because it spells out every step from bytes to game result: see Stake’s provably fair implementation pages (checked Nov 4, 2026). Other casinos use variations; always read your casino’s own formula before verifying.

The inputs

InputWho controls itWhat you see before betting
Server seedCasinoOnly its SHA-256 hash
Client seedYou (editable)The value itself
NonceCounter, +1 per betThe current number
Cursor / roundCounter inside one betOnly matters when a game needs many random numbers

Stake describes the server seed as “a random 64-character hex string” and shows you the hash before any bet. To see the actual seed you rotate to a new pair, which reveals the old one.

Here are the example values for the walkthrough. They are not from any live account; we generated the server seed as the SHA-256 of a fixed sentence so anyone can recreate it.

server seed:       8c9fde6152d07cd42666fee4bf737a5b49ffd0d9e0e799aa23beb03f3b554bc1
SHA-256(seed):     4a187be55d6615c7064b6b132eedcda9c87b3c58caacceab07b00651e89abe7a
client seed:       verify-dont-trust
nonce:             1
round (cursor):    0

Step 1: check the commitment

Before you trust any result, confirm the revealed server seed matches the hash you were shown earlier:

printf "%s" "8c9fde6152d07cd42666fee4bf737a5b49ffd0d9e0e799aa23beb03f3b554bc1" | shasum -a 256

Expected output: 4a187be55d6615c7064b6b132eedcda9c87b3c58caacceab07b00651e89abe7a

If the hashes differ, stop. Nothing after this step means anything.

One detail to check on your own casino: whether it hashes the seed as text (as above) or as raw bytes. The two give different hashes. The casino’s own “unhash” or verify tool will tell you which convention it uses.

Step 2: HMAC-SHA256

Stake’s byte generator builds the message as clientSeed:nonce:round and keys the HMAC with the server seed:

const hmac = createHmac('sha256', serverSeed);
hmac.update(`${clientSeed}:${nonce}:${currentRound}`);

With our values, the message is verify-dont-trust:1:0. You can compute it with OpenSSL:

printf "%s" "verify-dont-trust:1:0" | openssl dgst -sha256 -hmac "8c9fde6152d07cd42666fee4bf737a5b49ffd0d9e0e799aa23beb03f3b554bc1"

Expected output: 30ddb43300f3cbbfedd37b3dfc4608101e5edae8dc9a479cf2bb53f91dbb41c7

That 64-character output is 32 bytes. Each game result uses 4 bytes, so one HMAC gives 8 random numbers. When a game needs more than 8 (a full Plinko path, a shuffled deck), the round counter goes up to 1, 2 and so on and a fresh HMAC is computed. Stake’s docs list Plinko as using “2 increments per game to cover possible 16 decisions”, which is exactly that: 16 numbers need 64 bytes, so two HMACs.

Step 3: bytes to a float

Take the first 4 bytes and treat each one as a digit in base 256. Stake’s conversion code adds value / 256 ** (i + 1) for each of the four bytes.

Our first four bytes are 30 dd b4 33 in hex, which is 48, 221, 180, 51 in decimal:

ByteValueDivisorContribution
1482560.1875
222165,5360.0033721924
318016,777,2160.0000107288
4514,294,967,2960.0000000119
Sum0.1908829331

That float is the raw random number for nonce 1. It is always at least 0 and below 1.

Step 4: float to a game result

This is where games differ. The randomness is identical; the translation is game-specific, and it is also where the house edge lives.

Dice. Stake’s dice formula is (float * 10001) / 100, rounded down to two decimals, which gives a roll from 0.00 to 100.00:

floor(0.1908829331 × 10001) / 100 = 19.09

Limbo. Stake’s documented limbo formula is 1e8 / (float * 1e8) * houseEdge, with the comment “houseEdge of 0.99 (1%)”, then floored to two decimals with a minimum of 1:

1 / 0.1908829331 × 0.99 = 5.1864…, floored to 5.18x

Notice the 0.99. That one constant is the 1% edge. Without it, the expected value of a limbo bet would be exactly break-even.

Plinko. Each float picks a direction with floor(float * 2): 0 means left, 1 means right. For a 16-row board you need 16 floats, so the generator uses round 0 and round 1. Our 16 directions for nonce 1 are:

0 0 1 1 0 1 1 0 | 0 0 0 0 0 0 1 0

That is 5 rights out of 16. Counting landing slots by the number of right bounces, the ball finishes in slot 5 of 0 to 16 (the sixth from the left). The Plinko odds guide shows how likely each slot is.

The next three bets

Same seeds, nonce goes up by one each time:

NonceMessageFirst 4 bytesFloatDice rollLimbo
1verify-dont-trust:1:030ddb4330.190882933119.095.18x
2verify-dont-trust:2:0f494a0bf0.955392882095.541.03x
3verify-dont-trust:3:04b160ae80.293305093429.333.37x

Rerun it yourself

This short Python script reproduces every number above. It uses only the standard library.

import hmac, hashlib, math

server_seed = "8c9fde6152d07cd42666fee4bf737a5b49ffd0d9e0e799aa23beb03f3b554bc1"
client_seed = "verify-dont-trust"

def floats(nonce, count):
    buf, rnd = b"", 0
    while len(buf) < count * 4:
        msg = f"{client_seed}:{nonce}:{rnd}".encode()
        buf += hmac.new(server_seed.encode(), msg, hashlib.sha256).digest()
        rnd += 1
    return [sum(b / 256 ** (j + 1) for j, b in enumerate(buf[i*4:i*4+4]))
            for i in range(count)]

print(hashlib.sha256(server_seed.encode()).hexdigest())
for nonce in (1, 2, 3):
    f = floats(nonce, 1)[0]
    dice = math.floor(f * 10001) / 100
    limbo = max(math.floor(1 / f * 0.99 * 100) / 100, 1)
    print(nonce, round(f, 10), dice, limbo)
print([math.floor(x * 2) for x in floats(1, 16)])

We cross-checked the HMAC and the float in Node.js with the built-in crypto module; it returns the same 30ddb433… digest and 0.1908829331.

Why the client seed matters

If the casino picked both seeds, it could search for a server seed that produces poor results for the bets it expects. Your client seed, chosen after the server seed’s hash is published, breaks that. It’s the same idea as cutting a deck someone else shuffled. Change it regularly, and never accept a site that won’t let you set it.

Where the algorithm can still mislead you

  • Edge in the formula. The 0.99 in limbo is visible. On some games the edge sits in a payout table instead. Read both.
  • Different games, different schemes. Stake’s own docs say Crash and Slide use a separate salted hash-chain model, not the per-bet seed pair above. The crash game guide walks through that one.
  • Unverified history. The math only protects bets you actually check. Rotate, reveal and recompute a sample from time to time.
  • Third-party slots. Studio games on the same site usually aren’t provably fair at all.

For the plain-language version of what provably fair does and doesn’t prove, see provably fair meaning.

Only play if you’re 18+ (or your country’s legal age) and with money you can afford to lose. Our responsible gambling page lists helplines by country.

Share:
Back to explainers

Related Posts

View All Posts »