From 1e03c93ac4f0c51c1813fafc0e3aea92cdfb44ce Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Sat, 27 Jan 2024 16:20:02 -0600 Subject: [PATCH] properly unpack verfication result --- src/ffi.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ffi.rs b/src/ffi.rs index da6fdd2..3a2bcfc 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -304,18 +304,24 @@ pub unsafe extern "C" fn verify_circuit( let result = catch_unwind(AssertUnwindSafe(|| { let inputs_vec: Vec = (*inputs).into(); let prepared_key = prepare_verifying_key(&(*pvk).into()); + let passed = GrothBn::verify_proof(&prepared_key, &(*proof).into(), inputs_vec.as_slice()) .map_err(|_| ERR_FAILED_TO_VERIFY_PROOF) .unwrap(); - if !passed { - ERR_FAILED_TO_VERIFY_PROOF - } else { - ERR_OK + match passed { + // println!("proof verified - passed"); + true => ERR_OK, + // println!("proof verified - failed"); + false => ERR_FAILED_TO_VERIFY_PROOF, } })); - to_err_code(result) + // println!("result: {:?}", result); + match result { + Err(e) => to_err_code(Err(e)), + Ok(c) => c, + } } #[no_mangle]