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.
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.