Expand description
SHA-256 helpers — replace the
Sha256::new(); hasher.update(...); hex::encode(hasher.finalize())
pattern repeated across runtime / keystore / cli / codegen.
Two surface levels:
sha256/sha256_hex— single-shot single-buffer hashing.sha256_file/sha256_file_hex— single-shot file hashing.Sha256Builder— multi-update (namespace prefixes, separator bytes) for domain-specific hashes that need more than one buffer fed in.
Sites with truly domain-specific shapes (e.g. cli’s sha256_dir
that walks a directory and folds filename + bytes per entry) stay
in their crates — the builder lets them share the hash primitive
without forcing a one-size-fits-all directory hasher.
Structs§
- Sha256
Builder - Multi-update SHA-256 builder. Use when the hash semantics require multiple buffers (namespace prefixes, separators, multi-field derivation):
Functions§
- sha256
- Hash
dataonce. Returns the raw 32-byte digest. - sha256_
dir - Hash a directory’s flat file contents in name-sorted order.
Empty / missing dirs hash to the empty string. Each entry is
folded as
<filename>:<bytes>\nso reorderings on disk don’t change the digest. Used by deployment-cache reconciliation (matchesmoonproof deploy --resume’s manifest-hash check) + any caller that needs a stable identity for akeys//zkir/directory. - sha256_
file - Read
pathand return the raw 32-byte SHA-256 of its contents. - sha256_
file_ hex - Read
pathand return the lowercase hex SHA-256 of its contents. - sha256_
hex - Hash
dataonce. Returns lowercase hex of the digest.