Skip to main content

Module hash

Module hash 

Source
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:

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§

Sha256Builder
Multi-update SHA-256 builder. Use when the hash semantics require multiple buffers (namespace prefixes, separators, multi-field derivation):

Functions§

sha256
Hash data once. 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>\n so reorderings on disk don’t change the digest. Used by deployment-cache reconciliation (matches moonproof deploy --resume’s manifest-hash check) + any caller that needs a stable identity for a keys/ / zkir/ directory.
sha256_file
Read path and return the raw 32-byte SHA-256 of its contents.
sha256_file_hex
Read path and return the lowercase hex SHA-256 of its contents.
sha256_hex
Hash data once. Returns lowercase hex of the digest.