26 releases (11 stable)

new 1.2.1 Jan 15, 2025
1.2.1-rc.0 Dec 9, 2024
1.2.0-rc.1 Nov 23, 2024
1.0.5 Jul 30, 2024
0.21.0 Mar 12, 2024

#1006 in Cryptography

Download history 5940/week @ 2024-09-27 4147/week @ 2024-10-04 3664/week @ 2024-10-11 4109/week @ 2024-10-18 6478/week @ 2024-10-25 5329/week @ 2024-11-01 5827/week @ 2024-11-08 4956/week @ 2024-11-15 7266/week @ 2024-11-22 6795/week @ 2024-11-29 7157/week @ 2024-12-06 5204/week @ 2024-12-13 2942/week @ 2024-12-20 1750/week @ 2024-12-27 4659/week @ 2025-01-03 5028/week @ 2025-01-10

15,369 downloads per month
Used in 11 crates (via risc0-zkvm)

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

~7–18MB
~263K SLoC