pub fn lookup_verify(
    vrf_public_key_slice: &[u8],
    root_hash_slice: &[u8],
    label_slice: &[u8],
    // JSON struct representing the lookup proof
    lookup_proof_ref: JsValue,
) -> Result<bool, JsValue> {
    let vrf_public_key: Vec<u8> = vrf_public_key_slice.to_vec();
    let label: AkdLabel = label_slice.to_vec();

    if root_hash_slice.len() < 32 {
        return Err(JsValue::from_str("Root hash byte length is too short"));
    }
    let mut root_hash: [u8; 32] = [0u8; 32];
    root_hash.copy_from_slice(root_hash_slice);

    match lookup_proof_ref.into_serde() {
        Ok(proof) => match crate::verify::lookup_verify(&vrf_public_key, root_hash, label, proof) {
            Ok(_) => Ok(true),
            Err(verification_error) => {
                let msg = format!("{}", verification_error);
                Err(JsValue::from_str(&msg))
            }
        },
        Err(serialization_error) => {
            let msg = format!(
                "Error deserializing lookup proof structure: {}",
                serialization_error
            );
            Err(JsValue::from_str(&msg))
        }
    }
}
/// Verify a lookup proof in WebAssembly, utilizing serde serialized structure for the proof
Verify a lookup proof in WebAssembly, utilizing serde serialized structure for the proof
Verify a lookup proof in WebAssembly utilizing serde serialized structure for the proof
pub fn lookup_verify(
    vrf_public_key_slice: &[u8],
    root_hash_slice: &[u8],
    label_slice: &[u8],
    // JSON struct representing the lookup proof
    lookup_proof_ref: JsValue,
) -> Result<bool, JsValue> {
    let vrf_public_key: Vec<u8> = vrf_public_key_slice.to_vec();
    let label: AkdLabel = label_slice.to_vec();
    if root_hash_slice.len() < 32 {
        return Err(JsValue::from_str("Root hash byte length is too short"));
    }
    let mut root_hash: [u8; 32] = [0u8; 32];
    root_hash.copy_from_slice(root_hash_slice);
    match lookup_proof_ref.into_serde() {
        Ok(proof) => match crate::verify::lookup_verify(&vrf_public_key, root_hash, label, proof) {
            Ok(_) => Ok(true),
            Err(verification_error) => {
                let msg = format!("{}", verification_error);
                Err(JsValue::from_str(&msg))
            }
        },
        Err(serialization_error) => {
            let msg = format!(
                "Error deserializing lookup proof structure: {}",
                serialization_error
            );
            Err(JsValue::from_str(&msg))
        }
    }
}
pub fn lookup_verify ( vrf_public_key_slice : & [ u8 ] , root_hash_slice : & [ u8 ] , label_slice : & [ u8 ] , // JSON struct representing the lookup proof lookup_proof_ref : JsValue , ) -> Result < bool , JsValue > { let vrf_public_key : Vec < u8 > = vrf_public_key_slice . to_vec ( ) ; let label : AkdLabel = label_slice . to_vec ( ) ; if root_hash_slice . len ( ) < 32 { return Err ( JsValue :: from_str ( " " ) ) ; } let mut root_hash : [ u8 ; 32 ] = [ 0u8 ; 32 ] ; root_hash . copy_from_slice ( root_hash_slice ) ; match lookup_proof_ref . into_serde ( ) { Ok ( proof ) => match crate :: verify :: lookup_verify ( & vrf_public_key , root_hash , label , proof ) { Ok ( _ ) => Ok ( true ) , Err ( verification_error ) => { let msg = format ! ( " " verification_error ) ; Err ( JsValue :: from_str ( & msg ) ) } } , Err ( serialization_error ) => { let msg = format ! ( " " serialization_error ) ; Err ( JsValue :: from_str ( & msg ) ) } } }
Verify a lookup proof in WebAssembly, utilizing serde serialized structure for the proof
Verify a lookup proof in WebAssembly utilizing serde serialized structure for the proof
vrf_public_key_slice
&[u8]
root_hash_slice
&[u8]
label_slice
&[u8]
lookup_proof_ref
JsValue
vrf_public_key_slice
&[u8]
root_hash_slice
&[u8]
label_slice
&[u8]
lookup_proof_ref
JsValue