mirror of
https://github.com/logos-storage/logos-storage-proofs-circuits.git
synced 2026-01-05 23:13:06 +00:00
update the workflow scripts and benchmarks
This commit is contained in:
parent
1c51aca81b
commit
ad503d4e10
1
workflow/.gitignore
vendored
1
workflow/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
build/
|
build/
|
||||||
build_big/
|
build_big/
|
||||||
|
build*/
|
||||||
tmp/
|
tmp/
|
||||||
@ -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).
|
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:
|
Approximate time to run this on an M2 (8+4 cores), with 10 samples:
|
||||||
|
|
||||||
- compiling the circuit: 8 seconds
|
- compiling the circuit: 8 seconds
|
||||||
- circuit-specific setup (with 1 contributor): 85 seconds
|
- circuit-specific setup (with 1 contributor): 85 seconds
|
||||||
- size of the `.zkey` file (only 1 contributor): 110 megabytes
|
- 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 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:
|
Same with 50 samples:
|
||||||
|
|
||||||
- compiling: 37 seconds
|
- compiling: 37 seconds
|
||||||
- circuit-specific setup: ~420 seconds
|
- circuit-specific setup: ~430 seconds
|
||||||
- `.zkey` file: 525 megabytes
|
- `.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:
|
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
|
### Preliminaries
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,9 @@ CLI_ARGS="--depth=$MAXDEPTH \
|
|||||||
--seed=$SEED \
|
--seed=$SEED \
|
||||||
--nslots=$NSLOTS \
|
--nslots=$NSLOTS \
|
||||||
--ncells=$NCELLS \
|
--ncells=$NCELLS \
|
||||||
--index=$SLOTINDEX"
|
--index=$SLOTINDEX \
|
||||||
|
--field=bn254 \
|
||||||
|
--hash=poseidon2"
|
||||||
|
|
||||||
if [[ "$1" == "--export" ]]
|
if [[ "$1" == "--export" ]]
|
||||||
then
|
then
|
||||||
|
|||||||
@ -16,16 +16,18 @@ ${NIMCLI_DIR}/cli $CLI_ARGS -v --output=input.json
|
|||||||
|
|
||||||
# --- generate the witness ---
|
# --- generate the witness ---
|
||||||
|
|
||||||
|
start=`date +%s`
|
||||||
echo ""
|
echo ""
|
||||||
echo "generating the witness..."
|
echo "generating the witness..."
|
||||||
cd ${CIRCUIT_MAIN}_js
|
cd ${CIRCUIT_MAIN}_js
|
||||||
time node generate_witness.js ${CIRCUIT_MAIN}.wasm ../input.json ../witness.wtns
|
time node generate_witness.js ${CIRCUIT_MAIN}.wasm ../input.json ../witness.wtns
|
||||||
cd ${ORIG}/build
|
cd ${ORIG}/build
|
||||||
|
end=`date +%s`
|
||||||
|
echo "Generating the witness took `expr $end - $start` seconds."
|
||||||
|
|
||||||
# --- create the proof ---
|
# --- create the proof ---
|
||||||
|
|
||||||
PROVER="snarkjs"
|
PROVER="snarkjs"
|
||||||
# PROVER="nim"
|
|
||||||
|
|
||||||
RS=`which rapidsnark`
|
RS=`which rapidsnark`
|
||||||
if [[ ! -z "$RS" ]]
|
if [[ ! -z "$RS" ]]
|
||||||
@ -33,9 +35,13 @@ then
|
|||||||
PROVER="rapidsnark"
|
PROVER="rapidsnark"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# PROVER="zikkurat"
|
||||||
|
PROVER="nim"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "creating the proof... using prover: \`$PROVER\`"
|
echo "creating the proof... using prover: \`$PROVER\`"
|
||||||
|
|
||||||
|
start=`date +%s`
|
||||||
case $PROVER in
|
case $PROVER in
|
||||||
snarkjs)
|
snarkjs)
|
||||||
time snarkjs groth16 prove ${CIRCUIT_MAIN}.zkey witness.wtns proof.json public.json
|
time snarkjs groth16 prove ${CIRCUIT_MAIN}.zkey witness.wtns proof.json public.json
|
||||||
@ -46,11 +52,16 @@ case $PROVER in
|
|||||||
nim)
|
nim)
|
||||||
time nim-groth16 -tpv --zkey=${CIRCUIT_MAIN}.zkey --wtns=witness.wtns -o=proof.json -i=public.json
|
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\`"
|
echo "unknown prover \`$PROVER\`"
|
||||||
exit 99
|
exit 99
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
end=`date +%s`
|
||||||
|
echo "Creating the proof took `expr $end - $start` seconds."
|
||||||
|
|
||||||
# --- verify the proof ---
|
# --- verify the proof ---
|
||||||
|
|
||||||
|
|||||||
@ -14,8 +14,13 @@ ${NIMCLI_DIR}/cli $CLI_ARGS -v --circom=${CIRCUIT_MAIN}.circom
|
|||||||
|
|
||||||
# --- compile the circuit ---
|
# --- compile the circuit ---
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
start=`date +%s`
|
||||||
CIRCUIT_INCLUDES="-l${CIRCUIT_LIB_DIR} -l${CIRCUIT_POS_DIR} -l${CIRCUIT_PRF_DIR}"
|
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 ---
|
# --- circuit specific setup ---
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user