Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jjyr/mmr.py
Merkle Mountain Range in python
https://github.com/jjyr/mmr.py
merkle-mountain-range merkle-tree mmr python
Last synced: 2 months ago
JSON representation
Merkle Mountain Range in python
- Host: GitHub
- URL: https://github.com/jjyr/mmr.py
- Owner: jjyr
- Created: 2019-06-27T15:31:47.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-06T03:36:58.000Z (over 5 years ago)
- Last Synced: 2024-10-11T01:08:35.337Z (3 months ago)
- Topics: merkle-mountain-range, merkle-tree, mmr, python
- Language: Python
- Size: 36.1 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MMR.py
Merkle Mountain Range
## Install
`pip3 install -U git+https://github.com/jjyr/mmr.py.git`
## Example
``` python
from mmr import MMRdef 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](tests) to learn more.
## License
MIT