From 7ed6765d365418a2aa61908ee2c128ffde010443 Mon Sep 17 00:00:00 2001 From: cameronvoell Date: Wed, 10 Apr 2024 11:02:46 -0700 Subject: [PATCH] added function comments and updated formatting --- openmls/src/group/core_group/mod.rs | 2 +- openmls/src/group/mls_group/proposal.rs | 26 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/openmls/src/group/core_group/mod.rs b/openmls/src/group/core_group/mod.rs index 992b5aa775..ed9eaefb80 100644 --- a/openmls/src/group/core_group/mod.rs +++ b/openmls/src/group/core_group/mod.rs @@ -1044,6 +1044,7 @@ impl CoreGroup { }) } + /// Create a new group context extension proposal pub(crate) fn create_group_context_ext_proposal( &self, framing_parameters: FramingParameters, @@ -1083,7 +1084,6 @@ impl CoreGroup { // Test functions #[cfg(test)] impl CoreGroup { - pub(crate) fn use_ratchet_tree_extension(&self) -> bool { self.use_ratchet_tree_extension } diff --git a/openmls/src/group/mls_group/proposal.rs b/openmls/src/group/mls_group/proposal.rs index d3bd05c3e1..f636288601 100644 --- a/openmls/src/group/mls_group/proposal.rs +++ b/openmls/src/group/mls_group/proposal.rs @@ -4,7 +4,10 @@ use openmls_traits::{ }; use super::{ - core_group, errors::{ProposalError, ProposeAddMemberError, ProposeRemoveMemberError}, CreateGroupContextExtProposalError, GroupContextExtensionProposal, GroupContextExtensionsProposalValidationError, MlsGroup, MlsGroupState, PendingCommitState, Proposal + core_group, + errors::{ProposalError, ProposeAddMemberError, ProposeRemoveMemberError}, + CreateGroupContextExtProposalError, GroupContextExtensionProposal, MlsGroup, MlsGroupState, + PendingCommitState, Proposal, }; use crate::{ binary_tree::LeafNodeIndex, @@ -319,6 +322,10 @@ impl MlsGroup { } } + /// Creates a proposals with a new set of `extensions` for the group context. + /// + /// Returns an error when the group does not support all the required capabilities + /// in the new `extensions`. pub fn propose_group_context_extensions( &mut self, provider: &impl OpenMlsProvider, @@ -355,15 +362,16 @@ impl MlsGroup { provider: &impl OpenMlsProvider, extensions: Extensions, signer: &impl Signer, - ) -> Result<(MlsMessageOut, Option, Option), CreateGroupContextExtProposalError> - { + ) -> Result< + (MlsMessageOut, Option, Option), + CreateGroupContextExtProposalError, + > { self.is_operational()?; - // Create inline add proposals from key packages - let mut inline_proposals = vec![]; - inline_proposals.push(Proposal::GroupContextExtensions(GroupContextExtensionProposal { - extensions, - })); + // Create group context extension proposals + let inline_proposals = vec![Proposal::GroupContextExtensions( + GroupContextExtensionProposal { extensions }, + )]; let params = CreateCommitParams::builder() .framing_parameters(self.framing_parameters()) @@ -371,7 +379,7 @@ impl MlsGroup { .inline_proposals(inline_proposals) .build(); let create_commit_result = self.group.create_commit(params, provider, signer).unwrap(); - + let mls_messages = self.content_to_mls_message(create_commit_result.commit, provider)?; self.group_state = MlsGroupState::PendingCommit(Box::new(PendingCommitState::Member( create_commit_result.staged_commit,