Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Reinitializing a group

Reinitialization (ReInit) replaces a group with a new successor group that carries over the same members but may use different parameters — a new group id, protocol version, ciphersuite, or group context extensions. This is the mechanism to use when, for example, a group needs to migrate to a stronger ciphersuite. See RFC 9420 §11.2.

Reinitialization happens in two phases:

  1. A member proposes a ReInit and someone commits it. A commit that references a ReInit proposal must contain no other proposals. Once the commit is merged, the old group is suspended: it becomes inactive and can no longer be used for regular operations. Its only remaining purpose is to seed the successor group exactly once.
  2. One member creates the successor group with the parameters from the ReInit proposal, adds all the other members, and mixes in a resumption PSK from the old group’s final epoch. The other members join the successor group from the resulting Welcome.

Committing a ReInit

A commit containing a ReInit proposal cannot contain other proposals, and merging it suspends the old group. After this, MlsGroup::is_active returns false and further operations on the old group fail — the only remaining use of the old group is to seed the successor.

Since the ReInit proposal must be committed alone, it is advisable to commit it directly by value:

    // Alice commits a ReInit proposal by value to reinitialize the group as
    // a new group with a fresh group id (and, optionally, a new protocol version,
    // ciphersuite or extensions).
    let new_group_id = GroupId::random(alice_provider.rand());
    let reinit_proposal = ReInitProposal::new(
        new_group_id.clone(),
        ProtocolVersion::Mls10,
        ciphersuite,
        Extensions::empty(),
    );

    // Alice commits the ReInit proposal. Merging it suspends the old group: it
    // becomes inactive and can only be used to seed the successor group.
    let bundle = alice_group
        .commit_builder()
        .add_proposal(Proposal::ReInit(Box::new(reinit_proposal.clone())))
        .load_psks(alice_provider.storage())
        .unwrap()
        .build(
            alice_provider.rand(),
            alice_provider.crypto(),
            &alice_signer,
            |_| true,
        )
        .unwrap()
        .stage_commit(alice_provider)
        .unwrap();
    let commit_message = bundle.into_commit();
    alice_group.merge_pending_commit(alice_provider).unwrap();
    assert!(!alice_group.is_active());

    // Alice exports the ReInitInfo. It holds everything needed for the reinit, alice_group can be discarded.
    let alice_reinit_info = alice_group.reinit_info(reinit_proposal.clone()).unwrap();
    drop(alice_group);

Alternatively to commit-by-value, the ReInit can be proposed and committed separately:

    // Alice proposes to reinitialize the group as a new group with a fresh
    // group id (and, optionally, a new protocol version, ciphersuite or
    // extensions).
    let new_group_id = GroupId::random(alice_provider.rand());
    let reinit_proposal = ReInitProposal::new(
        new_group_id.clone(),
        ProtocolVersion::Mls10,
        ciphersuite,
        Extensions::empty(),
    );
    let (proposal_message, _proposal_ref) = alice_group
        .propose_reinit(alice_provider, reinit_proposal.clone(), &alice_signer)
        .unwrap();

Commit the proposal:

    // Alice commits the ReInit proposal. Merging it suspends the old group: it
    // becomes inactive and can only be used to seed the successor group.
    let bundle = alice_group
        .commit_builder()
        .consume_proposal_store(true)
        .load_psks(alice_provider.storage())
        .unwrap()
        .build(
            alice_provider.rand(),
            alice_provider.crypto(),
            &alice_signer,
            |_| true,
        )
        .unwrap()
        .stage_commit(alice_provider)
        .unwrap();
    let commit_message = bundle.into_commit();
    alice_group.merge_pending_commit(alice_provider).unwrap();
    assert!(!alice_group.is_active());

    let alice_reinit_info = alice_group.reinit_info(reinit_proposal.clone()).unwrap();
    drop(alice_group);

When committing from the proposal queue, the application itself must make sure that the ReInit proposal is the only one in the commit. If it accepts other proposals, building the commit will throw an error. RFC 9420 §12.2 states that other proposals SHOULD be preferred over ReInit. Applications that follow this advice must reject the ReInit proposal in f of CommitBuilder::build if there are other proposals.

Every other member processes and merges the commit, which suspends their view of the group as well:


    // Bob processes and merges the ReInit commit, suspending his group too.
    let processed = bob_group
        .process_message(
            bob_provider,
            commit_message.into_protocol_message().unwrap(),
        )
        .unwrap();

    let ProcessedMessageContent::StagedCommitMessage(staged) = processed.into_content() else {
        panic!("expected a staged commit message")
    };
    // Bob extracts the reinit proposal
    let bob_reinit_proposal = staged
        .reinit_proposal()
        .expect("staged commit contains no reinit proposal")
        .clone();

    bob_group
        .merge_staged_commit(bob_provider, *staged)
        .unwrap();
    assert!(!bob_group.is_active());

    // Bob extracts ReInitInfo. It holds everything needed for the reinit, bob_group can be discarded.
    let bob_reinit_info = bob_group.reinit_info(bob_reinit_proposal).unwrap();
    drop(bob_group);

Creating the successor group

All members export a ReInitInfo from their suspended old group with MlsGroup::reinit_info, passing the ReInit proposal the suspending commit covered. reinit_info returns None if the group is still active. The ReInitInfo contains all details needed to complete the reinit, so the old group can be discarded. The info carries the old group’s resumption PSK secret and must be handled as sensitive key material.

The committer or any other member uses MlsGroupBuilder::reinit to seed the new group. The application is responsible for seeding only a single successor from a suspended group:

    // Alice creates the successor group with the ReInit parameters and welcomes
    // Bob, mixing in the old group's resumption PSK via `reinit`.
    // This also sets protocol version, ciphersuite, group_id, and group_context.extensions
    // to the values of the ReInit proposal.
    let bob_new_key_package = generate_key_package(
        ciphersuite,
        bob_credential_with_key,
        Extensions::empty(),
        bob_provider,
        &bob_signer,
    );

    let (mut alice_successor, bundle) = MlsGroup::builder()
        .use_ratchet_tree_extension(true)
        .number_of_resumption_psks(5)
        .reinit(alice_reinit_info)
        .build_reinit(
            alice_provider,
            &alice_signer,
            alice_credential_with_key,
            [bob_new_key_package.key_package().clone()],
        )
        .unwrap();

    let successor_welcome = bundle.into_welcome().unwrap();
    alice_successor
        .merge_pending_commit(alice_provider)
        .unwrap();

Joining the successor group

The other members then join the successor group from the Welcome with StagedWelcome::build_from_reinit. This injects the old group’s resumption PSK and verifies that the reinit PSK in the Welcome references the old group and its final epoch; otherwise it fails with WelcomeError::ReInitPredecessorMismatch. The remaining checks run when build is called on the returned JoinBuilder: the successor’s protocol version, ciphersuite, group id and extensions must match the ReInit proposal, and the successor must be at epoch 1.

New group’s members must be identical to the old group’s. A simple membership check by equal credential is on by default and can be disabled with JoinBuilder::check_members(false). In that case, the application must ensure that the new member credentials in StagedWelcome::members() match the old ones captured in ReInitInfo::member_credentials(). Use this path when the application uses credentials that don’t allow checking equivalence of members by checking exact equality of credentials.

    // Bob joins the successor group from the reinit welcome, validating it
    // against his suspended old group.
    let join_config = MlsGroupJoinConfig::builder()
        .use_ratchet_tree_extension(true)
        .number_of_resumption_psks(5)
        .build();
    let bob_staged_welcome = StagedWelcome::build_from_reinit(
        bob_provider,
        &join_config,
        successor_welcome,
        bob_reinit_info,
    )
    .unwrap()
    .with_ratchet_tree(alice_successor.export_ratchet_tree().into())
    // .check_members(false) // optional; the membership check is on by default
    .build()
    .unwrap();
    // when setting .check_members(false): check that `bob_staged_welcome.members()`
    // represents the same members as `bob_reinit_info.member_credentials()`.
    let bob_successor = bob_staged_welcome.into_group(bob_provider).unwrap();

If the receiver does not yet know which old group a Welcome belongs to or whether it is a reinit at all, it can decrypt the Welcome once with StagedWelcome::process_resuming_welcome, read the reinit PSK’s old group id and epoch with required_resumption_secret(), select the matching ReInitInfo, and finish with PendingResumingWelcome::build_from_reinit. If it turns out not to be a reinit welcome, continue with PendingResumingWelcome::build.

    // Bob joins the successor group from the reinit welcome, validating it
    // against his suspended old group.
    let join_config = MlsGroupJoinConfig::builder()
        .use_ratchet_tree_extension(true)
        .number_of_resumption_psks(5)
        .build();

    let pending_welcome =
        StagedWelcome::process_resuming_welcome(bob_provider, &join_config, successor_welcome)
            .unwrap();

    // Bob finds the matching predecessor info, e.g. in a database
    let required_info = pending_welcome
        .required_resumption_secret()
        .expect("not a reinit welcome");
    assert_eq!(required_info.psk_group_id(), bob_reinit_info.old_group_id());
    assert_eq!(required_info.psk_epoch(), bob_reinit_info.old_group_epoch());
    assert_eq!(required_info.usage(), ResumptionPskUsage::Reinit);

    // Bob finishes the Welcome
    let bob_successor = pending_welcome
        .build_from_reinit(bob_provider, bob_reinit_info)
        .unwrap()
        .with_ratchet_tree(alice_successor.export_ratchet_tree().into())
        .build()
        .unwrap()
        .into_group(bob_provider)
        .unwrap();