A Sparse Merkle Tree for a key/value map
Project description
Sparse Merkle Tree
A Sparse Merkle Tree for a key/value map.
This is a Python port of the great work here: celestiaorg
The tree implements the same optimisations specified in the Libra whitepaper, to reduce the number of hash operations required per tree operation to O(k) where k is the number of non-empty elements in the tree.
Example
tree = SparseMerkleTree()
root = tree.update(b"a", b"a1")
assert b"a1" == tree.get(b"a")
proof = tree.prove(b"a")
assert verify_proof(proof, root, b"a", b"a1")
tree.delete(b"a")
assert b"" == tree.get(b"a")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sparse-merkle-tree-0.3.0.tar.gz
(10.4 kB
view hashes)
Built Distribution
Close
Hashes for sparse_merkle_tree-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e92ac231bec8f8e8993465a110bdb27bc9af08d3bbed364d59322e6ddaae1b6 |
|
MD5 | 5aa7d4f4965cd7d60a147eba839e9da8 |
|
BLAKE2b-256 | 58e93defee8f5ed04a8e05b9f578bbfa1b9721dc110fd8043de7b823fb6d71ee |