Skip to main content

Python port of merkletreejs

Project description

                _   _     _
  _ __  ___ _ _| |_| |___| |_ _ _ ___ ___ _ __ _  _
 | '  \/ -_) '_| / / / -_)  _| '_/ -_) -_) '_ \ || |
 |_|_|_\___|_| |_\_\_\___|\__|_| \___\___| .__/\_, |
                                         |_|   |__/

MerkleTree.py

A Python port of merkletreejs. :warning: Currently EXTREMELY unstable and doesn't work for many cases yet. :warning:

PyPI version

Installation

pip install merkletreepy

Working Code Examples

sha256

from merkletreepy import MerkleTree
import hashlib

def sha256(x):
    return hashlib.sha256(x).digest()

leaves = [sha256(leaf.encode()) for leaf in "abc"]
tree = MerkleTree(leaves, sha256)
root = tree.get_root()
leaf = sha256("a".encode())
bad_leaf = sha256("x".encode())
proof = tree.get_proof(leaf)
tree.verify(proof, leaf, root)      # returns True
tree.verify(proof, bad_leaf, root)  # returns False

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

merkletreepy-0.0.4.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file merkletreepy-0.0.4.tar.gz.

File metadata

  • Download URL: merkletreepy-0.0.4.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10

File hashes

Hashes for merkletreepy-0.0.4.tar.gz
Algorithm Hash digest
SHA256 2981d218e03d0c53cc1ed7dbc2d4d8426986e120c3544458a404483124024816
MD5 6dd6d532ca1e50402328515e8d16143e
BLAKE2b-256 094339bb0ac9b1aed291f45edad373fb3836ebc8dab10af0dd8a0e9e4ffe4897

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