Skip to content

Commit 825c1c5

Browse files
committed
refactor: Expose authentication_structure_node_indices
Needed downstream, for compressing `RemovalRecord` lists.
1 parent f5fbed4 commit 825c1c5

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

twenty-first/src/util_types/merkle_tree.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,15 @@ impl MerkleTree {
203203
Ok(nodes)
204204
}
205205

206-
/// Given a list of leaf indices, return the indices of exactly those nodes that
207-
/// are needed to prove (or verify) that the indicated leafs are in the Merkle
208-
/// tree.
209-
// This function is not defined as a method (taking self as argument) since it's
210-
// needed by the verifier, who does not have access to the Merkle tree.
211-
fn authentication_structure_node_indices(
206+
/// Compute the node indices for an authentication structure.
207+
///
208+
/// Given a list of leaf indices, return the indices of exactly those nodes
209+
/// that are needed to prove (or verify) that the indicated leafs are in the
210+
/// Merkle tree.
211+
///
212+
/// Returns an error if any of the leaf indices is bigger than the number of
213+
/// leafs.
214+
pub fn authentication_structure_node_indices(
212215
num_leafs: MerkleTreeLeafIndex,
213216
leaf_indices: &[MerkleTreeLeafIndex],
214217
) -> Result<impl ExactSizeIterator<Item = MerkleTreeLeafIndex> + use<>> {

0 commit comments

Comments
 (0)