tornado-nova/scripts/buildCircuit.sh

18 lines
1.3 KiB
Bash
Raw Normal View History

2021-06-06 19:31:32 +02:00
#!/bin/bash -e
2021-06-09 12:30:08 +02:00
POWERS_OF_TAU=14 # circuit will support max 2^POWERS_OF_TAU constraints
2021-06-06 19:31:32 +02:00
mkdir -p artifacts/circuits
2021-06-09 12:30:08 +02:00
if [ ! -f artifacts/circuits/ptau$POWERS_OF_TAU ]; then
echo "Generating powers of tau file"
npx snarkjs powersoftau new bn128 $POWERS_OF_TAU artifacts/circuits/tmp_ptau$POWERS_OF_TAU
npx snarkjs powersoftau contribute artifacts/circuits/tmp_ptau$POWERS_OF_TAU artifacts/circuits/tmp2_ptau$POWERS_OF_TAU
npx snarkjs powersoftau prepare phase2 artifacts/circuits/tmp2_ptau$POWERS_OF_TAU artifacts/circuits/ptau$POWERS_OF_TAU
rm artifacts/circuits/tmp_ptau$POWERS_OF_TAU artifacts/circuits/tmp2_ptau$POWERS_OF_TAU
fi
2021-06-06 19:31:32 +02:00
npx circom -v -r artifacts/circuits/$1.r1cs -w artifacts/circuits/$1.wasm -s artifacts/circuits/$1.sym circuits/$1.circom
2021-06-09 12:30:08 +02:00
npx snarkjs groth16 setup artifacts/circuits/$1.r1cs artifacts/circuits/ptau$POWERS_OF_TAU artifacts/circuits/tmp_$1.zkey
npx snarkjs zkey contribute artifacts/circuits/tmp_$1.zkey artifacts/circuits/$1.zkey
npx snarkjs zkey export solidityverifier artifacts/circuits/$1.zkey artifacts/circuits/Verifier.sol
#zkutil setup -c artifacts/circuits/$1.r1cs -p artifacts/circuits/$1.params
#zkutil generate-verifier -p artifacts/circuits/$1.params -v artifacts/circuits/Verifier.sol
2021-06-06 19:31:32 +02:00
npx snarkjs info -r artifacts/circuits/$1.r1cs