code wiki / _hdl_build / nx_connect_msg.nx
nx_connect_msg.nx
buildroot/runtime/_hdl_build/nx_connect_msg.nx
about
nx_connect_msg.nx -- ACTUAL FUNCTIONALITY rung: the CONNECT messaging core. The real chat
primitive that Telegram/Messenger/WeChat are built on -- here, sovereign and content-blind.
Delivers + gates: ordered per-conversation message log (monotonic seq); delivery state machine
(sent->delivered->read, no backward); edit + delete-for-all (tombstone); multi-device DELTA sync
(since-cursor: a device that has up to seq N fetches only seq>N); OFFLINE-SAFE dedup (idempotent
by client message id -- a resent message is stored once); and CONTENT-BLIND storage -- the server
holds only ciphertext; the per-conversation key lives only on clients, so the server can read
ZERO plaintext (measured) -- vs WeChat, whose server reads + censors everything.
HONEST: the cipher here is an additive keyed transform STANDING IN for the production AEAD
(ecosystem ChaCha20/AES-GCM) -- it proves the content-blind INFORMATION FLOW (server never holds
plaintext/key), not cryptographic strength. So content-blind flips to PRESENT (gated), not
PARITY/EXCEEDS. 7 checks incl. negative controls. 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
| 17 | const F_MAGIC_4096: i64 = 4096 |
| 18 | const F_MAGIC_12345: i64 = 12345 |
| 19 | const F_MAGIC_9001: i64 = 9001 |
| 20 | const F_MAGIC_9002: i64 = 9002 |
| 21 | const F_MAGIC_9003: i64 = 9003 |
| 22 | const F_MAGIC_1099: i64 = 1099 |
| 24 | const STRIDE: i64 = 8 |
| 25 | const F_SEQ: i64 = 0 |
| 26 | const F_CID: i64 = 1 |
| 27 | const F_SENDER:i64 = 2 |
| 28 | const F_STATE: i64 = 3 |
| 29 | const F_EDIT: i64 = 4 |
| 30 | const F_DEL: i64 = 5 |
| 31 | const F_CIPHER:i64 = 6 |
| 32 | const F_LANG: i64 = 7 |
| 33 | const ST_SENT: i64 = 0 |
| 34 | const ST_DELIV:i64 = 1 |
| 35 | const ST_READ: i64 = 2 |
functions
| 37 | 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 } |
| 38 | 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 } |
| 40 | func find_idx(log: *i64, cnt: i64, seq: i64) -> i64 |
| 47 | func log_append(log: *i64, cntp: *i64, cid: i64, sender: i64, content: i64, key: i64, lang: i64) -> i64 called by 1: main |
| 63 | func client_decrypt(log: *i64, idx: i64, key: i64) -> i64 { return log[idx*STRIDE+F_CIPHER]-key } called by 1: main |
| 65 | func set_state(log: *i64, cnt: i64, seq: i64, ns: i64) -> i64 |
| 71 | func edit_msg(log: *i64, cnt: i64, seq: i64, newc: i64, key: i64) -> i64 |
| 75 | func del_msg(log: *i64, cnt: i64, seq: i64) -> i64 |
| 79 | func delta_count(log: *i64, cnt: i64, cursor: i64) -> i64 called by 1: main |
| 85 | func tcheck(pass: i64, label: *u8, fails: *i64) -> i64 |
| 91 | func main() -> i64 |