I am creating a network with three layers. A sender layer, A gateway layer, and a Receiver layer; each having different platforms. See diagram below

enter image description here

All platforms have published their public keys on a trusted public database server (not shown on the diagram).

A sender S wants to send a message to the receiver layer but it can only send the message via one of the platforms in the Gateway layer. Let's call it G.

The message contains a public section that can be accessed by anyone and a private section that should be accessible only by the receiver layer. Something like below

    "public"  : { <public data>  },
    "private" : { <private data - encrypted> }

Every time S sends a message to G; G uses the public section of the message to verify the authenticity of the sender and to identify a subset of Receivers { R1, R2 ... Rp } where p <= n; and broadcasts the message to the "p" receivers.

How does S encrypt the message such that only {R1, R2 ... Rp} are able to decrypt the message and not G?

Some additional forces that exist are as follows:

  • Sender platforms layer can have 1-100000000 independent devices each having its own key pair
  • The gateway platforms could range from a 1-500 platforms
  • The receiver layer could have 1-10000000 platforms each having its own key pair

Any ideas on how to achieve this? I can do this using two Gateways, G1 and G2 where one G1 broadcasts the public key of S and G2 broadcasts the message. The receiver can check if the broadcaster of the key is different from the broadcaster of the message and return an "INSECURE_TRANSACTION" error of sorts. But is there a way to make it work using only one Gateway? Any help would be appreciated.

  • If {R1, R2,...,Rp} is a fixed set, then you can consider sharing a key between just them. If its going to be a different group everytime, then I don't think you have much in terms of options.
    – Limit
    Commented Mar 3, 2021 at 20:20
  • You may wish to review Messaging Layer Security (MLS). Generally speaking, this protocol has a grouping layer between the recipients and the message(s). The message for the group is encrypted with a key derived for the group, and all members of the group can derive this key due to their participation. In your diagram, the gateway (the Delivery Service in MLS) won't be able to decrypt the message. This avoids the requirement for the sender to perform p encryptions for every message.
    – brynk
    Commented Mar 4, 2021 at 0:52

2 Answers 2


If I understand your question correctly, what you are describing boils down to sending an encrypted message to multiple recipients.

The way this is typically done is that the sender randomly generates a single symmetric key, and encrypts the message using that key. Then the sender encrypts that symmetric key with each recipient's public key. The message is broadcasted to all of the recipients, along with the all of the encrypted symmetric keys.

This way, the network is not sending N different messages to N different recipients - the same message is broadcasted to all recipients.


One way that comes to my mind is using methods like Diffie-Hellman tree, to generate a Diffie Hellman key-pair which is shared between all recipients. It is then used by the sender to send message. But key sharing session can be quite slow depending on the number of participants, and needs to be redone as soon as someone leaves or enters the system. There are some newer group messaging protocols to get around this problem that I have not looked into yet.

You must log in to answer this question.

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