Skip to main content

MMR.py

Merkle Mountain Range

Install

pip3 install -U git+https://github.com/jjyr/mmr.py.git

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

Release files for mmr.py 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mmr.py 0.0.4
File Size Uploaded
mmr.py-0.0.4.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mmr.py 0.0.4
File Interpreter ABI Platform
mmr.py-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 9.1 kB

Release files / mmr.py-0.0.4.tar.gz

Download URL mmr.py-0.0.4.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4052cd58b21e0f22b6b74112f42323a619aff56509e342721878b2f191e02540
BLAKE2b-256 checksum
How to use checksums
81982aeb4a883fa5256ae04e89b2185143ecd8a167436dc61fac5bdb935c926c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Release files / mmr.py-0.0.4-py3-none-any.whl

Download URL mmr.py-0.0.4-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d053bcab181f8b9b96090f926d52ece9a2f603fcf75663967e269bdfd5ff808f
BLAKE2b-256 checksum
How to use checksums
79ded46d19d740cfa43af8478fa80f9b15e6069dbcede39ba3bd0d94725f0a36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page