diff --git a/workflow/.gitignore b/workflow/.gitignore index c77d435..659e6b8 100644 --- a/workflow/.gitignore +++ b/workflow/.gitignore @@ -1,3 +1,4 @@ build/ build_big/ +build*/ tmp/ \ No newline at end of file diff --git a/workflow/README.md b/workflow/README.md index 0e21286..f9c1de1 100644 --- a/workflow/README.md +++ b/workflow/README.md @@ -16,28 +16,44 @@ NOTE: the examples below assume `bash`. In particular, it won't work with `zsh` To have an overview of what all the different steps and files are, see [PROOFS.md](PROOFS.md). -### Some measurements +### Some benchmarks Approximate time to run this on an M2 (8+4 cores), with 10 samples: - compiling the circuit: 8 seconds - circuit-specific setup (with 1 contributor): 85 seconds - size of the `.zkey` file (only 1 contributor): 110 megabytes +- generating the witness (WASM): 0.3 seconds - proving with `snarkjs` (slow): 7.7 seconds +- proving wiht `zikkurat` (single threaded): 13 seconds +- proving with `nim-groth16` (old version): 2 seconds Same with 50 samples: - compiling: 37 seconds -- circuit-specific setup: ~420 seconds +- circuit-specific setup: ~430 seconds - `.zkey` file: 525 megabytes -- snarkjs prove: 34 seconds +- generating the witness (WASM): 1.2 seconds +- proving with `snarkjs`: 36 seconds +- proving wiht `zikkurat` (single threaded): 52 seconds +- proving with `nim-groth16` (old version): 9.4 seconds And with 100 samples: -- compiling: 76 seconds -- circuit-specific setup: ~1000 seconds -- `.zkey` file -- snarkjs prove: 76 seconds +- compiling: 76 seconds +- circuit-specific setup: ~1050 seconds +- `.zkey` file +- generating the witness (WASM): 2.3 seconds +- proving with `snarkjs`: 76 seconds +- proving wiht `zikkurat` (single threaded): 102 seconds +- proving with `nim-groth16` (old version): 18 seconds + +TODO: + +- add `arkworks` prover +- add `rapidsnarks` prover (doesn't run on ARM) +- update `nim-groth16` to `constantine-0.1` (should be faster because no workarounds) +- add multithreading to `zikkurat` ### Preliminaries diff --git a/workflow/cli_args.sh b/workflow/cli_args.sh index 6ea183b..525791c 100755 --- a/workflow/cli_args.sh +++ b/workflow/cli_args.sh @@ -13,7 +13,9 @@ CLI_ARGS="--depth=$MAXDEPTH \ --seed=$SEED \ --nslots=$NSLOTS \ --ncells=$NCELLS \ - --index=$SLOTINDEX" + --index=$SLOTINDEX \ + --field=bn254 \ + --hash=poseidon2" if [[ "$1" == "--export" ]] then diff --git a/workflow/prove.sh b/workflow/prove.sh index 8fcf7d5..cfd66c8 100755 --- a/workflow/prove.sh +++ b/workflow/prove.sh @@ -16,16 +16,18 @@ ${NIMCLI_DIR}/cli $CLI_ARGS -v --output=input.json # --- generate the witness --- +start=`date +%s` echo "" echo "generating the witness..." cd ${CIRCUIT_MAIN}_js time node generate_witness.js ${CIRCUIT_MAIN}.wasm ../input.json ../witness.wtns cd ${ORIG}/build +end=`date +%s` +echo "Generating the witness took `expr $end - $start` seconds." # --- create the proof --- PROVER="snarkjs" -# PROVER="nim" RS=`which rapidsnark` if [[ ! -z "$RS" ]] @@ -33,9 +35,13 @@ then PROVER="rapidsnark" fi +# PROVER="zikkurat" +PROVER="nim" + echo "" echo "creating the proof... using prover: \`$PROVER\`" +start=`date +%s` case $PROVER in snarkjs) time snarkjs groth16 prove ${CIRCUIT_MAIN}.zkey witness.wtns proof.json public.json @@ -46,11 +52,16 @@ case $PROVER in nim) time nim-groth16 -tpv --zkey=${CIRCUIT_MAIN}.zkey --wtns=witness.wtns -o=proof.json -i=public.json ;; + zikkurat) + time zikkurat-groth16 -tpv --zkey=${CIRCUIT_MAIN}.zkey --wtns=witness.wtns # -o=proof.json -i=public.json + ;; *) echo "unknown prover \`$PROVER\`" exit 99 ;; esac +end=`date +%s` +echo "Creating the proof took `expr $end - $start` seconds." # --- verify the proof --- diff --git a/workflow/setup.sh b/workflow/setup.sh index 076fe65..bc0d9dc 100755 --- a/workflow/setup.sh +++ b/workflow/setup.sh @@ -14,8 +14,13 @@ ${NIMCLI_DIR}/cli $CLI_ARGS -v --circom=${CIRCUIT_MAIN}.circom # --- compile the circuit --- +echo "" +start=`date +%s` CIRCUIT_INCLUDES="-l${CIRCUIT_LIB_DIR} -l${CIRCUIT_POS_DIR} -l${CIRCUIT_PRF_DIR}" -time circom --r1cs --wasm --O2 ${CIRCUIT_INCLUDES} ${CIRCUIT_MAIN}.circom +circom --r1cs --wasm --O2 ${CIRCUIT_INCLUDES} ${CIRCUIT_MAIN}.circom +end=`date +%s` +echo "Compiling the circuit took `expr $end - $start` seconds." +echo "" # --- circuit specific setup ---