add with checks init to pass sanity check flag

This commit is contained in:
Dmitriy Ryajov 2024-01-27 16:21:04 -06:00
parent 1e03c93ac4
commit 8f5491de53
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4

View File

@ -66,14 +66,15 @@ fn to_err_code(result: Result<i32, Box<dyn Any + Send>>) -> i32 {
#[no_mangle] #[no_mangle]
#[allow(private_interfaces)] #[allow(private_interfaces)]
pub unsafe extern "C" fn init_circom_config( pub unsafe extern "C" fn init_circom_config_with_checks(
r1cs_path: *const c_char, r1cs_path: *const c_char,
wasm_path: *const c_char, wasm_path: *const c_char,
zkey_path: *const c_char, zkey_path: *const c_char,
sanity_check: bool,
cfg_ptr: &mut *mut CircomBn254Cfg, cfg_ptr: &mut *mut CircomBn254Cfg,
) -> i32 { ) -> i32 {
let result = catch_unwind(AssertUnwindSafe(|| { let result = catch_unwind(AssertUnwindSafe(|| {
let cfg = CircomConfig::<Bn254>::new( let mut cfg = CircomConfig::<Bn254>::new(
CStr::from_ptr(wasm_path) CStr::from_ptr(wasm_path)
.to_str() .to_str()
.map_err(|_| ERR_WASM_PATH) .map_err(|_| ERR_WASM_PATH)
@ -86,6 +87,7 @@ pub unsafe extern "C" fn init_circom_config(
.map_err(|_| ERR_CIRCOM_BUILDER) .map_err(|_| ERR_CIRCOM_BUILDER)
.unwrap(); .unwrap();
cfg.sanity_check = sanity_check;
let proving_key = if !zkey_path.is_null() { let proving_key = if !zkey_path.is_null() {
let mut file = File::open( let mut file = File::open(
CStr::from_ptr(zkey_path) CStr::from_ptr(zkey_path)
@ -124,6 +126,17 @@ pub unsafe extern "C" fn init_circom_config(
to_err_code(result) to_err_code(result)
} }
#[no_mangle]
#[allow(private_interfaces)]
pub unsafe extern "C" fn init_circom_config(
r1cs_path: *const c_char,
wasm_path: *const c_char,
zkey_path: *const c_char,
cfg_ptr: &mut *mut CircomBn254Cfg,
) -> i32 {
init_circom_config_with_checks(r1cs_path, wasm_path, zkey_path, false, cfg_ptr)
}
#[no_mangle] #[no_mangle]
#[allow(private_interfaces)] #[allow(private_interfaces)]
pub unsafe extern "C" fn init_circom_compat( pub unsafe extern "C" fn init_circom_compat(