This package is used to generate a Swift SDK that wraps Mopro bindings for use in iOS applications.
Warning
The current mopro-swift-package supports only the Circom multiplier2 circuit.
To use your own circuits, please follow the Getting Started guide and replace the witness function with your own WASM or witness files.
-
Open your project in Xcode.
-
Go to File > Add package dependencies.
-
In Search or Enter Package URL, enter the URL:
https://github.com/zkmopro/mopro-swift-package -
Choose the version and add the package to your project.
Add the following to your Package.swift dependencies:
let package = Package(
name: "YourSwiftProject",
// ...
dependencies: [
.package(url: "https://github.com/zkmopro/mopro-swift-package", from: "0.3.0") // Or change to your own URL
],
// ...
targets: [
.target(
name: "YourSwiftProject",
dependencies: [
.product(name: "MoproFFI", package: "mopro-swift-package")
],
),
]
)- Add the following to your
Podfile:
pod 'MoproFFI', :git => 'https://github.com/zkmopro/mopro-swift-package.git', :branch => 'main'
- Run the installation command:
pod installHere is an example of how to integrate and use this package
import MoproFFI
// ...
let generateProofResult = try generateCircomProof(zkeyPath: zkeyPath, circuitInputs: input_str, proofLib: ProofLib.arkworks)Or checkout the test-e2e app.
Warning
The default bindings are built specifically for the multiplier2 circom circuit. If you'd like to update the circuit or switch to a different proving scheme, please refer to the How to Build the Package section.
Circuit source code: https://github.com/zkmopro/circuit-registry/tree/main/multiplier2
Example .zkey file for the circuit: http://ci-keys.zkmopro.org/multiplier2_final.zkey
This package relies on bindings generated by the Mopro CLI. To learn how to build Mopro bindings, refer to the Getting Started section. If you'd like to generate custom bindings for your own circuits or proving schemes, check out the guide on how to use the Mopro CLI: Rust Setup for Android/iOS Bindings.
Then, replace the entire bindings directory with your generated files in the following location: Sources/MoproiOSBindings
Alternatively, you can run the following commands to copy your generated bindings into the correct location:
cp -r ../path/to/your/bindings/MoproiOSBindings ./SourcesThis work was initially sponsored by a joint grant from PSE and 0xPARC. It is currently incubated by PSE.
This project is heavily inspired by ezkl-swift-package and follows a similar approach for integrating native cryptographic libraries into Swift via a Swift Package.