Skip to main content

🌳 The simple and easy implementation of Merkle Tree

Project description

🌳 Merkly

The simple and easy implementation of Python Merkle Tree


CodeQL Lint Test PyPI

GitHub last commit GitHub commit activity PyPI - Python Version PyPI - Downloads PyPI - License

Table of Contents

Credits

GitHub Contributors Image

How to install

poetry add merkly
pip install merkly

How to works

  • We use keccak-256 under-the-hood

This library provides a clean and easy to use implementation of the Merkle Tree with the following features:

  • Create Leaf
  • Create Root
  • Create Proof
  • Verify Proof
merkle-tree

How to Use

Create a Merkle Tree

from merkly.mtree import MerkleTree

# create a Merkle Tree
mtree = MerkleTree(['a', 'b', 'c', 'd']

# show original input
assert mtree.raw_leafs == ['a', 'b', 'c', 'd']

# show leafs 
assert mtree.leafs == []

Create a Root

from merkly.mtree import MerkleTree

# create a Merkle Tree
mtree = MerkleTree(['a', 'b', 'c', 'd'])

# get root of tree
assert mtree.root == ""

Create Proof of a leaf

from merkly.mtree import MerkleTree

# create a Merkle Tree
mtree = MerkleTree(['a', 'b', 'c', 'd'])

# get proof of a leaf
assert mtree.proof("b") == []

Verify Proof of a leaf

from merkly.mtree import MerkleTree

# create a Merkle Tree
mtree = MerkleTree(['a', 'b', 'c', 'd'])

# get proof of a leaf
p = mtree.proof("b")

# verify your proof
assert mtree.verify(p) == True

Roadmap

Feature Status Priority
Create Root 🔥
Create Proof 🔥
Verify Proof 🔥
Support OpenZeppelin 🔥
Compatible with MerkleTreeJs 🔥
Use any Hash function 🧐
Leafs of any size 🧐

Contributing

License

MIT

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

merkly-0.5.1.tar.gz (6.0 kB view hashes)

Uploaded Source

Built Distribution

merkly-0.5.1-py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 3

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