Skip to content

Bisht13/gnark-bn254-verifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages