diff --git a/hash/cpu/bench/Blake3/Unix/bench.cfg b/hash/cpu/bench/Blake3/Unix/bench.cfg new file mode 100644 index 0000000..e3c47c2 --- /dev/null +++ b/hash/cpu/bench/Blake3/Unix/bench.cfg @@ -0,0 +1,7 @@ +name: "Blake3 CPU benchmark; official Rust implementation" +timeout: 60 +params: + [ MEGABYTES: [ 1,4,16,64,256 ] + , NTHREADS: [ 1,2,4,8 ] + ] +tags: CPU, Blake3, Rust diff --git a/hash/cpu/bench/Poseidon2/Zikkurat/bench.cfg b/hash/cpu/bench/Poseidon2/Zikkurat/bench.cfg new file mode 100644 index 0000000..2b001a2 --- /dev/null +++ b/hash/cpu/bench/Poseidon2/Zikkurat/bench.cfg @@ -0,0 +1,8 @@ +name: "Poseidon2 CPU benchmark; Zikkurat/C implementation" +author: Balazs Komuves +timeout: 60 +params: + [ TREE_DEPTH: [ 8,10,12,14,16 ] + , NTHREADS: [ 1,2,4,8 ] + ] +tags: CPU, Poseidon2, Zikkurat, C diff --git a/hash/cpu/bench/SHA256/C/bench.cfg b/hash/cpu/bench/SHA256/C/bench.cfg new file mode 100644 index 0000000..698ee16 --- /dev/null +++ b/hash/cpu/bench/SHA256/C/bench.cfg @@ -0,0 +1,8 @@ +name: "SHA256 CPU benchmark; Aaron D. Gifford's C implementation" +timeout: 60 +params: + [ WHICH: [ LINEAR, MERKLE ] + , MEGABYTES: [ 1,4,16,64,256 ] + , NTHREADS: [ 1,2,4,8 ] + ] +tags: CPU, SHA256, C diff --git a/hash/cpu/bench/SHA256/Unix/bench.cfg b/hash/cpu/bench/SHA256/Unix/bench.cfg new file mode 100644 index 0000000..a4bf604 --- /dev/null +++ b/hash/cpu/bench/SHA256/Unix/bench.cfg @@ -0,0 +1,6 @@ +name: "SHA256 CPU benchmark; Unix tool included in the OS" +timeout: 60 +params: + [ MEGABYTES: [ 1,4,16,64,256 ] + ] +tags: CPU, SHA256, Unix diff --git a/hash/cpu/bench/SHA256/Unix/run.sh b/hash/cpu/bench/SHA256/Unix/run.sh index e3562c7..3413c4e 100755 --- a/hash/cpu/bench/SHA256/Unix/run.sh +++ b/hash/cpu/bench/SHA256/Unix/run.sh @@ -6,4 +6,21 @@ fi echo "MEGABYTES = $ZKBENCH_MEGABYTES" -./build/fakedata $ZKBENCH_MEGABYTES | shasum -a256 -b - \ No newline at end of file +OSTYPE=`uname -s` + +case $OSTYPE in + Darwin) + ./build/fakedata $ZKBENCH_MEGABYTES | shasum -a256 -b - + ;; + Linux) + ./build/fakedata $ZKBENCH_MEGABYTES | sha256sum -b - + ;; + FreeBSD) + ./build/fakedata $ZKBENCH_MEGABYTES | sha256sum -b - + ;; + + *) + echo "unknown operating system \`$OSTYPE\`" + exit 99 + ;; +esac diff --git a/hash/snark/bench/Poseidon2/bench.cfg b/hash/snark/bench/Poseidon2/bench.cfg new file mode 100644 index 0000000..743c64e --- /dev/null +++ b/hash/snark/bench/Poseidon2/bench.cfg @@ -0,0 +1,11 @@ + +name: "Poseidon2 Groth16 benchmarks" +author: Balazs Komuves +timeout: 300 +rerun_from: build +params: + [ PROVER: [ snarkjs, rapidsnark ] + , INPUT_SIZE: [ 256, 512, 1024, 2048 ] + , WHICH: [ hash_sponge_rate1, hash_sponge_rate2, hash_merkle ] + ] +tags: Groth16, Poseidon2, $PROVER diff --git a/hash/snark/bench/Poseidon2/build.sh b/hash/snark/bench/Poseidon2/build.sh index b15f12f..56148bc 100755 --- a/hash/snark/bench/Poseidon2/build.sh +++ b/hash/snark/bench/Poseidon2/build.sh @@ -14,8 +14,12 @@ mkdir -p build gcc -O3 generate_input.c -o build/generate_input || { echo "gcc failed"; exit 101; } -NAME=${ZKBENCH_WHICH} -sed "s/ZKBENCH_INPUT_SIZE/${ZKBENCH_INPUT_SIZE}/g" ${NAME}.circom.template >build/${NAME}.circom +#NAME=${ZKBENCH_WHICH} +NAME="hash" +echo ${NAME}.circom.template \ + | sed "s/ZKBENCH_INPUT_SIZE/${ZKBENCH_INPUT_SIZE}/g" \ + | sed "s/ZKBENCH_WHICH/${ZKBENCH_WHICH}/g" \ + >build/${NAME}.circom cd build diff --git a/hash/snark/bench/Poseidon2/hash.circom.template b/hash/snark/bench/Poseidon2/hash.circom.template new file mode 100644 index 0000000..b9b0020 --- /dev/null +++ b/hash/snark/bench/Poseidon2/hash.circom.template @@ -0,0 +1,49 @@ +pragma circom 2.0.0; + +include "../../../external/hash-circuits/circuits/poseidon2/poseidon2_hash.circom"; +include "../../../external/hash-circuits/circuits/poseidon2/poseidon2_merkle.circom"; + +//------------------------------------------------------------------------------ + +// sponge with rate=1 (capacity=2) +template Bench_hash_sponge_rate1(n) { + signal input inp[n]; + signal output out; + component sponge = PoseidonSponge(3,2,n,1); + sponge.inp <== inp; + sponge.out[0] ==> out; +} + +// sponge with rate=2 (capacity=1) +template Bench_hash_sponge_rate2(n) { + signal input inp[n]; + signal output out; + component sponge = PoseidonSponge(3,1,n,1); + sponge.inp <== inp; + sponge.out[0] ==> out; +} + +//------------------------------------------------------------------------------ + +function FloorLog2(n) { + return (n==0) ? -1 : (1 + FloorLog2(n>>1)); +} + +function CeilLog2(n) { + return (n==0) ? 0 : (1 + FloorLog2(n-1)); +} + +template Bench_hash_merkle2(n) { + var log2n = CeilLog2(n); + assert( (1< out; +} + +//------------------------------------------------------------------------------ + +component main {public [inp]} = Bench_ZKBENCH_WHICH( ZKBENCH_INPUT_SIZE ); diff --git a/hash/snark/bench/Poseidon2/hash_sponge.circom.template b/hash/snark/bench/Poseidon2/hash_sponge.circom.template deleted file mode 100644 index f8e8b28..0000000 --- a/hash/snark/bench/Poseidon2/hash_sponge.circom.template +++ /dev/null @@ -1,5 +0,0 @@ -pragma circom 2.0.0; - -include "../../../external/hash-circuits/circuits/poseidon2/poseidon2_hash.circom"; - -component main {public [inp]} = Poseidon2_hash( ZKBENCH_INPUT_SIZE ); diff --git a/hash/snark/external/hash-circuits b/hash/snark/external/hash-circuits index bf6cca3..e6b99b2 160000 --- a/hash/snark/external/hash-circuits +++ b/hash/snark/external/hash-circuits @@ -1 +1 @@ -Subproject commit bf6cca380547ca905ca0615cfdb6c49660e441a2 +Subproject commit e6b99b20f038f27390f590313ce7de227d6dd42a