{"id":18762767,"url":"https://github.com/arnaucube/merkletree-rs","last_synced_at":"2025-07-13T22:06:39.729Z","repository":{"id":57638127,"uuid":"188571101","full_name":"arnaucube/merkletree-rs","owner":"arnaucube","description":"Sparse MerkleTree implementation in Rust","archived":false,"fork":false,"pushed_at":"2019-10-16T05:40:02.000Z","size":50,"stargazers_count":19,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-15T04:44:55.615Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arnaucube.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}},"created_at":"2019-05-25T13:42:50.000Z","updated_at":"2024-09-25T17:06:43.000Z","dependencies_parsed_at":"2022-09-21T10:13:45.014Z","dependency_job_id":null,"html_url":"https://github.com/arnaucube/merkletree-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/arnaucube/merkletree-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaucube%2Fmerkletree-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaucube%2Fmerkletree-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaucube%2Fmerkletree-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaucube%2Fmerkletree-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arnaucube","download_url":"https://codeload.github.com/arnaucube/merkletree-rs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaucube%2Fmerkletree-rs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265212407,"owners_count":23728529,"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":[],"created_at":"2024-11-07T18:23:16.125Z","updated_at":"2025-07-13T22:06:39.671Z","avatar_url":"https://github.com/arnaucube.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# merkletree-rs [![Crates.io](https://img.shields.io/crates/v/merkletree-rs.svg)](https://crates.io/crates/merkletree-rs) [![Build Status](https://travis-ci.org/arnaucube/merkletree-rs.svg?branch=master)](https://travis-ci.org/arnaucube/merkletree-rs)\nSparse MerkleTree implementation in Rust.\n\nThe MerkleTree is optimized in the design and concepts, to have a faster and lighter MerkleTree, maintaining compatibility with a non optimized MerkleTree. In this way, the MerkleRoot of the optimized MerkleTree will be the same that the MerkleRoot of the non optimized MerkleTree.\n\nCompatible with the Go version: https://github.com/arnaucube/go-merkletree\n\n\n## Usage\nImport lib:\n```rust\nextern crate merkletree_rs;\nuse merkletree_rs::{db, MerkleTree, TestValue, Value};\n```\n\nCreate new tree:\n```rust\n// to build the storage, the first parameter is the path and the second parameter specifies if wants to use a in_memory database or a directory of the filesystem\nlet mut sto = db::Db::new(\"test\".to_string(), true);\nlet mut mt = MerkleTree::new(\u0026mut sto, 140 as u32);\n```\n\nAdd value to leaf:\n```rust\nlet val: TestValue = TestValue {\n    bytes: \"this is a test leaf\".as_bytes().to_vec(),\n    index_length: 15,\n};\nmt.add(\u0026val).unwrap();\n```\n\nGet proof:\n```rust\nlet mp = mt.generate_proof(val.hi());\nprintln!(\"{:?}\", mp);\n```\n\nVerify proof:\n```rust\n// check if the value exist\nlet v =\n    merkletree_rs::verify_proof(mt.get_root(), \u0026mp, val.hi(), val.ht(), mt.get_num_levels());\nprintln!(\"{:?}\", v);\n\n// check if the don't value exist (in that case, the 'ht' will be an empty value)\nlet v = merkletree_rs::verify_proof(\n    mt.get_root(),\n    \u0026mp,\n    val.hi(),\n    merkletree_rs::constants::EMPTYNODEVALUE,\n    mt.get_num_levels(),\n);\nprintln!(\"{:?}\", v);\n```\n\nPrint current MerkleRoot:\n```rust\nprintln!(\"{:?}\", mt.get_root());\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnaucube%2Fmerkletree-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnaucube%2Fmerkletree-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnaucube%2Fmerkletree-rs/lists"}