code wiki / _hdl_build / nx_seg_merkle.nx
nx_seg_merkle.nx
buildroot/runtime/_hdl_build/nx_seg_merkle.nx
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
imports: nx_syscalls.nxnx_sha256.nx
imported by: nx_seg_merkle_gate.nx
structs
| none |
consts
| none |
functions
| 10 | func 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 } |
| 11 | func 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 |
| 13 | func 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 } |
| 16 | func mk_root(leaves: *u8, n: i64, root: *u8) -> i64 |
| 34 | func mk_proof(leaves: *u8, n: i64, idx: i64, proof: *u8, dirs: *i64) -> i64 |
| 49 | func mk_verify(leaf: *u8, proof: *u8, dirs: *i64, depth: i64, root: *u8) -> i64 |