1- # Solidity Sparse Tree
1+ # Solidity Partial Merkle Tree
22
33## Credits
44
55This implementation is based on [ Christian Reitwießner] ( https://github.com/chriseth ) 's [ patricia-tree] ( https://github.com/chriseth/patricia-tree )
66
77
88##### latest released version
9- [ ![ npm] ( https://img.shields.io/npm/v/solidity-sparse -tree/latest.svg )] ( https://www.npmjs.com/package/solidity-sparse -tree )
10- [ ![ Build Status] ( https://travis-ci.org/commitground/solidity-sparse -tree.svg?branch=master )] ( https://travis-ci.org/commitground/solidity-sparse -tree )
11- [ ![ Coverage Status] ( https://coveralls.io/repos/github/commitground/solidity-sparse -tree/badge.svg?branch=master )] ( https://coveralls.io/github/commitground/solidity-sparse -tree?branch=develop )
9+ [ ![ npm] ( https://img.shields.io/npm/v/solidity-partial -tree/latest.svg )] ( https://www.npmjs.com/package/solidity-partial -tree )
10+ [ ![ Build Status] ( https://travis-ci.org/commitground/solidity-partial -tree.svg?branch=master )] ( https://travis-ci.org/commitground/solidity-partial -tree )
11+ [ ![ 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 )
1212
1313##### in progress
14- [ ![ npm] ( https://img.shields.io/npm/v/solidity-sparse -tree/next.svg )] ( https://www.npmjs.com/package/solidity-sparse -tree )
15- [ ![ Build Status] ( https://travis-ci.org/commitground/solidity-sparse -tree.svg?branch=develop )] ( https://travis-ci.org/commitground/solidity-sparse -tree )
16- [ ![ Coverage Status] ( https://coveralls.io/repos/github/commitground/solidity-sparse -tree/badge.svg?branch=develop )] ( https://coveralls.io/github/commitground/solidity-sparse -tree?branch=develop )
14+ [ ![ npm] ( https://img.shields.io/npm/v/solidity-partial -tree/next.svg )] ( https://www.npmjs.com/package/solidity-partial -tree )
15+ [ ![ Build Status] ( https://travis-ci.org/commitground/solidity-partial -tree.svg?branch=develop )] ( https://travis-ci.org/commitground/solidity-partial -tree )
16+ [ ![ 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 )
1717
1818[ ![ JavaScript Style Guide] ( https://cdn.rawgit.com/standard/standard/master/badge.svg )] ( https://github.com/standard/standard )
1919
@@ -22,27 +22,27 @@ This implementation is based on [Christian Reitwießner](https://github.com/chri
2222## Usage
2323
2424``` bash
25- npm i solidity-sparse -tree
25+ npm i solidity-partial -tree
2626npm i solidity-patricia-tree
2727```
2828
2929``` solidity
3030pragma solidity ^0.4.24;
3131
32- import {SparseTree} from "solidity-sparse-tree/contracts/tree.sol";
3332import {PatriciaTree} from "solidity-patricia-tree/contracts/tree.sol";
33+ import {PartialMerkleTree} from "solidity-partial-tree/contracts/tree.sol";
3434
35- contract TestSparseTree {
36- using SparseTree for SparseTree .Tree;
35+ contract TestPartialMerkleTree {
36+ using PartialMerkleTree for PartialMerkleTree .Tree;
3737 using PatriciaTree for PatriciaTree.Tree;
3838
3939 PatriciaTree.Tree patriciaTree;
40- SparseTree .Tree sparseTree ;
40+ PartialMerkleTree .Tree partialTree ;
4141
4242 /**
4343 * @dev we can reenact merkle tree transformation by submitting only referred siblings instead of submitting all nodes
4444 */
45- function testSparseTree () public {
45+ function testOnChainProof () public {
4646 // update merkle root
4747 patriciaTree.insert("key1", "val1");
4848 patriciaTree.insert("key2", "val2");
@@ -56,23 +56,23 @@ contract TestSparseTree {
5656 bytes32[] memory siblings;
5757 (branchMask, siblings) = patriciaTree.getProof("key1");
5858
59- // Init sparse tree with the root hash
60- sparseTree .initialize(phaseAOfPatriciaTree);
59+ // Init partial tree with the root hash
60+ partialTree .initialize(phaseAOfPatriciaTree);
6161 // commit branch (we submit sibling data here)
62- sparseTree .commitBranch("key1", "val1", branchMask, siblings);
62+ partialTree .commitBranch("key1", "val1", branchMask, siblings);
6363
6464 // Update key1 of patricia tree
6565 patriciaTree.insert("key1", "val4");
6666
67- // Update key1 of sparse tree
68- sparseTree .insert("key1", "val4");
67+ // Update key1 of partial tree
68+ partialTree .insert("key1", "val4");
6969
7070 // get updated root hashes of each tree
7171 bytes32 phaseBOfPatriciaTree = patriciaTree.getRootHash();
72- bytes32 phaseBOfSparseTree = sparseTree .getRootHash();
72+ bytes32 phaseBOfPartialTree = partialTree .getRootHash();
7373
7474 // We have succeeded to reenact merkle tree transformation without submitting all node data
75- require(phaseBOfPatriciaTree == phaseBOfSparseTree );
75+ require(phaseBOfPatriciaTree == phaseBOfPartialTree );
7676 }
7777}
7878```
@@ -90,9 +90,6 @@ npm install
9090
9191### Tests
9292
93- Test cases include the information about how the functions work, but also includes a demo scenario.
94- Running and reading the test cases will help you understand how it works.
95-
9693``` bash
9794npm run test
9895```
0 commit comments