Skip to main content

Module hash

Module hash 

Source
Expand description

SHA-256 content hashing — the one hash algorithm Capsule uses everywhere (content addressing, integrity verification, provenance chaining).

SSoT: Cryptography — Primitives § Cryptographic Hash. The same SHA-256 value is reused across layers rather than recomputed — the content-addressing hash is the value the signed manifest commits to and the upload protocol declares and verifies.

Hashing is streaming (incremental over chunks): the ciphertext hash of a large asset is computed as the STREAM chunks are produced, never by buffering the whole file. Sha256Hasher is the incremental interface; hash_bytes / hash_reader are the one-shot conveniences built on top of it.

Structs§

FromHexError
The provided string was not a valid 32-byte hex digest.
Hash32
A 32-byte SHA-256 digest.
Sha256Hasher
Incremental SHA-256 hasher: feed bytes with update, then finalize. Used to hash STREAM ciphertext as chunks are produced.

Constants§

SHA256_LEN
Length of a SHA-256 digest in bytes. Pinned by the crypto_suite_id inventory.

Functions§

hash_bytes
One-shot SHA-256 of a byte slice.
hash_reader
Stream a reader to completion, hashing in 64 KiB blocks without buffering the whole input.