{"id":24231500,"url":"https://github.com/olivmath/merkletreers","last_synced_at":"2025-09-22T23:31:57.356Z","repository":{"id":60735027,"uuid":"545093817","full_name":"olivmath/merkletreers","owner":"olivmath","description":"🌳 The simple and easy implementation of Merkle Tree","archived":false,"fork":false,"pushed_at":"2024-02-07T05:22:07.000Z","size":299,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-14T03:11:45.257Z","etag":null,"topics":["cryptography","ethereum","keccak256","merkle-proof","merkle-root","merkle-tree","merkletreejs","merkly","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/merkletreers","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"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":null,"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}},"created_at":"2022-10-03T19:18:34.000Z","updated_at":"2024-07-11T01:34:25.000Z","dependencies_parsed_at":"2024-02-05T04:32:52.847Z","dependency_job_id":"a4663e02-ffea-42fc-a58e-49f1fae91879","html_url":"https://github.com/olivmath/merkletreers","commit_stats":{"total_commits":35,"total_committers":2,"mean_commits":17.5,"dds":0.02857142857142858,"last_synced_commit":"ce78bc7d0e8877382cd4e04be7d70669993f01ec"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivmath%2Fmerkletreers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivmath%2Fmerkletreers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivmath%2Fmerkletreers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivmath%2Fmerkletreers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olivmath","download_url":"https://codeload.github.com/olivmath/merkletreers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233905173,"owners_count":18748596,"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":["cryptography","ethereum","keccak256","merkle-proof","merkle-root","merkle-tree","merkletreejs","merkly","rust"],"created_at":"2025-01-14T14:19:26.055Z","updated_at":"2025-09-22T23:31:51.989Z","avatar_url":"https://github.com/olivmath.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌳 Merkle Tree\n\nThe **simple and easy** implementation of **Rust Merkle Tree**\n\n---\n\n[![Build](https://github.com/olivmath/merkletreers/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/olivmath/merkletreers/actions/workflows/build.yml) [![Test](https://github.com/olivmath/merkletreers/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/olivmath/merkletreers/actions/workflows/test.yml) [![Crates.io](https://img.shields.io/crates/v/merkletreers.svg)](https://crates.io/crates/merkletreers)\n\n![GitHub last commit](https://img.shields.io/github/last-commit/olivmath/merkletreers)\n![GitHub commit activity](https://img.shields.io/github/commit-activity/m/olivmath/merkletreers)\n\n![Crates.io](https://img.shields.io/crates/l/merkletreers)\n\n## Table of Contents\n\n- [Credits](#credits)\n- [How to install](#how-to-install)\n- [How it works](#how-it-works)\n- [How to use](#how-to-use)\n- [Roadmap](#roadmap)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Credits\n\n[![GitHub Contributors Image](https://contrib.rocks/image?repo=olivmath/merkletreers)](https://github.com/olivmath/merkletreers/graphs/contributors)\n\n## How to install\n\n```shell\ncargo add merkletreers\n```\n\n## How to works\n\n- _We use keccak-256 under-the-hood_\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![](/asset.png)\n\n## How to Use\n\n**Create a Merkle Tree**\n\n```rust\nuse merkletreers::tree::MerkleTree;\nuse merkletreers::utils::hash_it;\n\n// Hash each element of leaves to convert into a [u8;32]\nlet leaves = [\"a\", \"b\", \"c\", \"d\", \"e\"]\n    .iter()\n    .map(|data| {\n        let mut buffer = [0u8; 32];\n        hash_it(data.as_bytes(), \u0026mut buffer);\n        buffer\n    })\n    .collect::\u003cVec\u003c[u8; 32]\u003e\u003e();\n\n// Create our Merkle tree\nlet tree = MerkleTree::new(leaves);\n```\n\n**Create a Root**\n\n```rust\nuse merkletreers::tree::MerkleTree;\nuse merkletreers::utils::hash_it;\n\n// Hash each element of leaves to convert into a [u8;32]\nlet leaves = [\"a\", \"b\", \"c\", \"d\", \"e\"]\n    .iter()\n    .map(|data| {\n        let mut buffer = [0u8; 32];\n        hash_it(data.as_bytes(), \u0026mut buffer);\n        buffer\n    })\n    .collect::\u003cVec\u003c[u8; 32]\u003e\u003e();\n\n// Create our Merkle tree\nlet tree = MerkleTree::new(leaves);\n\n// Create our Merkle Root\nlet root = tree.root;\nassert_eq!(\n    root,\n    [\n        29, 208, 210, 166, 174, 70, 109, 102, 92, 178, 110, 26, 49, 240, 124, 87, 174, 93, 247,\n        210, 188, 85, 156, 213, 130, 109, 65, 123, 233, 20, 26, 93\n    ]\n);\n```\n\n**Create Proof of a leaf**\n\n```rust\nuse merkletreers::node::{Node, Side};\nuse merkletreers::tree::MerkleTree;\nuse merkletreers::utils::hash_it;\n\n// Hash each element of leaves to convert into a [u8;32]\nlet leaves = [\"a\", \"b\", \"c\", \"d\", \"e\"]\n    .iter()\n    .map(|data| {\n        let mut buffer = [0u8; 32];\n        hash_it(data.as_bytes(), \u0026mut buffer);\n        buffer\n    })\n    .collect::\u003cVec\u003c[u8; 32]\u003e\u003e();\n\n// Create our Merkle tree\nlet tree = MerkleTree::new(leaves);\n\n// Create our Merkle Root\nlet root = tree.root;\nassert_eq!(\n    root,\n    [\n        29, 208, 210, 166, 174, 70, 109, 102, 92, 178, 110, 26, 49, 240, 124, 87, 174, 93, 247,\n        210, 188, 85, 156, 213, 130, 109, 65, 123, 233, 20, 26, 93\n    ]\n);\n\n// Create your Merkle Proof for 'c' element\n// First we need hash element to convert into a [u8; 32]\nlet mut leaf = [0u8; 32];\nhash_it(\"c\".as_bytes(), \u0026mut leaf);\nlet proof = tree.make_proof(leaf);\nassert_eq!(\n    vec![\n        Node {\n            data: [\n                241, 145, 142, 133, 98, 35, 110, 177, 122, 220, 133, 2, 51, 47, 76, 156, 130,\n                188, 20, 225, 155, 252, 10, 161, 10, 182, 116, 255, 117, 179, 210, 243\n            ],\n            side: Side::RIGHT\n        },\n        Node {\n            data: [\n                128, 91, 33, 216, 70, 177, 137, 239, 174, 176, 55, 125, 107, 176, 210, 1, 179,\n                135, 42, 54, 62, 96, 124, 37, 8, 143, 2, 91, 12, 106, 225, 248\n            ],\n            side: Side::LEFT\n        },\n        Node {\n            data: [\n                168, 152, 44, 137, 216, 9, 135, 251, 154, 81, 14, 37, 152, 30, 233, 23, 2, 6,\n                190, 33, 175, 60, 142, 14, 179, 18, 239, 29, 51, 130, 231, 97\n            ],\n            side: Side::RIGHT\n        }\n    ],\n    proof\n);\n```\n\n**Verify Proof of a leaf**\n\n```rust\nuse merkletreers::node::{Node, Side};\nuse merkletreers::tree::MerkleTree;\nuse merkletreers::utils::hash_it;\n\n\n// Hash each element of leaves to convert into a [u8;32]\nlet leaves = [\"a\", \"b\", \"c\", \"d\", \"e\"]\n    .iter()\n    .map(|data| {\n        let mut buffer = [0u8; 32];\n        hash_it(data.as_bytes(), \u0026mut buffer);\n        buffer\n    })\n    .collect::\u003cVec\u003c[u8; 32]\u003e\u003e();\n\n// Create our Merkle tree\nlet tree = MerkleTree::new(leaves);\n\n// Create our Merkle Root\nlet root = tree.root;\nassert_eq!(\n    root,\n    [\n        29, 208, 210, 166, 174, 70, 109, 102, 92, 178, 110, 26, 49, 240, 124, 87, 174, 93, 247,\n        210, 188, 85, 156, 213, 130, 109, 65, 123, 233, 20, 26, 93\n    ]\n);\n\n// Create your Merkle Proof for 'c' element\n// First we need hash element to convert into a [u8; 32]\nlet mut leaf = [0u8; 32];\nhash_it(\"c\".as_bytes(), \u0026mut leaf);\nlet proof = tree.make_proof(leaf);\nassert_eq!(\n    vec![\n        Node {\n            data: [\n                241, 145, 142, 133, 98, 35, 110, 177, 122, 220, 133, 2, 51, 47, 76, 156, 130,\n                188, 20, 225, 155, 252, 10, 161, 10, 182, 116, 255, 117, 179, 210, 243\n            ],\n            side: Side::RIGHT\n        },\n        Node {\n            data: [\n                128, 91, 33, 216, 70, 177, 137, 239, 174, 176, 55, 125, 107, 176, 210, 1, 179,\n                135, 42, 54, 62, 96, 124, 37, 8, 143, 2, 91, 12, 106, 225, 248\n            ],\n            side: Side::LEFT\n        },\n        Node {\n            data: [\n                168, 152, 44, 137, 216, 9, 135, 251, 154, 81, 14, 37, 152, 30, 233, 23, 2, 6,\n                190, 33, 175, 60, 142, 14, 179, 18, 239, 29, 51, 130, 231, 97\n            ],\n            side: Side::RIGHT\n        }\n    ],\n    proof\n);\n\n// Verify our Merkle Proof for 'c' element\nlet result = tree.check_proof(proof, leaf);\nassert_eq!(result, root);\n```\n\n## Roadmap\n\n| Feature                                                                        | Status | Priority |\n| ------------------------------------------------------------------------------ | ------ | -------- |\n| Create Root                                                                    | ✅     | 🔥       |\n| Create Proof                                                                   | ✅     | 🔥       |\n| Verify Proof                                                                   | ✅     | 🔥       |\n| Compatible with **[MerkleTreeJs](https://github.com/miguelmota/merkletreejs)** | ✅     | 🔥       |\n| Compatible with **[Merkly](https://github.com/olivmath/merkly)**               | ✅     | 🔥       |\n| Leafs of any size                                                              | ✅     | 🧐       |\n| Use any Hash function                                                          | ⏰     | 🧐       |\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%2Fmerkletreers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folivmath%2Fmerkletreers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folivmath%2Fmerkletreers/lists"}