pub fn compute_merkle_root(mut leaves: Vec<[u8; 32]>) -> [u8; 32] {
    if leaves.is_empty() {
        return [0u8; 32];
    }


    while leaves.len() > 1 {
        let mut next = Vec::new();
        for i in (0..leaves.len()).step_by(2) {
            let left = &leaves[i];
            let right = if i + 1 < leaves.len() { &leaves[i + 1] } else { &leaves[i] };
            next.push(hash_pair(left, right));
        }
        leaves = next;
    }
    leaves[0]
}
Computes the root of a merkle tree given the leaves.

The leaves are hashed using `compute_leaf_hash` and then the hashes are combined to form the root.
The root is computed by hashing pairs of hashes until only one hash remains.
examples/aggregation/program/src/main.rs