Verifiable dice: how to check that the dice are not rigged
Updated:
Short answer: In GammonMind, before the first roll of every game you see a commitment: the SHA-256 fingerprint of a secret 32-byte seed. Every die is derived from that seed and your client seed with HMAC-SHA256, a public, unbiased formula. When the game ends, the app reveals the seed and anyone can recompute every roll in the verifier, inside the browser and without sending anything to any server: if a single roll had been changed, it would not match.
Open the example in the verifier
How it works: commit and reveal
It is a commit-reveal scheme with three moments:
| When | What you see | What it is for |
|---|---|---|
| Before the first roll | The commitment: the SHA-256 of the server seed, in hexadecimal | It locks the seed: if the seed changed later, the fingerprint would no longer match |
| During the game | The rolls | Every die comes from the server seed, your client seed and the game number |
| When the game ends | The revealed seed | It lets anyone check the commitment and recompute every roll |
The server seed (serverSeed) is 32 bytes from a cryptographic generator, fresh for every game. Despite the name, it is generated on your own device: you do not need a connection to play with verifiable dice.
The client seed (clientSeed) is a text of your own. By default it is random and saved, and you can set any value you like in Settings. The nonce is the game number, so each game of a match has its own seed and its own commitment.
From seed to die
The dice come from a byte stream computed in 32-byte blocks:
block(ctr) = HMAC-SHA256(key = serverSeed, message = “clientSeed:nonce:ctr”), with ctr = 0, 1, 2…
The bytes are read in order: first the 32 bytes of block 0, then those of block 1, and so on. Each byte b, a number from 0 to 255, becomes a die like this:
- If b is less than 252, the die is (b mod 6) + 1.
- If b is 252, 253, 254 or 255, it is discarded and the next byte is read.
Why 252? Because 252 = 42 × 6: from 0 to 251, every remainder of division by 6 appears exactly 42 times, so all six faces are equally likely. Using all 256 values would make 1 to 4 come up slightly more often than 5 and 6. On average, one byte in 64 is discarded.
In what order the dice are used
Dice are always taken from the stream in the same order. The only thing that changes is how the game starts, which depends on the variant (see the rules of each one):
| How it starts | Where it is used | Order of the dice |
|---|---|---|
| S1: backgammon-style opening roll | Backgammon, Nackgammon and Hypergammon | One die for each side, the first for side 0; ties take two more. The higher roller plays those two numbers as the first roll |
| S2: opening roll, then the higher roller rerolls | Acey-Deucey, Tavla/Portes, Plakoto, Fevga, Long Nardy, Gul Bara and Jacquet | The same, but then the higher roller rolls two more dice, which are their first roll (it may be a double) |
| G: the winner of the previous game starts | Later games of a match in Tavla/Portes, Plakoto (and Tapa and Mahbusa), Fevga and Gul Bara | No opening roll: the first two dice are the winner’s first roll |
After the opening, every roll takes two dice from the stream, in the order they are played. After a plakoto draw there is no winner, so the next game starts with an opening roll again.
An example you can check
This is the first published test vector of the GammonMind engine:
| Item | Value |
|---|---|
| Server seed (serverSeed) | 0000000000000000000000000000000000000000000000000000000000000000 (64 zeros) |
| Commitment: SHA-256 of the seed | 66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925 |
| Client seed (clientSeed) | cliente |
| Nonce (game number) | 1 |
| Block 0 message | cliente:1:0 |
| Block 0 (HMAC-SHA256) | 4834f1ae9417196553390995c35bedf92f4145c1501dbe690066224232ef689b |
| First 10 dice | 1, 5, 2, 1, 5, 6, 2, 6, 6, 4 |
The first bytes of the block, in hexadecimal, are 48, 34, f1 and ae, that is, 72, 52, 241 and 174. Since 72 mod 6 = 0, the first die is a 1; 52 mod 6 = 4 gives a 5; 241 mod 6 = 1, a 2; and 174 mod 6 = 0, another 1. None of the first ten bytes reaches 252, so nothing is discarded.
How those dice are dealt
With the dice 1, 5, 2, 1, 5, 6, 2, 6, 6, 4, a game would start like this depending on how it opens:
| Roll | S1 | S2 | G |
|---|---|---|---|
| Opening | Side 0 rolls 1 and side 1 rolls 5: side 1 starts | The same: 1 against 5, side 1 starts | None |
| 1st roll | Side 1: plays 5-1 | Side 1: rerolls and gets 2-1 | Winner: 1-5 |
| 2nd roll | Side 0: 2-1 | Side 0: 5-6 | Opponent: 2-1 |
| 3rd roll | Side 1: 5-6 | Side 1: 2-6 | Winner: 5-6 |
| 4th roll | Side 0: 2-6 | Side 0: 6-4 | Opponent: 2-6 |
In S1, the 1 and the 5 of the opening are also side 1’s first roll. In S2, those two dice only decide who starts.
The verifier’s direct link
The verifier accepts all the data in the link itself, after the “#”:
/en/verify/#commit=…&seed=…&client=…&nonce=…&start=s1|s2|g&rolls=…
| Parameter | What it holds |
|---|---|
| commit | The commitment you saw before the game (64 hexadecimal characters) |
| seed | The seed revealed at the end (64 hexadecimal characters) |
| client | Your client seed, as is (URL-encoded if it contains spaces or accents) |
| nonce | The game number |
| start | How the game starts: s1 (backgammon-style opening), s2 (opening roll, then the higher roller rerolls) or g (the winner of the previous game starts, no opening roll) |
| rolls | How many rolls to show |
Everything after the “#” (the fragment) never leaves your browser: it does not reach any server, not even this website’s. The calculation runs in the page itself, with the same engine as the app compiled to JavaScript.
The example above, with an S2 opening and five rolls: /en/verify/#commit=66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925&seed=0000000000000000000000000000000000000000000000000000000000000000&client=cliente&nonce=1&start=s2&rolls=5
What it proves and what it does not
| Question | Answer |
|---|---|
| Was the seed changed during the game? | Proven: if the revealed seed does not produce the commitment you saw before the game, verification fails |
| Do the rolls come from that seed? | Proven: the verifier recomputes all of them, and they must match the game |
| Could the dice adapt to my moves? | No, if verification passes: the whole sequence was fixed before the first roll |
| Is any face favoured? | No: the formula is public and each face comes from 42 of the 252 accepted values |
| Does my client seed count? | Yes: it goes into every calculation, and if the app ignored it, the verifier would not match |
| How was the server seed chosen? | The scheme cannot prove that on its own: your device generates it with its cryptographic generator |
In short, verification guarantees that the dice were fixed before the first roll and that nobody touched them while you played. On top of that, by design, GammonMind’s bots never receive the seed or the stream: they only see the position, the dice already rolled and the score.
Luck meter and physical dice
“The dice are rigged” is the most common complaint about backgammon games. Besides verification, GammonMind has two more answers:
- Luck meter. It measures each player’s luck in the game by comparing equity before and after every roll, so you can see who had the better dice.
- Physical dice. You can play with your own dice and enter each roll. Those games have no commitment, are marked as such in the history and do not count toward Elo, achievements or leaderboards.
Step by step
- Note the commitment. Before the first roll, the app shows you the commitment (the SHA-256 fingerprint of the seed). Copy it or take a screenshot.
- Choose your client seed. If you like, set your own text as the client seed in Settings before the game starts.
- Play the game. Play as usual. Each game of a match has its own commitment and its own number (nonce).
- Get the revealed seed. When the game ends, the app reveals the server seed.
- Open the verifier. Tap “Verify” in the game, or open the verifier and enter the commitment, the seed, the client seed, the nonce and how the game started.
- Compare. The verifier checks that the SHA-256 of the seed matches the commitment and recomputes the rolls: they must be the same ones you played.
Frequently asked questions
- Are GammonMind’s dice rigged?
- No, and you can check it. Before each game you see the seed’s commitment; at the end the seed is revealed and the verifier recomputes every roll. If any roll had been changed, it would not match.
- What does commit-reveal mean?
- First the fingerprint (SHA-256) of a secret is shown, and later the secret itself. If the revealed secret produces the same fingerprint, it did not change in between.
- Is anything sent to a server when I verify?
- No. The verifier runs in your browser with the same engine as the app compiled to JavaScript, and the link data sits after the “#”, which browsers never send.
- What is the client seed for?
- It makes the rolls depend on something of yours too. Change it and every roll changes; and if the app did not use it, the verifier would not match.
- Why are some bytes discarded?
- To avoid bias. A byte has 256 values, which do not split evenly across 6 faces; with the first 252, each face comes up exactly 42 times.
- Who generates the server seed?
- Your own device, with a cryptographic generator. That is why the scheme proves the seed did not change during the game, but cannot prove on its own how it was chosen.