37 releases (18 stable)

2.0.0 Apr 1, 2025
1.4.0 Mar 25, 2025
1.3.0 Feb 25, 2025
1.2.1-rc.0 Dec 9, 2024
0.21.0 Mar 12, 2024

#5 in #groth16

Download history 1429/week @ 2024-12-25 3340/week @ 2025-01-01 6151/week @ 2025-01-08 6888/week @ 2025-01-15 6893/week @ 2025-01-22 7187/week @ 2025-01-29 8174/week @ 2025-02-05 8381/week @ 2025-02-12 8443/week @ 2025-02-19 7474/week @ 2025-02-26 7668/week @ 2025-03-05 6924/week @ 2025-03-12 38914/week @ 2025-03-19 7406/week @ 2025-03-26 9738/week @ 2025-04-02 6896/week @ 2025-04-09

64,026 downloads per month
Used in 27 crates (via risc0-zkvm)

Apache-2.0

1MB
37K 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

~9–21MB
~318K SLoC