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.

67 lines
2.8 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 & go 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. go run ../cli/cli.go -convert -pk circuit1k/proving_key.json -pkbin circuit1k/proving_key.go.bin
  42. echo "convert witness & pk of circuit5k to bin & go bin"
  43. node node_modules/wasmsnark/tools/buildwitness.js -i circuit5k/witness.json -o circuit5k/witness.bin
  44. node node_modules/wasmsnark/tools/buildpkey.js -i circuit5k/proving_key.json -o circuit5k/proving_key.bin
  45. go run ../cli/cli.go -convert -pk circuit5k/proving_key.json -pkbin circuit5k/proving_key.go.bin
  46. # echo "convert witness & pk of circuit10k to bin & go bin"
  47. # node node_modules/wasmsnark/tools/buildwitness.js -i circuit10k/witness.json -o circuit10k/witness.bin
  48. # node node_modules/wasmsnark/tools/buildpkey.js -i circuit10k/proving_key.json -o circuit10k/proving_key.bin
  49. # go run ../cli/cli.go -convert -pk circuit10k/proving_key.json -pkbin circuit10k/proving_key.go.bin
  50. #
  51. # echo "convert witness & pk of circuit20k to bin & go bin"
  52. # node node_modules/wasmsnark/tools/buildwitness.js -i circuit20k/witness.json -o circuit20k/witness.bin
  53. # node node_modules/wasmsnark/tools/buildpkey.js -i circuit20k/proving_key.json -o circuit20k/proving_key.bin
  54. # go run ../cli/cli.go -convert -pk circuit20k/proving_key.json -pkbin circuit20k/proving_key.go.bin