Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thewawar/exclusion-merkle-cbt
Complete Binary Merkle Tree for verify exclusion
https://github.com/thewawar/exclusion-merkle-cbt
blacklist exclusion merkle tree
Last synced: about 1 month ago
JSON representation
Complete Binary Merkle Tree for verify exclusion
- Host: GitHub
- URL: https://github.com/thewawar/exclusion-merkle-cbt
- Owner: TheWaWaR
- Created: 2021-07-08T14:40:59.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-09-15T03:05:44.000Z (over 2 years ago)
- Last Synced: 2024-11-21T17:46:31.513Z (about 1 month ago)
- Topics: blacklist, exclusion, merkle, tree
- Language: Rust
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Exclusion Complete Binary Merkle Tree
A merkle tree based on Nervos [Complete Binary Merkle Tree](https://github.com/nervosnetwork/merkle-tree) to support verifiing a leaf is not on a certain tree.## Example Usage
```rust
type StrKey = &'static str;
type StrLeaf = SimpleLeaf;
type StrRangeLeaf = SimpleRangeLeaf;
// A helper to compute root and build proof
type StrExCBMT = SimpleExclusionCBMT;// Can be seen as a black list
let all_leaves: Vec = vec!["b", "e", "g", "x"]
.into_iter()
.map(StrLeaf::new_with_key)
.collect();
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();
assert_eq!(
proof
.range_leaves()
.iter()
.map(|l| (*l.key(), *l.next_key()))
.collect::>(),
vec![("e", "g"), ("x", "b")]
);
assert!(proof
.verify_exclusion(&root, &excluded_keys)
.is_ok());
```