pub fn rebuild_merkle_root(
leaf: B256,
generalized_index: usize,
branch: &[B256],
) -> B256
Expand description
Rebuilds a Merkle tree root from a leaf value and its branch proof.
Given a leaf value, its generalized index in the tree, and the sibling hashes along the path to the root, this function reconstructs the Merkle root by iteratively hashing the current node with its sibling at each level.
§Arguments
leaf
- The leaf value to start reconstruction fromgeneralized_index
- The generalized index of the leaf in the Merkle treebranch
- Slice of sibling hashes along the path from leaf to root
§Returns
The reconstructed Merkle root hash