Skip to main content

openmls/group/mls_group/
reinit.rs

1//! Reinitialization (RFC 9420 ยง11.2).
2//!
3//! Reinitializing a group needs a small, fixed set of values
4//! from the old group's final epoch after committing the ReInit proposal.
5//! The old group exports these values into a [`ReInitInfo`] via
6//! [`MlsGroup::reinit_info`](crate::group::MlsGroup::reinit_info), and hands the
7//! owned struct to the receiver
8//! ([`StagedWelcome::build_from_reinit`](crate::group::StagedWelcome::build_from_reinit)),
9//! so the old group is no longer required to join the new group.
10
11use crate::{
12    credentials::Credential,
13    group::{GroupEpoch, GroupId},
14    messages::proposals::ReInitProposal,
15    schedule::ResumptionPskSecret,
16};
17use serde::{Deserialize, Serialize};
18
19/// The information a reinit needs from its old group.
20///
21/// Export this from the inactive old group with
22/// [`MlsGroup::reinit_info`](crate::group::MlsGroup::reinit_info) and pass it to
23/// the receiver API
24/// [`StagedWelcome::build_from_reinit`](crate::group::StagedWelcome::build_from_reinit)
25/// (or [`PendingResumingWelcome::build_from_reinit`](crate::group::PendingResumingWelcome::build_from_reinit)).
26///
27/// This is an owned snapshot, so it does not borrow the old group and can
28/// outlive it.
29///
30/// This carries the resumption PSK secret, which is sensitive key
31/// material and must be handled accordingly.
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct ReInitInfo {
34    pub(crate) proposal: ReInitProposal,
35    pub(crate) old_group_id: GroupId,
36    pub(crate) old_group_epoch: GroupEpoch,
37    pub(crate) resumption_psk_secret: ResumptionPskSecret,
38    pub(crate) member_credentials: Vec<Credential>,
39}
40
41impl ReInitInfo {
42    /// The committed reinit proposal.
43    pub fn proposal(&self) -> &ReInitProposal {
44        &self.proposal
45    }
46
47    /// The group_id of the old group.
48    pub fn old_group_id(&self) -> &GroupId {
49        &self.old_group_id
50    }
51
52    /// The final epoch of the old group.
53    pub fn old_group_epoch(&self) -> GroupEpoch {
54        self.old_group_epoch
55    }
56
57    /// The old group's resumption PSK secret for [`Self::old_group_epoch`].
58    ///
59    /// This is sensitive key material.
60    pub(crate) fn resumption_psk_secret(&self) -> &ResumptionPskSecret {
61        &self.resumption_psk_secret
62    }
63
64    /// The credentials of the old group's members, used by the receiver to
65    /// check that the new group has the same members.
66    pub fn member_credentials(&self) -> &[Credential] {
67        &self.member_credentials
68    }
69}