nx_asset_merkle.nx
buildroot/runtime/nx_asset_merkle.nx
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
imports: nx_syscalls.nxnx_canon_cid.nxnx_asset_catalog.nx
imported by: nx_asset_exceed_gate.nxnx_asset_merkle_gate.nx
structs
| none |
consts
| 21 | const K_MAGIC_4096: i64 = 4096 |
functions
| 23 | func 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 |
| 26 | func mr_strcmp(a: *u8, b: *u8) -> i64 |
| 39 | func mr_sort(cids: *i64, n: i64) -> i64 |
| 57 | func mr_concat_hash(l: *u8, r: *u8, out: *u8) -> i64 |
| 69 | func mr_root(prefix: *u8, out_root: *u8) -> i64 |
| 101 | func mr_contains(prefix: *u8, cid: *u8) -> i64 |