Skip to content

Commit

Permalink
feat(ffi): verify proof with arkzkey
Browse files Browse the repository at this point in the history
  • Loading branch information
vivianjeng authored and oskarth committed Nov 11, 2023
1 parent 7d27abc commit 1c78c24
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mopro-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ pub fn generate_proof2(
})
}

pub fn verify_proof2(proof: Vec<u8>, public_input: Vec<u8>) -> Result<bool, MoproError> {
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 {
Expand Down
3 changes: 3 additions & 0 deletions mopro-ffi/src/mopro.udl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ namespace mopro {

[Throws=MoproError]
GenerateProofResult generate_proof2(record<string, sequence<string>> circuit_inputs);

[Throws=MoproError]
boolean verify_proof2(bytes proof, bytes public_input);
};

dictionary SetupResult {
Expand Down
5 changes: 5 additions & 0 deletions mopro-ios/MoproKit/Include/moproFFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 1c78c24

Please sign in to comment.