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

circom-helper

v0.3.5

Published

A convenient way for developers to compile, cache, and execute circom circuits, as well as to generate proofs.

Downloads

190

Readme

circom-helper

circom-helper allows developers to test circom circuits quickly and easily.

It uses circom version 2, which has better performance than the previous version. Note that circuits written for the previous version of circom must be slightly modified to be compatible with circom 2.

To use the old version of circom, install circom-helper 0.1.0 or 0.2.0 via NPM.

It compiles circuits and exposes a JSON-RPC API which allows developers to generate witnesses and access signal values without writing command-line glue scripts.

Installation

npm i circom-helper

To build from source:

git clone [email protected]:weijiekoh/circom-helper.git && \
cd circom-helper && \
npm i && \
npm run build

Install OS dependencies

On Debian, Ubuntu, or derivatives:

sudo apt-get install libgmp-dev nlohmann-json3-dev nasm g++

On openSUSE or derivatives:

sudo zypper install gmp-devel nlohmann_json-devel nasm g++

User guide

  1. Create a config file. Use config.example.json as a reference.

    • The circuitDirs field should be an array of directories which contain the circom files you wish to compile. Note that there should not be any filename collisions, even across directories.
    • The circom field should be a path to the circom binary, relative to the config file's path.
    • The snarkjs field should be a path to the build/cli.cjs in a snarkjs node_modules package.
  2. Create a compiled/ and temp/ directory for compiled circuits and tempoary files.

  3. Run the server:

     npm run serve
  4. Run the internal test suite for the server:

     npm run test-server
  5. Run a test suite for the example circuit under example/:

     npm run test-snarks

JSON-RPC API

gen_witness

Generates a witness given a circuit name and public inputs.

Inputs:

  • circuit: the name of the circuit. For example, if test.circom is in one of the circuitDirs, and you want to generate a witness for inputs to this circuit, set this value as test.
  • inputs: the public inputs to the circuit (as a JS object). For example: { left: '1', right: '2' }. The number values should be strings as the JS safe integer limit is lower than the group order for BN254 and other elliptic curves used for ZK proofs.

Returns:

  • witness: an array of strings (e.g. [1, 3, 1, 2]).

To find the index of any signal (e.g. main.out), use get_signal_index. With this index, you can then look up this array and get the value of the signal.

get_signal_index

Inputs:

  • circuit: the name of the circuit.
  • name: the signal name (e.g. main.out).

Returns:

  • index: a numeric value as a string.