nx_blake2b.nx
buildroot/runtime/nx_blake2b.nx
about
nx_blake2b.nx -- RFC 7693 BLAKE2b-512 hash (variable output length).
BLAKE2b is the 64-bit-optimized member of the BLAKE2 family
(Aumasson, Neves, Wilcox-O'Hearn, Winnerlein 2013). The
substrate brick under nx_argon2id (RFC 9106) and any future
nx_blake3 / nx_kangaroo12 work.
Per cardinal feedback-bits-up-exceed-never-match:
This is the substrate's own BLAKE2b -- not a libsodium binding,
not an OpenSSL EVP wrap. The math runs on substrate i64 ops.
Per cardinal feedback-no-third-party-trust-native-or-nothing:
Validated against RFC 7693 Appendix A KAT byte-exactly. Any
change here MUST re-run the KAT smoke.
===== Algorithm summary (RFC 7693 sec 3) =========================
State: 8 x u64 chained hash words h[0..7], initialized to the
BLAKE2b IV (= SHA-512 IV: square roots of first 8 primes).
Parameter block (8-byte XOR into h[0]):
byte 0 : output digest length (1..64)
byte 1 : key length (0..64)
byte 2 : fanout (1 for sequential)
byte 3 : depth (1 for sequential)
byte 4-7 : leaf length (0 for sequential)
Compression F(h, block, t, last):
v[0..7] = h[0..7]
v[8..15] = IV[0..7]
v[12] ^= t low 64 bits (bytes-so-far including this block)
v[13] ^= t high 64 bits (0 in normal usage)
v[14] ^= 0xFFFFFFFFFFFFFFFF if last block
for r in 0..12:
Mix 8 column + 4 diagonal moves per RFC 7693 sec 3.2.
h[i] ^= v[i] ^ v[i+8] for i in 0..7
G(v, a, b, c, d, x, y):
dependencies 0 imports · 12 importers
diagram shows first 10 each side; +0 more imports, +2 more importers in the complete lists below.
imports: none
imported by: nx_argon2_block.nxnx_argon2id.nxnx_argon2id_b0_bisect.nxnx_argon2id_h0_bisect.nxnx_argon2id_t1_xvalidate.nxnx_argon2id_test.nxnx_argon2id_xvalidate_test.nxnx_blake2b_long.nxnx_blake2b_long_test.nxnx_blake2b_test.nxnx_gcode_manifest.nxnx_gcode_manifest_test.nx
structs
| 107 | struct NxBlake2b |
consts
| 79 | const NX_BLAKE2B_OK: i64 = 0 |
| 80 | const NX_BLAKE2B_BAD_OUT_LEN: i64 = 1 |
| 81 | const NX_BLAKE2B_BAD_KEY_LEN: i64 = 2 |
| 82 | const NX_BLAKE2B_BAD_ARG: i64 = 3 |
| 83 | const NX_BLAKE2B_VERDICT_N: i64 = 4 |
| 101 | const NX_BLAKE2B_BLOCK_BYTES: i64 = 128 |
| 102 | const NX_BLAKE2B_OUT_MAX: i64 = 64 |
| 103 | const NX_BLAKE2B_KEY_MAX: i64 = 64 |
| 117 | const NX_BLAKE2B_CTX_BYTES: i64 = 104 // 13 i64 fields * 8 |
functions
| 85 | func nx_blake2b_verdict_is_valid(v: i64) -> i64 called by 1: main |
| 91 | func nx_blake2b_verdict_name(v: i64) -> *u8 called by 1: main |
| 122 | func _b2b_shr64(x: i64, n: i64) -> i64 |
| 130 | func _b2b_rotr64(x: i64, n: i64) -> i64 |
| 139 | func _b2b_load_u64_le(buf: *u8, off: i64) -> i64 called by 1: _b2b_compress |
| 159 | func _b2b_store_u64_le(buf: *u8, off: i64, v: i64) -> i64 |
| 176 | func _b2b_iv(i: i64) -> i64 |
| 192 | func _b2b_sigma(row: i64, col: i64) -> i64 called by 1: _b2b_compress |
| 379 | func _b2b_mix(v: *i64, a: i64, b: i64, c: i64, d: i64, |
| 401 | func _b2b_compress(ctx: *NxBlake2b, block: *u8, |
| 469 | func nx_blake2b_init(ctx: *NxBlake2b, |
| 530 | func nx_blake2b_update(ctx: *NxBlake2b, |
| 615 | func nx_blake2b_final(ctx: *NxBlake2b, |
| 684 | func nx_blake2b_hash(msg: *u8, msg_len: i64, |