code wiki / (root) / nx_asset_merkle.nx

nx_asset_merkle.nx

buildroot/runtime/nx_asset_merkle.nx

4267 B107 linesdepth 9pulls 11 transitivereach 2 importersview sourcekind librarytopic asset
docsdependenciesstructsconstsfunctions

about

nx_asset_merkle.nx -- UNIVERSAL ORGANIZATION TOOLING arc, R8: WHOLE-INVENTORY MERKLE ROOT. org_research.tsv merkle-integrity (CONFIRMED): a MERKLE DAG over the content makes the WHOLE inventory tamper-evident + independently VERIFIABLE -- any byte change anywhere flips a single root hash, cheap to re-prove (the property git + IPFS have; incumbent DAM/KM on mutable DBs do NOT). R0 already gives PER-RECORD content-addressed integrity (each record's CID); this organ lifts it to the WHOLE catalog: one root hash over the set of member record CIDs. PURE COMPOSITION (Rule 15), ZERO new crypto: leaves = the R1 catalog's member CIDs (cat_list); the tree-hash is nx_canon_cid cid_of (the SAME sha256-based CID the records use). DETERMINISTIC + ORDER-INDEPENDENT: the leaves are SORTED before pairing, so the root depends only on the SET of records, never on insertion order -> the same inventory yields the same root on any machine. Construction: sort leaf CIDs; repeatedly pair adjacent nodes and hash parent = cid_of(left||right) (an odd node duplicates with itself), until one root remains. 0 leaves -> a fixed EMPTY root; 1 leaf -> cid_of(that leaf) so even a singleton inventory has a hashed root. No hardware/persistent-firmware writes (Rule 26). license_tier: ORIGINAL

dependencies 3 imports · 2 importers

nx_syscalls.nx nx_canon_cid.nx nx_asset_catalog.nx nx_asset_merkle.nx nx_asset_exceed_gate.nx nx_asset_merkle_gate.nx

imports: nx_syscalls.nxnx_canon_cid.nxnx_asset_catalog.nx

imported by: nx_asset_exceed_gate.nxnx_asset_merkle_gate.nx

structs

none

consts

21const K_MAGIC_4096: i64 = 4096

functions

23func mr_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: mr_root
26func mr_strcmp(a: *u8, b: *u8) -> i64
called by 2: mr_sortmr_contains
39func mr_sort(cids: *i64, n: i64) -> i64
called by 1: mr_root calls 1: mr_strcmp
57func mr_concat_hash(l: *u8, r: *u8, out: *u8) -> i64
called by 1: mr_root calls 2: sys_mmapcid_of
69func mr_root(prefix: *u8, out_root: *u8) -> i64
101func mr_contains(prefix: *u8, cid: *u8) -> i64