momentum-mod / website

Momentum Mod's main website.
https://momentum-mod.org
MIT License
55 stars 60 forks source link

Chat Signing #966

Open chovelyoukai opened 1 week ago

chovelyoukai commented 1 week ago

Suppose two users, Alice and Bob are in a lobby together. Alice wants to report to the moderators an offensive message sent by Bob so she sends the message to the moderators. But how can the moderators know that the message really was sent by Bob, and isn't a forgery meant to get him unjustly punished? To solve this problem, public-key cryptography can be used to sign messages, proving that they are authentic and untampered with. Here's how it would work in this situation ("the server" refers to the backend):

  1. Bob authenticates with the server and recieves his private key.
  2. Bob connects to a lobby with Alice, and Alice recieves his public key from the server.
  3. Bob sends an offensive message with his signature attached.
  4. Alice uses Bobs public key to verify the message is authentic, and the message is only displayed if it passes.
  5. Alice reports Bob's message by sending the message text and the signature to the server.
  6. The server verifies that that message was sent by Bob by using the known public key.
  7. Bob's message is verified to be authentic, so moderator action is taken against him.

A couple of things to note:

  1. The server controls both the public key and private key. The private key should ONLY be given to the user who is able to authenticate via Steam. The public key can be given to everyone.
  2. If Bob doesn't sign his message, then when Alice receives it she will not be able to verify it, so it won't be displayed at all.
  3. If Alice attempts to tamper with the message and report a modified message with the original signature, it will not verify because the contents of the signature are based on the message itself.

Further reading:

Gocnak commented 1 week ago

And some of my notes: