Expand description
Hand-rolled SHA-256.
Why hand-rolled: the dsfb-gpu-debug-core crate is no_std and
dependency-free by policy. The case file’s hash chain is the load-bearing
audit artifact; if it depended on an external SHA-256 crate, the chain
would inherit that crate’s compatibility and supply-chain surface. A
~150-line in-tree implementation eliminates both.
Correctness is validated against the published FIPS 180-4 test vectors plus a small handful of additional edge cases (empty input, one block, exactly 56 bytes, exactly 64 bytes, and a multi-block input).
API shape: a streaming Sha256 builder for incremental hashing of
pipeline buffers, and a sha256(bytes) one-shot wrapper for the cases
where the input is already in memory. Both produce a [u8; 32] digest.
Structs§
- Sha256
- Streaming SHA-256 state.
Constants§
- DIGEST_
BYTES - Length in bytes of a SHA-256 digest.
Functions§
- format_
digest - Format a 32-byte digest as a lowercase hex string with the
sha256:prefix the contract format expects. Used by the case-file serializer. - sha256
- One-shot SHA-256 of an in-memory byte slice. Useful when the caller has already assembled the canonical byte representation of a stage’s output.