{"id":24405239,"url":"https://github.com/sitano/merkle_light","last_synced_at":"2025-04-13T05:30:44.664Z","repository":{"id":26883583,"uuid":"111606102","full_name":"sitano/merkle_light","owner":"sitano","description":"_merkle_ is a lightweight Rust implementation of a Merkle tree, external dependencies agnostic, std::hash compatible with efficient memory layout","archived":false,"fork":false,"pushed_at":"2022-06-21T08:28:18.000Z","size":951,"stargazers_count":30,"open_issues_count":0,"forks_count":55,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T10:15:56.355Z","etag":null,"topics":["crypto","lightweight","merkle-proof","merkle-tree","rust","rust-library","spv"],"latest_commit_sha":null,"homepage":"https://en.wikipedia.org/wiki/Merkle_tree","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sitano.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":"2017-11-21T22:01:32.000Z","updated_at":"2024-06-18T12:41:03.000Z","dependencies_parsed_at":"2022-08-17T20:11:04.977Z","dependency_job_id":null,"html_url":"https://github.com/sitano/merkle_light","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitano%2Fmerkle_light","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitano%2Fmerkle_light/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitano%2Fmerkle_light/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitano%2Fmerkle_light/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sitano","download_url":"https://codeload.github.com/sitano/merkle_light/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670273,"owners_count":21142895,"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":["crypto","lightweight","merkle-proof","merkle-tree","rust","rust-library","spv"],"created_at":"2025-01-20T04:41:03.576Z","updated_at":"2025-04-13T05:30:44.633Z","avatar_url":"https://github.com/sitano.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# merkle\n\n[![Build Status](https://travis-ci.org/sitano/merkle_light.svg?branch=master\u0026style=flat)](https://travis-ci.org/sitano/merkle_light)\n[![Issues](http://img.shields.io/github/issues/sitano/merkle.svg?style=flat)](https://github.com/sitano/merkle_light/issues)\n![License](https://img.shields.io/badge/license-bsd3-brightgreen.svg?style=flat)\n[![Crates.io](https://img.shields.io/crates/v/merkle_light.svg)](https://crates.io/crates/merkle_light)\n\n*merkle* is a lightweight Rust implementation of a [Merkle tree](https://en.wikipedia.org/wiki/Merkle_tree).\n\n## Features\n\n- external dependency agnostic\n- `std::hash::Hasher` compatibility\n- standard types hasher implementations\n- `#[derive(Hashable)]` support for simple struct\n- customizable merkle leaf/node hashing algorithm\n- support for custom hash types (e.g. [u8; 16], [u64; 4], [u128; 2], struct)\n- customizable hashing algorithm\n- linear memory layout, no nodes on heap\n- buildable from iterator, objects or hashes\n- certificate transparency style merkle hashing support\n- SPV included\n\n## Documentation\n\nDocumentation is [available](https://sitano.github.io/merkle_light/merkle_light/index.html).\n\n# Examples\n\n* `test_sip.rs`: algorithm implementation example for std sip hasher, u64 hash items\n* `test_xor128.rs`: custom hash example xor128\n* `test_cmh.rs`: custom merkle hasher implementation example\n* `crypto_bitcoin_mt.rs`: bitcoin merkle tree using crypto lib\n* `crypto_chaincore_mt.rs`: chain core merkle tree using crypto lib\n* `ring_bitcoin_mt.rs`: bitcoin merkle tree using ring lib\n\n# Quick start\n\n```rust\nextern crate crypto;\nextern crate merkle_light;\n\nuse std::fmt;\nuse std::hash::Hasher;\nuse std::iter::FromIterator;\nuse crypto::sha3::{Sha3, Sha3Mode};\nuse crypto::digest::Digest;\nuse merkle_light::hash::{Algorithm, Hashable};\nuse merkle_light::merkle::MerkleTree;\n\npub struct ExampleAlgorithm(Sha3);\n\nimpl ExampleAlgorithm {\n    pub fn new() -\u003e ExampleAlgorithm {\n        ExampleAlgorithm(Sha3::new(Sha3Mode::Sha3_256))\n    }\n}\n\nimpl Default for ExampleAlgorithm {\n    fn default() -\u003e ExampleAlgorithm {\n        ExampleAlgorithm::new()\n    }\n}\n\nimpl Hasher for ExampleAlgorithm {\n    #[inline]\n    fn write(\u0026mut self, msg: \u0026[u8]) {\n        self.0.input(msg)\n    }\n\n    #[inline]\n    fn finish(\u0026self) -\u003e u64 {\n        unimplemented!()\n    }\n}\n\nimpl Algorithm\u003c[u8; 32]\u003e for ExampleAlgorithm {\n    #[inline]\n    fn hash(\u0026mut self) -\u003e [u8; 32] {\n        let mut h = [0u8; 32];\n        self.0.result(\u0026mut h);\n        h\n    }\n\n    #[inline]\n    fn reset(\u0026mut self) {\n        self.0.reset();\n    }\n}\n\nfn main() {\n    let mut h1 = [0u8; 32];\n    let mut h2 = [0u8; 32];\n    let mut h3 = [0u8; 32];\n    h1[0] = 0x11;\n    h2[0] = 0x22;\n    h3[0] = 0x33;\n\n    let t: MerkleTree\u003c[u8; 32], ExampleAlgorithm\u003e = MerkleTree::from_iter(vec![h1, h2, h3]);\n    println!(\"{:?}\", t.root());\n}\n```\n\n## Bug Reporting\n\nPlease report bugs either as pull requests or as issues in [the issue\ntracker](https://github.com/sitano/merkle_light). *merkle* has a\n**full disclosure** vulnerability policy. **Please do NOT attempt to report\nany security vulnerability in this code privately to anybody.**\n\n## License\n\nSee [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsitano%2Fmerkle_light","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsitano%2Fmerkle_light","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsitano%2Fmerkle_light/lists"}