Giter Club home page Giter Club logo

circom-helper's Introduction

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.

circom-helper's People

Contributors

aspiers avatar corydickson avatar weijiekoh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

circom-helper's Issues

Error installing circom-helper versions that support circom2

  • As shown below it is not possible to install circom-helper versions(^0.3.0) that support circom2.
  • I tried to implement it for poseidon-encryption supporting circom2 but I ended up utilizing circom_tester following the same logic.
    -> It worked fine but unfortunately, circom_tester is 2-4x slower ( I would be interested also to have it working as fast as circom-helper)

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.