nx_sha3_256_wasm.nx
buildroot/runtime/nx_sha3_256_wasm.nx
about
nx_sha3_256_wasm.nx -- SHA-3-256 (FIPS 202) self-contained for WAT target.
Sponge construction over Keccak-f[1600]:
* State = 25 lanes of 64-bit (5x5 matrix), stored as 200 bytes little-endian
* Rate r = 1088 bits = 136 bytes (SHA-3-256: capacity c = 512 bits)
* Padding: append 0x06 then pad with zeros, set high bit of last byte
(M || 0110 0... 0001 in bit order; the 0x06 = 01100000 in little-endian
bit numbering = M || 01 || 10*1 per FIPS 202 §B.2)
* Output: first 32 bytes of state
Inlined Keccak-f[1600]: 24 rounds of theta, rho, pi, chi, iota.
Each lane is 64-bit; we pack i64 in/out at byte level (LE) to keep
the WAT codegen path narrow (no i64 loads through u8 pointers).
API:
nx_sha3_256_one_shot(msg_ptr, msg_len, state_ptr, out_ptr) -> i64
msg_ptr -- input bytes
msg_len -- input length
state_ptr -- >= 256 bytes scratch (200 for state + 56 slack)
out_ptr -- 32 bytes for digest
Verified against FIPS 202 / NIST CAVP test vectors (empty + "abc" +
"The quick brown fox..." per common reference set).
license_tier: INDEPENDENT_REDERIVE
genealogy_id: international-research-sources/nist/fips_202
lineage_id: nishi_sha3_256_wasm_q1
dependencies 0 imports · 0 importers
imports: none
imported by: nobody (leaf or entry point)
structs
| none |
consts
| none |
functions
| 31 | func _lane_load(p: *u8) -> i64 called by 1: _keccak_f1600 |
| 50 | func _lane_store(p: *u8, v: i64) -> i64 called by 1: _keccak_f1600 |
| 65 | func _rotl64(x: i64, n: i64) -> i64 called by 1: _keccak_f1600 |
| 74 | func _keccak_rc(i: i64) -> i64 called by 1: _keccak_f1600 |
| 103 | func _rho_off(lane_idx: i64) -> i64 called by 1: _keccak_f1600 |
| 136 | func _keccak_f1600(state_ptr: *u8) -> i64 |
| 217 | func nx_sha3_256_one_shot(msg_ptr: *u8, msg_len: i64, calls 1: _keccak_f1600 |