Skip to main content

A stream that generates a merkle tree based on the incoming data.

Project description

Repository license PyPI package Travis CI result Documentation status Support badge

A stream that generates a merkle tree based on the incoming data

From The Dat Protocol:

A hash tree or merkle tree is a tree in which every leaf node is labelled with the hash of a data block and every non-leaf node is labelled with the cryptographic hash of the labels of its child nodes. Merkle trees in Dat are specialized flat trees that contain the content of the archives.

See the following for more:

A note on naming

For the purposes of uniformity and easy of discovery alongside the reference implementation, we use the same module name as merkle-tree-stream. This may cause confusion since it is not clear what exactly is referred to when using the term “stream” in the context of Python. To be clear, this module provides a Python iterator which appears to match the implementation and meaning of the reference implementation.

from hashlib import sha256
from merkle_tree_stream import MerkleTreeIterator

def leaf(node, roots=None):
    return sha256(

def parent(first, second):
    sha256 = hashlib.sha256()
    return sha256.digest()

merkle_iter = MerkleTreeIterator(leaf=leaf, parent=parent)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for merkle-tree-stream, version 0.0.1a2
Filename, size File type Python version Upload date Hashes
Filename, size merkle_tree_stream-0.0.1a2-py3-none-any.whl (6.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size merkle-tree-stream-0.0.1a2.tar.gz (10.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page