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

shplonkjs

v0.0.2

Published

shPLONK javascript implementation

Downloads

19

Readme

shplonkjs

This is a JavaScript and Pure Web Assembly library of ShPlonk commitment scheme. It has been designed to be integrated with Fflonk protocol, although it can be used as an independent scheme.

The readme is currently WIP.

Guide

0. Setup

The first step in order to use the library is to do the setup.

await setup(config, curve, ptauFilename, logger);

The config contains the following information:

  • Power: It is the power of two of the maximum number of constraints that the ceremony can accept
  • PolDefs: It contains all the polynomials that are opened in each of the opening points. For each polynomial, the following information needs to be provided: name, degree and stage.
  • ExtraMuls: Extra scalar group multiplications applied to each of the stages / opening points
  • OpenBy: Commits can be done by stage or by opening point. It can only have two values: "stage" or "openingPoints"

An example of configuration is the following:

{
    "power": 5,  //Circuit power
    "polDefs": [
        [
            {"name": "P1", "stage": 0, "degree": 32},
            {"name": "P2", "stage": 0, "degree": 32},
            {"name": "P3", "stage": 0, "degree": 32},
            {"name": "P4", "stage": 0, "degree": 32},
            {"name": "P5", "stage": 1, "degree": 33},
            {"name": "P6", "stage": 1, "degree": 33},
            {"name": "P7", "stage": 2, "degree": 34},
            {"name": "P8", "stage": 2, "degree": 33},
            {"name": "P9", "stage": 2, "degree": 101}
        ],
        [
            {"name": "P7", "stage": 2, "degree": 34},
            {"name": "P8", "stage": 2, "degree": 33},
            {"name": "P9", "stage": 2, "degree": 101}
        ],
    ], 
    "extraMuls": 3, 
    "openBy": "stage", 
}

Along with the configuration, the powers of tau filename needs to be provided.

Provided a config, the setup first calculates all the f_i polynomials that will be required in the shplonk protocol. Once this is done, it precomputes all the omegas (and roots) and checks that the powers of tau provided is valid. It returns the PTau and the zkey.

1. Commit

For each stage, f_i polynomials needs to be committed. This is done by calling the following function:

await commit(stage, pk, polynomials, PTau, curve, options);

2. Open

Once the polynomials for all the stages has been committed, the opening points will be computed. All the polynomials evaluations will be calculated, along with the W and W' needed for the shplonk commitment scheme.

await open(pk, PTau, polynomials, committedPols, curve, options);

If the protocol is applied by opening points, the f_i polynomials and its commitments calculated in the previous phase will be added to obtain the corresponding f_i

3. Verify openings

The verifier can check that the openings have been computed correctly by calling the following function:

await verifyOpenings(vk, committedPols, evaluations, curve, options);

4. Solidity verifier

await exportCalldata(vk, commits, evaluations, curve, options)
await exportSolidityVerifier(vk, curve, options)

License

Licensed under either of

  • Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Disclaimer

This code has not yet been audited, and should not be used in any production systems.