code wiki / _hdl_build / nx_filehash.nx
nx_filehash.nx
buildroot/runtime/_hdl_build/nx_filehash.nx
about
nx_filehash.nx -- SHA-256 OF A FILE, AND THE ONE-CALL "ARE THESE TWO ARTIFACTS THE SAME BYTES" TEST.
★WHY THIS EXISTS, and it is a gap the ecosystem's own laws made expensive. This codebase carries a
standing rule -- VERIFY THE INSTRUMENT AND THE ARTIFACT -- and a banked correction where a session
claimed two meshes were "byte-identical", was wrong, and recorded the reason: "I inferred byte-identity
from a matching tri count and matching bench scores and NEVER HASHED THE FILES." The reason nobody
hashed the files is that there was no way to: nx_sha256 exists as a LIBRARY with a dozen gates and
wasm builds, and `sha256_digest(bytes,n,out)` has been sitting in it the whole time, but NO ORGAN
exposed it over a PATH. So every "byte-identical" claim in this program has been rhetorical.
★This is the adoption gap in its purest form: the primitive was built, gated and never wired to the
one caller shape that every other lane needs. It is 90 lines.
nx_filehash <path> -> {"sha256":"<64 hex>","bytes":N}
nx_filehash cmp <a> <b> -> {"identical":0|1, both digests, both sizes}
nx_filehash selftest -> KAT + non-vacuity teeth
license_tier: ORIGINAL expect_exit: 0 No hw writes (Rule 26).
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_itoa_lib.nxnx_sha256.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 22 | const FH_DIGEST_BYTES: i64 = 32 |
| 23 | const FH_LENSLOT: i64 = 16 |
| 100 | const FH_KAT: *u8 = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" as *u8 |
functions
| 25 | func fh_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 30 | func fh_pn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 31 | func fh_streq(a: *u8, b: *u8) -> i64 |
| 37 | func fh_hex(d: *u8) -> i64 |
| 54 | func fh_hash_file(path: *u8, out: *u8) -> i64 |
| 63 | func fh_one(path: *u8) -> i64 |
| 77 | func fh_cmp(pa: *u8, pb: *u8) -> i64 |
| 101 | func fh_hex_into(d: *u8, out: *u8) -> i64 called by 1: fh_selftest |
| 114 | func fh_selftest() -> i64 |
| 177 | func main(argc: i64, argv: *i64) -> i64 |