A stream that generates a merkle tree based on the incoming data.
Project description
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:
The Dat Protocol: Merkle Tree
The Dat Protocol: Merkle Tree Stream
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. However, there is currently no stream implemented, only a generator is available. This is because the reference implementation of Hypercore 7 makes use of the generator only. A stream implementation may follow.
from hashlib import sha256
from merkle_tree_stream import MerkleTreeGenerator
def leaf(node, roots=None):
return 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('hello')
merkle.write('hashed')
merkle.write('world')
Documentation
Mirroring
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file merkle-tree-stream-0.0.1a3.tar.gz
.
File metadata
- Download URL: merkle-tree-stream-0.0.1a3.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18454663735ddc0b2b66f6fea754793c96a92dba9889839bb659ed6d7aff1162 |
|
MD5 | f106e802d0b58e615fdd992495efb83c |
|
BLAKE2b-256 | 4895aa2660d2189e89b5b033fd4c1081dab00e2934047113e02ca4091922f3f6 |
File details
Details for the file merkle_tree_stream-0.0.1a3-py3-none-any.whl
.
File metadata
- Download URL: merkle_tree_stream-0.0.1a3-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59fe50bebcd9e953709db0d6e8f04629c225e710a2812f38f53d8079ae8c5270 |
|
MD5 | 62ba93340cced6e81bcdc8c7caaedb0b |
|
BLAKE2b-256 | 48d0294992824f88284ef50fe0c6f336b777610463a45a8f479328dee529da9e |