INNER CODE UNIT · Rust
merkle_path_root
risc0/risc0-ethereum · crates/aggregation/src/lib.rs:424
pub fn merkle_path_root(
leaf_value: impl Borrow<Digest>,
path: impl IntoIterator<Item = impl Borrow<Digest>>,
) -> Digest {
let leaf = hash_leaf(leaf_value.borrow());
path.into_iter()
.fold(leaf, |a, b| commutative_keccak256(a.borrow(), b.borrow()))
}
/// Domain-separating tag value prepended to a digest before being hashed to form leaf node.
///
/// NOTE: It is explicitly not 32 bytes to avoid any chance of collision with a node value.
const LEAF_TAG: &[u8; 8] = b"LEAF_TAG";
/// Hash the given digest to form a leaf node.
///
/// This adds a tag to the given value and hashes it to ensure it is domain separated from any
/// internal nodes in the tree.