Function find_ancestor

Source
pub fn find_ancestor(
    target_layer: usize,
    node_index: usize,
    height: usize,
) -> usize
Expand description

Return the ancestor index of node_index at absolute target_layer for a perfect binary Merkle tree of height. Layers are numbered with leaves at 0 and root at height.

Example (height = 3):

  • find_ancestor(2, 3, 3) == 12
  • find_ancestor(2, 10, 3) == 13