#merkle #proof #blacklist #exclusion

no-std exclusion-merkle-cbt

Complete Binary Merkle Tree for verify exclusion

6 releases

0.3.3 Jul 12, 2021
0.3.2 Jul 10, 2021
0.2.1 Jul 9, 2021
0.1.0 Jul 8, 2021

#1197 in Data structures

22 downloads per month

MIT license

387 lines

Exclusion Complete Binary Merkle Tree

A merkle tree based on Nervos Complete Binary Merkle Tree to support verifiing a leaf is not on a certain tree.

Example Usage

type StrKey = &'static str;
type StrLeaf = SimpleLeaf<StrKey>;
type StrRangeLeaf = SimpleRangeLeaf<StrKey, Blake2bHasher>;
// A helper to compute root and build proof
type StrExCBMT = SimpleExclusionCBMT<StrKey, Blake2bHasher, MergeBlake2bH256>;

// Can be seen as a black list
let all_leaves: Vec<StrLeaf> = vec!["b", "e", "g", "x"]
let root = StrExCBMT::compute_root(&all_leaves);
// The keys not in the black list
let excluded_keys = vec!["f", "y", "z", "a"];
let proof = StrExCBMT::build_proof(&all_leaves, &excluded_keys).unwrap();
        .map(|l| (*l.key(), *l.next_key()))
    vec![("e", "g"), ("x", "b")]
    .verify_exclusion(&root, &excluded_keys)