Git Product home page Git Product logo

performance-test-of-hash-functions-groth16's Introduction

Prover Side Performance Test of Groth16 of Hash Functions

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

Results

WASM File Sizes

R1CS File Sizes

Witness File Sizes

Prover Key Sizes

Prover Runtimes

Requirements

  • Circom: 2.1.8
  • NodeJS: 20.10.0
  • SnarkJS: 0.7.3

Install Dependencies

npm install

Trusted Setup Ceremony (powersoftau)

Start the Ceremony

mkdir ZKSetup && snarkjs powersoftau new bn128 16 ZKSetup/pot16_0000.ptau -v

Contribution to the Ceremony

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

Verify the Ceremony

snarkjs powersoftau verify ZKSetup/pot16_final.ptau

Generate WASM files

circom circuits/sha256.circom --wasm
circom circuits/mimc.circom --wasm
circom circuits/poseidon.circom --wasm
circom circuits/pedersen.circom --wasm

Generate R1CS files

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

Generate witness files

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

Generate Prover Keys

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

Generate Verification Keys

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

Generate Proofs

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

Verify Proofs

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

Analysis

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

Plot Analyzed Data

node visualizor.js

performance-test-of-hash-functions-groth16's People

Contributors

sudiptab2100 avatar

Stargazers

Vikas Rushi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.