nx_argon2_block.nx
buildroot/runtime/nx_argon2_block.nx
about
nx_argon2_block.nx -- RFC 9106 sec 3.5/3.6 Argon2 G compression
+ P permutation.
The third and final brick in the Argon2id arc (before the
orchestrator that ties indexing + memory matrix together). G is
what gives Argon2 its memory hardness: it's intentionally slow on
GPU/ASIC because it requires 1024-byte block-at-a-time mixing
that can't be unrolled or pipelined deeply.
===== G compression function (RFC 9106 sec 3.5) =================
G(X, Y) -> Z where X, Y, Z are each 1024-byte blocks.
1. R = X XOR Y (1024 bytes)
2. Save R as R_save for the final XOR.
3. View R as 8x8 matrix of u128 registers (each u128 = 2 u64).
Equivalently: 8 rows of 16 u64 words (a row = 128 bytes).
4. Row-wise: apply P to each of 8 rows.
5. Column-wise: apply P to each of 8 "columns" (gathered slice
of 16 u64 from rows i = 0..7 at columns 2j, 2j+1).
6. Output Z = R XOR R_save.
===== P permutation (RFC 9106 sec 3.6) ==========================
P operates on 16 u64 words v_0..v_15 in-place. Same call pattern
as BLAKE2b's round but using GB (modified G with 2*L(a)*L(b)
instead of message words):
GB(v_0, v_4, v_8, v_12)
GB(v_1, v_5, v_9, v_13)
GB(v_2, v_6, v_10, v_14)
GB(v_3, v_7, v_11, v_15)
GB(v_0, v_5, v_10, v_15)
GB(v_1, v_6, v_11, v_12)
GB(v_2, v_7, v_8, v_13)
GB(v_3, v_4, v_9, v_14)
===== GB function (RFC 9106 sec 3.6) ============================
GB(a, b, c, d):
dependencies 1 imports · 8 importers
imports: nx_blake2b.nx
imported by: nx_argon2_block_test.nxnx_argon2_g_xvalidate_test.nxnx_argon2id.nxnx_argon2id_b0_bisect.nxnx_argon2id_h0_bisect.nxnx_argon2id_t1_xvalidate.nxnx_argon2id_test.nxnx_argon2id_xvalidate_test.nx
structs
| none |
consts
| 77 | const NX_MAGIC_4294967295: i64 = 4294967295 |
| 81 | const NX_A2B_OK: i64 = 0 |
| 82 | const NX_A2B_BAD_ARG: i64 = 1 |
| 83 | const NX_A2B_VERDICT_N: i64 = 2 |
| 91 | const NX_A2B_BLOCK_BYTES: i64 = 1024 |
| 92 | const NX_A2B_BLOCK_WORDS: i64 = 128 // 1024 / 8 |
functions
| 85 | func nx_a2b_verdict_name(v: i64) -> *u8 |
| 96 | func _a2b_shr64(x: i64, n: i64) -> i64 |
| 103 | func _a2b_rotr64(x: i64, n: i64) -> i64 |
| 111 | func _a2b_load_u64_le(buf: *u8, off: i64) -> i64 called by 1: nx_argon2_g |
| 124 | func _a2b_store_u64_le(buf: *u8, off: i64, v: i64) -> i64 |
| 140 | func _a2b_gb(v: *i64, ia: i64, ib: i64, ic: i64, id: i64) -> i64 |
| 176 | func _a2b_p(v: *i64, base: i64) -> i64 |
| 199 | func nx_argon2_g(x: *u8, y: *u8, out: *u8, called by 4: mainmain_ar2_gen_address_blocknx_argon2id_hash calls 3: _a2b_load_u64_le_a2b_p_a2b_store_u64_le |