inicasino.netContents

Crypto casino questions · 16 / 23

Provably fair at a Bitcoin casino, from dice sites to seed pairs

Provably fair is the method a Bitcoin casino uses to let players recompute a game result instead of taking it on faith. It grew up around Bitcoin dice games, and the dice game is still the clearest way to understand it.

Short answer

Provably fair is a way for a Bitcoin casino to show that a result was fixed before the bet. The operator publishes the hash of a secret, the result is computed from that secret and from values the player supplies, and after the secret is revealed anyone can repeat the computation. It shows how one round was drawn and nothing about the house edge or about payment.

Flow diagram with 4 steps: Before play; The roll; Rotation; The check.
How the scheme grew out of Bitcoin dice games, and how to check a roll today.

Key facts

  • The commitment is a SHA-256 hash of the server seed, shown before the bet.
  • In the seed-pair form the result is an HMAC-SHA256 of the client seed and nonce under the server seed (RFC 2104).
  • A dice roll from 0.00 to 99.99 is the first four bytes of that output scaled to 10000 values, in the scheme this site's tools use. Operators differ.
  • A round can be verified only after its server seed is revealed, which happens when the seed pair is rotated.
  • The check needs no Bitcoin transaction. It is arithmetic on text that you can run offline.

The problem it answers

A player on the internet cannot watch a die being thrown. The operator's software produces a number and reports it. If the operator could pick the number after seeing the bet, it could make any bet lose. Provably fair removes that option with a commitment: the operator fixes its part of the result before the bet and proves afterwards that it did not change it.

The first form, bets as Bitcoin transactions

In the earliest design a bet was a Bitcoin transaction sent to an address that stood for a chosen win chance. The operator had published hashes of a series of secrets in advance, one for each day. The roll was computed from the day's secret together with the identifier of the bet transaction. After the day ended the secret was published, and anyone could hash it, compare it with the hash published earlier and recompute every roll of that day.

Two properties of Bitcoin made this work. Transactions are public: bitcoin.org states that “All Bitcoin transactions are stored publicly and permanently on the network”, so the bet and the payout could be seen by anyone. And a transaction identifier is fixed by the player's own transaction, so the operator could not choose it.

This account of the early design is given as background. It names no site, and we found no neutral source for the history that does not, so no date or first use is claimed here.

The second form, server seed, client seed and nonce

Waiting for a Bitcoin block for every roll is slow, so dice sites moved the bets off the chain into account balances and kept the commitment. The transaction identifier was replaced by two values: a client seed that the player sets, and a nonce that counts the bets. The daily secret became a server seed that the player can ask to have revealed and replaced at any time. This scheme is widely used by Bitcoin casino games today.

Comparison grid. The two forms of provably fair dice compared: Bets as Bitcoin transactions; Server seed, client seed and nonce; Where a bet is recorded; The operator's commitment; What the player contributes.
The two forms of provably fair dice compared
The two forms of provably fair dice compared
ElementBets as Bitcoin transactionsServer seed, client seed and nonce
Where a bet is recordedOn the Bitcoin blockchainIn the casino's database
The operator's commitmentHashes of secrets, published for days aheadThe hash of the current server seed
What the player contributesThe identifier of the bet transactionA client seed, and a nonce that counts the bets
When the secret is revealedAfter the day it belongs toWhen the player asks for a new seed pair
Who can see the betsAnyoneThe casino and the player
One roll under the seed scheme
  1. Before playThe casino shows the SHA-256 hash of its server seed. You save it and set your own client seed.
  2. The rollThe result is computed from HMAC-SHA256 of your client seed and the nonce, keyed with the server seed.
  3. RotationYou ask for a new seed pair. The old server seed is revealed.
  4. The checkYou hash the revealed seed, compare it with the saved hash and recompute the roll.

HMAC is defined in RFC 2104. What each of the three inputs is for is explained on the page about the server seed, client seed and nonce. A worked roll with every intermediate value is on the provably fair verifier, and the same check with ordinary command-line tools on the page about verifying a bet by hand.

Why the hash can be relied on

The whole scheme rests on two properties of the hash function. NIST describes them on its hash functions page. Preimage resistance: given a hash value, it is computationally infeasible to find an input that produces it, so the published hash does not give the seed away. Second preimage resistance: it is computationally infeasible to find a second input with the same hash as a given one, so the casino cannot swap the seed afterwards. NIST lists the preimage strength of SHA-256 as 256 bits.

What the proof leaves open

A verified roll shows how one number was made. It does not show that the payout for that number matches the rules, that the stated return is true, or that a withdrawal will be paid. In the account-based form the bets are no longer public transactions, so the open record of the first design is gone and only the per-roll proof remains. The page on whether crypto casinos are rigged sets out the wider picture.

A dice game that is drawn honestly still has a house edge. With a 1 % edge, a bet with a 49.5 % win chance pays 2.0000 times the stake, where an even game would pay more. Verifying the roll does not change that price.

How do you verify a provably fair Bitcoin dice roll?

The steps use the scheme implemented by this site's provably fair verifier. Operators differ in details, so compare with the scheme your game documents.

  1. Save the server seed hash. Copy it from the fairness panel of the game before you bet.
  2. Set a client seed of your own. Type a new one after the hash is on screen.
  3. Bet and write down the nonce. Note the nonce and the roll of each bet you mean to check.
  4. Rotate the seed pair. The game then shows the server seed it had been using.
  5. Check the commitment. The SHA-256 hash of the revealed seed must equal the hash you saved. The seed hash checker compares them.
  6. Recompute the roll. Enter server seed, client seed and nonce in the verifier, choose the conversion rule your game states, and compare the number.
  7. Repeat for a few bets. Change only the nonce. Pick the bets after the fact, including the ones that surprised you.

What does a worked example look like?

Take test vector V1 of this site. The server seed is reference-test-server-seed-0001, the client seed is reference-client and the nonce is 0. The commitment shown before the bet is the SHA-256 hash of the server seed, 9088b0a58305a44b0ec72f1af9ef3e2e4927d17a516fdbf805707fdebdf69107.

The HMAC output begins with the bytes 253, 63, 156, 101. Read as one number and divided by 4294967296 they give the fraction 0.9892518756. Scaled to 10000 values the result is 9892, which a dice game shows as a roll of 98.92. The page on verifying by hand reaches the same number with ordinary command-line tools.

Where is the house edge in a provably fair dice game?

Bar chart. Multiplier paid by a dice bet at a 1 % edge, by chance to win: 10 % = 9.90; 25 % = 3.96; 49.5 % = 2.00; 75 % = 1.32; 90 % = 1.10.
Multiplier paid by a dice bet at a 1 % edge, by chance to win.

In the payout, not in the draw. A bet that wins with a chance of 49.5 % pays 2.0000 times the stake at a 1 % edge, where a game without an edge would pay 2.0202. On average each unit staked returns 0.99 units, and this holds for every chance you can pick.

Payout multipliers of a dice bet at a 1 % edge
Chance to winMultiplier paidMultiplier without an edgeAverage return per unit staked
10 %9.9010.000.99
25 %3.964.000.99
49.5 %2.00002.02020.99
75 %1.321.33330.99
90 %1.101.11110.99

Which mistakes do players make when verifying?

  • Trying to verify a bet while its server seed is still in use. The seed is revealed only after rotation.
  • Not saving the hash before betting, which leaves nothing to compare the revealed seed with.
  • Keeping the client seed the page suggested. A seed generated by the operator's page may have been known to it when it committed.
  • Mixing up the nonce. Each bet under one seed pair has its own number, and games differ in whether they count from 0 or from 1.
  • Pasting the seed with a trailing space or a line break, which changes the hash completely.
  • Using a verifier built for a different scheme. Byte order, separators and the conversion rule differ between operators, as the page from hash to number shows.

Which terms does this page use?

Server seed
The operator's secret for a series of bets. Its hash is shown first, the seed itself after rotation.
Client seed
A value you supply and can change. It keeps the operator from knowing the result when it commits.
Nonce
A counter that rises by one with every bet under the same seed pair.
Commitment
The published hash of the server seed. See commit-reveal explained.
HMAC-SHA256
A keyed hash defined in RFC 2104. Here the server seed is the key and the client seed with the nonce is the message.
Seed rotation
Ending the current seed pair and starting a new one, at which point the old server seed is revealed.

Questions people ask

What does provably fair mean at a Bitcoin casino?

That the casino commits to a secret before you bet, by showing its hash, and reveals the secret later, so that you can recompute each result yourself from the secret, your own seed and the bet number.

Is a provably fair Bitcoin dice game free of a house edge?

No. Provably fair concerns how the number is drawn. The edge is set by the payout for each win chance and is part of the published rules.

Do I need Bitcoin knowledge to verify a roll?

No. In the seed scheme the check needs a SHA-256 and an HMAC-SHA256 computation, which a browser, Python or OpenSSL can do. No wallet is involved, and no wallet secret must ever be entered into a checker.

Is provably fair the same on every Bitcoin casino?

The idea is the same. The exact message format, the hash function and the rule that turns bytes into a roll differ, and each operator has to publish its own.

How do I verify a provably fair bet?

Save the server seed hash before you bet, set your own client seed, note the nonce, rotate the seed pair, check that the revealed seed hashes to the saved value, and recompute the result with the provably fair verifier. The numbered steps are on this page.

Why can I not verify a bet right away?

Because the check needs the server seed, and the operator keeps it secret while it is in use. A seed revealed during use would let anyone compute the coming results. It is shown when you rotate to a new pair.

Does provably fair use the Bitcoin blockchain?

In the seed-pair form it does not. The seeds and results live in the casino's database and the check is arithmetic you can do offline. The older form, with bets sent as Bitcoin transactions, is described on this page.

Can a provably fair Bitcoin casino refuse to pay?

Yes. The proof covers the draw. Payment is a transaction the operator sends or does not send, and a Bitcoin transaction cannot be reversed by the person who sent it, so a deposit cannot be pulled back either.

What is the difference between SHA-256 and HMAC-SHA256 here?

SHA-256 turns the server seed into its public commitment. HMAC-SHA256 mixes the server seed with the client seed and the nonce to produce the result. The seed hash checker does the first and the provably fair verifier the second.

Can I control the result by choosing my client seed?

No. You do not know the server seed when you choose, so you cannot tell which client seed leads to which result. Your seed only makes sure that the operator could not tell either when it committed.

Sources

How we checked: statements about a named body link to that body's own page and carry the date we read it. Numbers in worked examples are computed by the site's build from the formulas shown, with routines covered by its test suite.