{"id":18674062,"url":"https://github.com/nervosnetwork/sparse-merkle-tree","last_synced_at":"2025-04-07T14:12:40.328Z","repository":{"id":39995062,"uuid":"382252641","full_name":"nervosnetwork/sparse-merkle-tree","owner":"nervosnetwork","description":null,"archived":false,"fork":false,"pushed_at":"2023-06-26T20:32:08.000Z","size":2542,"stargazers_count":50,"open_issues_count":13,"forks_count":38,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-31T13:16:23.525Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/nervosnetwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-07-02T06:30:30.000Z","updated_at":"2025-03-04T04:53:55.000Z","dependencies_parsed_at":"2025-01-15T03:55:43.550Z","dependency_job_id":"1790c0ef-22ff-4a71-bcff-12408027c8ea","html_url":"https://github.com/nervosnetwork/sparse-merkle-tree","commit_stats":{"total_commits":177,"total_committers":10,"mean_commits":17.7,"dds":0.5932203389830508,"last_synced_commit":"5739f3faa509934ec69a10696ee3e1f37c52aa34"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fsparse-merkle-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fsparse-merkle-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fsparse-merkle-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fsparse-merkle-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nervosnetwork","download_url":"https://codeload.github.com/nervosnetwork/sparse-merkle-tree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247666014,"owners_count":20975788,"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-07T09:17:23.309Z","updated_at":"2025-04-07T14:12:40.300Z","avatar_url":"https://github.com/nervosnetwork.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sparse merkle tree\n\n[![Crates.io](https://img.shields.io/crates/v/sparse-merkle-tree.svg)](https://crates.io/crates/sparse-merkle-tree)\n[Docs](https://docs.rs/sparse-merkle-tree)\n\nAn optimized sparse merkle tree.\n\n| size | proof size | update | get | merkle proof | verify proof |\n| --- | --- | --- | --- | --- | --- |\n| 2n + log(n) | log(n) | log(n) | log(n) | log(n) | log(n) |\n\nFeatures:\n\n* Multi-leaves existence / non-existence merkle proof\n* Customizable hash function\n* Storage backend agnostic\n* Rust `no_std` support\n\nThis article describes algorithm of this data structure [An optimized compacted sparse merkle tree](SMT.md)\n\n## Construction\n\nA sparse merkle tree is a perfectly balanced tree contains `2 ^ N` leaves:\n\n``` txt\n# N = 256 sparse merkle tree\nheight:\n                   0\n                /     \\\n255            0        1\n\n.............................\n\n           /   \\          /  \\\n1         0     1        0    1\n         / \\   / \\      / \\   / \\\n0       0   1 0  1 ... 0   1 0   1\n       0x00..00 0x00..01   ...   0x11..11\n```\n\nThe above graph demonstrates a sparse merkle tree with `2 ^ 256` leaves, which can mapping every possible `H256` value into leaves. The height of the tree is `256`, from top to bottom, we denote `0` for each left branch and denote `1` for each right branch, so we can get a 256 bits path, which also can represent in `H256`, we use the path as the key of leaves, the most left leaf's key is `0x00..00`, and the next key is `0x00..01`, the most right key is `0x11..11`.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnervosnetwork%2Fsparse-merkle-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnervosnetwork%2Fsparse-merkle-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnervosnetwork%2Fsparse-merkle-tree/lists"}