properly unpack verfication result

This commit is contained in:
Dmitriy Ryajov 2024-01-27 16:20:02 -06:00
parent e00ae0a814
commit 1e03c93ac4
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
1 changed files with 11 additions and 5 deletions

View File

@ -304,18 +304,24 @@ pub unsafe extern "C" fn verify_circuit(
let result = catch_unwind(AssertUnwindSafe(|| {
let inputs_vec: Vec<Fr> = (*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]