npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

precise-proofs

v1.0.3

Published

Precise Proofs validation for javascript(https://github.com/centrifuge/precise-proofs)

Downloads

6

Readme

Precise Proofs Js

Read the introduction on Precise-Proofs

Precise Proofs Js is a library for validating fields/leafs from Merkle proofs created with precise-proofs. The library supports 2 hashing functions(SHA2_256SHA3_256) and hex or base base64 encoding for the hashes. Out of the box it uses hex encoding and SHA2_256.

In case you generate your proofs with SHA3_256 and have them base64 encoded. You can switch using the following code:

import {PreciseProofs, SHA3_256} from "precise-proofs-js";

const preciseProofs = new PreciseProofs('base64',SHA3_256);

Supported Proof format

  
// Sorted Hashes
{
    "property": "valueA",
    "value": "Example",
    "salt": "d555901541825e5d40612d220142c7428c385c48e0245fd3a40b8e3b64679be1",
    "sorted_hashes": [
        "60c3dfcdd85fcef1d4826d4695fb5064aa8434d014f2c1547f9398bdf72bdb75",
        "8951fa82c3f5563d88769a9ecb8f6e03b389c06ff64a1b26dc5898cefe95a42f",
        "46d0a998333fc2c8b4cfff1d5e122f7c32ff46f0a4410f63821f45cc02fd3723"
    ]
}


// Hex with our without the 0x prefix
{
    "property": "valueA",
    "value": "Example",
    "salt": "d555901541825e5d40612d220142c7428c385c48e0245fd3a40b8e3b64679be1",
    "hashes":[  
        { "right": "60c3dfcdd85fcef1d4826d4695fb5064aa8434d014f2c1547f9398bdf72bdb75=" },
        { "left": "8951fa82c3f5563d88769a9ecb8f6e03b389c06ff64a1b26dc5898cefe95a42f" },
        { "right": "46d0a998333fc2c8b4cfff1d5e122f7c32ff46f0a4410f63821f45cc02fd3723" }
    ]
}
    
    
// Base64 Ecoded
{  
    "property":"ValueA",
    "value":"Example",
    "salt":"1VWQFUGCXl1AYS0iAULHQow4XEjgJF/TpAuOO2Rnm+E=",
    "hashes":[  
        { "right": "kYXAGhDdPiFMq1ZQMOZiKmSf1S1eHNgJ6BIPSIExOj8=" },
        { "left":" GDgT7Km6NK6k4N/Id4CZXErL3p6clNX7sVnlNyegdG0=" },
        { "right": "qOZzS+YM8t1OfC87zEKgkKz6q0f3wwk5+ed+PR/2cDA=" }
    ]
}


    

Usage:

import {PreciseProofs} from "precise-proofs-js";

const rootHash = "29dbffa68e5cd48bb4cb2504190f10883fb187793b2f70eab81fb5440c6809b6";
let proof = {
    "property": "valueA",
    "value": "Example",
    "salt": "d555901541825e5d40612d220142c7428c385c48e0245fd3a40b8e3b64679be1",
    "hashes": [
        "60c3dfcdd85fcef1d4826d4695fb5064aa8434d014f2c1547f9398bdf72bdb75",
        "8951fa82c3f5563d88769a9ecb8f6e03b389c06ff64a1b26dc5898cefe95a42f",
        "46d0a998333fc2c8b4cfff1d5e122f7c32ff46f0a4410f63821f45cc02fd3723"
    
    ]
}

const preciseProofs = new PreciseProofs();
const valid = preciseProofs.isValidField(proof, rootHash)
// valid  === true


// With base64 encoding
const base64RootHash = "Qpvx6jMpfee4eXYeDm+DO+Z8iArdnYdm3J3BH0AUxHU=";
const base64Proof = {
    "property": "value1",
    "value": "1",
    "salt": "Bs89XQyxE05c57R5KVb8aFk7rqf+A5XUgxlH3t1hRoY=",
    "hashes": [
    {
      "left": "bklbhC4cmgYc+w3k5an7PWICQHNZtozeqD16b7GE5ZI="
    },
    {
      "right": "5hFb4MZvIgE9RQnQDlOGGjahlgDIJwX7Id98oxFECbo="
    },
    {
      "right": "CT59ksUtUWOq+HagFoJgJziPOiHkHlvsvytA6TnTLq8="
    }
    ]
}

const base64PreciseProofs = new PreciseProofs('base64');
    
const base64Valid = base64PreciseProofs.isValidField(base64Proof, base64RootHash)
// base64Valid  === true 

Missing features

The following features are being worked on:

  • construct tree and generate proof