{"id":19155026,"url":"https://github.com/rkdud007/alloy-merkle-tree","last_synced_at":"2025-04-07T13:09:02.201Z","repository":{"id":222964187,"uuid":"758852166","full_name":"rkdud007/alloy-merkle-tree","owner":"rkdud007","description":"Minimal Merkle Tree implementations","archived":false,"fork":false,"pushed_at":"2024-12-22T15:23:33.000Z","size":81,"stargazers_count":28,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T12:06:25.412Z","etag":null,"topics":["ethereum","merkle-tree","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rkdud007.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-17T09:13:46.000Z","updated_at":"2024-12-22T15:23:12.000Z","dependencies_parsed_at":"2024-10-17T15:34:40.410Z","dependency_job_id":"20109197-e22e-48c1-96b9-0f93ab7e993f","html_url":"https://github.com/rkdud007/alloy-merkle-tree","commit_stats":{"total_commits":35,"total_committers":4,"mean_commits":8.75,"dds":0.2571428571428571,"last_synced_commit":"41342fbde2291d3556574f1d5897255871b10914"},"previous_names":["rkdud007/alloy-merkle-tree"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkdud007%2Falloy-merkle-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkdud007%2Falloy-merkle-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkdud007%2Falloy-merkle-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkdud007%2Falloy-merkle-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rkdud007","download_url":"https://codeload.github.com/rkdud007/alloy-merkle-tree/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247657281,"owners_count":20974345,"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":["ethereum","merkle-tree","rust"],"created_at":"2024-11-09T08:29:08.134Z","updated_at":"2025-04-07T13:09:02.156Z","avatar_url":"https://github.com/rkdud007.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# alloy-merkle-tree\n\n![CI](https://img.shields.io/github/actions/workflow/status/rkdud007/alloy-merkle-tree/ci.yml?style=flat-square\u0026logo=githubactions\u0026logoColor=white\u0026label=CI)\n[![Crates.io](https://img.shields.io/crates/v/alloy-merkle-tree?style=flat-square\u0026logo=lootcrate)](https://crates.io/crates/alloy-merkle-tree)\n[![Documentation](https://img.shields.io/docsrs/alloy-merkle-tree)](https://docs.rs/alloy-merkle-tree)\n\nMinimal Merkle Tree implementation\n\n- various tree implementation\n  - PerfectBinaryMerkleTree\n  - IncrementalMerkleTree\n  - StandardBinaryTree\n- type compatible with alloy-primitives\n- keccak hash as native hash\n- support features: insert, proof, verify\n\n## Install\n\n```bash\n❯ cargo add alloy-merkle-tree\n```\n\n## Support\n\n### MerkleTree\n\nPerfect Binary Merkle Tree\n\n```rust\nlet mut tree = MerkleTree::new();\n// Should be 2 ^ N leaves\nlet num_leaves = 16;\nfor i in 0..num_leaves {\n    tree.insert(B256::from(U256::from(i)));\n}\ntree.finish();\n\nfor i in 0..num_leaves {\n    let proof = tree.create_proof(\u0026B256::from(U256::from(i))).unwrap();\n    assert!(MerkleTree::verify_proof(\u0026proof));\n}\n```\n\n### IncrementalMerkleTree\n\nused in the [ETH2 Deposit Contract](https://etherscan.io/address/0x00000000219ab540356cbb839cbe05303d7705fa)\n\n```rust\n let mut tree = IncrementalMerkleTree::\u003c8\u003e::new();\nfor i in 0..1 \u003c\u003c (8 - 1) {\n    tree.append([i as u8; 32].into()).unwrap();\n}\nfor i in 0..1 \u003c\u003c (8 - 1) {\n    let leaf = [i as u8; 32].into();\n    let proof = tree.proof_at_index(i).unwrap();\n    assert!(tree.verify_proof(leaf, i, \u0026proof));\n}\n```\n\n### StandardBinaryMerkleTree\n\n[StandardMerkleTree](https://github.com/OpenZeppelin/merkle-tree)\n\n```rust\nlet num_leaves = 1000;\nlet mut leaves = Vec::new();\nfor i in 0..num_leaves {\n    leaves.push(i.to_string());\n}\nlet tree = StandardMerkleTree::of_sorted(leaves.clone());\n\nfor leaf in leaves.iter() {\n    let proof = tree.get_proof(leaf);\n    let bool = tree.verify_proof(leaf.to_string(), proof);\n    assert!(bool);\n}\n\n```\n\n### reference\n\n- [merkle-tree](https://github.com/personaelabs/merkle-tree)\n- [StandardMerkleTree](https://github.com/OpenZeppelin/merkle-tree)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frkdud007%2Falloy-merkle-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frkdud007%2Falloy-merkle-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frkdud007%2Falloy-merkle-tree/lists"}