From a3b9c196f6afa5a4468235174117111fd5f4d1f7 Mon Sep 17 00:00:00 2001 From: Richard Hua Date: Thu, 9 Nov 2023 15:28:33 -0800 Subject: [PATCH] Expose full member --- openmls/src/group/mls_group/membership.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/openmls/src/group/mls_group/membership.rs b/openmls/src/group/mls_group/membership.rs index 334c9893d4..1a3fab38c7 100644 --- a/openmls/src/group/mls_group/membership.rs +++ b/openmls/src/group/mls_group/membership.rs @@ -205,6 +205,23 @@ impl MlsGroup { .leaf(leaf_index) .map(|leaf| leaf.credential()) } + + /// Returns the [`Member`] corresponding to the given + /// leaf index. Returns `None` if the member can not be found in this group. + pub fn member_at(&self, leaf_index: LeafNodeIndex) -> Option { + self.group + .public_group() + // This will return an error if the member can't be found. + .leaf(leaf_index) + .map(|leaf_node| { + Member::new( + leaf_index, + leaf_node.encryption_key().as_slice().to_vec(), + leaf_node.signature_key().as_slice().to_vec(), + leaf_node.credential().clone(), + ) + }) + } } /// Helper `enum` that classifies the kind of remove operation. This can be used to