2021-07-26 12:45:07 +03:00
|
|
|
//! Arkworks - Circom Compatibility layer
|
|
|
|
|
//!
|
|
|
|
|
//! Given a Circom WASM-compiled witness.wasm, it can read it and calculate the corresponding
|
|
|
|
|
//!
|
|
|
|
|
//! ## WASM Witness Generator
|
|
|
|
|
//!
|
|
|
|
|
//! ## Types
|
|
|
|
|
//! * ZKey
|
|
|
|
|
//! * WTNS
|
|
|
|
|
//! * R1CS
|
|
|
|
|
//! * WASM
|
|
|
|
|
//! * Sys?
|
|
|
|
|
//!
|
|
|
|
|
//! Inputs:
|
|
|
|
|
//! * circuit.wasm
|
|
|
|
|
//! * input.json
|
|
|
|
|
//!
|
|
|
|
|
//! Outputs:
|
|
|
|
|
//! * witness.wtns
|
|
|
|
|
//!
|
|
|
|
|
//! Given a circuit WASM and an input.json calculates the corresponding witness
|
|
|
|
|
//!
|
|
|
|
|
//! ## Proof calculator
|
|
|
|
|
//!
|
|
|
|
|
//! Inputs:
|
|
|
|
|
//! * witness.wtns / witness.json
|
|
|
|
|
//! * circuit.zkey
|
|
|
|
|
//!
|
|
|
|
|
//! Given a witness (and r1cs?) synthesizes the circom circuit
|
|
|
|
|
//! And then feeds it to the arkworks groth16 prover
|
|
|
|
|
//!
|
|
|
|
|
//! Outputs:
|
|
|
|
|
//! * public.json
|
|
|
|
|
//! * proof.json
|
|
|
|
|
//!
|
|
|
|
|
//! ## Smart Contract connector class
|
|
|
|
|
//!
|
|
|
|
|
//! Given an Arkworks proof, it's able to translate it to the Circom-verifier
|
|
|
|
|
//! expected arguments
|
|
|
|
|
//!
|
|
|
|
|
//! (No Dark Forest specific modifications included, these are part of df-snark)
|
|
|
|
|
//!
|
|
|
|
|
//! ## Binary
|
|
|
|
|
//!
|
|
|
|
|
//! CLIs for each of the above + logging to stdout
|
|
|
|
|
//!
|
|
|
|
|
//! witness for the specified inputs
|
|
|
|
|
//!
|
|
|
|
|
//! ## Commands
|
|
|
|
|
//!
|
|
|
|
|
//! Compile a circuit:
|
|
|
|
|
//! `circom circuit.circom --r1cs --wasm --sym`
|
|
|
|
|
//!
|
|
|
|
|
//! Phase2 over circuit + PoT
|
|
|
|
|
//! `snarkjs zkey new circuit.r1cs powersOfTau28_hez_final_10.ptau circuit_0000.zkey`
|
|
|
|
|
//! `snarkjs zkey contribute circuit_0000.zkey circuit_final.zkey`
|
|
|
|
|
//! `snarkjs zkey export verificationkey circuit_final.zkey verification_key.json`
|
|
|
|
|
//!
|
|
|
|
|
//! Witness calculation from inputs:
|
|
|
|
|
//! `snarkjs wtns calculate circuit.wasm input.json witness.wtns`
|
|
|
|
|
//! `snarkjs wtns export json witness.wtns witness.json`
|
|
|
|
|
//!
|
|
|
|
|
//! Groth16 proof calculation:
|
|
|
|
|
//! `snarkjs groth16 prove circuit_final.zkey witness.wtns proof.json public.json`
|
|
|
|
|
//!
|
|
|
|
|
//! Groth16 Proof verification:
|
|
|
|
|
//! `snarkjs groth16 verify verification_key.json public.json proof.json`
|
|
|
|
|
|
2021-07-26 17:53:45 +03:00
|
|
|
mod witness;
|
2021-07-26 12:45:07 +03:00
|
|
|
|
2021-07-26 17:53:45 +03:00
|
|
|
pub mod circom;
|
|
|
|
|
pub use circom::{CircomBuilder, CircomCircuit, CircomConfig, R1CStoQAPCircom};
|
2021-07-26 12:45:07 +03:00
|
|
|
|
|
|
|
|
pub mod ethereum;
|
|
|
|
|
|
2021-07-26 17:53:45 +03:00
|
|
|
mod zkey;
|
|
|
|
|
pub use zkey::read_zkey;
|