add dup function

This commit is contained in:
Jaremy Creechley 2024-06-03 17:01:59 +01:00
parent 18d30300a5
commit 19904d5cae
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
1 changed files with 25 additions and 0 deletions

View File

@ -63,6 +63,31 @@ fn to_err_code(result: Result<i32, Box<dyn Any + Send>>) -> i32 {
}
}
#[no_mangle]
#[allow(private_interfaces)]
pub unsafe extern "C" fn circom_config_duplicate(
orig_cfg_ptr: *mut CircomBn254Cfg,
cfg_ptr: &mut *mut CircomBn254Cfg,
) -> i32 {
let result = catch_unwind(AssertUnwindSafe(|| {
let cfg = (*(*orig_cfg_ptr).cfg).clone();
let proving_key = (*(*orig_cfg_ptr).proving_key).clone();
let circom_bn254_cfg = CircomBn254Cfg {
cfg: Box::into_raw(Box::new(cfg)),
proving_key: Box::into_raw(Box::new(proving_key)),
_marker: std::marker::PhantomData,
};
*cfg_ptr = Box::into_raw(Box::new(circom_bn254_cfg));
ERR_OK
}));
to_err_code(result)
}
#[no_mangle]
#[allow(private_interfaces)]
pub unsafe extern "C" fn init_circom_config_with_checks(