🎲Cards shuffling

RACE Poker's decentralized shuffling

Algorithm described here can be applied for any number of players. For simplicity, we consider a situation when 2 players are in the game: Alice & Bob.

Shuffling procedure

Synchronous stream cipher is used for encryption that satisfies:

encrypt(k2,encrypt(k1,x))encrypt(k1,encrypt(k2,x))encrypt(k2,encrypt(k1,x))≡encrypt(k1,encrypt(k2,x))encryptpartial(k)decryptpartial(k)identityencryptpartial(k)∘decryptpartial(k)≡identity

C stands for the collection of 52 cards:

C=(c1,c2,...,c52)C=(c1,c2, ..., c52) The whole collection is encrypted with a single key

Cencrypted=encrypt(k,C)=(encrypt(k,c1),,encrypt(k,c52))Cencrypted=encrypt(k,C)=(encrypt(k,c1),…,encrypt(k,c52))

In this step Alice & Bob encrypt & shuffle collection of 52 cards each with own single key

In these steps Alice & Bob encrypt each card with an independent key:

K=(k1,k2,,k52)K=(k1,k2,…,k52)Cencrypted=encrypt(K,C)=(encrypt(k1,c1),,encrypt(k52,c52))Cencrypted=encrypt(K,C)=(encrypt(k1,c1),…,encrypt(k52,c52))

K=(k1,k2,,k52)K=(k1,k2,…,k52)K=(k1,k2,…,k52)Cencrypted=encrypt(K,C)=(encrypt(k1,c1),,encrypt(k52,c52))Cencrypted=encrypt(K,C)=(encrypt(k1,c1),…,encrypt(k52,c52))

The final encryption with 52 keys

The whole encryption procedure made by all clients:

That means both Alice & Bob don't know what card is in what position now.

To reveal cards Alice & Bob need to share cards' individual keys with each other.

Until Alice shares a certain key, Bob and server doesn't know what card it is.

Alice & Bob can now play the game and share the keys according to the game logic.

Players, server need to run the same encryption/decryption process for game to go.

Alice & Bob have to reach consensus on the game progress, and transactor to verify it.

Final result

Last updated