I am building a system where the clients should be able to communicate with each other. However I want all the data to be hidden from the server where the information is stored in a database.

How can the users invite more users and share the encryption key without that the server also get the key?

  1. First user creates a key (locally on the device) to encrypt the messages (symmetric encryption).
  2. First user invites another user. How can the key be distributed from the first user to the second user without that the server also get this information? Same question goes for user three etc.
  3. The idea is that the second user, after accepting invite, can read all the data that the first user have created and that now user two and three can create new data that user one can read.
  4. I don't want the users having to enter passwords or such things.
  5. The clients cannot communicate directly with each other, it has to go through the server.

I suppose that when the key has been distributed it's quite easy to just store that on the clients and then the key can be used to both decrypt and encrypt the messages. If a client loses the key I suppose that that user needs a new invite to be able to read the data again. For this system it is not required that the key needs to be changed if someone leaves the group.

  • 2
    What do you need more than the Signal Protocol?
    – kelalaka
    Commented Jan 23, 2021 at 21:43
  • 1
    That, and why do you want to use symmetric encryption? Commented Jan 23, 2021 at 22:03
  • Note that, for full security, either the users must be able to communicate outside of the service, or there must be some trusted entity (typically a server or certificate authority) authenticating the users (or both). If the server is malicious, it can substitute one user's public key / public [EC]DH parameters with its own, and the only way the victim will know they're being man-in-the-middle attacked is if they have some alternative way to verify the other party's public key is the same as the one they see.
    – CBHacking
    Commented Oct 21, 2021 at 19:55

1 Answer 1


Matrix.org have an implementation of the double ratchet algorithm used by signal for end to end encryption and they have an implementation for groups as well. It is available as a free library (Apache license) on their site with bindings for JavaScript, Python, Java (Android), and Objective-C as well as some others provided by third parties.


  • Signal protocol >= The protocol combines the Double Ratchet algorithm, prekeys, and a triple Elliptic-curve Diffie–Hellman (3-DH) handshake,[5] and uses Curve25519, AES-256, and HMAC-SHA256 as primitives.
    – kelalaka
    Commented Jan 23, 2021 at 22:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .