Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openmls/src/credentials/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn that_unknown_credential_types_are_de_serialized_correctly() {
CredentialType::Unknown(got_proposal_type) => {
assert_eq!(credential_type, got_proposal_type);
}
other => panic!("Expected `CredentialType::Unknown`, got `{:?}`.", other),
other => panic!("Expected `CredentialType::Unknown`, got `{other:?}`."),
}

// Test serialization.
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ mod test {
assert_eq!(extension_type, got_extension_type);
assert_eq!(extension_data, &got_extension_data.0);
}
other => panic!("Expected `Extension::Unknown`, got {:?}", other),
other => panic!("Expected `Extension::Unknown`, got {other:?}"),
}

// Test serialization.
Expand Down
46 changes: 46 additions & 0 deletions openmls/src/group/mls_group/processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,52 @@ impl MlsGroup {
))
}

/// Like [Self::commit_to_pending_proposals] but with additional inline proposals.
#[allow(clippy::type_complexity)]
pub async fn commit_to_inline_proposals<KeyStore: OpenMlsKeyStore>(
&mut self,
backend: &impl OpenMlsCryptoProvider<KeyStoreProvider = KeyStore>,
signer: &impl Signer,
inline_proposals: Vec<Proposal>,
) -> Result<
(MlsMessageOut, Option<MlsMessageOut>, Option<GroupInfo>),
CommitToPendingProposalsError<KeyStore::Error>,
> {
self.is_operational()?;

let empty_proposal_store = Default::default();

// Create Commit over all inline proposals
// TODO #751
let params = CreateCommitParams::builder()
.framing_parameters(self.framing_parameters())
.proposal_store(&empty_proposal_store)
.inline_proposals(inline_proposals)
.build();
let create_commit_result = self.group.create_commit(params, backend, signer).await?;

// Convert PublicMessage messages to MLSMessage and encrypt them if required by
// the configuration
let mls_message = self.content_to_mls_message(create_commit_result.commit, backend)?;

// Set the current group state to [`MlsGroupState::PendingCommit`],
// storing the current [`StagedCommit`] from the commit results
self.group_state = MlsGroupState::PendingCommit(Box::new(PendingCommitState::Member(
create_commit_result.staged_commit,
)));

// Since the state of the group might be changed, arm the state flag
self.flag_state_change();

Ok((
mls_message,
create_commit_result
.welcome_option
.map(|w| MlsMessageOut::from_welcome(w, self.group.version())),
create_commit_result.group_info,
))
}

/// Merge a [StagedCommit] into the group after inspection. As this advances
/// the epoch of the group, it also clears any pending commits.
pub async fn merge_staged_commit<KeyStore: OpenMlsKeyStore>(
Expand Down
2 changes: 2 additions & 0 deletions openmls/src/group/public_group/diff/apply_proposals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ impl<'a> PublicGroupDiff<'a> {
invitation_list.push((leaf_index, add_proposal.clone()))
}

self.diff.trim_tree();

// Process PSK proposals
let presharedkeys: Vec<PreSharedKeyId> = proposal_queue
.filtered_by_type(ProposalType::PreSharedKey)
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/messages/proposals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ mod tests {
ProposalType::Unknown(got_proposal_type) => {
assert_eq!(proposal_type, got_proposal_type);
}
other => panic!("Expected `ProposalType::Unknown`, got `{:?}`.", other),
other => panic!("Expected `ProposalType::Unknown`, got `{other:?}`."),
}

// Test serialization.
Expand Down
3 changes: 1 addition & 2 deletions openmls/src/treesync/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl TreeSyncDiff<'_> {

/// Trims the tree by shrinking it until the last full leaf is in the
/// right part of the tree.
fn trim_tree(&mut self) {
pub(crate) fn trim_tree(&mut self) {
// Nothing to trim if there's only one leaf left.
if self.leaf_count() == MIN_TREE_SIZE {
return;
Expand Down Expand Up @@ -257,7 +257,6 @@ impl TreeSyncDiff<'_> {
// This also erases any cached tree hash in the direct path.
self.diff
.set_direct_path_to_node(leaf_index, &TreeSyncParentNode::blank());
self.trim_tree();
}

/// Derive a new direct path for the leaf with the given index.
Expand Down
Loading