# main to build any circom CIRCOM_DIR=`pwd`/circom/ SNARKJS_DIR=`pwd`/snarkjs/ CIRCUITS_DIR=`pwd`/circuits/ TAU_DIR=`pwd`/tau INPUT_DIR=`pwd`/inputs OUTPUT_DIR=`pwd`/output HOME_DIR=`pwd` CIRCOM_BIN=$CIRCOM_DIR/target/debug/circom SNARKJS_BIN=$SNARKJS_DIR/cli.js MAIN=$1 set -ex cd $CIRCOM_DIR cargo build cd $HOME_DIR mkdir -p $OUTPUT_DIR cd $CIRCUITS_DIR $CIRCOM_BIN $MAIN.circom --r1cs --wasm -o $OUTPUT_DIR cd $HOME_DIR cd $INPUT_DIR node $MAIN.js cd $HOME_DIR cd $OUTPUT_DIR node $SNARKJS_BIN groth16 setup $OUTPUT_DIR/$MAIN.r1cs $TAU_DIR/pot18_final.ptau $OUTPUT_DIR/key0.zkey node $SNARKJS_BIN zkey contribute --name="random str 123" --entropy="random str 456" key0.zkey proof_key.zkey node $SNARKJS_BIN zkey export verificationkey proof_key.zkey verification_key.json node ${MAIN}_js/generate_witness.js ${MAIN}_js/$MAIN.wasm $INPUT_DIR/$MAIN.json witness.wtns node $SNARKJS_BIN groth16 prove proof_key.zkey witness.wtns proof.json output.json node $SNARKJS_BIN groth16 verify verification_key.json output.json proof.json cd $HOME_DIR