Skip to content

Blogpost: de-mls with Waku #159

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

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open

Blogpost: de-mls with Waku #159

wants to merge 11 commits into from

Conversation

seemenkina
Copy link

No description provided.

@seemenkina seemenkina self-assigned this Dec 23, 2024
seemenkina and others added 4 commits January 20, 2025 13:35
…anations of the MLS protocol, its decentralized adaptation, and Waku's pub-sub architecture. Included insights on key management, user roles, and the actor-based system design for message processing.
… structure by enhancing explanations of the MLS protocol, Waku's pub-sub architecture, and key management processes. Added sections on message distribution, user roles, and future work, while correcting terminology and formatting for better readability.
seugu and others added 5 commits January 22, 2025 03:30
…with Waku documentation. Added new sections on actor communication and cryptographic key management, along with a new image for better illustration of the architecture.
…treamlined actor responsibilities, and removed outdated code snippets. Focused on Waku integration and user/group actor functionalities for improved understanding.
@seemenkina seemenkina marked this pull request as ready for review January 24, 2025 12:18
@seemenkina seemenkina requested a review from kaiserd January 24, 2025 12:22
Copy link
Contributor

@fryorcraken fryorcraken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed part, will continue tomorrow

One straightforward approach to SGM is a pairwise group chat, where each pair of group members establishes a unique encryption key using Diffie-Hellman. While this method ensures security, it falls short in terms of practicality:

- **High storage requirements**: Each participant must store encryption keys for every other participant.
- **Inefficient encryption**: Each message must be encrypted separately for every participant, leading to significant computational overhead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And data, as each separately encrypted must then be sent over the wire, whatever this wire might be. Or stored in DB.


The Message Layer Security (MLS) protocol offers scalable and secure group messaging protocol by organizing participants into a cryptographic tree structure, enabling efficient operations like adding or removing members with logarithmic time complexity relative to the group size. MLS provides strong security guarantees, including FS and PCS.

MLS assumes that we have the two services are provided:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MLS assumes that two services are provided (grammar)


### Waku

Waku is a peer-to-peer communication network designed to facilitate private, secure, and censorship-resistant communication by eliminating centralized intermediaries. Built on the Gossipsub protocol, Waku operates as a messaging layer where users join groups by subscribing to specific pub-sub topics. These topics define the scope and nature of the messages exchanged, allowing for adaptable communication patterns. The Waku network is composed of multiple interconnected Waku nodes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Content topics, not pub sub topics.
Not sure "groups" here is the right name. "Channels" may be more appropriate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Id present Waku by saying routing layer is broadcast and content topics can be used to tag and filter messages.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I'll fix misprinting and update Waku representation


de-MLS provides two different user management configurations, both utilizing the Waku protocol for DS:

1. **Single Admin Over a Single Waku Node**:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the number of waku node matter?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, you're right, I think it doesn't matter


### Distribution of the Messages

Since the Waku is based on gossipsub protocol and accordingly from the network point of view joining a group for a user will look like subscribing to the necessary topics.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is conflating concepts I think. Maybe best to ignore the gossipsub part and focus on content topics concept.

We have pub-sub topics that send messages in the network. We also have content topics, which determine the groups and what messages are sent.

There are three types of topics:
- `app_msg`: The owner of the topic where messages encrypted with the group key are sent, thanks to encryption, even if someone not from the group subscribes to the topic, they will not be able to read the correspondence itself.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand the concept of "owner of topic"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't phrase it correctly, thanks for seeing that, I'll correct it now


We have pub-sub topics that send messages in the network. We also have content topics, which determine the groups and what messages are sent.

There are three types of topics:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing you propose to use 3 content topics per group?

We usually recommend using a single content topic, and optimize later.

But you can still define 3 message types for clarity purposes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I user group-id as application name and 3 types of different content topics to filter messages. My idea was that it would reduce unnecessary processing from the user's point of view and he could ignore messages from irrelevant topics (like welcome after he joined the group), but we can of course discuss a more authentic implementation later on

I also already have different message type inside topics

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. The rule of thumb here is to have the number of content topics match the filter use cases. Afaics all users in a group would always be subscribed to receive both app and commit messages and only temporarily to welcome? If so, ideally we'll have two content topics - one "all group" content topic for app and commit messages and a second for the welcome messages.

Having three types of topics specified here is perfectly fine, though. The above is an implementation detail that can be fine tuned.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: in fact, it seems like multiple groups could perhaps share the same welcome content topic and then a single content topic for each group's app/commit messages. (Such implementation details may be out of scope for your post.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: in fact, it seems like multiple groups could perhaps share the same welcome content topic and then a single content topic for each group's app/commit messages. (Such implementation details may be out of scope for your post.)

I think it's only possible if there's only one admin for the groups

but yes, I think we can discuss this in detail later and how technically it will be organised in the end.

- `commit_msg`: All messages related to changes in the group state - adding users, deleting users, key rotation - are sent here. By design only administrators can send messages about the deletion and addition of users, key update is still under development. At this stage proposal and commit messages are not differentiated and all are considered commit messages
- `welcome`: A special topic for joining the group. With it, we solve the problem of how users can join a group without the server side. This topic is also used for providing the key packages by the users.

This architecture does not require a direct 1-to-1 channel with the admin for join requests. However, it does allow for the possibility that the admin can personally request a key package and manually add a member to the group.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of "1-to-1 channel" which makes assumptions, i'd say that "join requests dont need an out of band secure channel, and are handled within the de-MLS DS layer"


#### Communication between actors: WebSocket <-> Application <-> Waku

** Websocket actor **
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the transport matter? Isnt it just the "app actor"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean web socket part?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I find the "websocket" part confusing

… Waku protocol, and group communication topics
Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this interesting write-up! I've added some comments below.


We have pub-sub topics that send messages in the network. We also have content topics, which determine the groups and what messages are sent.

There are three types of topics:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. The rule of thumb here is to have the number of content topics match the filter use cases. Afaics all users in a group would always be subscribed to receive both app and commit messages and only temporarily to welcome? If so, ideally we'll have two content topics - one "all group" content topic for app and commit messages and a second for the welcome messages.

Having three types of topics specified here is perfectly fine, though. The above is an implementation detail that can be fine tuned.


- `Ethereum key` is used to authenticate the user via their private key, with the user's ID essentially functioning as their wallet address. Alternatively, this step can be replaced by any Web3 service that supports authorization. Therefore, all users in the group can be assured about the authenticity of the other users.
- `OpenMLS keys` is utilized for the reference implementation of de-MLS based on OpenMLS, which provides all necessary APIs to work with MLS such as creating and storing key packages. The ultimate goal is to leverage Ethereum accounts to manage all necessary keys for groups. However, since OpenMLS currently lacks support for Ethereum curve operations, these keys are temporarily linked through specification within the identity wallet rather than direct allocation.
- `Admin keys` is a constantly rotating key used in the welcome topic to securely receive key packages from users.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth describing how this key is distributed. Is the current admin public key simply broadcast periodically on the welcome topic?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, I'll add more details

in a nutshell, it's a public key and a signature under it, and every epoch I generate a new one.

1. **On-chain consensus mechanisms**: Outsourcing consensus to a smart contract solution for transparent and immutable agreement.
2. **Off-chain consensus mechanisms**: Utilizing off-chain consensus protocol to design efficient, decentralized protocols.

### Waku Integration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some sense de-MLS is a new "application" over Waku. That is, it defines new payloads that are encapsulated in Waku messages - for Welcome messages, commits, group messages, key packages, etc. It would be interesting to see a "wire protocol" at some point that explains how all of this is encoded into Waku payloads (or just a reference to a spec where the payloads are defined).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much, it really will be interesting to add

I little got lost while I was trying to figure out what to describe by code in general and missed this part

The architecture is built on an actor-based model, enabling a focus on the processing of messages rather than the specifics of how messages are transmitted between different entities.
We will give a brief overview of the architecture and the main actors. Let's start with the actors which are provide all network communication: the `waku actor` and the `websocket actor`.

#### Communication between actors: WebSocket <-> Application <-> Waku
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to admit that I'm a bit confused by this section and diagram :). It seems quite complex, but from a de-MLS perspective just describes an abstracted Waku actor responsible for subscribing/publishing to the necessary content topics and interfacing with the de-MLS application?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm increasingly feeling like this section doesn't make sense for blogpost :)

Maybe only what you suggested above about description of how payload is formed and different types of messages for different topics will be enough as integration details

And this one looks like documentation for code


We have pub-sub topics that send messages in the network. We also have content topics, which determine the groups and what messages are sent.

There are three types of topics:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: in fact, it seems like multiple groups could perhaps share the same welcome content topic and then a single content topic for each group's app/commit messages. (Such implementation details may be out of scope for your post.)

Co-authored-by: Hanno Cornelius <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants