code wiki / _hdl_build / nx_aid_federation.nx
nx_aid_federation.nx
buildroot/runtime/_hdl_build/nx_aid_federation.nx
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
imports: nx_food_science.nxnx_seg_store.nxnx_syscalls.nx
imported by: nx_aid_federation_gate.nx
structs
| none |
consts
| 17 | const AF_MAGIC_4096: i64 = 4096 |
| 19 | const AF_MOD: i64 = 1000000007 |
functions
| 21 | func af_put(prefix: *u8, key: *u8, val: *u8) -> i64 called by 3: af_seed_saltaf_list_appendaf_submit calls 5: fd_streq_storess_beginss_addfd_seg_nextss_commit |
| 32 | func af_seed_salt(prefix: *u8, salt: *u8) -> i64 { return af_put(prefix, "aidfed:salt" as *u8, salt) } |
| 33 | func af_salt(prefix: *u8, out: *u8) -> i64 |
| 43 | func af_hash2(salt: *u8, s: *u8) -> i64 called by 1: af_make_token |
| 54 | func af_make_token(prefix: *u8, stable_id: *u8, out: *u8) -> i64 |
| 63 | func 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 } |
| 64 | func 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 } |
| 65 | func 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 } |
| 67 | func af_list_append(prefix: *u8, key: *u8, token: *u8) -> i64 |
| 91 | func af_orgn(prefix: *u8, org: *u8) -> i64 |
| 99 | func af_submit(prefix: *u8, org: *u8, token: *u8, day: i64) -> i64 |
| 113 | func af_sub_str(prefix: *u8, org: *u8, seq: i64, f: i64, out: *u8) -> i64 |
| 122 | func af_org_has_token(prefix: *u8, org: *u8, token: *u8, now: i64, period: i64) -> i64 |
| 135 | func af_sub_day(prefix: *u8, org: *u8, seq: i64) -> i64 |
| 141 | func af_token_org_count(prefix: *u8, token: *u8, now: i64, period: i64) -> i64 called by 3: af_is_cross_dipperaf_render_reviewmain calls 4: sys_mmapaf_orgs_keyss_getaf_org_has_token |
| 169 | func af_is_cross_dipper(prefix: *u8, token: *u8, now: i64, period: i64) -> i64 |
| 175 | func af_render_review(prefix: *u8, now: i64, period: i64, out: *u8) -> i64 |