Provably Fair Gambling

What does provably fair mean?

The worse fear a player has playing at an online casino is being cheated by the site they are playing at.

In the Bitcoin gambling community a standard solution has been developed to allow players to verify the results of their bets, to prove that the house did not alter them in their favor.

How does it work?

Dice

You can use this 3rd party tool to verify your bets from the Pocket Rockets Casino dice game http://dicesites.com/betking/verifier without the need to understand the math behind the method.

  1. When you first visit the site we generate a random string of characters on the server used as your Server Seed. A new server seed can be generated by you before you roll.
  2. A SHA-512 hash of the server seed is shown to you before you bet to prove we can't change it.
  3. When you bet we get a Client Seed you supply (one is auto generated by your browser that you can change).
  4. We take the server seed, client seed and the number of rolls that you have used the current server seed for in the format: n:s:n, n:c:n. Where n is the number of rolls, s the server seed and c the client seed. We take the HMACSHA512 hash of that. We convert the first 5 characters of the hash to decimal and that is your roll.
  5. Sometimes the first 5 characters will not result in a number we can use and so we loop through the next 5 characters 6-10, 11-15 etc until we find one. The code for this is below.


Roulette

  1. When you first visit the site we generate a random string of characters on the server used as your Server Seed. A new server seed is created for your after each bet.
  2. A SHA-512 hash of the server seed is shown to you before you bet to prove we can't change it.
  3. When you bet we get a Client Seed you supply (one is auto generated by your browser that you can change).
  4. We take the server seed and combine it with the client seed. We then take the sha256 of this seed and generate a seed to pass to a Mersenne Twister random number generator.
  5. We then take a deck, of numbers 0-36, and shuffle it with the Fisher–Yates shuffle algorithm and the Mersenne Twister RNG.
  6. The top number of the deck is your roulette spin result.

Here's a sample of the code used to generate and verify the roulette spins. Mersenne Twister and SHA256 libraries must be used.



Crash

Using an initial server seed we generated a chain of 10,000,000 SHA256 hashes, each hash being the lowercase, hexadecimal string of the previous.

The 10 millionth hash in the chain is the hash used for game number 1 and the first hash in the chain is used for game 10,000,000.

We also use a salt that was the hash of a Bitcoin block that had not been mined yet, this was block 545340 and the hash is 00000000000000000012ca8e5e79b171a7b93f30761c2bc3ac80ef1966e88f8b

You can see our seeding event here that proves we didn't know the salt in advance.

Below is the code used to generate a crash game result from hash