From 1c78c24924586af435aea0ee8319ce3d5e8c08b4 Mon Sep 17 00:00:00 2001 From: "Ya-wen, Jeng" Date: Sun, 12 Nov 2023 00:53:08 +0800 Subject: [PATCH] feat(ffi): verify proof with arkzkey --- mopro-ffi/src/lib.rs | 7 +++++++ mopro-ffi/src/mopro.udl | 3 +++ mopro-ios/MoproKit/Include/moproFFI.h | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/mopro-ffi/src/lib.rs b/mopro-ffi/src/lib.rs index 6a840f03..c43bbd6b 100644 --- a/mopro-ffi/src/lib.rs +++ b/mopro-ffi/src/lib.rs @@ -76,6 +76,13 @@ pub fn generate_proof2( }) } +pub fn verify_proof2(proof: Vec, public_input: Vec) -> Result { + let deserialized_proof = circom::serialization::deserialize_proof(proof); + let deserialized_public_input = circom::serialization::deserialize_inputs(public_input); + let is_valid = circom::verify_proof2(deserialized_proof, deserialized_public_input)?; + Ok(is_valid) +} + // TODO: Use FFIError::SerializationError instead impl MoproCircom { pub fn new() -> Self { diff --git a/mopro-ffi/src/mopro.udl b/mopro-ffi/src/mopro.udl index a8c2fdbc..0de5438e 100644 --- a/mopro-ffi/src/mopro.udl +++ b/mopro-ffi/src/mopro.udl @@ -7,6 +7,9 @@ namespace mopro { [Throws=MoproError] GenerateProofResult generate_proof2(record> circuit_inputs); + + [Throws=MoproError] + boolean verify_proof2(bytes proof, bytes public_input); }; dictionary SetupResult { diff --git a/mopro-ios/MoproKit/Include/moproFFI.h b/mopro-ios/MoproKit/Include/moproFFI.h index 38a53245..a58cb120 100644 --- a/mopro-ios/MoproKit/Include/moproFFI.h +++ b/mopro-ios/MoproKit/Include/moproFFI.h @@ -88,6 +88,8 @@ void uniffi_mopro_fn_func_initialize_mopro(RustCallStatus *_Nonnull out_status ); RustBuffer uniffi_mopro_fn_func_generate_proof2(RustBuffer circuit_inputs, RustCallStatus *_Nonnull out_status ); +int8_t uniffi_mopro_fn_func_verify_proof2(RustBuffer proof, RustBuffer public_input, RustCallStatus *_Nonnull out_status +); RustBuffer ffi_mopro_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status ); RustBuffer ffi_mopro_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status @@ -107,6 +109,9 @@ uint16_t uniffi_mopro_checksum_func_initialize_mopro(void ); uint16_t uniffi_mopro_checksum_func_generate_proof2(void +); +uint16_t uniffi_mopro_checksum_func_verify_proof2(void + ); uint16_t uniffi_mopro_checksum_method_moprocircom_setup(void