This commit is contained in:
Dmitriy Ryajov 2023-03-20 18:46:27 -06:00
parent 1b5b249f59
commit ea4a2a082e
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4

View File

@ -1,30 +1,30 @@
// use crate::storageproofs::StorageProofs;
// use std::str;
use crate::storageproofs::StorageProofs;
use std::str;
// #[no_mangle]
// pub extern "C" fn init(
// r1cs: *const u8,
// r1cs_len: usize,
// wasm: *const u8,
// wasm_len: usize,
// ) -> *mut StorageProofs {
// let r1cs = unsafe {
// let slice = std::slice::from_raw_parts(r1cs, r1cs_len);
// str::from_utf8(slice).unwrap()
// };
#[no_mangle]
pub extern "C" fn init(
r1cs: *const u8,
r1cs_len: usize,
wasm: *const u8,
wasm_len: usize,
) -> *mut StorageProofs {
let r1cs = unsafe {
let slice = std::slice::from_raw_parts(r1cs, r1cs_len);
str::from_utf8(slice).unwrap()
};
// let wasm = unsafe {
// let slice = std::slice::from_raw_parts(wasm, wasm_len);
// str::from_utf8(slice).unwrap()
// };
let wasm = unsafe {
let slice = std::slice::from_raw_parts(wasm, wasm_len);
str::from_utf8(slice).unwrap()
};
// let storage_proofs = Box::into_raw(Box::new(StorageProofs::new(
// wasm.to_string(),
// r1cs.to_string(),
// )));
let storage_proofs = Box::into_raw(Box::new(StorageProofs::new(
wasm.to_string(),
r1cs.to_string(),
)));
// return storage_proofs;
// }
return storage_proofs;
}
// #[cfg(test)]
// mod tests {