Function sway_libs::merkle::sparse::leaf_digest
pub fn leaf_digest(key: b256, leaf_hash: b256) -> b256
Expand description
Returns the computed leaf hash of “MTH(D[n]) = SHA-256(0x00 || MTH(D[0:k]) || MTH(D[k:n]))”.
Arguments
key
: [b256] - The key of the leaf in the Sparse Merkle Tree.leaf_hash
: [b256] - The sha256 hash that makes up the leaf.
Returns
- [b256] - The computed leaf hash.
Examples
use sway_libs::merkle::sparse::leaf_digest;
use std::bytes::Bytes;
fn foo() {
let data = b256::new();
let key = b256::zero();
let digest = leaf_digest(key, data);
assert(digest == 0x54f05a87f5b881780cdc40e3fddfebf72e3ba7e5f65405ab121c7f22d9849ab4);
}