Skip to content

tucnakomet1/zkVMs-bachelor-thesis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

zkVMs benchmarks

This repository contain Fibonacci, SHA-256, Poseidon and STARK to SNARK benchmarks of SP1 and RISC Zero zkVMs.

You can find my bachelor thesis in the UK digital repository.

Installation

It is assumed that rust is installed.

Here is a quick linux installation guide, but it is recommended to go to the official sites - RISC Zero docs, SP1 docs.

If you plan to generate SNARK proofs, you also need to have docker installed.

RISC Zero installation

# make rzup available in CLI
curl -L https://risczero.com/install | bash

# download RISC Zero toolchain
rzup install

SP1 installation

# make sp1up available in CLI
curl -L https://sp1up.succinct.xyz | bash

# download SP1 toolchain
sp1up

Structure

This repository contains three folders risc0bench, sp1bench and graphs.

Structure of risc0 folder

This folder contains following subfolders:

  • host: host method, parse CLI, runs the prover and verifier.
  • method/guest: guest method, contains Fibonacci, SHA-256 and Poseidon hash functions.

Structure of SP1 folder

This folder contains following subfolders:

  • script: host method, parse CLI, runs the prover and verifier.
  • program: guest method, contains Fibonacci, SHA-256 and Poseidon hash function.
  • lib: guest sha256 function, called by evm program
  • utils: method for calculating size of the proof
  • contracts: evm folder, contains generated solidity code

Usage

To run the benchmark, go to a specific folder first:

cd risc0bench 
# or
cd sp1bench/script
# or
cd graphs

RISC Zero

Run the following command in the main RISC Zero directory (/risc0bench):

cargo run -- --n 10 --sha256 --snark  # > log.txt
  • where n can be any integer (by default 20) and denotes the number of benchmark repetitions
  • you can choose between flags --fibonacci, --sha256, --poseidon, --poseidon2
  • flag --snark is optional - if used, the Groth16 proof is generated
  • if you want to save logs, use also > log.txt

There are two Poseidon hash implementation, one using SP1 library, the second (poseidon2) using RISC Zero library.

SP1

Inside sp1bench/script run the following script:

# for normal STARK proof generation
RUST_LOG=info cargo run --release -- --n 10 --sha256 # > log.txt

# for a SNARK proof generation - choose between groth16 and plonk
RUST_LOG=info cargo run --release --bin evm -- --system groth16 --n 10 # > log.txt
RUST_LOG=info cargo run --release --bin evm -- --system plonk --n 10 # > log.txt
  • where n is again any integer denoting the number of benchmark repetitions
  • you can choose between flags --fibonacci, --sha256, --poseidon
  • if you want to save logs, use also > log.txt
  • if you want to generate SNARK:
    • you have to include --bin evm flag
    • you can choose between --system groth16 and --system plonk

You can run fibonacci/sha256/poseidon only in normal mode. By running EVM, sha256 is always forced - other functions are not compatible

Graphs

This folder contains python codes for scraping the results of benchmarks.

About

Benchmarks of SP1 and RISC Zero zkVMs - Fibonacci, SHA-256, Poseidon and STARK to SNARK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published