Computes the N - 1 internal nodes of a balanced Merkle tree from its N leaves (root last);
N must be a power of 2 greater than 1.
Leaves are consumed as-is: this helper does not hash leaf preimages, it only hashes pairs upward.
The same hasher is applied at every layer (the leaf/base layer and all internal-node layers
alike), so there is NO domain separation between the leaf hashing and the internal-node hashing. An
internal node is therefore just hasher(left, right), indistinguishable in form from a leaf.
WARNING: because of this, callers MUST pass leaves that are already domain-separated from this
helper's internal-node hashes (i.e. produced by a hash whose domain differs from hasher), so that
an internal-node value can never be a valid leaf. (Per-tree domain separation of the node hashing
itself is likewise the caller's choice: pass the tree-specific hasher, e.g. nullifier_merkle_hash.)
Computes the
N - 1internal nodes of a balanced Merkle tree from itsNleaves (root last);Nmust be a power of 2 greater than 1.Leaves are consumed as-is: this helper does not hash leaf preimages, it only hashes pairs upward. The same
hasheris applied at every layer (the leaf/base layer and all internal-node layers alike), so there is NO domain separation between the leaf hashing and the internal-node hashing. An internal node is therefore justhasher(left, right), indistinguishable in form from a leaf.WARNING: because of this, callers MUST pass leaves that are already domain-separated from this helper's internal-node hashes (i.e. produced by a hash whose domain differs from
hasher), so that an internal-node value can never be a valid leaf. (Per-tree domain separation of the node hashing itself is likewise the caller's choice: pass the tree-specific hasher, e.g.nullifier_merkle_hash.)