Skip to main content

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.


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")

assert b"" == tree.get(b"a")

Project details

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)

Uploaded source

Built Distribution

sparse_merkle_tree-0.3.0-py3-none-any.whl (11.2 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page