Skip to main content

Module hash

Module hash 

Source
Expand description

Substrate primitive for BLAKE3 hex digests.

Two peer entries — hex_blake3 for the in-memory-buffer shape (hex::encode(blake3::hash(bytes).as_bytes())) every three-pillar attestation producer that fed BLAKE3 a single buffer restated by hand pre-lift, and hex_blake3_hash for the streaming-digest shape (hex::encode(hash.as_bytes()) where hash = blake3::Hasher::finalize()) every consumer that folded per-item updates into a Hasher before finalizing walked. Both peers ride through ONE hex-encoding step at hex_blake3_hash so a future swap onto blake3::Hash::to_hex().to_string() (or a different encoding — base32, base64url, uppercase hex for a downstream tool) lands at ONE substrate function and every downstream three-pillar consumer inherits the upgrade mechanically.

Return type is String for wire-shape stability with the pre-lift consumers — ReceiptEnvelope.{intent,artifact,control}_hash are typed as String, so a Cow/&str return would force allocation at every call site regardless.

§Which peer to call

  • Have &[u8] in hand → hex_blake3. Internally it composes hex_blake3_hash over blake3::hash(bytes).
  • Have a blake3::Hasher you already folded per-item updates into → hex_blake3_hash(&h.finalize()). Skips the one-shot round-trip through &[u8] that would force the caller to materialize the full input buffer just to re-hash it.

Functions§

hex_blake3
Compute the lowercase 64-char BLAKE3 hex digest of bytes.
hex_blake3_hash
Streaming-digest peer of hex_blake3 — the ONE substrate owner of the 1-link hex::encode(hash.as_bytes()) encoding step every three-pillar producer that folded per-item updates into a blake3::Hasher walked pre-lift.