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.

Source Distribution

merkle-tree-stream-0.0.1a5.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

merkle_tree_stream-0.0.1a5-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file merkle-tree-stream-0.0.1a5.tar.gz.

File metadata

  • Download URL: merkle-tree-stream-0.0.1a5.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.8.0 Linux/4.9.0-12-amd64

File hashes

Hashes for merkle-tree-stream-0.0.1a5.tar.gz
Algorithm Hash digest
SHA256 0ae6c9397149da08d000e53b8b8bb94373b7365ac425c5eec80cd7726135147a
MD5 cac9947eec5309b0595f5a1da27afa05
BLAKE2b-256 d634096b30f916b36ac1e6241d6328e8ed8b869d465b259898053475379a85f9

See more details on using hashes here.

File details

Details for the file merkle_tree_stream-0.0.1a5-py3-none-any.whl.

File metadata

File hashes

Hashes for merkle_tree_stream-0.0.1a5-py3-none-any.whl
Algorithm Hash digest
SHA256 81f486805ef15e92f37e0b59382827ad95e3a7c968a959afb353ba9831f49b23
MD5 420f0bd735effd9e950fe5542f97678f
BLAKE2b-256 328fb06c466afc2717219fa8b0bb01c4a1388e7e12c098f6d1da9de254a57fa2

See more details on using hashes here.

Supported by

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