{"id":24231828,"url":"https://github.com/olivmath/merkly","last_synced_at":"2025-08-09T19:38:38.422Z","repository":{"id":37513302,"uuid":"505456709","full_name":"olivmath/merkly","owner":"olivmath","description":"🌳  The simple and easy implementation of Merkle Tree","archived":false,"fork":false,"pushed_at":"2025-01-01T10:48:15.000Z","size":2095,"stargazers_count":56,"open_issues_count":10,"forks_count":13,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T17:02:19.256Z","etag":null,"topics":["blockchain","brownie","cryptography","ethereum","keccak256","merkle-proof","merkle-root","merkle-tree","nft","python","smart-contracts","solidity","vyper","vyper-contracts","whitelist"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/merkly","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/olivmath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-20T13:38:40.000Z","updated_at":"2025-03-11T14:17:12.000Z","dependencies_parsed_at":"2025-01-14T14:41:08.285Z","dependency_job_id":"cac2a581-bc8b-46a8-b516-56f3137a1402","html_url":"https://github.com/olivmath/merkly","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":"olivmath/template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivmath%2Fmerkly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivmath%2Fmerkly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivmath%2Fmerkly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivmath%2Fmerkly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olivmath","download_url":"https://codeload.github.com/olivmath/merkly/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378138,"owners_count":20929296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","brownie","cryptography","ethereum","keccak256","merkle-proof","merkle-root","merkle-tree","nft","python","smart-contracts","solidity","vyper","vyper-contracts","whitelist"],"created_at":"2025-01-14T14:35:57.326Z","updated_at":"2025-04-05T18:05:25.672Z","avatar_url":"https://github.com/olivmath.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pypi.org/project/merkly/\"\u003e\n    \u003cimg alt=\"Merkly\" src=\"https://raw.githubusercontent.com/olivmath/merkly/main/assets/merkly-banner.png\" width=\"1000\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003eThe simple and easy implementation of Python Merkle Tree.\u003c/p\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://pypi.org/project/merkly/\"\u003e\n        \u003cimg src=\"https://img.shields.io/pypi/v/merkly\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/olivmath/merkly/actions/workflows/ci.yml\"\u003e\n        \u003cimg src=\"https://github.com/olivmath/merkly/actions/workflows/ci.yml/badge.svg?branch=main\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pypi.org/project/merkly/\"\u003e\n        \u003cimg src=\"https://img.shields.io/pypi/pyversions/merkly\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pypi.org/project/merkly/\"\u003e\n        \u003cimg src=\"https://img.shields.io/pypi/dm/merkly\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/olivmath/merkly/graphs/code-frequency\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/commit-activity/m/olivmath/merkly\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/olivmath/merkly/blob/main/LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/pypi/l/merkly\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## Table of Contents\n\n- [Credits](#credits)\n- [Documentation](#Documentation)\n- [Roadmap](#roadmap)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Credits\n\n[![GitHub Contributors Image](https://contrib.rocks/image?repo=olivmath/merkly)](https://github.com/olivmath/merkly/graphs/contributors)\n\n## Documentation\n\n**HOW TO INSTALL**\n\n```\npoetry add merkly\n```\n\n```\npip install merkly\n```\n\n**HOW TO WORKS**\n\n\u003e **WARNING:** We use keccak-256 under-the-hood if you dont pass your hash function\n\nThis library provides a clean and easy to use implementation of the Merkle Tree with the following features:\n\n- Create Leaf\n- Create Root\n- Create Proof\n- Verify Proof\n\n**HOW TO USE**\n\n**Creating a Merkle Tree**\n\n```python\nfrom merkly.mtree import MerkleTree\nfrom typing import Callable\n\n# choose any hash function that is of type (bytes, bytes) -\u003e bytes\nmy_hash_function: Callable[[bytes, bytes], bytes] = lambda x, y: x + y\n\n# create a Merkle Tree\nmtree = MerkleTree(['a', 'b', 'c', 'd'], my_hash_function)\n\n# show original input\nassert mtree.raw_leaves == ['a', 'b', 'c', 'd']\n\n# hashed leaves\nassert mtree.leaves == [b'a', b'b', b'c', b'd']\n\n# shorted hashed leaves\nassert mtree.short_leaves == [b'a', b'b', b'c', b'd']\n```\n\n**Creating a Default Merkle Tree (with Keccak256)**\n\n```python\nfrom merkly.mtree import MerkleTree\n\n# create a Merkle Tree with keccak256\nmtree = MerkleTree(['a', 'b', 'c', 'd'])\n\n# show original input\nassert mtree.raw_leaves == ['a', 'b', 'c', 'd']\n\n# hashed leaves (just bytes)\nassert mtree.leaves == [\n    b':\\xc2%\\x16\\x8d\\xf5B\\x12\\xa2\\\\\\x1c\\x01\\xfd5\\xbe\\xbf\\xea@\\x8f\\xda\\xc2\\xe3\\x1d\\xddo\\x80\\xa4\\xbb\\xf9\\xa5\\xf1\\xcb', b'\\xb5U=\\xe3\\x15\\xe0\\xed\\xf5\\x04\\xd9\\x15\\n\\xf8-\\xaf\\xa5\\xc4f\\x7f\\xa6\\x18\\xed\\no\\x19\\xc6\\x9bA\\x16lU\\x10', b'\\x0bB\\xb69\u003c\\x1fS\\x06\\x0f\\xe3\\xdd\\xbf\\xcdz\\xad\\xcc\\xa8\\x94FZZC\\x8fi\\xc8}y\\x0b\"\\x99\\xb9\\xb2', b'\\xf1\\x91\\x8e\\x85b#n\\xb1z\\xdc\\x85\\x023/L\\x9c\\x82\\xbc\\x14\\xe1\\x9b\\xfc\\n\\xa1\\n\\xb6t\\xffu\\xb3\\xd2\\xf3'\n]\n\n# shorted hashed leaves\nassert mtree.short_leaves == [b':\\xc2', b'\\xb5U', b'\\x0bB', b'\\xf1\\x91']\n\n\n# human leaves\nassert mtree.human_leaves == [\n    \"3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb\",\n    \"b5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510\",\n    \"0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2\",\n    \"f1918e8562236eb17adc8502332f4c9c82bc14e19bfc0aa10ab674ff75b3d2f3\",\n]\n# shorted human hashed leaves\nassert mtree.human_short_leaves == [\"3ac2\", \"b555\", \"0b42\", \"f191\"]\n```\n\n**Creating a Root**\n\n```python\nfrom merkly.mtree import MerkleTree\n\n# create a Merkle Tree\nmtree = MerkleTree(['a', 'b', 'c', 'd'])\n\n# get root of tree (This is compatible with MerkleTreeJS)\nassert mtree.root.hex() == '68203f90e9d07dc5859259d7536e87a6ba9d345f2552b5b9de2999ddce9ce1bf'\n```\n\n**Creating Proof of a leaf**\n\n```python\nfrom merkly.mtree import MerkleTree\nfrom merkly.node import Node, Side\n\n# create a Merkle Tree\nmtree = MerkleTree(['a', 'b', 'c', 'd'])\n\n# get proof of a `raw` leaf\nassert mtree.proof('b') == [\n    Node(\n        data=b\"3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb\",\n        side=Side.LEFT\n    ),\n    Node(\n        data=b\"d253a52d4cb00de2895e85f2529e2976e6aaaa5c18106b68ab66813e14415669\",\n        side=Side.RIGHT\n    )\n]\n```\n\n**Checking the proof of a sheet**\n\n```python\nfrom merkly.mtree import MerkleTree\nfrom merkly.node import Node, Side\n\n\n# create a Merkle Tree\nmtree = MerkleTree(['a', 'b', 'c', 'd'])\n\n# get proof of a raw leaf\np = [\n    Node(\n        data=b\"3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb\",\n        side=Side.LEFT\n    ),\n    Node(\n        data=b\"d253a52d4cb00de2895e85f2529e2976e6aaaa5c18106b68ab66813e14415669\",\n        side=Side.RIGHT\n    )\n]\n\n# verify your proof of raw leaf\nassert mtree.verify(p, 'b') == True\n```\n\n## Roadmap\n\n| Feature                               | Status      | Version |\n| ------------------------------------- | ----------- | ------- |\n| Auto deploy PyPi                      | ✅ Deployed | 0.2.0   |\n| Create Root                           | ✅ Deployed | 0.4.0   |\n| Create Proof                          | ✅ Deployed | 0.5.0   |\n| Verify Proof                          | ✅ Deployed | 0.6.0   |\n| Use any Hash function                 | ✅ Deployed | 0.7.0   |\n| Leafs of any size                     | ✅ Deployed | 0.8.0   |\n| Security deprecation pysha3           | ✅ Deployed | 0.8.1   |\n| Compatible with MerkleTreeJs          | ✅ Deployed | 1.0.0   |\n| First Issue solved by community       | ✅ Deployed | 1.0.0   |\n| Human readable leaves                 | ✅ Deployed | 1.1.0   |\n| Accelerator code with Rust            | 🏗️ Alpha    | 1.2.0   |\n| Tutorial how to use with solidity     | 🖊️ Design   | x.x.x   |\n| Tutorial how to use with MerkleTreeJS | 🖊️ Design   | x.x.x   |\n\n## Contributing\n\n- Before read a code of conduct: **[CODE_OF_CONDUCT](CODE_OF_CONDUCT.md)**\n- Follow the guide of development: **[CONTRIBUTING](CONTRIBUTING.md)**\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folivmath%2Fmerkly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folivmath%2Fmerkly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folivmath%2Fmerkly/lists"}