code wiki / _hdl_build / nx_video_client_live_verify.nx

nx_video_client_live_verify.nx source

↩ module page · 79 lines · 4575 B

1// nx_video_client_live_verify.nx -- SOVEREIGN end-to-end LIVE verify: take the raw 2// HTTPS response fetched from https://nishifamily.com/video/nx_video_client.wasm 3// (response = HTTP headers + body), locate the wasm magic (\0asm), and prove the 4// BODY is exactly the rebuilt+VM-gated client wasm: body length == 12990, parses 5// under the sovereign VM, all 15 app.js exports present, vc_ladder_floor VM==native. 6// No curl/cmp/xxd -- all in-organ. expect_exit: 0 license_tier: ORIGINAL 7import "nx_syscalls.nx" 8import "nx_gate_emit_lib.nx" 9import "nx_wasm_vm.nx" 10import "nx_video_client_wasm.nx" 11 12const LIVE_PATH: *u8 = "/mnt/c/Users/elder/AppData/Local/Temp/claude/C--Users-elder/35f4610b-08b2-4d75-94eb-2f2ef485113d/scratchpad/live_vcw.wasm" 13const EXPECT_BODY: i64 = 12990 14 15func main() -> i64 { 16 g_puts("nx_video_client LIVE verify (raw HTTPS response -> find wasm body -> prove == deployed)\n" as *u8) 17 var pass: i64 = 0; var total: i64 = 0 18 19 let box: *i64 = sys_mmap(16) as *i64 20 let resp: *u8 = sys_read_file(LIVE_PATH, box) 21 if (resp as i64) == 0 { g_puts(" FAIL cannot read fetched live response\n" as *u8); g_puts("verdict=RED\n" as *u8); sys_exit(1); return 1 } 22 let rlen: i64 = box[0] 23 g_puts(" fetched response bytes=" as *u8); g_pn(rlen); g_puts("\n" as *u8) 24 25 // locate the wasm magic \0asm (00 61 73 6D) -- body starts there, HTTP headers precede it 26 var mo: i64 = 0 - 1 27 var i: i64 = 0 28 while i < rlen - 4 { 29 if resp[i] == (0 as u8) { if resp[i+1] == (0x61 as u8) { if resp[i+2] == (0x73 as u8) { if resp[i+3] == (0x6D as u8) { 30 mo = i; i = rlen 31 } } } } 32 i = i + 1 33 } 34 g_puts(" wasm magic at offset=" as *u8); g_pn(mo); g_puts(" (HTTP header bytes=" as *u8); g_pn(mo); g_puts(")\n" as *u8) 35 pass = pass + g_check("wasm magic \\0asm found in the live response" as *u8, mo >= 0); total = total + 1 36 if mo < 0 { g_puts("verdict=RED\n" as *u8); sys_exit(1); return 1 } 37 38 let body: *u8 = ((resp as i64) + mo) as *u8 39 let blen: i64 = rlen - mo 40 g_puts(" live wasm BODY bytes=" as *u8); g_pn(blen); g_puts(" (expect " as *u8); g_pn(EXPECT_BODY); g_puts(")\n" as *u8) 41 pass = pass + g_check("live body length == the deployed+VM-gated wasm (12990)" as *u8, blen == EXPECT_BODY); total = total + 1 42 43 let mod: *WasmMod = wm_new(body, blen) 44 var parse_ok: i64 = 0 45 if wm_parse(mod) == 0 { parse_ok = 1 } 46 pass = pass + g_check("live wasm body PARSES under the sovereign VM" as *u8, parse_ok); total = total + 1 47 if parse_ok == 0 { g_puts("verdict=RED\n" as *u8); sys_exit(1); return 1 } 48 mod.mem = sys_mmap(mod.mem_bytes) as *u8 49 50 var miss: i64 = 0 51 if wm_find_export(mod, "vc_wire_pack" as *u8) < 0 { miss = miss + 1 } 52 if wm_find_export(mod, "vc_wire_parse" as *u8) < 0 { miss = miss + 1 } 53 if wm_find_export(mod, "vc_ladder_floor" as *u8) < 0 { miss = miss + 1 } 54 if wm_find_export(mod, "vc_ladder_step" as *u8) < 0 { miss = miss + 1 } 55 if wm_find_export(mod, "vc_wr_u32" as *u8) < 0 { miss = miss + 1 } 56 if wm_find_export(mod, "vc_rd_u32" as *u8) < 0 { miss = miss + 1 } 57 if wm_find_export(mod, "vc_f32_to_i16" as *u8) < 0 { miss = miss + 1 } 58 if wm_find_export(mod, "vc_i16_to_f32" as *u8) < 0 { miss = miss + 1 } 59 if wm_find_export(mod, "vc_lpc_encode" as *u8) < 0 { miss = miss + 1 } 60 if wm_find_export(mod, "vc_lpc_decode" as *u8) < 0 { miss = miss + 1 } 61 if wm_find_export(mod, "vc_nv1_validate" as *u8) < 0 { miss = miss + 1 } 62 if wm_find_export(mod, "vc_nv1_next" as *u8) < 0 { miss = miss + 1 } 63 if wm_find_export(mod, "vc_nv1_header" as *u8) < 0 { miss = miss + 1 } 64 if wm_find_export(mod, "vc_nv1_chunk" as *u8) < 0 { miss = miss + 1 } 65 if wm_find_export(mod, "vc_nv1_end" as *u8) < 0 { miss = miss + 1 } 66 pass = pass + g_check("live wasm has all 15 app.js exports" as *u8, miss == 0); total = total + 1 67 68 var lf_ok: i64 = 1 69 var n: i64 = 1 70 while n <= 8 { 71 if wm_run(mod, "vc_ladder_floor" as *u8, n, 0,0,0,0, 1) != vc_ladder_floor(n) { lf_ok = 0 } 72 n = n + 1 73 } 74 pass = pass + g_check("live wasm vc_ladder_floor VM==native (the deployed governor file is faithful)" as *u8, lf_ok); total = total + 1 75 76 g_puts("---- vc LIVE verify: passed " as *u8); g_pn(pass); g_puts(" / " as *u8); g_pn(total); g_puts(" ----\n" as *u8) 77 if pass == total { g_puts("verdict=GREEN -- the LIVE family-room wasm IS the verified overseas-recovery build\n" as *u8); sys_exit(0); return 0 } 78 g_puts("verdict=RED\n" as *u8); sys_exit(1); return 1 79}