BackgammonPearl

Dice you can check

Check a game's dice

When the game or match is over, tap the seal on the game-over card, then Check these dice. This page opens with everything filled in, and your browser recomputes the seal and every roll, and sends the game's values nowhere.

The app's dice sheet shows it when the game ends, or in a match, when the match ends. Tap it there to copy it. Until then it stays closed, on purpose.
Leave it empty and the page shows the seal of the seed above.
In the order the dice sheet lists them. Against the computer offline there is only yours.
Rolls are numbered from 1 across the whole match. Opening rolls count too, and a match keeps counting from game to game.
The rolls as the dice sheet lists them, with or without their numbers. Paste them and every roll is compared, not just shown.

How a roll is computed

The same code runs in the app and on the server; this page is a copy of it. Every roll of a match comes from one HMAC:

mac  = HMAC-SHA256(key = server seed bytes,
                   message = phoneSeed1 ":" phoneSeed2 ":" rollNumber)
byte = the first byte of mac that is below 252
v    = byte mod 36
dice = (floor(v / 6) + 1,  v mod 6 + 1)

252 is 7 × 36, so each of the 36 ordered rolls is equally likely. Bytes 252 to 255 are skipped because keeping them would favour the first four rolls a little. If none of the 32 bytes is below 252 (a chance of about 2-192, far too rare to expect), a + is appended to the phone-seed part and the MAC is computed again: phoneSeed1:phoneSeed2+:rollNumber, then ++, and so on.

The seal shown before the first roll is SHA-256(server seed bytes) as hex. A server seed has 16 to 64 bytes; the game uses 32. A phone seed is 1 to 128 characters of letters, digits, _ and -; the app makes 32 hex characters.

Why this works

The seal is on the table before the first roll, so the server cannot swap its seed once it sees how the game goes: the seal would change too. Your phone draws its own seed after the seal is shown, so the server cannot pick a seed to suit it. Every roll depends on both, and you hold everything needed to recompute them.

If the page shows a roll that differs from what you saw on the board, or a seal that does not match, keep the link and write to [email protected]. We want to know.

Linking to this page

The app's Check these dice button opens this page with everything after the # in the link, the part your browser never sends to a server: /check/#v=1&s=…&c=…&p=a,b&r=6344…&g=52,48. s is the server seed, c the seal, p the phone seeds in seat order, r every roll as two digits in roll order, and g, for a match of several games, how many rolls each game used.