Back to support

Fair dice

How Tavli fixes a match's dice before its first roll, and how anyone can check them afterwards.

Every tavli player has said it: the dice are against me. In Tavli that is an answerable complaint. The dice of a match are decided before it starts, and at the end the app hands you everything needed to prove it.

What the app does

  1. Before the first roll of a match, the app draws a secret 32-byte seed from the system's secure random source.
  2. It shows that seed's fingerprint, the SHA-256 of the seed as 64 hexadecimal characters, in Settings under "Fair dice". This is published before a single die is thrown, and the seed itself stays hidden.
  3. Every die of the match comes from the seed and nothing else. The SHA-256 of the seed followed by an 8-byte big-endian counter (0, 1, 2 and so on) gives 32 bytes at a time. Bytes of 252 and above are thrown away, so every face is exactly as likely as every other; each byte kept is one die, its value modulo 6 plus 1. The opening roll, both players' rolls and the computer's rolls all come from this one sequence, in the order they are rolled.
  4. When the match is decided, the app reveals the seed, shows how many times each face came up for each side, and offers "Copy the proof": the fingerprint, the seed and every die in order.

Checking a match yourself

With the copied proof and any SHA-256 tool:

  1. The SHA-256 of the seed's bytes must equal the fingerprint the app showed before the match started. If it does, the app could not have changed the seed once play began.
  2. Replaying step 3 above from that seed must give exactly the dice listed in the proof, in that order. If it does, no roll was chosen after the fact.

The app performs both checks itself on every finished match before it says "These dice were fixed before the first roll."

Matches between two devices

A Game Center match is turn-based, so neither device can wait for the other to answer before rolling. One shared seed revealed in advance would not do, because both sides would then hold every future die, and a fresh exchange before every roll is not possible when the other player may be asleep. Tavli does this instead.

So neither device can choose a die, and neither knows a roll before its own sitting begins.

What this does not claim

Published here because a fairness claim with the limits left out is worth less than one with them written down.

Questions

Email tavli@dkcreative.uk. If you find a fault in any of this, it is worth telling us and it will be fixed and credited.