13 releases (5 stable)

new 1.0.4 Jul 26, 2024
1.0.3 Jul 17, 2024
1.0.1 Jun 5, 2024
1.0.0-rc.6 May 29, 2024
0.21.0 Mar 12, 2024

#1187 in Cryptography

Download history 829/week @ 2024-04-05 967/week @ 2024-04-12 928/week @ 2024-04-19 1166/week @ 2024-04-26 1632/week @ 2024-05-03 2289/week @ 2024-05-10 2278/week @ 2024-05-17 1566/week @ 2024-05-24 2031/week @ 2024-05-31 2098/week @ 2024-06-07 1975/week @ 2024-06-14 2518/week @ 2024-06-21 2305/week @ 2024-06-28 2889/week @ 2024-07-05 4247/week @ 2024-07-12 2955/week @ 2024-07-19

12,931 downloads per month
Used in 5 crates (2 directly)

Apache-2.0

1MB
38K SLoC

Groth16

This library implements a verifier for the Groth16 protocol over the BN_254 elliptic curve.

Example

use risc0_groth16::{ProofJson, PublicInputsJson, Verifier, VerifyingKeyJson};

const TEST_VERIFICATION_KEY: &str = test_data!("verification_key.json");
const TEST_PROOF: &str = test_data!("proof.json");
const TEST_PUBLIC_INPUTS: &str = test_data!("public.json");

fn verify() {
    let verifying_key: VerifyingKeyJson = serde_json::from_str(TEST_VERIFICATION_KEY).unwrap();
    let proof: ProofJson = serde_json::from_str(TEST_PROOF).unwrap();
    let public_inputs = PublicInputsJson {
        values: serde_json::from_str(TEST_PUBLIC_INPUTS).unwrap(),
    };
    let verifier = Verifier::from_json(proof, public_inputs, verifying_key).unwrap();
    verifier.verify().unwrap();
}

STARK to SNARK

It also provides the stark_to_snark function to run a prover Groth16 recursion prover via Docker. After generating a RISC Zero STARK proof, this function can be used to transform it into a Groth16 proof. This function becomes available when the prove feature flag is enabled.

IMPORTANT: This feature requires an x86 architecture and Docker installed. Additionally, specific installation steps must be followed to use this functionality.

The recommended way to get a Groth16 proof is to use the Prover trait in the risc0-zkvm crate. With ProverOpts::groth16() it will produce a Groth16 proof.

Dependencies

~6–16MB
~228K SLoC