Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove unwraps inside verify_gnark_proof (issue 1830) #1834

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions crates/verifier/src/groth16/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@ impl Groth16Verifier {
public_inputs: &[[u8; 32]],
groth16_vk: &[u8],
) -> Result<(), Groth16Error> {
let proof = load_groth16_proof_from_bytes(proof).unwrap();
let groth16_vk = load_groth16_verifying_key_from_bytes(groth16_vk).unwrap();
let proof = load_groth16_proof_from_bytes(proof)?;
let groth16_vk = load_groth16_verifying_key_from_bytes(groth16_vk)?;

let public_inputs =
public_inputs.iter().map(|input| Fr::from_slice(input).unwrap()).collect::<Vec<_>>();
let public_inputs = public_inputs
.iter()
.map(|input| Fr::from_slice(input))
.collect::<Result<Vec<_>, bn::FieldError>>()
.map_err(|_| Groth16Error::GeneralError(Error::InvalidData))?;
verify_groth16_algebraic(&groth16_vk, &proof, &public_inputs)
}
}
11 changes: 7 additions & 4 deletions crates/verifier/src/plonk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,14 @@ impl PlonkVerifier {
public_inputs: &[[u8; 32]],
plonk_vk: &[u8],
) -> Result<(), PlonkError> {
let plonk_vk = load_plonk_verifying_key_from_bytes(plonk_vk).unwrap();
let proof = load_plonk_proof_from_bytes(proof, plonk_vk.qcp.len()).unwrap();
let plonk_vk = load_plonk_verifying_key_from_bytes(plonk_vk)?;
let proof = load_plonk_proof_from_bytes(proof, plonk_vk.qcp.len())?;

let public_inputs =
public_inputs.iter().map(|input| Fr::from_slice(input).unwrap()).collect::<Vec<_>>();
let public_inputs = public_inputs
.iter()
.map(|input| Fr::from_slice(input))
.collect::<Result<Vec<_>, bn::FieldError>>()
.map_err(|_| PlonkError::GeneralError(Error::InvalidData))?;
verify_plonk_algebraic(&plonk_vk, &proof, &public_inputs)
}
}
Loading