Skip to content
Merged
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
11 changes: 6 additions & 5 deletions mls-rs/src/tree_kem/tree_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,23 @@ impl TreeKemPublic {
) -> Result<(), MlsError> {
let num_leaves = self.total_leaf_count();

let trailing_blanks = (0..num_leaves)
.rev()
.map_while(|l| {
let leaves = updated_leaves
.iter()
.copied()
.chain((0..num_leaves).rev().map_while(|l| {
self.tree_hashes
.current
.get(2 * l as usize)
.is_none()
.then_some(LeafIndex(l))
})
}))
.collect::<Vec<_>>();

// Update the current hashes for direct paths of all modified leaves.
tree_hash(
&mut self.tree_hashes.current,
&self.nodes,
Some([updated_leaves, &trailing_blanks].concat()),
Some(leaves),
&[],
num_leaves,
cipher_suite_provider,
Expand Down
Loading