mirror of
https://github.com/logos-storage/circom-compat-ffi.git
synced 2026-01-07 15:23:10 +00:00
add with checks init to pass sanity check flag
This commit is contained in:
parent
1e03c93ac4
commit
8f5491de53
17
src/ffi.rs
17
src/ffi.rs
@ -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(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user