Skip to main content

Module hash

Module hash 

Source
Expand description

crate::hash — the pluggable σ-axis hash family (wiki ADR-007 / ADR-010: the substrate ships no hasher; the application selects one).

UOR-ADDR’s κ-label is <algorithm>:<lowercase-hex-digest>. The algorithm is the realization’s selected σ-axis H; ψ₉ folds the canonical carrier through H and formats the label (crate::resolvers). AddrHash is the fingerprint-width-erased façade over a concrete prism Hasher: it carries the wire prefix ("sha256", "blake3", …), the digest width, and a digest_carrier method that folds the (streamed) carrier through the axis and returns the digest in a fixed MAX_DIGEST_BYTES buffer.

Erasing the Hasher<FP_MAX> const-generic into the AddrHash method is what lets the single AddressResolverTuple carry both the 32-byte axes and the 64-byte Sha512Hasher without a free FP_MAX parameter (which would be unconstrained — E0207 — in the tuple’s Has*Resolver impls). The model still binds the concrete Hasher<FP_MAX> as its σ-axis, so the foundation pipeline computes the full-width content fingerprint.

§Admissible axes

foundation 0.5.2 generalized the resolver tower over FP_MAX, so every prism hasher is admissible:

axisLABEL_PREFIXOUTPUT_BYTESLABEL_BYTESauthority
Sha256Hashersha2563271FIPS 180-4 §6.2
Blake3Hasherblake33271BLAKE3 §2 (the reference spec)
Sha3_256Hashersha3-2563273FIPS 202 §6.1
Keccak256Hasherkeccak2563274Keccak SHA-3 submission (pre-FIPS padding)
Sha512Hashersha51264135FIPS 180-4 §6.4

Constants§

MAX_DIGEST_BYTES
The widest admissible digest (Sha512Hasher = 64 bytes). Every AddrHash::digest_carrier returns a buffer of this width; the first OUTPUT_BYTES are significant.
MAX_LABEL_BYTES
The widest admissible κ-label (sha512: + 128 hex = 135). The κ-label formatter (crate::resolvers) sizes its stack scratch to this and writes the active axis’s LABEL_BYTES prefix.

Traits§

AddrHash
A prism hasher usable as a UOR-ADDR σ-axis. Fingerprint-width-erased: the κ-label prefix + digest width are associated consts, and digest_carrier folds the carrier through the concrete Hasher<FP_MAX> internally.

Functions§

label_bytes
The κ-label ASCII byte width for a <prefix>:<hex> label over a digest_bytes-wide digest: prefix.len() + 1 (':') + 2 × digest_bytes.