code wiki / (root) / nx_cap_mint.nx

nx_cap_mint.nx

buildroot/runtime/nx_cap_mint.nx

2985 B49 linesdepth 8pulls 10 transitivereach 1 importersview sourcekind tooltopic cap
docsdependenciesstructsconstsfunctions

about

nx_cap_mint.nx -- CLI to MINT a capability token for R0's tools/call (R2 live). Reads the HMAC secret from a keyfile (the vault-provisioned prod secret -- the SAME file R0 loads), and mints a capability granting <allow> until <exp>. Operator-run (holds the keyfile); the eventual auth-gated self-service issuance endpoint is the ratchet. nx_cap_mint <keyfile> <allow-comma-list-or-*> <exp-epoch> <nonce> -> prints the capability token to stdout. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_cap_token.nx nx_cap_mint.nx nx_cap_mint_gate.nx

imports: nx_cap_token.nx

imported by: nx_cap_mint_gate.nx

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

main cm_puts cm_atoi sys_read_file sys_openat_rd sys_lseek sys_mmap sys_read sys_close cm_mint cm_streq_n capt_issue capt_payload capt_catb capt_catn signed_cookie_sign sc_sign_bytes sys_mmap ↻ hmac_sha256 sys_mmap ↻ sha256_digest sha256_init sha256_update sha256_final b64_encode b64_enc_char capt_slen

structs

none

consts

7const CM_MAGIC_2048: i64 = 2048
14const CM_PLACEHOLDER: *u8 = "nishi-tools-cap-hmac-secret-v1-REPLACE-FROM-VAULT" as *u8

functions

9func cm_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 1: main
10func cm_atoi(s: *u8) -> i64 { var v: i64 = 0; var i: i64 = 0; while s[i] != (0 as u8) { let d: i64 = s[i] as i64; if d >= 48 { if d <= 57 { v = v * 10 + (d - 48) } } i = i + 1 } return v }
called by 1: main
17func cm_streq_n(a: *u8, alen: i64, b: *u8) -> i64
called by 1: cm_mint
26func cm_mint(secret: *u8, secretlen: i64, allow: *u8, allen: i64, exp: i64, nonce: i64, out: *u8, cap: i64) -> i64
called by 2: mainmain calls 2: cm_streq_ncapt_issue
31func main(argc: i64, argv: *i64) -> i64