code wiki / (root) / nx_blake2b.nx

nx_blake2b.nx

buildroot/runtime/nx_blake2b.nx

24167 B696 linesdepth 0pulls 0 transitivereach 162 importersview sourcekind librarytopic blake2b
docsdependenciesstructsconstsfunctions

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

nx_blake2b.nx nx_argon2_block.nx nx_argon2id.nx nx_argon2id_b0_bisect.nx nx_argon2id_h0_bisect.nx nx_argon2id_t1_xvalidate.nx nx_argon2id_test.nx nx_argon2id_xvalidate_test.nx nx_blake2b_long.nx nx_blake2b_long_test.nx nx_blake2b_test.nx

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

107struct NxBlake2b

consts

79const NX_BLAKE2B_OK: i64 = 0
80const NX_BLAKE2B_BAD_OUT_LEN: i64 = 1
81const NX_BLAKE2B_BAD_KEY_LEN: i64 = 2
82const NX_BLAKE2B_BAD_ARG: i64 = 3
83const NX_BLAKE2B_VERDICT_N: i64 = 4
101const NX_BLAKE2B_BLOCK_BYTES: i64 = 128
102const NX_BLAKE2B_OUT_MAX: i64 = 64
103const NX_BLAKE2B_KEY_MAX: i64 = 64
117const NX_BLAKE2B_CTX_BYTES: i64 = 104 // 13 i64 fields * 8

functions

85func nx_blake2b_verdict_is_valid(v: i64) -> i64
called by 1: main
91func nx_blake2b_verdict_name(v: i64) -> *u8
called by 1: main
122func _b2b_shr64(x: i64, n: i64) -> i64
130func _b2b_rotr64(x: i64, n: i64) -> i64
called by 1: _b2b_mix calls 1: _b2b_shr64
139func _b2b_load_u64_le(buf: *u8, off: i64) -> i64
called by 1: _b2b_compress
159func _b2b_store_u64_le(buf: *u8, off: i64, v: i64) -> i64
called by 1: nx_blake2b_final calls 1: _b2b_shr64
176func _b2b_iv(i: i64) -> i64
192func _b2b_sigma(row: i64, col: i64) -> i64
called by 1: _b2b_compress
379func _b2b_mix(v: *i64, a: i64, b: i64, c: i64, d: i64,
called by 1: _b2b_compress calls 1: _b2b_rotr64
401func _b2b_compress(ctx: *NxBlake2b, block: *u8,
469func nx_blake2b_init(ctx: *NxBlake2b,
called by 2: nx_blake2b_hashmain calls 1: _b2b_iv
530func nx_blake2b_update(ctx: *NxBlake2b,
called by 1: nx_blake2b_hash calls 1: _b2b_compress
615func nx_blake2b_final(ctx: *NxBlake2b,
684func nx_blake2b_hash(msg: *u8, msg_len: i64,