MixinNetwork / libsignal_protocol_dart

Signal Protocol library for Dart/Flutter
https://pub.dev/packages/libsignal_protocol_dart
GNU General Public License v3.0
159 stars 42 forks source link

Distributing DistributionMessage #73

Open Swepilot opened 1 year ago

Swepilot commented 1 year ago

Hi!

I've been studying this package, examples and reading other issues for a few days now. What I fail to get my head around is how to distribute the DistributionMessage to other members in a group chat. Examples run fine but then all members (Alice, Bob & Dean) all are in the same function with direct access to all variables.

Currently I have written a small test program that stores the chat messages (cipher text) in a Firestore database. It works fine to "chat" between two different devices, but only because I am storing the DistributionMessage along with the cipherText. This is obviously not how it should be done. Should the DistriubutionMessage be sent to all members using the normal 1-to-1 session or some other mechanism?

Furthermore, should I every time I send a message go through every member of the group and .process their DistributionMessage before encrypting the message to be sent? Is this how one achieve the behaviour that new members cannot see old messages, because their distribution message was not included when the message was encrypted?

for each member in chat {
   await bobGroupSessionBuilder.process(
      member[GroupSender], member[DistributionMessage]);
}

Thankful for any guidance!

/Nik

Tougee commented 1 year ago

Is this how one achieve the behaviour that new members cannot see old messages, because their distribution message was not included when the message was encrypted?

  • yes
anisalibegic commented 2 weeks ago

@Tougee You said:

you only need to send and process DistributionMessage the first time you join in chat (all members should refresh their keys if someone exits chat for forward secrecy)

After a group is created, each user needs to go and click on a chat if he wants to decrypt upcoming messages. In Signal app I can create a group and immediately send few messages and every member will receive those messages even though he never clicked on a chat to send those keys. So, the question is how to encrypt a message with each member key if member is offline or did not joined a chat after I added him?