code wiki / _hdl_build / nx_nbk.nx

nx_nbk.nx

buildroot/runtime/_hdl_build/nx_nbk.nx

7008 B149 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

⚠ DEPRECATED 2026-06-22 (audit: DUPLICATE) -- the OWNED content-addressed container ALREADY EXISTS as the sovereign storage substrate: nx_canon_cid (byte-deterministic NXR1 + CID=nxc1-+sha256) + nx_uxf_cid (multicodec profiles incl. UXF_ARCHIVE=5 + UXF_MEDIA=3) + nx_uxf_decode (tolerant reader). This file reinvented that with a WEAKER djb2 CID and non-canonical ordering. DO NOT build further on nx_nbk. The reader/media bundling rung must be a UXF_ARCHIVE packer that reuses nx_canon_cid + nx_uxf_cid (entry-name -> bytes), NOT a new format. Kept only as a reference for that rebuild. (operator: "we already built a format, audit so we avoid duplicates.") nx_nbk.nx -- the SOVEREIGN NISHI BOOK container (.nbk): the superior media format WE OWN that every lock-in format (EPUB / MOBI / AZW / PDF) migrates INTO. One self-contained, content-addressed, integrity-verified file. Format SSOT (this library; pack + reader + gate all import it so they cannot disagree). LAYOUT: header(32) | payloads (concatenated) | directory header: "NXBK"(4) ver(1)=1 flags(3)=0 | nentries(BE u32 @8) | dir_offset(BE u32 @12) | cid(BE u64 @16) | rsvd(8) payload: each entry's raw bytes, back to back, starting at offset 32 dir: nentries records: name_len(BE u16) name(bytes) data_off(BE u32) data_len(BE u32) entry_hash(BE u64) WHY SUPERIOR (vs MOBI/EPUB, which have ZERO content integrity + can carry DRM): - content-addressed: cid = djb2 over ALL payloads -> a corrupted/tampered byte is DETECTED (nbk_check) - per-entry integrity: each entry carries its own hash -> pinpoints which part corrupted - NO DRM by construction: a format we own cannot lock us out of our own device - deterministic: same inputs -> byte-identical .nbk -> reproducible, auditable CID - streamable: the directory is self-describing -> read any entry by offset without scanning the whole file (djb2 cid here is a fast content-id + corruption detector; a cryptographic CID (sha256/blake3) is a hardening rung.) license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_nbk.nx nx_nbk_gate.nx nx_nbk_pack.nx

imports: nx_syscalls.nx

imported by: nx_nbk_gate.nxnx_nbk_pack.nx

structs

none

consts

26const K_MAGIC_5381: i64 = 5381
27const K_MAGIC_67108864: i64 = 67108864

functions

29func nbk_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 2: nbk_packnbk_get
30func nbk_djb2(p: *u8, n: i64) -> i64 { var h: i64=K_MAGIC_5381; var i: i64=0; while i<n { h = ((h<<5)+h) + (p[i] as i64); i=i+1 } return h }
called by 2: nbk_packnbk_check
32func nbk_put16(m: *u8, o: i64, v: i64) -> i64 { m[o]=((v>>8)&0xff) as u8; m[o+1]=(v&0xff) as u8; return o+2 }
called by 1: nbk_pack
33func nbk_put32(m: *u8, o: i64, v: i64) -> i64 { m[o]=((v>>24)&0xff) as u8; m[o+1]=((v>>16)&0xff) as u8; m[o+2]=((v>>8)&0xff) as u8; m[o+3]=(v&0xff) as u8; return o+4 }
called by 1: nbk_pack
35func nbk_put64(m: *u8, o: i64, v: i64) -> i64
called by 1: nbk_pack
41func nbk_be16(b: *u8, o: i64) -> i64 { return ((b[o] as i64)<<8) | (b[o+1] as i64) }
called by 2: nbk_checknbk_get
42func nbk_be32(b: *u8, o: i64) -> i64 { return ((b[o] as i64)<<24)|((b[o+1] as i64)<<16)|((b[o+2] as i64)<<8)|(b[o+3] as i64) }
called by 2: nbk_checknbk_get
43func nbk_be64(b: *u8, o: i64) -> i64 { var v: i64=0; var i: i64=0; while i<8 { v = (v<<8) | (b[o+i] as i64); i=i+1 } return v }
called by 1: nbk_check
46func nbk_pack(path: *u8, names: *i64, datas: *i64, lens: *i64, count: i64) -> i64
88func nbk_check(m: *u8, n: i64) -> i64
121func nbk_get(m: *u8, n: i64, name: *u8, out: *u8, cap: i64) -> i64
called by 1: main calls 3: nbk_be32nbk_slennbk_be16