Coder Social home page Coder Social logo

sha256-zk-benchmark's Introduction

Sha256 benchmarks in SP1, Risc0 and Risc0 groth 16

This repository includes different crates for computing sha256 hashs in Risc0 and SP1 execution environments.

The focus of the benchmarks is primarily on proof size.

SP1 circuit

    let mut output_hashes: Vec<Vec<u8>> = Vec::new();
    let rounds = sp1_zkvm::io::read::<u32>();
    for i in 0..rounds {
        let sha_input = [1u8; 32];
        let mut hasher = Sha256::new();
        hasher.update(&sha_input);
        output_hashes.push(hasher.finalize().to_vec());
    };
    let output: Output = Output {
        sha256_hashes: output_hashes,
    };
    sp1_zkvm::io::commit(&output);

sha256 library used: sha2-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-v0.10.8" }

See here

Risc0 circuit

    // read the input
    let rounds: u32 = env::read();
    let mut output_hashes: Vec<Digest> = Vec::new();
    // test sha256
    for i in 0..rounds {
        let sha_input = [1u8; 32];
        let sha_hash: Digest = *Impl::hash_bytes(&sha_input);
        output_hashes.push(sha_hash);
    }
    let output: Output = Output {
        sha256_hashes: output_hashes,
    };
    env::commit(&output);

sha256 library used: use risc0_zkvm::sha::{Digest, Impl, Sha256};

See here

SP1 proof size benchmark

1 hash 10 hashs 100 hashs 1000 hashs
1.44 MB 1.52 MB 2.81 MB x

SP1 proof speed benchmark

1 hash 10 hashs 100 hashs 1000 hashs
1s 4s 27s x

Risc0 proof size benchmark

1 hash 10 hashs 100 hashs 1000 hashs
215.6 KB 216.2 KB 256.7 KB x

Risc0 proof speed benchmark

1 hash 10 hashs 100 hashs 1000 hashs
19s 19s 78s x

Risc0-Groth16 proof size benchmark

1 hash 10 hashs 100 hashs 1000 hashs
485 B 773 B 3653 B x

Risc0-Groth16 proof speed benchmark

1 hash 10 hashs 100 hashs 1000 hashs
223s 223s 286s x

Disclaimer: I had to run the SP1 benchmarks on my Macbook, on Ubuntu I encountered this error:

Machine used for SP1: M2 Macbook Air, 8GB Ram.

The reason why a different machine was used for the SP1 benchmarks is this issue related to curve25519-dalek v4.1.2.

The machine used for Risc0 and Risc0-groth16 was a 32GB Ram, 8-core x86-64 Ubuntu server.

sha256-zk-benchmark's People

Contributors

jonas089 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.