code wiki / _hdl_build / nx_aid_federation.nx

nx_aid_federation.nx

buildroot/runtime/_hdl_build/nx_aid_federation.nx

10955 B209 linesdepth 4pulls 5 transitivereach 1 importersview sourcekind librarytopic aid
docsdependenciesstructsconstsfunctions

about

nx_aid_federation.nx -- LIB: CROSS-ORG charity federation (R-AID-R1). Catches a double-dipper claiming across DIFFERENT food banks WITHOUT any org sharing PII. Mechanism: each org locally computes a SALTED TOKEN = hash(federation_salt || recipient_stable_id) and submits ONLY the token (never the name/PII). The same person yields the same token at every org, so a token appearing at >=2 orgs in the period = a cross-org double-claim. HONEST SCOPE (load-bearing): this proves the ARCHITECTURE -- (A) no PII crosses an org boundary (af_submit takes a TOKEN, by signature; the stored record holds only digits + a day), (B) same person -> same token -> overlap detected, (C) FAIL-OPEN preserved (there is NO auto-deny here -- detection only RAISES a review flag; a human decides, mirroring nx_aid). The token DIGEST is a deliberately-swappable primitive: this uses a polynomial hash for the demo; PRODUCTION MUST swap in a cryptographic hash (sha256) + a coordinator-held high-entropy salt (ideally a real private-set-intersection protocol). Tokens are linkable BY DESIGN (that is how overlap is found) -- harden the primitive + salt management before real deployment. Sovereign seg-store (knowledge/store/aidfed-*, NO TSV), integer-only. license_tier: ORIGINAL

dependencies 3 imports · 1 importers

nx_food_science.nx nx_seg_store.nx nx_syscalls.nx nx_aid_federation.nx nx_aid_federation_gate.nx

imports: nx_food_science.nxnx_seg_store.nxnx_syscalls.nx

imported by: nx_aid_federation_gate.nx

structs

none

consts

17const AF_MAGIC_4096: i64 = 4096
19const AF_MOD: i64 = 1000000007

functions

21func af_put(prefix: *u8, key: *u8, val: *u8) -> i64
32func af_seed_salt(prefix: *u8, salt: *u8) -> i64 { return af_put(prefix, "aidfed:salt" as *u8, salt) }
called by 1: main calls 1: af_put
33func af_salt(prefix: *u8, out: *u8) -> i64
called by 1: af_make_token calls 2: sys_mmapss_get
43func af_hash2(salt: *u8, s: *u8) -> i64
called by 1: af_make_token
54func af_make_token(prefix: *u8, stable_id: *u8, out: *u8) -> i64
63func af_orgs_key(out: *u8) -> i64 { var o: i64 = 0; o = as_append(out, o, "aidfed:orgs" as *u8); out[o] = 0 as u8; return o }
64func af_orgn_key(org: *u8, out: *u8) -> i64 { var o: i64 = 0; o = as_append(out, o, "aidfed:orgn:" as *u8); o = as_append(out, o, org); out[o] = 0 as u8; return o }
called by 2: af_orgnaf_submit calls 1: as_append
65func af_sub_key(org: *u8, seq: i64, out: *u8) -> i64 { var o: i64 = 0; o = as_append(out, o, "aidfed:sub:" as *u8); o = as_append(out, o, org); out[o] = 58 as u8; o = o + 1; o = fd_apnum(out, o, seq); out[o] = 0 as u8; return o }
67func af_list_append(prefix: *u8, key: *u8, token: *u8) -> i64
91func af_orgn(prefix: *u8, org: *u8) -> i64
99func af_submit(prefix: *u8, org: *u8, token: *u8, day: i64) -> i64
113func af_sub_str(prefix: *u8, org: *u8, seq: i64, f: i64, out: *u8) -> i64
122func af_org_has_token(prefix: *u8, org: *u8, token: *u8, now: i64, period: i64) -> i64
135func af_sub_day(prefix: *u8, org: *u8, seq: i64) -> i64
141func af_token_org_count(prefix: *u8, token: *u8, now: i64, period: i64) -> i64
169func af_is_cross_dipper(prefix: *u8, token: *u8, now: i64, period: i64) -> i64
called by 1: main calls 1: af_token_org_count
175func af_render_review(prefix: *u8, now: i64, period: i64, out: *u8) -> i64