Follow

BlackJack Deck - Provably Fair

To generate the sequence of cards to deal, BetBTC starts by generating a shuffled array of cards even before user hits the deal button. The sequence of cards ordered and shuffled (1º shuffle by BetBTC) are saved on the new deck.

cards = ['ac','ad','ah','as','kc','kd','kh','ks','qc','qd','qh','qs','jc','jd','jh','js','10c','10d','10h','10s','9c','9d','9h','9s','8c','8d','8h','8s','7c','7d','7h','7s','6c','6d','6h','6s','5c','5d','5h','5s','4c','4d','4h','4s','3c','3d','3h','3s','2c','2d','2h','2s']*(size of deck)
shuffled = cards.shuffle

 

This guarantees that the unencrypted deck we will show you afterwards was generated before the hand started and it also proves that it was not manipulated or altered in the meantime.

 

Before user starts an hand we provide you the following data regarding the deck, a server_seed and Deck Hash are generated with the following:

  • server_seed = SecureRandom.hex(8)
  • Deck Hash = Digest::SHA2.hexdigest "#{server_seed}#{shuffled.join(",")}"

 

At this stage we have a complete set of cards shuffled by BetBTC, however it's important to remember that we are only halfway because we will now make the second shuffle with the client seed.

We generate a key with both client_seed and server_seed:

key = Digest::SHA2.hexdigest "#{client_seed}#{server_seed}"

 

Then we pick on the last 8 characters of this generated key and convert it to hexadecimal to generate our seed:

seed = encryption[(key.length-8)..key.length].to_i(16)

 

To make our second and final shuffle using the client key, we will shuffle the first array (with the first shuffle) using as random algorithm, the seed generated previously.

Final Shuffle = shuffled.shuffle(random: Random.new(seed))

0 Comments

Please sign in to leave a comment.
Powered by Zendesk