circom-helper v0.3.5
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 git@github.com:weijiekoh/circom-helper.git && \
cd circom-helper && \
npm i && \
npm run buildInstall 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
Create a config file. Use
config.example.jsonas a reference.- The
circuitDirsfield should be an array of directories which contain thecircomfiles you wish to compile. Note that there should not be any filename collisions, even across directories. - The
circomfield should be a path to thecircombinary, relative to the config file's path. - The
snarkjsfield should be a path to thebuild/cli.cjsin asnarkjsnode_modulespackage.
- The
Create a
compiled/andtemp/directory for compiled circuits and tempoary files.Run the server:
npm run serveRun the internal test suite for the server:
npm run test-serverRun 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, iftest.circomis in one of thecircuitDirs, and you want to generate a witness for inputs to this circuit, set this value astest.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.
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago