How it works

How FairDice works

A short tour of the cryptography that makes a roll provably fair.

1. The seed is locked before the game

The game server picks a secret 256-bit seed and publishes only its SHA-256 fingerprint (the commitment). A hash cannot be reversed, so players learn nothing about future rolls, but the server can no longer switch to another seed: any other seed would produce a different fingerprint.

2. Players mix in their own randomness

Each player's device contributes a client seed, or the game uses the next value of the public beacon. Because it arrives after the commitment, the operator could not have searched for a seed that favours anyone.

3. Every roll is numbered

Roll number k is HMAC-SHA256(server seed, client seed : k). The counter makes every roll unique and ordered: a roll cannot be silently repeated, skipped or replaced, because the proof states exactly how many draws happened and of which kind.

4. One link proves the whole match

When the game ends the seed is revealed inside a link. Your browser recomputes every roll, checks the fingerprint against the one you saw at the start, and shows the statistics. No server, not even ours, has to be trusted.

Who could cheat, and why they cannot

The game operator

Committed to the seed before knowing the players' seeds. Changing it afterwards breaks the hash.

A player

Never sees the server seed until the end, so cannot predict the next roll even knowing every client seed.

fairdice.ir

Is not involved at all: the SDK runs in the game server and verification runs in your browser. The protocol and test vectors are public.

Anatomy of a proof link

The token in https://fairdice.ir/v/... is just base64url-encoded JSON. Here is a real one for three backgammon rolls:

{
  "v": 1,
  "s": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
  "c": "alice|bob",
  "n": 0,
  "o": [
    [
      "d",
      [
        6,
        2
      ],
      3
    ]
  ],
  "g": "Backgammon",
  "t": 1796259139
}