A Merkle tree supporting append, update, remove operations.
Project description
Mutable Merkle
mutable_merkle
provides a merkle tree with append, update and remove leaf functionality. This
is intended to support solutions that are not just append only.
m1 = mutable_merkle.tree.MerkleTree.new([b"a", b"b", b"c", b"e", b"f"], hash_type="sha256")
m2 = mutable_merkle.tree.MerkleTree.new([b"a", b"b", b"c", b"d", b"e", b"f"], hash_type="sha256")
m3 = mutable_merkle.tree.MerkleTree(hash_type="sha256")
m2.remove_leaf(3)
for value in [b"a", b"b", b"c", b"e", b"f"]:
m3.add_leaf(value)
assert m1.root == m2.root
assert m1.root == m3.root
Serialization
Along with update and remove leaf functionality, mutable_merkle
has been designed
around being serializable as well. This supports storage of the merkle tree as well
as transmission of the proofs.
mt = mutable_merkle.tree.MerkleTree.new(
[b"a", b"b", b"c", b"d", b"e", b"f", b"g", b"h", b"i", b"j"],
hash_type=hash_type,
)
payload = mt.marshal()
mt_reload = mutable_merkle.tree.MerkleTree.unmarshal(payload)
assert mt == mt_reload
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
mutable_merkle-0.1.1.tar.gz
(8.0 kB
view details)
Built Distribution
File details
Details for the file mutable_merkle-0.1.1.tar.gz
.
File metadata
- Download URL: mutable_merkle-0.1.1.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.6.8 Linux/5.0.0-37-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 392a3cf26bae21ceeaf4696fe91071d13070bf3acdd8854bb734ed6c7210ec6c |
|
MD5 | ba68cdb6fea12bbe1e5bfe50e48e2833 |
|
BLAKE2b-256 | 1aaae27be73d4e0c209072e2b5d8fa4ca6ff30b4c79365a4997ba4977b00035f |
File details
Details for the file mutable_merkle-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: mutable_merkle-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.6.8 Linux/5.0.0-37-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c31c574d4708a8ff8c86d8688c43bff21034223f90946bf3b8c9b45ac5fb4a3 |
|
MD5 | 30c41d71b766f6429bbf706618c4a6cd |
|
BLAKE2b-256 | 5f8beac3b7345f34ad7326799d85b643b84e7a449456e94373d5fa4c179b459d |