gnark-bn254-verifier

Crates.iognark-bn254-verifier
lib.rsgnark-bn254-verifier
version1.0.2
sourcesrc
created_at2024-08-14 08:41:23.254197
updated_at2024-08-14 15:16:20.433182
descriptionA rust gnark verifier for BN254 curve
homepage
repositoryhttps://github.com/Bisht13/gnark-bn254-verifier
max_upload_size
id1337032
size59,050
Aditya Bisht (Bisht13)

documentation

README

gnark BN254 Verifier

The gnark-bn254-verifier crate is used for verifying Groth16 and PlonK proofs on the Bn254 curve, ensuring compatibility with proofs generated by the gnark library. One can save proofs and verification keys from gnark and subsequently load them to this library for verifying the proofs with ease.

How to save proofs and verification keys from gnark

To save the proof and verification key from gnark, one can use the following code snippet:

// Write the verifier key.
vkFile, err := os.Create("vk.bin")
if err != nil {
    panic(err)
}
defer vkFile.Close()
_, err = vk.WriteTo(vkFile)
if err != nil {
    panic(err)
}

// Write the proving key.
proofFile, err := os.Create("proof.bin")
if err != nil {
    panic(err)
}
defer proofFile.Close()
_, err = proof.WriteTo(proofFile)
if err != nil {
    panic(err)
}

Usage

To use this library, add it as a dependency in your Cargo.toml:

[dependencies]
gnark-bn254-verifier = "1.0.2"

Then, you can verify a proof by calling the verify function:

use gnark_bn254_verifier::{verify, ProvingSystem, Fr};

fn main() {

    let proof = std::fs::read("proof.bin").unwrap();
    let vk = std::fs::read("vk.bin").unwrap();

    if verify(&proof, &vk, &[Fr::from(1u8), Fr::from(7u8)], ProvingSystem::Plonk) {
        println!("Proof is valid");
    } else {
        println!("Proof is invalid");
    }
}

Features

  • Verification of Groth16 and PlonK proofs generated using gnark.
  • Easy integration into Rust projects.
Commit count: 0

cargo fmt