pub fn merkleize<D: Digest<OutputSize = U32>>(
chunks: &[[u8; 32]],
limit: usize,
) -> [u8; 32]Expand description
SSZ merkleize — pad chunks to max(limit, chunks.len()) rounded up
to the next power of two, build a balanced binary tree using
hash(left || right), and return the root.
limit is the type-level chunk cap (e.g. ceil(N * size_of_T / 32) for
List<T, N>). When chunks.len() > limit, the limit is bumped up to
chunks.len() (callers should validate the type-level cap separately).
Empty input with limit == 0 returns a zero hash (the root of a single
zero chunk).
Complexity: O(chunks.len() + depth) hash operations, independent of
limit. This is achieved by only materialising the “real” prefix at
each level; the implicit zero-padded suffix folds into zero_hash(d)
without iteration.