Provably Fair Blackjack


Rudi kwenye Blogu

Trust in bad. Insist on Proof.

"Trust" is an interesting word. Generally, people hear the word "Trust" and they have a positive feeling. But in the world of online gaming, trust SHOULD have the opposite effect. When it comes to money, you should never trust anybody, and that includes licensed gaming sites AND in-person casinos.

For most gaming sites, you are asked to trust that the website is fair. Players must trust that the site is not shuffling multiple times to obtain a house-favorable deck order. Players must trust that the website is not modifying the deck (removing or adding cards) or even not dealing off the top of the deck. Just because an online casino looks nice or has a lot of bells and whistles does not mean they provide a fair game. And for in-person Casinos, you must trust that there's a full and fair deck in the shoe. I recently returned from a Las Vegas trip, and I asked the blackjack dealer if I could audit the shoe. I asked if I could look at all the cards and ensure they were all there with no extra cards. My request was denied - so I'm forced to trust them. Trust is bad.

This site uses an established 'Provably Fair Shuffle' that allows the player to independently shuffle the cards after the shoe is consumed to ensure the card order exactly matches the order that they observed during game play. The remainder of this article describes this process.

First, there are a few concepts you should be familiar with:

Hashing

Hashing, simply, is converting some text into other text. For example:

Hash("Hello World") --> "uU0nuZNNPgilLlLX2n2r+sSE7+N6U4DukIj3rOLvzek="
Hash("secret seed") --> "8sE2VPNth+fbkbjYROyLkNegaV8p5eLFJKNCjs6onSU="

There are a few properties of this hash function that are important to understand:

  • For every unique input, there is a unique output
  • The results are repeatable. Meaning, if you re-enter "hello world" into the hash function, you will see the exact same output as the first time.
  • The results are one-way. Meaning, if you have the output text "uU0nuZNNPgilLlLX2n2r+sSE7+N6U4DukIj3rOLvzek=", it is impossible to figure out the original "hello world" text.

Random Number Generators (RNG) and Seeds

When creating an online blackjack game, the developer uses a tool called a "Random Number Generator" (RNG) to produce random numbers which are used during the shuffle. A common shuffle procedure will follow this process to shuffle cards in a shoe:

  1. Start with card #1
  2. Use RNG to generate a random number between 1 and 52
  3. Swap card #1 with the random card from step 2
  4. Repeat steps 1 through 3 for all cards

In the shuffle described above, the RNG creates 52 random numbers between 1 and 52. Before creating the first random number, a "Seed" is passed to the RNG which controls the outcome of all random values. If the same seed is passed to the RNG, it will create the same sequence of random numbers at a later time. For example:

Shuffle #1:

RNG(Seed=a7b21)
RNG.GetNumber returns 27
RNG.GetNumber returns 7
RNG.GetNumber returns 50
...

Shuffle #2:

RNG(Seed=a7b21)
RNG.GetNumber returns 27  <-- Same as Shuffle #1 due to same seed.
RNG.GetNumber returns 7  <-- Same as Shuffle #1 due to same seed.
RNG.GetNumber returns 50  <-- Same as Shuffle #1 due to same seed.
...

Proving a Fair Shuffle

You should now understand Hashing, Random Number Generators and Seeds. If this is still a bit fuzzy, you should re-read the previous sections until you have a good understanding. We will be using these concepts below.

The 'Provably Fair' pattern:

  1. Both the house and the player create a portion of the final seed used by the random number generator. Let's label these: House Seed and Player Seed.
    Final Seed = House Seed + Player Seed
    
    House Seed = 3Ja5bQjP/mVdxXjQ+eVN0zydNlsnYdJn+SXxaXl8W2o=
    Player Seed = GjykF8aAey39pKCr+L7Kdqk54BKgM1wGG9QF2hbjcGc=
    
    Final Seed = 3Ja5bQjP/mVdxXjQ+eVN0zydNlsnYdJn+SXxaXl8W2o=GjykF8aAey39pKCr+L7Kdqk54BKgM1wGG9QF2hbjcGc=
          
  2. The House Seed is hashed by the website to keep the house seed secret. It's important to keep the house seed secret because if the player knows the unhashed house seed, they can reproduce the shuffle and figure out the next cards to be dealt. By showing the hashed house seed to the player, the player can be sure that the unhashed seed will not change. If the house DID change the house seed at a later time, then the house seed hash would also have to change.
    Hash("3Ja5bQjP/mVdxXjQ+eVN0zydNlsnYdJn+SXxaXl8W2o=") = dFPGp/j+6NrfcWPBwptSTfs3MQ8ejOAaMtzHCERolvM=
  3. After the shoe is no longer used, the website shows the unhashed house seed to the player. The player can then do the following to prove the shuffle was fair:
    1. Hash the unhashed house seed and confirm the hashed house seed matches the hashed house seed observed prior to shuffle. This proves the house did not change the house seed prior to the player providing the player seed.
    2. Now that the player has both the unhashed house seed and the player seed, they can repeat the shuffle to see the exact order of cards observed during the game.

Verification Tools

As described above, you (the player) needs to hash the house seed and re-shuffle the deck to prove the shoe is fair. This website provides a page where this can be done, or there is an external tool where you can see the actual code that performs these tasks. Both methods are described below.

Internal Verification Tool

Link to Verification Page

In Step 1, you are asked to provide a 'ShoeID'. Here's how to find the ShoeID:

  1. Go to the Ledger page and select a date.
  2. Click on the hand that you want to verify.
  3. Click on the Show Shoe button. If the Shoe is no longer in use, you will see the player seed, house seed, house seed hash and the shuffled shoe. Here is a screenshot:
    Show Shoe Screenshot
  4. Click the ShoeID link, and this will bring you to the Verification Tool with the ShoeID pre-populated.
    Provable Screenshot 1
  5. Copy the displayed House Seed (in Step 1) into the House Seed input box (in Step 2) and click the Hash House Seed button. Verify the Hashed House Seed matches the Hashed House Seed that you recorded prior to shuffle.
  6. Copy the Player Seed from Step 1 into the Player Seed input box in Step 3. This will shuffle the shoe using the provided house and player seeds from step 2 and 3.
  7. Feel free to change the player and house seeds to see how the shuffled shoe changes. Once the seeds match that observed during game play, you should see the exact same card order in the shoe.
  8. At this point, you can do whatever verification you like, for example:
    1. Verify deck order matches.
    2. Verify cards were dealt correctly.

External Verification Tool

It's very possible you do not 'Trust' the Internal Verification Tool above because it is provided by the same site where you play the game. If this is you, then congratulations, you are understanding this article. You can use this external site to do the shuffle verification outside the context of this website. You have access to all the code (yellow box) used to perform the hashing and shuffle. Although this external tool uses the same algorithms to shuffle the shoes, there is no link or communication between this external site and this website. Here's a link to the site: StackBlitz

To use this external tool to shuffle the shoe, simply enter both the player and house seeds in the input boxes provided (red box). Once entered, the page will automatically hash the house seed (green box) and shuffle the deck (blue box). Here's a screenshot of this external site:

StackBlitz Screenshot