code wiki / _hdl_build / nx_connect_groupkey.nx
nx_connect_groupkey.nx
buildroot/runtime/_hdl_build/nx_connect_groupkey.nx
about
nx_connect_groupkey.nx -- VIDEO ROOM E2E group keying (MLS-style sender-key ratchet). Hardens the
content-blind exceed from "server-decoded=0 by design" to "cryptographically cannot decode, over
time and across membership changes." Models the key SCHEDULE (integer one-way KDF); the production
primitive is the ecosystem HKDF/SHA -- named substrate, not reinvented here.
Key schedule:
ratchet(k) = KDF(k + RATCHET_LABEL) -- per-epoch forward ratchet (forward secrecy)
rekey(k, commit) = KDF(k + commit) -- membership change; commit secret goes ONLY to
current members, so a removed member diverges
Properties gated: (1) forward secrecy -- a current key cannot derive a PAST key (one-way);
(2) removed member cannot derive the post-removal key (no commit) -> excluded from future;
(3) added member gets current+forward only, never the past; (4) the server holds ZERO key material
(reinforces content-blind); (5) membership change increments epoch + rotates the key;
(6) NEG-CONTROL: a static single key exposes ALL epochs on one compromise; our ratchet exposes 0
past epochs. 7 checks. 100% sovereign. license_tier: ORIGINAL expect_exit: 0
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 18 | const HP: i64 = 1000000007 |
| 19 | const HA: i64 = 2654435761 |
| 20 | const HB: i64 = 2246822519 |
| 21 | const HC: i64 = 540041351 |
| 22 | const HD: i64 = 700000001 |
| 23 | const RATCHET_LABEL: i64 = 1 |
functions
| 25 | func sw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 26 | func sn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 } |
| 28 | func modp(h: i64) -> i64 { return h - (h/HP)*HP } called by 1: kdf |
| 29 | func kdf(x: i64) -> i64 { var h: i64=modp(x+HC); h=modp(h*HA); h=modp(h+HD); h=modp(h*HB); return h } // one-way (model) |
| 30 | func ratchet(k: i64) -> i64 { return kdf(k + RATCHET_LABEL) } |
| 31 | func rekey(k: i64, commit: i64) -> i64 { return kdf(k + commit) } |
| 34 | func reachable_fwd(from: i64, target: i64, c2: i64, c3: i64) -> i64 |
| 42 | func tcheck(pass: i64, label: *u8, fails: *i64) -> i64 |
| 48 | func main() -> i64 |