# Card Generation

I would like to propose to the public the algorithm for the card game, which eliminates the "cheating". Those. the alignment of the game is generated jointly by the participants, and the “showdown” of a specific card can be made for only one player.

For simplicity, the algorithm is described for three people, but it is easily extended to any N> = 3.

Each player generates three random permutations: A1..3. The product A = A3 * A2 * A1 is the layout of the game. Now, if it is necessary to open the card with number i, the first player transfers to the second A1 (i), the second transfers to the third A2 (A1 (i)) = A2 * A1 (i), the third publishes A (i) = A3 * A2 * A1 ( i). If the card needs to be revealed only for the third player - A (i) he will not publish.

The third player generates a random permutation of C3 and transfers it to the first player, and transfers to the second player D3 = (C3 ^ (- 1)) * A3. Now, if it is necessary to open the card only for the second player, the first player passes to the second A1 (i), the second passes back to the first D3 * A2 * A1 (i) and the first calculates C3 * D3 * A2 * A1 (i) = A (i) .

Further, the third player generates a random permutation F3 and passes it to the second player, he passes G3 = A3 * F3 ^ (- 1) to the first player. Now, if it is necessary to open the card only for the first player, he passes the second A1 (i), the second passes him back F3 * A2 * A1 (i) and the first calculates G3 * F3 * A2 * A1 (i) = A (i).

Before the start of the game, each player publishes for each random permutation X the hash of the number X + k * n, where 0

Limitations of the algorithm:

- the data exchanged between two peers is transmitted via an encrypted channel, the certificates of the participants are known to everyone in advance.

- the possibility of collusion of two participants should be excluded.

For simplicity, the algorithm is described for three people, but it is easily extended to any N> = 3.

Each player generates three random permutations: A1..3. The product A = A3 * A2 * A1 is the layout of the game. Now, if it is necessary to open the card with number i, the first player transfers to the second A1 (i), the second transfers to the third A2 (A1 (i)) = A2 * A1 (i), the third publishes A (i) = A3 * A2 * A1 ( i). If the card needs to be revealed only for the third player - A (i) he will not publish.

The third player generates a random permutation of C3 and transfers it to the first player, and transfers to the second player D3 = (C3 ^ (- 1)) * A3. Now, if it is necessary to open the card only for the second player, the first player passes to the second A1 (i), the second passes back to the first D3 * A2 * A1 (i) and the first calculates C3 * D3 * A2 * A1 (i) = A (i) .

Further, the third player generates a random permutation F3 and passes it to the second player, he passes G3 = A3 * F3 ^ (- 1) to the first player. Now, if it is necessary to open the card only for the first player, he passes the second A1 (i), the second passes him back F3 * A2 * A1 (i) and the first calculates G3 * F3 * A2 * A1 (i) = A (i).

Before the start of the game, each player publishes for each random permutation X the hash of the number X + k * n, where 0

Limitations of the algorithm:

- the data exchanged between two peers is transmitted via an encrypted channel, the certificates of the participants are known to everyone in advance.

- the possibility of collusion of two participants should be excluded.