Function binary_merkle_tree::merkle_proof

source ·
pub fn merkle_proof<H, I, T>(
    leaves: I,
    leaf_index: u32,
) -> MerkleProof<H::Out, T>
where H: Hasher, H::Out: Default + Copy + AsRef<[u8]>, I: IntoIterator<Item = T>, I::IntoIter: ExactSizeIterator, T: AsRef<[u8]>,
Expand description

Construct a Merkle Proof for leaves given by indices.

The function constructs a (partial) Merkle Tree first and stores all elements required to prove requested item (leaf) given the root hash.

Both the Proof and the Root Hash is returned.

§Panic

The function will panic if given leaf_index is greater than the number of leaves.