Expand description
Tagged Merkle hashing for binary Merkle trees (HSH-007).
Normative: HSH-007 / hashing NORMATIVE
Crate spec: SPEC §3.3
Prefixes: crate::HASH_LEAF_PREFIX and crate::HASH_TREE_PREFIX (BLK-005).
§What this module is for
hash_leafandhash_nodeare the explicit SHA-256 formulas Chia uses for leaf and internal nodes inchia_sdk_types::MerkleTree(seemerkle_tree.rsin that crate:HASH_LEAF_PREFIX = &[1],HASH_TREE_PREFIX = &[2]— upstream source).- DIG block code builds those trees via the crate-internal
merkle_util::merkle_tree_roothelper and directchia_sdk_types::MerkleTree::newcalls; do not hand-roll a parallel Merkle implementation with different tags.
§What this is not
chia_consensus::merkle_set::compute_merkle_set_root(additions/removals roots) uses Chia’s radix / sorted-set tree and a different internalhash(ltype, rtype, left, right)— not0x01||data/0x02||a||b. That path is correct for HSH-004/HSH-005 but is out of scope for the formulas in this file (see the crate-internalmerkle_utilmodule for Merkle-set callers).
§Rationale
Exposing hash_leaf / hash_node makes the domain separation testable and gives downstream crates a
single place to name the tagging scheme, while the actual tree shape remains delegated to chia-sdk-types.
Functions§
- hash_
leaf - Leaf digest: SHA-256(
HASH_LEAF_PREFIX‖data) (SPEC §3.3). - hash_
node - Internal node digest: SHA-256(
HASH_TREE_PREFIX‖left‖right) (SPEC §3.3).