### What is Provably Fair?

"Provably Fair" is an industry standard that guarantees a casino is giving you a fair chance at winning.

At a high level, the fairness of the blackjack game is guaranteed through the random procedure by which the card deck is shuffled. Everybody participates in the shuffle, including the server and each player on the table.

This happens in four phases.

#### 1. Server and Players chose their secrets

Before a new round starts, the server performs a first secret shuffle on the deck. The server and each player on the table pick a secret random number.

#### 2. Server and Players commit to their secrets

Each player will commit to their individual random number and reveal their commitment publicly.

The commitment guarantees no player will be able to subsequently change the random number they have picked, but it also does not disclose any secret random number.

In a similar way, the server will commit to its secret shuffle of the deck as well as the secret number it picked.

#### 3. Server and players reveal their secrets

Each player will then receive from the server a global commitment (a short version of the server commitment combined with all players' commitments). Upon receiving this global commitment, each player will reveal his secret random number.

#### 4. Server shuffles the deck

The server receives each player's random number. It uses a combination of its own random number and each player's random number to shuffle the deck.

#### How is a player random number picked?

The random number is obtained in the browser in Javascript. We use your Browser Native Crypto module if your Browser supports it. However, you don't have to trust our word for it. By opening the provably fair settings you can modify it until before the rounds starts. As soon as the round starts, you commit to your secret random number and will not be able to change it anymore.

A new random number is picked for every round.

#### What is a commitment?

A commitment to a secret random number is a cryptographic hash of the secret number. Sha256 is used as a hash function.
The secret number is large enough to guarantee that no one will be able to obtain the secret with the sole knowledge of the commitment.

A property of the hash is that it is practically impossible to find another random number which hashes to the same value. This is why it is a commitment.

#### What is the global commitment?

It is a Sha256 hash of the server random number, the initial shuffle and each player's commitment. It is used to save space on the screen instead of showing each player's commitment separately. In the case of two players on the table, it is equal to the following:

#### The initial shuffle?

The initial shuffle the server performs is necessary to cover a large enough space of possible card permutations. This is because the second shuffle is seeded with a 32 bit seed, which is not enough to represent the large possible number of card permutations.

The initial shuffle is made public at the end of the round to allow for independent verification of the round fairness. The shuffle is represented by an array of 312 numbers representing each card in a 6-deck game. Numbers range from 0 to 52 for each card in a single deck (therefore the same number will appear 6 times - once for each deck): 0 for the 2 of hearts, 1 for the 3 of hearts, 12 for the ace of hearts, and so on, where the order of suits is heart, diamond, club and spade.

#### How is the deck shuffled?

The server uses a Fisher-Yates algorithm to shuffle the deck using a combination of all the players random numbers and its own random number as the source of randomness.

The combination is obtained by concatenating the server random number, then each player's random number in a fixed order, then hashing the result, taking the modulo 2^32 and using it as a seed to the Mersenne Twister random number generator used in the shuffling algorithm.
In the case of two players on the table, the seed is equal to the following:

Given the random number of each player and the server's random number and the initial shuffle, anyone can independently verify that the correct shuffle was performed by the server.

#### Why is it fair?

No one discloses his secret number before they have received everybody commitments including the server commitment to the initial shuffle. This guarantees their secret number will not leak too early. Without the knowledge of each player's secret number, no one - even the server - can tell what the final shuffle will look like, even if they know everybody commitments.

No one can change their secret number after they committed to it, not even CakeBet server. This guarantees the shuffling procedure is truly random and thus fair. At the end of the round, every one can verify the fairness of the game independently.

#### How to verify the round was fair

At the end of the round, the server will reveal each player's random number, the initial shuffle and its own random number.

The verification procedure happens in two steps:

**Step 1. Global commitment verification** Anyone can verify the global commitment they received was computed correctly, and therefore no one could have possibly changed his random number after any other player revealed his secret number and the server could not have possibly modified the initial shuffle.

In the case of two players on the table, the global commitment value should be equal to the following:

**Step 2. Final shuffle verification** Anyone can then compute the seed used for the shuffle algoritm as described in How is the deck shuffled, use the seed to shuffle the initial shuffled decks and confirm that the resulting cards were the actual cards that were observed during the round.

An online verifier can be found from the provably fair settings and can be used at the end of each round.

If you would like to verify the fairness a bit more in depth, we provide you with a python script to get you started!

#### Partially verified rounds

We try very hard to make every round provably fair. However, we do not control the network connection of players on the table. This means, that in some rare scenario, some player will send us a commitment to his private random number but will never send us subsequently his actual random number. In the absence of such a number we cannot guess it, so we proceed without it. The verification of the final shuffle can still proceed but the verification of the global commitment can only be done partially. In the case of two players on the table, with the first player's random number missing, anyone can verify the global commitment is equal to:

Due to the low occurence of these situations, our game is provably fair, since the rate at which these situations occur is much lower than our house edge.

If you have any concern about this process, you may contact us at support@cakebet.com.