lib for mobile

This commit is contained in:
psippl 2022-01-28 18:17:18 +01:00
parent 089f126e4f
commit 997a4ec44b
3 changed files with 22 additions and 0 deletions

4
README.md Normal file
View File

@ -0,0 +1,4 @@
# README
## mobile
`cargo build --release --lib --target aarch64-apple-ios`

15
src/lib.rs Normal file
View File

@ -0,0 +1,15 @@
use std::os::raw::{c_char};
use std::ffi::{CString, CStr};
mod identity;
#[no_mangle]
pub extern fn generate_identity_commitment(seed: *const c_char) -> *mut c_char {
let c_str = unsafe { CStr::from_ptr(seed) };
let seed = match c_str.to_str() {
Err(_) => "there",
Ok(string) => string,
};
let id = identity::Identity::new(seed.as_bytes());
CString::new(id.identity_commitment().to_str_radix(10)).unwrap().into_raw()
}

3
src/libsemaphore.h Normal file
View File

@ -0,0 +1,3 @@
#include <stdint.h>
const char* generate_identity_commitment(const char* to);