code wiki / _hdl_build / nx_voprf_kat_register.nx
nx_voprf_kat_register.nx source
↩ module page · 41 lines · 3034 B
1// nx_voprf_kat_register.nx -- registers the VOPRF verification (the OPAQUE building block, RFC 9497
2// OPRF P-256/SHA-256) + the finalize relocation fix. ENGINEER evidence = the RFC KAT is REBUILT + rerun
3// here (prove-all). Atomic alloc via the Librarian. license_tier: ORIGINAL
4import "nx_cap_register.nx"
5import "nx_capreg_librarian.nx"
6import "nx_syscalls.nx"
7
8func vkr_build_run(name: *u8) -> i64 {
9 let pid: i64 = sys_fork()
10 if pid == 0 {
11 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4)
12 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) }
13 let argv: *i64 = sys_mmap(32) as *i64
14 argv[0] = "_offc/nx_sov_build_run.elf" as *u8 as i64
15 argv[1] = name as i64
16 argv[2] = 0
17 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = 0
18 sys_execve("_offc/nx_sov_build_run.elf" as *u8, argv, envp); sys_exit(127)
19 }
20 let st: *i64 = sys_mmap(16) as *i64
21 sys_wait4(pid, st, 0)
22 return st[0]
23}
24
25func main() -> i64 {
26 var allok: i64 = 1
27 if vkr_build_run("nx_voprf_rfc_kat" as *u8) != 0 { allok = 0 }
28 cr_w(1, "ENGINEER: VOPRF RFC9497 A.3.1.1 KAT rebuild+rerun pass=" as *u8); cr_wn(1, allok); cr_w(1, "\n" as *u8)
29 let eng: i64 = ig_engineer(1, 1, 1, allok)
30 let dec: i64 = ig_decision(eng, ig_council(eng, 1, 1, 2), 1)
31 if dec != IG_INGEST { cr_w(1, "HELD\n" as *u8); sys_exit(1) }
32 if cr_can_register(5, 2, 6, dec) != 1 { cr_w(1, "REFUSED\n" as *u8); sys_exit(1) }
33 let lp: *u8 = "/tmp/nishi_cap_registry.log" as *u8
34 let jp: *u8 = "knowledge/status/cap_registry_durable.log" as *u8
35 let idx: i64 = cl_next_idx(lp, jp)
36 let ok: i64 = cl_register_dual(lp, jp, idx, 2, 2, "VER VOPRF-RFC9497 (the OPAQUE building block VERIFIED) -- nx_voprf (RFC9497 OPRF P-256/SHA-256, Base mode) shipped with NO test = the whole modern-auth charter rested on UNVERIFIED crypto. Now gated against the RFC's OWN vector (Appendix A.3.1.1): full Blind->BlindEvaluate->Finalize round trip == RFC Output a0b34de5.. (output is blind-independent so our random blind still reproduces it EXACTLY -> validates RFC9380 hash-to-curve + P-256 scalar-mult + blind/unblind modular inverse + Finalize hash, the whole stack, vs the standard); + blind-independence (2nd random run == RFC) + input-sensitivity KATs. FOUND+FIXED a real bug doing it: NXCC-VOPRF-FINALIZE-MISCOMPILE -- Finalize miscompiled inside the 12-func nx_voprf.nx (memory-state-dependent wrong output), localized by RFC fixed-intermediate staging (BlindEvaluate exact-matched RFC, isolating the bug to Finalize's frame), fixed by relocating to hub/nx_voprf_finalize.nx. UNBLOCKS OPAQUE login (V-MODAUTH-2) = the S-class-exceed auth (server never sees the password) the operator flagged as superior to username/password. Composes nx_p256_*/nx_ed25519 stacks + nx_h2c_p256")
37 if ok != 1 { cr_w(1, "DUAL-WRITE FAILED\n" as *u8); sys_exit(1) }
38 cr_w(1, "CAPREG idx=" as *u8); cr_wn(1, idx); cr_w(1, " REGISTERED (VOPRF verified, OPAQUE unblocked)\n" as *u8)
39 sys_exit(0)
40 return 0
41}