You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.6 KiB

  1. #!/bin/sh
  2. # npm install
  3. rm -r build
  4. mkdir build
  5. cd build
  6. compile_and_ts() {
  7. echo $(date +"%T") "circom ../circuits/$CIRCUIT.circom --r1cs --wasm --sym"
  8. itime="$(date -u +%s)"
  9. ../node_modules/.bin/circom ../circuits/$CIRCUIT.circom --r1cs --wasm --sym
  10. ftime="$(date -u +%s)"
  11. echo " ($(($(date -u +%s)-$itime))s)"
  12. echo $(date +"%T") "snarkjs info -r $CIRCUIT.r1cs"
  13. ../node_modules/.bin/snarkjs info -r $CIRCUIT.r1cs
  14. echo $(date +"%T") "snarkjs setup"
  15. itime="$(date -u +%s)"
  16. ../node_modules/.bin/snarkjs setup -r $CIRCUIT.r1cs --pk $CIRCUIT-proving_key.json --vk $CIRCUIT-verification_key.json
  17. echo " ($(($(date -u +%s)-$itime))s)"
  18. echo $(date +"%T") "trusted setup generated"
  19. # sed -i 's/null/["0","0","0"]/g' proving_key.json
  20. echo $(date +"%T") "snarkjs generateverifier"
  21. itime="$(date -u +%s)"
  22. ../node_modules/.bin/snarkjs generateverifier --vk $CIRCUIT-verification_key.json -v $CIRCUIT-verifier.sol
  23. echo " ($(($(date -u +%s)-$itime))s)"
  24. echo $(date +"%T") "generateverifier generated"
  25. sed -i "s/solidity ^0.5.0/solidity ^0.6.0/g" ${CIRCUIT}-verifier.sol
  26. sed -i "s/gas/gas()/g" ${CIRCUIT}-verifier.sol
  27. sed -i "s/return the sum/return r the sum/g" ${CIRCUIT}-verifier.sol
  28. sed -i "s/return the product/return r the product/g" ${CIRCUIT}-verifier.sol
  29. sed -i "s/contract Verifier/contract ${CONTRACT}Verifier/g" ${CIRCUIT}-verifier.sol
  30. sed -i "s/Pairing/${CONTRACT}Pairing/g" ${CIRCUIT}-verifier.sol
  31. cp ${CIRCUIT}-verifier.sol ../contracts/
  32. }
  33. CIRCUIT="deposit"
  34. CONTRACT="Deposit"
  35. compile_and_ts
  36. CIRCUIT="withdraw"
  37. CONTRACT="Withdraw"
  38. compile_and_ts