circom-compat/src/lib.rs
src/lib.rsRaw
1//! Arkworks - Circom Compatibility layer
2//!
3//! Given a Circom WASM-compiled witness.wasm, it can read it and calculate the corresponding
4//!
5//! ## WASM Witness Generator
6//!
7//! ## Types
8//! * ZKey
9//! * WTNS
10//! * R1CS
11//! * WASM
12//! * Sys?
13//!
14//! Inputs:
15//! * circuit.wasm
16//! * input.json
17//!
18//! Outputs:
19//! * witness.wtns
20//!
21//! Given a circuit WASM and an input.json calculates the corresponding witness
22//!
23//! ## Proof calculator
24//!
25//! Inputs:
26//! * witness.wtns / witness.json
27//! * circuit.zkey
28//!
29//! Given a witness (and r1cs?) synthesizes the circom circuit
30//! And then feeds it to the arkworks groth16 prover
31//!
32//! Outputs:
33//! * public.json
34//! * proof.json
35//!
36//! ## Smart Contract connector class
37//!
38//! Given an Arkworks proof, it's able to translate it to the Circom-verifier
39//! expected arguments
40//!
41//! (No Dark Forest specific modifications included, these are part of df-snark)
42//!
43//! ## Binary
44//!
45//! CLIs for each of the above + logging to stdout
46//!
47//! witness for the specified inputs
48//!
49//! ## Commands
50//!
51//! Compile a circuit:
52//! `circom circuit.circom --r1cs --wasm --sym`
53//!
54//! Phase2 over circuit + PoT
55//! `snarkjs zkey new circuit.r1cs powersOfTau28_hez_final_10.ptau circuit_0000.zkey`
56//! `snarkjs zkey contribute circuit_0000.zkey circuit_final.zkey`
57//! `snarkjs zkey export verificationkey circuit_final.zkey verification_key.json`
58//!
59//! Witness calculation from inputs:
60//! `snarkjs wtns calculate circuit.wasm input.json witness.wtns`
61//! `snarkjs wtns export json witness.wtns witness.json`
62//!
63//! Groth16 proof calculation:
64//! `snarkjs groth16 prove circuit_final.zkey witness.wtns proof.json public.json`
65//!
66//! Groth16 Proof verification:
67//! `snarkjs groth16 verify verification_key.json public.json proof.json`
68
69mod witness;
70
71pub mod circom;
72pub use circom::{CircomBuilder, CircomCircuit, CircomConfig, R1CStoQAPCircom};
73
74pub mod ethereum;
75
76mod zkey;
77pub use zkey::read_zkey;