dig-smt
The DIG Network generic sparse-merkle-tree mechanism: a sha256 SMT over 32-byte keys with real
membership and non-membership proofs. Extracted verbatim (byte-identical roots) from
dig-identity's profile tree so the mechanism can be
reused without pulling in any DIG-domain code.
dig-smt is the generic MECHANISM only — it knows nothing about DIG slots, values, profiles, or
DIDs. A caller supplies raw 32-byte keys and opaque value bytes; a higher-level crate builds a domain
schema (slot-key derivation, value encoding) on top and consumes this tree.
It wraps the audited Nervos sparse-merkle-tree crate
— the merkle construction is never re-implemented; dig-smt supplies only the sha256 node hasher and
the leaf-hash scheme.
Byte-contract
For a given set of (key, value) leaves, the 32-byte root is byte-identical to dig-identity's
current profile root. A DIG profile root is on-chain-anchored, so this is a frozen §5.1 / NC-9
contract, pinned by a golden root vector (tests/golden_root.rs). See SPEC.md for the
normative hashing and proof contract.
Usage
use ;
let mut tree = new;
let name_key = ;
tree.set.unwrap;
let root = tree.root;
// Prove the key holds "Ada" using only (root, key, value, proof).
let membership = tree.prove_membership.unwrap;
assert!;
// Prove a different key is absent.
let absent_key = ;
let absent = tree.prove_non_membership.unwrap;
assert!;
Install
[]
= "0.1"
License
GPL-2.0-only.