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

snarkit

v0.0.11

Published

A command line tool to test circom circuit with given inputs/outputs

Downloads

19

Readme

snarkit

A toolkit to compile and debug circom circuit.

Features

Better support for huge circuits

snarkit supports both wasm witness generator and native(cpp) witness generator. So compared to the snarkjs official tool, snarkit is more friendly for developing huge circuits by using native backend.

Better error detection

snarkit can print very helpful error messages when the circuit code goes wrong. It can display the code line number and the component/signals related to the error, so we can detect the reason for the error quickly and fix it. Example:

# display incorrect component and signals
$ snarkit check ./testdata/num2bits_err/

Invalid constraint:
0 * 0 != ((-1)*signal1 + 1*signal2 + 2*signal3 + 4*signal4 + 8*signal5 + 16*signal6 + 32*signal7 + 64*signal8 + 128*signal9)
Related signals:
signal1: main.num, value: 3
signal2: main.bits[0], value: 1
signal3: main.bits[1], value: 1
signal4: main.bits[2], value: 1
signal5: main.bits[3], value: 0
signal6: main.bits[4], value: 0
signal7: main.bits[5], value: 0
signal8: main.bits[6], value: 0
signal9: main.bits[7], value: 0
please check your circuit and input

# display incorrect code line number
$ snarkit check ./testdata/num2bits_err/ --sanity_check

Constraint doesn't match, /home/ubuntu/repos/snarkit/testdata/num2bits_err/circuit.circom:11:4: 3 != 7circuit: /home/ubuntu/repos/snarkit/testdata/num2bits_err/calcwit.cpp:201: void Circom_CalcWit::checkConstraint(int, PFrElement, PFrElement, const char*): Assertion `false' failed.
Aborted (core dumped)

Example

The following demos how to test a circuit with given inputs/outputs.

$ npm install snarkit

# first, you should prepare the circuit and input/output as the following structure
# all the input.json/output.json pair inside data/*** folder will be tested
# output.json can be an empty json file if you don't need to test against any circuit outputs.
$ find num2bits/
num2bits/
num2bits/data
num2bits/data/case01
num2bits/data/case01/output.json
num2bits/data/case01/input.json
num2bits/circuit.circom

# Snarkit has two backend: wasm and native(cpp). Only native backend can process huge circuits, you have to install some dependencies first before using it.

# use wasm backend
# compile the circuit
$ npx snarkit compile num2bits --backend wasm
# test the circuit
$ npx snarkit check num2bits --backend wasm

# use native backend
# install deps
$ sudo apt install nlohmann-json3-dev nasm g++ libgmp-dev
# compile the circuit
$ npx snarkit compile num2bits --backend native
# test the circuit
$ npx snarkit check num2bits --backend native

Misc

If you encounter FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory you can try increasing max-old-space-size by setting NODE_ARGS ENV to fully utilize your RAM. For example,

$ export NODE_ARGS='--max-old-space-size=16384'
$ npx snarkit compile num2bits --backend native -f

If still encountering error, then you should try compiling it in a machine with larger RAM.