feat(wasm): expose seeded_key_gen

This commit is contained in:
Richard Ramos 2022-12-06 08:25:47 -04:00 committed by RichΛrd
parent 60e3369621
commit 3551435d60
2 changed files with 20 additions and 1 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "rln-wasm"
version = "0.0.4"
version = "0.0.5"
edition = "2021"
license = "MIT or Apache2"

View File

@ -116,6 +116,25 @@ pub fn wasm_key_gen(ctx: *const RLNWrapper) -> Result<Uint8Array, String> {
}
}
#[allow(clippy::not_unsafe_ptr_arg_deref)]
#[wasm_bindgen(js_name = generateSeededMembershipKey)]
pub fn wasm_seeded_key_gen(ctx: *const RLNWrapper, seed: Uint8Array) -> Result<Uint8Array, String> {
let wrapper = unsafe { &*ctx };
let mut output_data: Vec<u8> = Vec::new();
if wrapper
.instance
.seeded_key_gen(&seed.to_vec()[..], &mut output_data)
.is_ok()
{
let result = Uint8Array::from(&output_data[..]);
std::mem::forget(output_data);
Ok(result)
} else {
std::mem::forget(output_data);
Err("could not generate membership key".into())
}
}
#[allow(clippy::not_unsafe_ptr_arg_deref)]
#[wasm_bindgen(js_name = verifyRLNProof)]
pub fn wasm_verify_rln_proof(ctx: *const RLNWrapper, proof: Uint8Array) -> Result<bool, String> {