INNER CODE UNIT · Rust
hash_leaf
risc0/risc0-ethereum · crates/aggregation/src/lib.rs:442
fn hash_leaf(value: &Digest) -> Digest {
let mut hasher = Keccak256::new();
hasher.update(LEAF_TAG);
hasher.update(value.as_bytes());
hasher.finalize().0.into()
}
/// Computes the hash of a sorted pair of [Digest].
fn commutative_keccak256(a: &Digest, b: &Digest) -> Digest {
let mut hasher = Keccak256::new();
if a.as_bytes() < b.as_bytes() {
hasher.update(a.as_bytes());
hasher.update(b.as_bytes());
} else {
hasher.update(b.as_bytes());
hasher.update(a.as_bytes());
}
hasher.finalize().0.into()