Skip to main content

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

Project description

merkle-tree-stream

Build Status

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

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.

Install

$ pip install merkle-tree-stream

Example

import hashlib

def _leaf(node, roots=None):
    return hashlib.sha256(node.data).digest()

def _parent(first, second):
    sha256 = hashlib.sha256()
    sha256.update(first.data)
    sha256.update(second.data)
    return sha256.digest()

merkle = MerkleTreeGenerator(leaf=leaf, parent=parent)

merkle.write(b"a")
merkle.write(b"b")

assert len(merkle) == 2 + 1

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.1a5
Filename, size File type Python version Upload date Hashes
Filename, size merkle_tree_stream-0.0.1a5-py3-none-any.whl (15.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size merkle-tree-stream-0.0.1a5.tar.gz (15.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page