Metadata-Version: 2.1
Name: merkle-tree-stream
Version: 0.0.1a3
Summary: A stream that generates a merkle tree based on the incoming data.
Home-page: https://hack.decentral1.se/datpy/merkle-tree-stream
Author: decentral1se
Author-email: lukewm@riseup.net
Maintainer: decentral1se
Maintainer-email: lukewm@riseup.net
License: GPLv3
Project-URL: Source Code, https://hack.decentral1.se/datpy/merkle-tree-stream
Project-URL: Documentation, https://merkle-tree-stream.readthedocs.io/
Project-URL: Maintainer Support, https://decentral1.se
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Requires-Python: >=3.6
Requires-Dist: attrs (<20.0,>=19.1.0)
Requires-Dist: flat-tree (<1.0,>=0.0.1a3)
Provides-Extra: changelog
Requires-Dist: towncrier (<20.0,<=19.2.0) ; extra == 'changelog'
Provides-Extra: docs
Requires-Dist: sphinx ; extra == 'docs'
Requires-Dist: sphinx-autodoc-typehints (<2.0,>=1.6.0) ; extra == 'docs'

.. _header:

******************
merkle-tree-stream
******************

.. image:: https://img.shields.io/badge/license-MIT-brightgreen.svg
   :target: LICENSE
   :alt: Repository license

.. image:: https://badge.fury.io/py/merkle-tree-stream.svg
   :target: https://badge.fury.io/py/merkle-tree-stream
   :alt: PyPI package

.. image:: https://travis-ci.com/datpy/merkle-tree-stream.svg?branch=master
   :target: https://travis-ci.com/datpy/merkle-tree-stream
   :alt: Travis CI result

.. image:: https://readthedocs.org/projects/merkle-tree-stream/badge/?version=latest
   :target: https://merkle-tree-stream.readthedocs.io/en/latest/
   :alt: Documentation status

.. image:: https://img.shields.io/badge/support-maintainers-brightgreen.svg
   :target: https://decentral1.se
   :alt: Support badge

.. _introduction:

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

From `The Dat Protocol`_: 

.. _The Dat Protocol: https://datprotocol.github.io/book/ch01-01-flat-tree.html

    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.

    .. _Flat Trees: https://flat-tree.readthedocs.io/en/latest/

See the following for more:

  * The Dat Protocol: `Merkle Tree`_
  * The Dat Protocol: `Merkle Tree Stream`_

.. _Merkle Tree: https://datprotocol.github.io/book/ch01-02-merkle-tree.html
.. _Merkle Tree Stream: https://datprotocol.github.io/book/ch02-02-merkle-tree-stream.html

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.

.. _merkle-tree-stream: https://github.com/mafintosh/merkle-tree-stream
.. _stream: https://docs.python.org/3/library/asyncio-stream.html

.. _example:

.. code-block:: python

    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:

Documentation
*************

* `merkle-tree-stream.readthedocs.io`_

.. _merkle-tree-stream.readthedocs.io: https://merkle-tree-stream.readthedocs.io/

Mirroring
*********

* `hack.decentral1.se/datpy/merkle-tree-stream`_
* `github.com/datpy/merkle-tree-stream`_

.. _hack.decentral1.se/datpy/merkle-tree-stream: https://hack.decentral1.se/datpy/merkle-tree-stream
.. _github.com/datpy/merkle-tree-stream: https://github.com/datpy/merkle-tree-stream


