Module utils

Source

Functions§

check_condition
Check a condition and return a custom error if false.
descendant_range
Return the (start, count) range of descendant indices of node_index located at target_layer (leaves = 0, root = height) in a perfect binary Merkle tree indexed by layer left→right as in the prompt.
find_ancestor
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.
first_index_in_layer
Return the first global index at a given layer for a perfect binary Merkle tree of height. Layers are numbered with leaves at 0 and root at height.