sha256d's CPU reference: FIPS 180-4 SHA-256, double SHA-256 of an 80-byte header, Bitcoin's little-endian targets
$ sexc add @ajax/mesh-ref-sha256d- total 3
- drwxr-xr-x-../
- drwxr-xr-x-Oct 27 01:59v/# 1 version
- drwxr-xr-x-Oct 27 01:59files/# the files of 0.1.0
- latest
- 0.1.0, published Oct 27 01:59 by ajax
- owners
- ajax
- license
- MIT
- dependencies
- none
- dependents
- @ajax/mesh-assemble, @ajax/mesh-blobd, @ajax/mesh-blobs-store, @ajax/mesh-jobd, @ajax/mesh-prog-hashjob-wasm, @ajax/mesh-prog-pipesink, @ajax/mesh-prog-pipesink-w-wasm, @ajax/mesh-prog-sha-verify-wasm, @ajax/mesh-prog-sha256d
- keywords
- alphaos mesh reference sha256 bitcoin
- homepage
- https://github.com/thomasdavis/alpha-c-mesh/tree/main/packages/mesh-ref-sha256d
- repository
- https://github.com/thomasdavis/alpha-c-mesh
1# @ajax/mesh-ref-sha256d 2 3programs/sha256d's CPU reference: SHA-256 written plainly from FIPS 180-4, double SHA-256, an 80-byte 4block header hashed at a nonce and time, and Bitcoin's little-endian 256-bit targets (`zbits`, 5`zbits_target`, `le_lt`, the reversed-hex display). The checkers compare the GPU miner against these. 6 7**Ported from** `crates/mesh-ref/src/sha.rs`. Freestanding (no libc). 8 9**Tested** with the FIPS 180-4 vectors (empty, "abc", the 448-bit message, 1000 × "a") and golden outputs 10from the Rust for `sha256d`, `hash_at`, `display`, `zbits`, the targets at 0..256 bits and `le_lt`. 11 12## Differences 13 14- Rust returns `[u8; 32]` and `String`; here the caller passes the output buffers. 15- `zbits_target` clamps z above 256 to 256 (the Rust would index out of bounds).