circuit prod build

This commit is contained in:
poma 2021-10-17 13:53:13 +03:00
parent c46f3ae1a9
commit d4b381a0a2
No known key found for this signature in database
GPG Key ID: BA20CB01FE165657
2 changed files with 15 additions and 0 deletions

View File

@ -8,6 +8,7 @@
},
"scripts": {
"circuit": "./scripts/buildCircuit.sh 2 && ./scripts/buildCircuit.sh 16",
"circuit_prod": "rm -rf ./artifacts/circuits && ./scripts/buildCircuit_prod.sh 2 && ./scripts/buildCircuit_prod.sh 16 && tar -czvf artifacts/circuits.tar.gz artifacts/circuits",
"compile": "npx hardhat compile",
"build": "npm run circuit && npm run compile",
"deploy": "npx hardhat run scripts/deploy.js --network optimism",

14
scripts/buildCircuit_prod.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash -e
POWERS_OF_TAU=15 # circuit will support max 2^POWERS_OF_TAU constraints
mkdir -p artifacts/circuits
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
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/transaction$1_0.zkey
npx snarkjs zkey contribute artifacts/circuits/transaction$1_0.zkey artifacts/circuits/transaction$1_1.zkey
npx snarkjs zkey beacon artifacts/circuits/transaction$1_1.zkey artifacts/circuits/transaction$1.zkey e586fccaf245c9a1d7e78294d4802018f3001149a71b8f10cd997ef8235aa372 10
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
npx snarkjs info -r artifacts/circuits/transaction$1.r1cs