|
|
|
|
|
by pmontra
1294 days ago
|
|
Imagine a card game with a deck and two players. The deck knows which player got which card. Each player knows its own cards and the ones on the table. The deck should not run in the browser of one of the players because that player could inspect the status of the deck and know which cards were handed to the other one. To answer your question: maybe, but for almost any game you need a trusted third party that holds the secret state of the game. A third browser somewhere or a headless server? Exceptions: complete information games like go, chess and checkers. Everything is public. Games with a dice like backgammon starts to be problematic because how can one player trust the dice of the other player? A shared random seed would let them know in advance all the rolls. |
|
I have an algorithm for that. To roll a dice: 1. both players create a random x bytes long number.
2. both players make a hash from their number and then send it to the other one.
3. players exchange their random numbers and check if hashes are correct
4. concat both players random numbers and hash it to get the final random number
By exchanging hashes, both players can be sure that other player didn't tamper with their random number after getting yours.
(edited formatting)