code wiki / (root) / nx_cap_keygen_gate.nx

nx_cap_keygen_gate.nx

buildroot/runtime/nx_cap_keygen_gate.nx

4635 B67 linesdepth 8pulls 14 transitivereach 0 importersview sourcekind gate/prooftopic cap
docsdependenciesstructsconstsfunctions

about

nx_cap_keygen_gate.nx -- proves nx_cap_keygen provisions a REAL CSPRNG signing secret that (a) is 256-bit hex, (b) lands on disk 0600 byte-exact with no trailing newline, (c) has real entropy (two draws differ), (d) is fail-safe (refuses a silent overwrite), and -- the composition that matters -- (e) actually WORKS as an HMAC signing key: a capability minted with it VERIFIES, and (f) is independent: a token signed by one key is DENIED under another (unforgeable across keys). Closes GAP 2 of the MCP grant and ties it to GAP 1 (mint) + verify. license_tier: ORIGINAL expect_exit: 0

dependencies 3 imports · 0 importers

nx_cap_keygen.nx nx_cap_token.nx nx_gate.nx nx_cap_keygen_gate.nx

imports: nx_cap_keygen.nxnx_cap_token.nxnx_gate.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gw sys_write ck_provision sys_read_file sys_openat_rd sys_lseek sys_mmap sys_read sys_close nx_csprng_fill sys_mmap ↻ nx_csprng_urandom_path sys_openat_rd ↻ sys_read ↻ sys_close ↻ ck_hexd kg_expect gw ↻ gn sys_write ↻ sys_mmap ↻ kg_all_hex kg_is_hex sys_read_file ↻ kg_eqn capt_issue capt_payload capt_catb capt_catn signed_cookie_sign sc_sign_bytes sys_mmap ↻ hmac_sha256 sys_mmap ↻ sha256_digest sys_mmap ↻ sha256_init sha256_update sha256_final

structs

none

consts

11const KG_PATH: *u8 = "/tmp/nx_capkeygen_gate.key" as *u8

functions

13func kg_is_hex(c: i64) -> i64 { if c >= 48 { if c <= 57 { return 1 } } if c >= 97 { if c <= 102 { return 1 } } return 0 }
called by 1: kg_all_hex
14func kg_all_hex(s: *u8, n: i64) -> i64 { var i: i64 = 0; while i < n { if kg_is_hex(s[i] as i64) == 0 { return 0 } i = i + 1 } return 1 }
called by 1: main calls 1: kg_is_hex
15func kg_eqn(a: *u8, b: *u8, n: i64) -> i64 { var i: i64 = 0; while i < n { if a[i] != b[i] { return 0 } i = i + 1 } return 1 }
called by 1: main
17func kg_expect(actual: i64, expected: i64, pass: *i64, tot: *i64, label: *u8) -> i64
called by 1: main calls 2: gwgn
24func main() -> i64