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.

63 lines
2.3 KiB

  1. #!/bin/sh
  2. npm install
  3. compile_and_ts_and_witness() {
  4. echo $(date +"%T") "circom circuit.circom --r1cs --wasm --sym"
  5. itime="$(date -u +%s)"
  6. ../node_modules/.bin/circom circuit.circom --r1cs --wasm --sym
  7. ftime="$(date -u +%s)"
  8. echo " ($(($(date -u +%s)-$itime))s)"
  9. echo $(date +"%T") "snarkjs info -r circuit.r1cs"
  10. ../node_modules/.bin/snarkjs info -r circuit.r1cs
  11. echo $(date +"%T") "snarkjs setup"
  12. itime="$(date -u +%s)"
  13. ../node_modules/.bin/snarkjs setup
  14. echo " ($(($(date -u +%s)-$itime))s)"
  15. echo $(date +"%T") "trusted setup generated"
  16. sed -i 's/null/["0","0","0"]/g' proving_key.json
  17. echo "calculating witness"
  18. ../node_modules/.bin/snarkjs calculatewitness --wasm circuit.wasm --input inputs.json --witness witness.json
  19. echo $(date +"%T") "snarkjs generateverifier"
  20. itime="$(date -u +%s)"
  21. ../node_modules/.bin/snarkjs generateverifier
  22. echo " ($(($(date -u +%s)-$itime))s)"
  23. echo $(date +"%T") "generateverifier generated"
  24. }
  25. echo "compile & trustesetup for circuit1k"
  26. cd circuit1k
  27. compile_and_ts_and_witness
  28. echo "compile & trustesetup for circuit5k"
  29. cd ../circuit5k
  30. compile_and_ts_and_witness
  31. # echo "compile & trustesetup for circuit10k"
  32. # cd ../circuit10k
  33. # compile_and_ts_and_witness
  34. # echo "compile & trustesetup for circuit20k"
  35. # cd ../circuit20k
  36. # compile_and_ts_and_witness
  37. cd ../
  38. echo "convert witness & pk of circuit1k to bin"
  39. node node_modules/wasmsnark/tools/buildwitness.js -i circuit1k/witness.json -o circuit1k/witness.bin
  40. node node_modules/wasmsnark/tools/buildpkey.js -i circuit1k/proving_key.json -o circuit1k/proving_key.bin
  41. echo "convert witness & pk of circuit5k to bin"
  42. node node_modules/wasmsnark/tools/buildwitness.js -i circuit5k/witness.json -o circuit5k/witness.bin
  43. node node_modules/wasmsnark/tools/buildpkey.js -i circuit5k/proving_key.json -o circuit5k/proving_key.bin
  44. # echo "convert witness & pk of circuit10k to bin"
  45. # node node_modules/wasmsnark/tools/buildwitness.js -i circuit10k/witness.json -o circuit10k/witness.bin
  46. # node node_modules/wasmsnark/tools/buildpkey.js -i circuit10k/proving_key.json -o circuit10k/proving_key.bin
  47. #
  48. # echo "convert witness & pk of circuit20k to bin"
  49. # node node_modules/wasmsnark/tools/buildwitness.js -i circuit20k/witness.json -o circuit20k/witness.bin
  50. # node node_modules/wasmsnark/tools/buildpkey.js -i circuit20k/proving_key.json -o circuit20k/proving_key.bin