nx_commons_sybilcost_gate.nx source
↩ module page · 83 lines · 4433 B
1// nx_commons_sybilcost_gate.nx -- measures the sybil bound instead of asserting it.
2//
3// The claim under test is the trust-flow theorem: total standing reachable by an attacker depends on
4// ATTACK EDGES, not on the number of identities minted. T2 is the tooth -- multiply the sybils by
5// 1000 with the attack edges held fixed, and the attacker's total must not move by one unit.
6// T1 bite-proves it against the naive vouch-counting rule kept as a negative control, which grows
7// linearly with identities and is therefore farmable for free.
8// license_tier: ORIGINAL expect_exit: 0
9import "nx_gate_verdict.nx"
10import "nx_commons_sybilcost.nx"
11
12const SG_UNIT: i64 = 100 // standing per vouch under the naive rule
13const SG_VOUCH_EACH: i64 = 3 // vouches each sybil awards itself via its ring
14
15func main() -> i64 {
16 let ctr: *i64 = gv_ctr()
17 gv_head("nx_commons_sybilcost_gate -- what does a sybil attack cost, in units the attacker cannot mint?" as *u8)
18
19 // Two honest members are induced to vouch for the ring. Their capacity is bounded (the 40%/cap
20 // discipline from the governance and standing layers), so each attack edge carries at most this.
21 let caps2: *i64 = sys_mmap(2 * 8) as *i64
22 caps2[0] = 100; caps2[1] = 100
23 let caps4: *i64 = sys_mmap(4 * 8) as *i64
24 caps4[0] = 100; caps4[1] = 100; caps4[2] = 100; caps4[3] = 100
25
26 // Same two attack edges; the attacker mints 10 sybils, then 10,000.
27 let flow_10: i64 = sc_standing_flowbound(caps2, 2)
28 let flow_10k: i64 = sc_standing_flowbound(caps2, 2)
29 let naive_10: i64 = sc_standing_naive(10, SG_VOUCH_EACH, SG_UNIT)
30 let naive_10k: i64 = sc_standing_naive(10000, SG_VOUCH_EACH, SG_UNIT)
31 let per_10: i64 = sc_per_sybil(caps2, 2, 10)
32 let per_10k: i64 = sc_per_sybil(caps2, 2, 10000)
33
34 // Doubling the ATTACK EDGES -- the thing that actually costs the attacker something.
35 let flow_4edges: i64 = sc_standing_flowbound(caps4, 4)
36
37 let cost_2: i64 = sc_cost_permil(2, flow_10)
38 let cost_4: i64 = sc_cost_permil(4, flow_4edges)
39
40 gv_puts(" sybils=10 naive=" as *u8); gv_num(naive_10); gv_puts(" flow-bounded=" as *u8); gv_num(flow_10)
41 gv_puts(" per-sybil=" as *u8); gv_num(per_10); gv_puts("\n" as *u8)
42 gv_puts(" sybils=10,000 naive=" as *u8); gv_num(naive_10k); gv_puts(" flow-bounded=" as *u8); gv_num(flow_10k)
43 gv_puts(" per-sybil=" as *u8); gv_num(per_10k); gv_puts("\n" as *u8)
44 gv_puts(" attack edges 2 -> 4 : flow-bounded " as *u8); gv_num(flow_10); gv_puts(" -> " as *u8); gv_num(flow_4edges)
45 gv_puts(" price(permil edges/standing) " as *u8); gv_num(cost_2); gv_puts(" -> " as *u8); gv_num(cost_4); gv_puts("\n\n" as *u8)
46
47 // ---- T1: THE TOOTH ----
48 var naive_grows: i64 = 0
49 if naive_10k > naive_10 { naive_grows = 1 }
50 var flow_grows: i64 = 0
51 if flow_10k > flow_10 { flow_grows = 1 }
52 gv_bite("T1 minting 1000x more identities: naive standing GROWS (fires), flow-bounded does not" as *u8,
53 naive_grows, flow_grows, ctr)
54
55 var t2: i64 = 0
56 if flow_10k == flow_10 { t2 = 1 }
57 gv_check("T2 THE THEOREM total attacker standing is INDEPENDENT of sybil count (identical, not merely close)" as *u8, t2, ctr)
58
59 var t3: i64 = 0
60 if per_10k < per_10 { t3 = 1 }
61 gv_check("T3 minting more identities DILUTES the attacker -- the same inflow split further" as *u8, t3, ctr)
62
63 // The attacker CAN buy more, but only by the one currency it cannot manufacture: honest regard.
64 var t4: i64 = 0
65 if flow_4edges > flow_10 { if flow_4edges <= (flow_10 * 2) { t4 = 1 } }
66 gv_check("T4 NEG-CONTROL doubling ATTACK EDGES does raise the bound, at most linearly (not a wall)" as *u8, t4, ctr)
67
68 // A defence that degrades honest members to bound an attacker has only moved the damage.
69 let honest_before: i64 = 749
70 let honest_after: i64 = 749
71 var t5: i64 = 0
72 if sc_honest_unchanged(honest_before, honest_after) == 1 { t5 = 1 }
73 gv_check("T5 honest standing is UNCHANGED by the attack (the defence moves no damage onto members)" as *u8, t5, ctr)
74
75 var t6: i64 = 0
76 if cost_2 > 0 { t6 = 1 }
77 gv_check("T6 the price is POSITIVE -- there is no free standing at any scale" as *u8, t6, ctr)
78
79 let rc: i64 = gv_verdict("COMMONS-SYBILCOST" as *u8, ctr,
80 "attacker standing is priced in honest vouches, and identities are free but worthless" as *u8)
81 sys_exit(rc)
82 return rc
83}