Skip to main content

Simple Merkle Tree

Project description

# pymerkletools
[![PyPI version](https://badge.fury.io/py/merkletools.svg)](https://badge.fury.io/py/merkletools)
[![Build Status](https://travis-ci.org/aliciawyy/pymerkletools.svg?branch=master)](https://travis-ci.org/aliciawyy/pymerkletools)
[![codecov](https://codecov.io/gh/aliciawyy/pymerkletools/branch/master/graph/badge.svg)](https://codecov.io/gh/aliciawyy/pymerkletools)
[![Maintainability](https://api.codeclimate.com/v1/badges/cfa9766c9537f10f72f1/maintainability)](https://codeclimate.com/github/aliciawyy/pymerkletools/maintainability)

This project is adapted from the [pymerkletools](https://github.com/aliciawyy/pymerkletools) of Tierion.

It includes a `MerkleTree` class for creating Merkle trees, generating merkle proofs, and verification of merkle proofs.

## Installation

```
pip install pymerkletree
```

## Examples

The source code is simple by itself and examples can be found in the folder `demo`.

## Notes

### About tree generation

1. Internally, leaves are stored as `bytearray`. When the tree is built, it is
generated by hashing together the `bytearray` values.
2. Lonely leaf nodes are promoted to the next level up, as depicted below.

ROOT=Hash(H+E)
/ \
/ \
H=Hash(F+G) E
/ \ \
/ \ \
F=Hash(A+B) G=Hash(C+D) E
/ \ / \ \
/ \ / \ \
A B C D E


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

pymerkletree-1.0.5.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distributions

pymerkletree-1.0.5-py3-none-any.whl (5.5 kB view hashes)

Uploaded Python 3

pymerkletree-1.0.5-py2-none-any.whl (5.5 kB view hashes)

Uploaded Python 2

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