Skip to main content

Merkle Mountain Range in python

Project description

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

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

mmr.py-0.0.4.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mmr.py-0.0.4-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file mmr.py-0.0.4.tar.gz.

File metadata

  • Download URL: mmr.py-0.0.4.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for mmr.py-0.0.4.tar.gz
Algorithm Hash digest
SHA256 4052cd58b21e0f22b6b74112f42323a619aff56509e342721878b2f191e02540
MD5 56689cd43125842477bd46e191d8201f
BLAKE2b-256 81982aeb4a883fa5256ae04e89b2185143ecd8a167436dc61fac5bdb935c926c

See more details on using hashes here.

File details

Details for the file mmr.py-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: mmr.py-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for mmr.py-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d053bcab181f8b9b96090f926d52ece9a2f603fcf75663967e269bdfd5ff808f
MD5 c0fcc61bcf59ef0843f055d6c25bb098
BLAKE2b-256 79ded46d19d740cfa43af8478fa80f9b15e6069dbcede39ba3bd0d94725f0a36

See more details on using hashes here.

Supported by

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