code wiki / _hdl_build / nx_seg_merkle.nx

nx_seg_merkle.nx

buildroot/runtime/_hdl_build/nx_seg_merkle.nx

3250 B59 linesdepth 5pulls 5 transitivereach 1 importersview sourcekind librarytopic seg
docsdependenciesstructsconstsfunctions

about

nx_seg_merkle.nx -- CAP-SEG-MERKLE: Merkle proof-of-inclusion over a sovereign store's records (IPLD / certificate-transparency class). A verifier holding ONLY the 32-byte ROOT + a compact O(log n) PROOF can confirm a record is in the store WITHOUT reading the store -- tamper-evident inclusion, portable (root+proof cross the interop boundary that nx_seg_store's published spec opens). leaf = a 32-byte record hash; node = sha256(left||right); odd tail duplicates itself (Bitcoin/CT convention). Composes nx_sha256. A LIBRARY (no main -> run its _gate). license_tier: ORIGINAL

dependencies 2 imports · 1 importers

nx_syscalls.nx nx_sha256.nx nx_seg_merkle.nx nx_seg_merkle_gate.nx

imports: nx_syscalls.nxnx_sha256.nx

imported by: nx_seg_merkle_gate.nx

structs

none

consts

none

functions

10func mk_cpy(dst: *u8, src: *u8, n: i64) -> i64 { var i: i64=0; while i<n { dst[i]=src[i]; i=i+1 } return 0 }
11func mk_eq(a: *u8, b: *u8, n: i64) -> i64 { var i: i64=0; while i<n { if a[i]!=b[i] { return 0 } i=i+1 } return 1 }
called by 1: mk_verify
13func mk_node(l: *u8, r: *u8, out: *u8) -> i64 { let b: *u8=sys_mmap(64); mk_cpy(b, l, 32); mk_cpy((b as i64 + 32) as *u8, r, 32); sha256_digest(b, 64, out); return 0 }
16func mk_root(leaves: *u8, n: i64, root: *u8) -> i64
called by 1: main calls 3: sys_mmapmk_cpymk_node
34func mk_proof(leaves: *u8, n: i64, idx: i64, proof: *u8, dirs: *i64) -> i64
called by 1: main calls 3: sys_mmapmk_cpymk_node
49func mk_verify(leaf: *u8, proof: *u8, dirs: *i64, depth: i64, root: *u8) -> i64
called by 1: main calls 4: sys_mmapmk_cpymk_nodemk_eq