Crates.io | gnark-bn254-verifier |
lib.rs | gnark-bn254-verifier |
version | 1.0.2 |
source | src |
created_at | 2024-08-14 08:41:23.254197 |
updated_at | 2024-08-14 15:16:20.433182 |
description | A rust gnark verifier for BN254 curve |
homepage | |
repository | https://github.com/Bisht13/gnark-bn254-verifier |
max_upload_size | |
id | 1337032 |
size | 59,050 |
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.
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)
}
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");
}
}
gnark
.