New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

solidity-patricia-tree

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solidity-patricia-tree

Patricia Tree solidity implemenation

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-71.43%
Maintainers
1
Weekly downloads
 
Created
Source

Solidity Patricia Tree

Credits

This is a rewritten version of Christian Reitwießner's patricia-trie to use his patricia tree implementation as a solidity library through npm.

latest released version

npm Build Status Coverage Status

in progress

npm Build Status Coverage Status

JavaScript Style Guide

Usage

npm i solidity-patricia-tree

pragma solidity ^0.4.25;

import {PatriciaTree} from "solidity-patricia-tree/contracts/tree.sol"; 

contract TestPatriciaTree {
    using PatriciaTree for PatriciaTree.Tree;
    PatriciaTree.Tree tree;

    function test() public {
        // testInsert();
        testProofs();
    }

    function testInsert() internal {
        tree.insert("one", "ONE");
        tree.insert("two", "ONE");
        tree.insert("three", "ONE");
        tree.insert("four", "ONE");
        tree.insert("five", "ONE");
        tree.insert("six", "ONE");
        tree.insert("seven", "ONE");
        // update
        tree.insert("one", "TWO");
    }

    function testProofs() internal {
        tree.insert("one", "ONE");
        uint branchMask;
        bytes32[] memory siblings;
        (branchMask, siblings) = tree.getProof("one");
        PatriciaTree.verifyProof(tree.root, "one", "ONE", branchMask, siblings);
        tree.insert("two", "TWO");
        (branchMask, siblings) = tree.getProof("one");
        PatriciaTree.verifyProof(tree.root, "one", "ONE", branchMask, siblings);
        (branchMask, siblings) = tree.getProof("two");
        PatriciaTree.verifyProof(tree.root, "two", "TWO", branchMask, siblings);
    }
}

Development

Pre-requisites

npm install -g truffle
npm install -g ganache
npm install

Tests

Test cases include the information about how the functions work, but also includes a demo scenario. Running and reading the test cases will help you understand how it works.

npm run test

Contributors

License

MIT LICENSE

Keywords

FAQs

Package last updated on 09 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc