From 2bedb81786efe2abdeacd7eb9347f4697c188ed3 Mon Sep 17 00:00:00 2001 From: fedemagnani <0xdrun@gmail.com> Date: Sun, 1 Dec 2024 20:48:25 +0100 Subject: [PATCH] issue 1830 --- crates/verifier/src/groth16/mod.rs | 11 +++++++---- crates/verifier/src/plonk/mod.rs | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/crates/verifier/src/groth16/mod.rs b/crates/verifier/src/groth16/mod.rs index f8c03bbe29..9075d6491b 100644 --- a/crates/verifier/src/groth16/mod.rs +++ b/crates/verifier/src/groth16/mod.rs @@ -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::>(); + let public_inputs = public_inputs + .iter() + .map(|input| Fr::from_slice(input)) + .collect::, bn::FieldError>>() + .map_err(|_| Groth16Error::GeneralError(Error::InvalidData))?; verify_groth16_algebraic(&groth16_vk, &proof, &public_inputs) } } diff --git a/crates/verifier/src/plonk/mod.rs b/crates/verifier/src/plonk/mod.rs index 9828da0521..613c2cab00 100644 --- a/crates/verifier/src/plonk/mod.rs +++ b/crates/verifier/src/plonk/mod.rs @@ -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::>(); + let public_inputs = public_inputs + .iter() + .map(|input| Fr::from_slice(input)) + .collect::, bn::FieldError>>() + .map_err(|_| PlonkError::GeneralError(Error::InvalidData))?; verify_plonk_algebraic(&plonk_vk, &proof, &public_inputs) } }