Merkle Mountain Range in python
Project description
MMR.py
Merkle Mountain Range
Install
pip3 install mmr.py
Example
from mmr import MMR
def test_mmr():
def serialize(i):
return i.to_bytes(4, 'little')
mmr = MMR()
# push 0..11 into MMR, and record MMR positions
positions = [mmr.add(serialize(i)) for i in range(0, 11)]
merkle_root = mmr.get_root()
# proof
elem = 5
pos = positions[elem]
# generate proof for 5
proof = mmr.gen_proof(pos)
# verify proof
result = proof.verify(root=merkle_root, pos=pos,
elem=serialize(elem))
assert(result)
print("Ok")
test_mmr()
See tests to learn more.
License
MIT
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
mmr.py-0.0.3.tar.gz
(4.0 kB
view hashes)
Built Distribution
mmr.py-0.0.3-py3-none-any.whl
(4.9 kB
view hashes)