Skip to main content

root_from_path

Function root_from_path 

Source
pub fn root_from_path(
    index: u32,
    total: u32,
    leaf: &[u8],
    path: &[Vec<u8>],
) -> Result<[u8; 32], BlockProofError>
Expand description

Follow path up from the leaf at index of a tree of total leaves, returning the root it leads to. path runs from the leaf’s sibling up to a child of the root.

The position decides the order each pair is hashed in, so a path leads to the tree’s root only from the position it was built for. total is the caller’s claim: a path can also fit a tree of another size, at another position.