Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hostless Mode #22

Open
jonaswre opened this issue Nov 30, 2021 · 0 comments
Open

Hostless Mode #22

jonaswre opened this issue Nov 30, 2021 · 0 comments

Comments

@jonaswre
Copy link
Contributor

jonaswre commented Nov 30, 2021

I think we should try to make the library as p2p as possible.
To achieve true p2p one thing we need to get rid of this the need for a host.

In boardgame.io a host is the one entity that is trusted by all clients.
The responsibility of the host are the following:

  • authenticate clients
  • create randoms
  • store clients private state
  • verify valid moves

To get rid of the host, these responsibility need to be handled trustless from within all clients.

Authentication

Authentication will be handled like in any other p2p network through public-key cryptography.

And this is the only part where we need some sort of trust to a single entity.
Not to verify identities but to initiate a game and to invite other players to that game.

Ones the game has started that trust is no longer needed.
Every client can verify moves from any other client, because their communication will be signed by the users private key.

Create randoms

This is one of the trickier challenges to overcome.
In boardgame.io the random values need to be random, that means nobody should be able to control the outcome of the random value. Secondly the random value need to be secret so nobody but the client ,who created the random value, knows what that value is. Because that value might be used to draw a random card or do anything else that is random and secret to the client.

To generate a random value like mentioned above.
The clients that needs a random value, sends a request to all clients. Part of that request is a random value that is encrypted by that client. Because the value is send before any other parts of the random value are known, there is no way to choose the value to get a wanted outcome. Secondly because this value is encrypted by the client, the other client cant influence the outcome by choosing a value that fits their needs. This also means nobody but the client who asked for the random value can know what that value is.

Store clients private state

Clients private state is encrypted and replicated to all clients.

Verify valid moves

This is an another interesting problem. Since there a certain parts that needs to be secret during the game. Verification can only happen in certain situations. For example when a random card is drawn. That move can only be verified after that card should no longer be kept secret. There maybe a way to find these things automatically. But to allow for most compatibility. The moves in a game can only be verified after the game has ended. So when ctx.events.endGame() is called every client publishs their encryption key(s) these keys can then be used by any client to find out if the game has been cheated in. This is an important charakteristik of a p2p network. Trust needs to be replaced by verification.

Draw a card and keep it hidden

There is an another Problem that need to be adressed since some games will require that mechanism. To draw a random card from a pile and keep that hidden. Its not enough to keep the random value hidden. The card will need to be removed from the pile. Observing the removal will give a way what card was drawn. To make that work, every card in the pile will need to be encrypted with a diffrent key. And these keys will need to be splitted and every client gets one part of the key. So when a card is drawn. Every client sends their part to the client that has drawn the card. That way only the client that has drawn the card has all parts of the key and can decrypt and see what card was drawn.
I think this part will need to be investigated futher. Because the encryption of the card will need made without ever giving away the full encryption key.

EDIT: It seems like somebody far smarter has already solved this issue. Its called Mental Poker But we would need to evaluate if full distribution is performat enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant