nx_media_exclusion_gate.nx source
↩ module page · 49 lines · 2724 B
1// nx_media_exclusion_gate.nx -- GREEN/RED gate for nx_media_exclusion. Proves the do-not-recover check on SYNTHETIC
2// fingerprints (no real hashes): a blocklisted fingerprint is refused; a re-encoded/resized variant (within Hamming
3// threshold) is ALSO refused (catches re-uploads); unrelated media is allowed; a variant beyond the threshold is
4// allowed (no over-blocking); an empty blocklist allows everything. Image stack. license_tier: ORIGINAL
5import "nx_media_exclusion.nx"
6import "nx_gate.nx"
7
8func main() -> i64 {
9 gw("=== nx_media_exclusion_gate: refuse blocklisted media + its re-uploads (synthetic fingerprints) ===\n" as *u8)
10 let N: i64=3
11 let bd: *i64=sys_mmap(64) as *i64
12 let bt: *i64=sys_mmap(64) as *i64
13 bd[0]=0x1122334455667788; bt[0]=6
14 bd[1]=0x0f0f0f0f0f0f0f0f; bt[1]=4
15 bd[2]=0x7777aaaa3333cccc; bt[2]=8
16
17 var pass: i64=0; var tot: i64=0
18
19 // T1 exact blocklisted fingerprint -> BLOCKED
20 let r1: i64=excl_blocked(bd[0], bd, bt, N)
21 tot=tot+1; if r1==0 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
22 gw("T1 EXACT match -> BLOCKED (idx=" as *u8); gn(r1); gw(")\n" as *u8)
23
24 // T2 re-uploaded copy (re-encode/resize -> Hamming 2 <= thresh 4) -> BLOCKED
25 let q2: i64=bd[1] ^ 6
26 let r2: i64=excl_blocked(q2, bd, bt, N)
27 tot=tot+1; if r2==1 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
28 gw("T2 RE-UPLOAD (near-variant, Hamming 2) -> BLOCKED (idx=" as *u8); gn(r2); gw(") -- the key property\n" as *u8)
29
30 // T3 unrelated media -> ALLOWED
31 let r3: i64=excl_blocked(0x0102040810204080, bd, bt, N)
32 tot=tot+1; if r3<0 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
33 gw("T3 UNRELATED media -> ALLOWED\n" as *u8)
34
35 // T4 variant BEYOND the threshold (Hamming 6 > thresh 4) -> ALLOWED (no over-blocking)
36 let q4: i64=bd[1] ^ 0x3f
37 let r4: i64=excl_blocked(q4, bd, bt, N)
38 tot=tot+1; if r4<0 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
39 gw("T4 BEYOND threshold (Hamming 6) -> ALLOWED (no false-positive over-block)\n" as *u8)
40
41 // T5 empty blocklist -> ALLOWED
42 let r5: i64=excl_blocked(bd[0], bd, bt, 0)
43 tot=tot+1; if r5<0 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
44 gw("T5 EMPTY blocklist -> ALLOWED (starts empty; grows by takedown/hash-feed)\n" as *u8)
45
46 gw("\n=== nx_media_exclusion_gate " as *u8); gn(pass); gw("/" as *u8); gn(tot); gw(" ===\n" as *u8)
47 if pass==tot { gw("MEDIA-EXCLUSION-GATE verdict=GREEN -- blocklisted content + re-uploads refused by construction\n" as *u8); sys_exit(0); return 0 }
48 gw("MEDIA-EXCLUSION-GATE RED\n" as *u8); sys_exit(1); return 1
49}