{"id":16469266,"url":"https://github.com/commitground/solidity-partial-tree","last_synced_at":"2025-03-23T11:32:40.730Z","repository":{"id":57365937,"uuid":"158427850","full_name":"commitground/solidity-partial-tree","owner":"commitground","description":"Solidity implementation of partial merkle tree for a light weight side chain execution verification","archived":false,"fork":false,"pushed_at":"2019-04-09T06:13:58.000Z","size":650,"stargazers_count":13,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-02T00:12:13.537Z","etag":null,"topics":["chain","light","merkle","partial","side","solidity","tree"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/commitground.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":"2018-11-20T17:33:18.000Z","updated_at":"2023-06-26T02:09:12.000Z","dependencies_parsed_at":"2022-08-23T19:01:09.892Z","dependency_job_id":null,"html_url":"https://github.com/commitground/solidity-partial-tree","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/commitground%2Fsolidity-partial-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commitground%2Fsolidity-partial-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commitground%2Fsolidity-partial-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commitground%2Fsolidity-partial-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/commitground","download_url":"https://codeload.github.com/commitground/solidity-partial-tree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244296950,"owners_count":20430336,"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":["chain","light","merkle","partial","side","solidity","tree"],"created_at":"2024-10-11T12:06:38.181Z","updated_at":"2025-03-23T11:32:40.394Z","avatar_url":"https://github.com/commitground.png","language":"JavaScript","readme":"# Solidity Partial Merkle Tree\n\n## Credits \n\nThis implementation is based on [Christian Reitwießner](https://github.com/chriseth)'s [patricia-trie](https://github.com/chriseth/patricia-trie) \n\n\n##### latest released version\n[![npm](https://img.shields.io/npm/v/solidity-partial-tree/latest.svg)](https://www.npmjs.com/package/solidity-partial-tree)\n[![Build Status](https://travis-ci.org/commitground/solidity-partial-tree.svg?branch=master)](https://travis-ci.org/commitground/solidity-partial-tree)\n[![Coverage Status](https://coveralls.io/repos/github/commitground/solidity-partial-tree/badge.svg?branch=master)](https://coveralls.io/github/commitground/solidity-partial-tree?branch=develop)\n\n##### in progress\n[![npm](https://img.shields.io/npm/v/solidity-partial-tree/next.svg)](https://www.npmjs.com/package/solidity-partial-tree)\n[![Build Status](https://travis-ci.org/commitground/solidity-partial-tree.svg?branch=develop)](https://travis-ci.org/commitground/solidity-partial-tree)\n[![Coverage Status](https://coveralls.io/repos/github/commitground/solidity-partial-tree/badge.svg?branch=develop)](https://coveralls.io/github/commitground/solidity-partial-tree?branch=develop)\n\n[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)\n\n\n\n## Usage\n\n```bash\nnpm i solidity-partial-tree\nnpm i solidity-patricia-tree\n```\n\n```solidity\npragma solidity ^0.4.24;\n\nimport {PatriciaTree} from \"solidity-patricia-tree/contracts/tree.sol\";\nimport {PartialMerkleTree} from \"solidity-partial-tree/contracts/tree.sol\";\n\ncontract TestPartialMerkleTree {\n    using PartialMerkleTree for PartialMerkleTree.Tree;\n    using PatriciaTree for PatriciaTree.Tree;\n\n    PatriciaTree.Tree patriciaTree;\n    PartialMerkleTree.Tree partialTree;\n\n    /**\n     * @dev we can reenact merkle tree transformation by submitting only referred siblings instead of submitting all nodes\n     */\n    function testOnChainProof() public {\n        // update merkle root\n        patriciaTree.insert(\"key1\", \"val1\");\n        patriciaTree.insert(\"key2\", \"val2\");\n        patriciaTree.insert(\"key3\", \"val3\");\n\n        // root hash of patricia tree @ phase A\n        bytes32 phaseAOfPatriciaTree = patriciaTree.getRootHash();\n\n        // get siblings to update \"key1\"\n        uint branchMask;\n        bytes32[] memory siblings;\n        (branchMask, siblings) = patriciaTree.getProof(\"key1\");\n\n        // Init partial tree with the root hash\n        partialTree.initialize(phaseAOfPatriciaTree);\n        // commit branch (we submit sibling data here)\n        partialTree.commitBranch(\"key1\", \"val1\", branchMask, siblings);\n\n        // Update key1 of patricia tree\n        patriciaTree.insert(\"key1\", \"val4\");\n\n        // Update key1 of partial tree\n        partialTree.insert(\"key1\", \"val4\");\n\n        // get updated root hashes of each tree\n        bytes32 phaseBOfPatriciaTree = patriciaTree.getRootHash();\n        bytes32 phaseBOfPartialTree = partialTree.getRootHash();\n\n        // We have succeeded to reenact merkle tree transformation without submitting all node data\n        require(phaseBOfPatriciaTree == phaseBOfPartialTree);\n    }\n}\n```\n\n\n## Development \n\n### Pre-requisites\n\n```bash\nnpm install -g truffle\nnpm install -g ganache-cli\nnpm install\n```\n\n### Tests\n\n```bash\nnpm run test\n```\n\n## Contributors\n- [Wanseob Lim](https://github.com/james-lim)\u003c[email@wanseob.com](mailto:email@wanseob.com)\u003e\n\n## License\n\n[MIT LICENSE](./LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommitground%2Fsolidity-partial-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommitground%2Fsolidity-partial-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommitground%2Fsolidity-partial-tree/lists"}