code wiki / _hdl_build / nx_connect_msg.nx

nx_connect_msg.nx

buildroot/runtime/_hdl_build/nx_connect_msg.nx

8602 B164 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic connect
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_connect_msg.nx

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

main sys_mmap log_append client_decrypt delta_count set_state find_idx find_idx ↻ edit_msg find_idx ↻ del_msg find_idx ↻ sw sys_write sn sys_mmap ↻ sys_write ↻ tcheck sw ↻ sys_exit

structs

none

consts

17const F_MAGIC_4096: i64 = 4096
18const F_MAGIC_12345: i64 = 12345
19const F_MAGIC_9001: i64 = 9001
20const F_MAGIC_9002: i64 = 9002
21const F_MAGIC_9003: i64 = 9003
22const F_MAGIC_1099: i64 = 1099
24const STRIDE: i64 = 8
25const F_SEQ: i64 = 0
26const F_CID: i64 = 1
27const F_SENDER:i64 = 2
28const F_STATE: i64 = 3
29const F_EDIT: i64 = 4
30const F_DEL: i64 = 5
31const F_CIPHER:i64 = 6
32const F_LANG: i64 = 7
33const ST_SENT: i64 = 0
34const ST_DELIV:i64 = 1
35const ST_READ: i64 = 2

functions

37func sw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: tcheckmain calls 1: sys_write
38func 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 }
called by 1: main calls 2: sys_mmapsys_write
40func find_idx(log: *i64, cnt: i64, seq: i64) -> i64
47func log_append(log: *i64, cntp: *i64, cid: i64, sender: i64, content: i64, key: i64, lang: i64) -> i64
called by 1: main
63func client_decrypt(log: *i64, idx: i64, key: i64) -> i64 { return log[idx*STRIDE+F_CIPHER]-key }
called by 1: main
65func set_state(log: *i64, cnt: i64, seq: i64, ns: i64) -> i64
called by 1: main calls 1: find_idx
71func edit_msg(log: *i64, cnt: i64, seq: i64, newc: i64, key: i64) -> i64
called by 1: main calls 1: find_idx
75func del_msg(log: *i64, cnt: i64, seq: i64) -> i64
called by 1: main calls 1: find_idx
79func delta_count(log: *i64, cnt: i64, cursor: i64) -> i64
called by 1: main
85func tcheck(pass: i64, label: *u8, fails: *i64) -> i64
called by 1: main calls 1: sw
91func main() -> i64