code wiki / (root) / nx_sha512_wasm.nx

nx_sha512_wasm.nx

buildroot/runtime/nx_sha512_wasm.nx

12278 B285 linesdepth 0pulls 0 transitivereach 0 importersview sourcekind orphan librarytopic sha512
docsdependenciesstructsconstsfunctions

about

nx_sha512_wasm.nx -- SHA-512 (FIPS 180-4) self-contained for WAT target. Same algorithmic shape as SHA-256 but 64-bit words, 80 rounds, different K + initial H + σ/Σ rotate amounts. NishiLang's i64 natively fits each word so no 32-bit masking dance. API for the embedder: nx_sha512_one_shot(in_ptr, in_len, ctx_ptr, out_ptr) -> i64 in_ptr -- input bytes in_len -- byte count ctx_ptr -- caller-allocated >=1024-byte scratch (we use ~720) out_ptr -- 64-byte digest destination Memory layout of ctx_ptr (caller need not zero): bytes 0.. 127 : 128-byte partial block buffer (block size = 1024 bits) bytes 128.. 191 : 64 bytes of H state (h0..h7 as 8x i64 LE) bytes 192.. 199 : total bit length (i64) -- low 64 only; SHA-512 spec uses 128-bit length, but practical inputs fit in 64 bits (16 EiB). We zero-pad the high 64. bytes 200.. 919 : W[0..79] message schedule (80 i64s = 640 bytes) Verified against FIPS 180-4 + RFC 6234 test vectors. license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/nist/fips_180_4 lineage_id: nishi_sha512_wasm_q11

dependencies 0 imports · 0 importers

imports: none

imported by: nobody (leaf or entry point)

structs

none

consts

28const W_OFF: i64 = 200

functions

32func _rotr64(x: i64, n: i64) -> i64
called by 1: _sha512_compress
42func _be64_read(buf: *u8, off: i64) -> i64
called by 1: _sha512_compress
56func _be64_write(buf: *u8, off: i64, v: i64) -> i64
called by 1: nx_sha512_one_shot
69func _i64_le_get(buf: *u8, idx: i64) -> i64
called by 1: _sha512_compress
80func _i64_le_set(buf: *u8, idx: i64, v: i64) -> i64
called by 1: _sha512_compress
94func _h_get(ctx: *u8, i: i64) -> i64
105func _h_set(ctx: *u8, i: i64, v: i64) -> i64
120func _sha512_k(i: i64) -> i64
called by 1: _sha512_compress
164func _sha512_compress(ctx: *u8) -> i64
229func nx_sha512_one_shot(in_ptr: *u8, in_len: i64, ctx: *u8, out_ptr: *u8) -> i64