iOS
Getting started with a new project
- Install
mopro-cli
. See Getting Started. - Create a new project
mopro init --platforms ios \
cd mopro-example-app
- Prepare circuits
mopro prepare
- Build the project
mopro build --platforms ios
- Open the project in xcode
open ios/ExampleApp/ExampleApp.xcworkspace
Getting started with exported bindings
- Install
mopro-cli
. See Getting Started. - Prepare circuits
mopro prepare
- Build the project
mopro build --platforms ios
- Export bindings
mopro export-bindings --platforms ios --destination out
- Create an
xcframework
withxcodebuild
e.g. for simulator
xcodebuild -create-xcframework \
-library out/ios/aarch64-apple-ios-sim/release/libmopro_ffi.a \
-headers out/ios/Bindings \
-output "out/ios/Mopro.xcframework"
e.g. for both simulator and device
Please specify ios_device_type
in mopro-config.toml to build for both device
and simulator
.
xcodebuild -create-xcframework \
-library out/ios/aarch64-apple-ios-sim/release/libmopro_ffi.a \
-headers out/ios/Bindings \
-library out/ios/aarch64-apple-ios/release/libmopro_ffi.a \
-headers out/ios/Bindings \
-output "out/ios/Mopro.xcframework"
- Import both the XCFramework
Mopro.xcframework
and the Swift file bindingsBindings/mopro.swift
files into your project (drag and drop should work). - Use
moproFFI
in swift like
import moproFFI
...
try initializeMopro()
...
Swift API
MoproCircom
Initialize a MoproCircom
object.
Usage:
let moproCircom = MoproCircom()
initialize
Initializes the instance with the given zkeyPath
and wasmPath
.
func initialize(zkeyPath: String, wasmPath: String) throws
Usage:
try moproCircom.initialize(zkeyPath: zkeyPath, wasmPath: wasmPath)
generateProof
Generates a proof based on the provided circuit inputs.
func generateProof(circuitInputs: [String: [String]]) throws -> GenerateProofResult
Usage:
var inputs = [String: [String]]()
let a = 3
let b = 5
inputs["a"] = [String(a)]
inputs["b"] = [String(b)]
let generateProofResult = try moproCircom.generateProof(circuitInputs: inputs)
verifyProof
Verifies the provided proof against the given inputs.
func verifyProof(proof: Data, publicInput: Data) throws -> Bool
Usage:
let isValid = try moproCircom.verifyProof(
proof: generateProofResult.proof,
publicInput: generateProofResult.inputs
)
generateProofStatic
Generates a proof based on the provided circuit inputs.
Note: The function is different from generateProof
.
In this function, the zkey and wasm are precompiled during cargo build
.
You can specify the mopro-config.toml to build the default circuits.
func generateProofStatic(circuitInputs: [String: [String]]) throws -> GenerateProofResult
verifyProofStatic
Verifies the provided proof against the given inputs.
Note: The function is different from verifyProof
.
In this function, the zkey and wasm are precompiled during cargo build
.
You can specify the mopro-config.toml to build the default circuits.
func verifyProofStatic(proof: Data, publicInput: Data) throws -> Bool
toEthereumInputs
Convert public inputs data to a string array.
func toEthereumInputs(inputs: Data) -> [String]
toEthereumProof
Convert proof data to a proof structure which can be submitted to a verifier contract.
func toEthereumProof(proof: Data) -> ProofCalldata