There are two ways to join an existing MLS group in OpenMLS: receiving a Welcome message from an existing member, or creating an external commit to join the group from the outside.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/openmls/openmls/llms.txt
Use this file to discover all available pages before exploring further.
Joining from a Welcome message
When you’re added to a group, you’ll receive aWelcome message. This is a two-step process that allows you to inspect the welcome before fully joining.
use openmls::prelude::*;
let mls_message_in = MlsMessageIn::tls_deserialize(&mut serialized_message.as_slice())?;
let welcome = match mls_message_in.extract() {
MlsMessageBodyIn::Welcome(welcome) => welcome,
_ => return Err("Expected a Welcome message"),
};
let processed_welcome = ProcessedWelcome::new_from_welcome(
provider,
&mls_group_join_config,
welcome,
)?;
let staged_welcome = processed_welcome.into_staged_welcome(
provider,
ratchet_tree, // Option<RatchetTreeIn>
)?;
If the group uses the ratchet tree extension, you can pass
None for the ratchet tree parameter. Otherwise, you must provide the ratchet tree from the member who added you.Examining a Welcome message
Before joining, you can inspect the Welcome message to decide whether to accept the invitation:Discarding an unwanted Welcome
If you decide not to join, you should properly clean up the welcome to ensure local state is deleted.Using the join builder
For more control over the join process, use the builder pattern:Joining via external commit
External commits allow you to join a group without being added by an existing member. You’ll need the group’sGroupInfo and ratchet tree.
The
GroupInfo should be obtained over a secure channel from an existing group member or the delivery service.use openmls::prelude::*;
let (mls_group, commit_message, group_info) = MlsGroup::external_commit_builder(
provider.crypto(),
&provider,
signer,
verifiable_group_info,
credential_with_key,
)
.with_ratchet_tree(ratchet_tree)
.with_aad(b"external commit")
.leaf_node_parameters(
LeafNodeParameters::builder()
.with_capabilities(capabilities)
.build()
)
.load_psks(provider.storage())?
.build(provider.rand(), provider.crypto(), signer, |_| true)?
.finalize(provider)?;
When joining via external commit, the resulting
MlsGroup instance starts with a pending commit. You must merge this commit for the group to function properly. If the external commit is rejected, you’ll need to create a new external commit based on the latest group state.Important considerations
Related types
ProcessedWelcome::new_from_welcome()- Processes a Welcome messageStagedWelcome::into_group()- Converts a staged welcome into an MlsGroupMlsGroup::external_commit_builder()- Creates an external commit to join a groupMlsGroupJoinConfig- Configuration for joining groups
Next steps
Processing messages
Learn how to handle incoming messages
Sending messages
Start sending messages to the group