This is a performance test of the prover side of the Groth16 proof system for hash functions. The test will be conducted on the following hash functions:
- SHA256
- MiMC
- Poseidon
- Pedersen
Groth16 has constant proof size and verification time. But the prover side has a variable time and space complexity depending on the circuit complexity. So, we will analyze the prover side performance of the Groth16 proof system for the above hash functions on the following parameters:
- WASM File Size
- R1CS File Size
- Witness File Size
- Prover Key Size
- Prover Time
- Circom: 2.1.8
- NodeJS: 20.10.0
- SnarkJS: 0.7.3
npm install
mkdir ZKSetup && snarkjs powersoftau new bn128 16 ZKSetup/pot16_0000.ptau -v
First contribution
snarkjs powersoftau contribute ZKSetup/pot16_0000.ptau ZKSetup/pot16_0001.ptau --name="First contribution" -v
Final contribution
snarkjs powersoftau prepare phase2 ZKSetup/pot16_0001.ptau ZKSetup/pot16_final.ptau -v
snarkjs powersoftau verify ZKSetup/pot16_final.ptau
circom circuits/sha256.circom --wasm
circom circuits/mimc.circom --wasm
circom circuits/poseidon.circom --wasm
circom circuits/pedersen.circom --wasm
circom circuits/sha256.circom --r1cs -o sha256_js
circom circuits/mimc.circom --r1cs -o mimc_js
circom circuits/poseidon.circom --r1cs -o poseidon_js
circom circuits/pedersen.circom --r1cs -o pedersen_js
node sha256_js/generate_witness.js sha256_js/sha256.wasm input.json sha256_js/witness.wtns
node mimc_js/generate_witness.js mimc_js/mimc.wasm input.json mimc_js/witness.wtns
node poseidon_js/generate_witness.js poseidon_js/poseidon.wasm input.json poseidon_js/witness.wtns
node pedersen_js/generate_witness.js pedersen_js/pedersen.wasm input.json pedersen_js/witness.wtns
snarkjs groth16 setup sha256_js/sha256.r1cs ZKSetup/pot16_final.ptau sha256_js/prover_key.zkey
snarkjs groth16 setup mimc_js/mimc.r1cs ZKSetup/pot16_final.ptau mimc_js/prover_key.zkey
snarkjs groth16 setup poseidon_js/poseidon.r1cs ZKSetup/pot16_final.ptau poseidon_js/prover_key.zkey
snarkjs groth16 setup pedersen_js/pedersen.r1cs ZKSetup/pot16_final.ptau pedersen_js/prover_key.zkey
snarkjs zkey export verificationkey sha256_js/prover_key.zkey sha256_js/verification_key.json
snarkjs zkey export verificationkey mimc_js/prover_key.zkey mimc_js/verification_key.json
snarkjs zkey export verificationkey poseidon_js/prover_key.zkey poseidon_js/verification_key.json
snarkjs zkey export verificationkey pedersen_js/prover_key.zkey pedersen_js/verification_key.json
snarkjs groth16 prove sha256_js/prover_key.zkey sha256_js/witness.wtns sha256_js/proof.json sha256_js/public.json
snarkjs groth16 prove mimc_js/prover_key.zkey mimc_js/witness.wtns mimc_js/proof.json mimc_js/public.json
snarkjs groth16 prove poseidon_js/prover_key.zkey poseidon_js/witness.wtns poseidon_js/proof.json poseidon_js/public.json
snarkjs groth16 prove pedersen_js/prover_key.zkey pedersen_js/witness.wtns pedersen_js/proof.json pedersen_js/public.json
snarkjs groth16 verify sha256_js/verification_key.json sha256_js/public.json sha256_js/proof.json
snarkjs groth16 verify mimc_js/verification_key.json mimc_js/public.json mimc_js/proof.json
snarkjs groth16 verify poseidon_js/verification_key.json poseidon_js/public.json poseidon_js/proof.json
snarkjs groth16 verify pedersen_js/verification_key.json pedersen_js/public.json pedersen_js/proof.json
Command: node analysis.js [hash_function] [number_of_iterations]
node analysis.js sha256 10
node analysis.js mimc 10
node analysis.js poseidon 10
node analysis.js pedersen 10
node visualizor.js