tornado-nova/scripts/buildCircuit.sh

16 lines
1.2 KiB
Bash
Raw Normal View History

2021-06-06 19:31:32 +02:00
#!/bin/bash -e
2021-06-09 12:58:57 +02:00
POWERS_OF_TAU=15 # 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 "Downloading powers of tau file"
curl -L https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_$POWERS_OF_TAU.ptau --create-dirs -o artifacts/circuits/ptau$POWERS_OF_TAU
2021-06-09 12:30:08 +02:00
fi
npx circom -v -r artifacts/circuits/transaction$1.r1cs -w artifacts/circuits/transaction$1.wasm -s artifacts/circuits/transaction$1.sym circuits/transaction$1.circom
npx snarkjs groth16 setup artifacts/circuits/transaction$1.r1cs artifacts/circuits/ptau$POWERS_OF_TAU artifacts/circuits/tmp_transaction$1.zkey
2021-06-16 14:20:16 +02:00
echo "qwe" | npx snarkjs zkey contribute artifacts/circuits/tmp_transaction$1.zkey artifacts/circuits/transaction$1.zkey
npx snarkjs zkey export solidityverifier artifacts/circuits/transaction$1.zkey artifacts/circuits/Verifier$1.sol
sed -i.bak "s/contract Verifier/contract Verifier${1}/g" artifacts/circuits/Verifier$1.sol
#zkutil setup -c artifacts/circuits/transaction$1.r1cs -p artifacts/circuits/transaction$1.params
#zkutil generate-verifier -p artifacts/circuits/transaction$1.params -v artifacts/circuits/Verifier.sol
npx snarkjs info -r artifacts/circuits/transaction$1.r1cs