update the workflow scripts and benchmarks

This commit is contained in:
Balazs Komuves 2024-11-15 16:30:35 +01:00
parent 1c51aca81b
commit ad503d4e10
No known key found for this signature in database
GPG Key ID: F63B7AEF18435562
5 changed files with 45 additions and 10 deletions

1
workflow/.gitignore vendored
View File

@ -1,3 +1,4 @@
build/
build_big/
build*/
tmp/

View File

@ -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

View File

@ -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

View File

@ -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 ---

View File

@ -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 ---