mopro-cli
mopro
is a CLI tool for client-side proving of Zero Knowledge Proofs. It simplifies the process of initializing, building, updating, and testing projects across different platforms and configurations.
Think of it as Foundry for client-side proving.
Installation
To use mopro
, you need to have Rust and Cargo installed on your system. You can install them from the official Rust website.
Run cargo install --path .
to install the mopro
CLI util.
Usage
Here are the basic commands of mopro
:
-
mopro init
: Initialize a new project with support for multiple platforms.- options:
--adapter <ADAPTER> [default: circom]
--platforms <PLATFORMS>... [default: core]
--project-name <PROJECT_NAME> [default: mopro-example-app]
- options:
-
mopro deps
: Install required dependencies. -
mopro prepare
: Prepare and build circuit and its artifacts.- options:
--config <CONFIG> [default: mopro-config.toml]
- options:
-
mopro build
: Build the project for specified platforms.- options:
--config <CONFIG> [default: mopro-config.toml]
--adapter <ADAPTER> [default: circom]
--platforms <PLATFORMS>... [default: core]
- options:
-
mopro test
: Run tests for specific platform and test cases.- options:
--config <CONFIG> [default: mopro-config.toml]
--adapter <ADAPTER> [default: circom]
--platforms <PLATFORMS>... [default: core]
--test-case <TEST_CASE>
- options:
-
mopro export-bindings
: Export platform bindings to some other directory.- options:
--platforms <PLATFORMS>... [default: ios]
-d, --destination <DESTINATION>
- options:
(May be added soon: mopro update
: Update bindings with new API for specified platforms.)
Prerequisites
To use mopro-cli
, make sure you have installed the prerequisites.
Examples
Basic example
Initialize, build and test a circuit with Rust bindings:
-
Set
MOPRO_ROOT
export MOPRO_ROOT=/Users/user/repos/github.com/zkmopro/mopro
-
Install dependencies
mopro deps
-
Default to circom adapter and core Rust bindings
mopro init
-
Go to the newly created directory
cd mopro-example-app
-
Prepare circuit artifacts
mopro prepare
-
Build the project
mopro build
-
Run end-to-end-test
mopro test
iOS
Initialize and build an app with iOS support.
mopro init --platforms ios
cd mopro-example-app
mopro prepare
mopro build --platforms ios
# Open project in XCode
open ios/ExampleApp/ExampleApp.xcworkspace
# Currently testing only available for Rust bindings,
# Can run iOS tests from newly created Xcode project
mopro test
Android
Initialize and build an app with Android support.
mopro init --platforms android
cd mopro-example-app
mopro prepare
mopro build --platforms android
# Open android project in Android Studio
open android -a Android\ Studio
Web
Initialize and build a web app.
mopro init --platforms web
cd mopro-example-app
mopro prepare
mopro build --platforms web
Open web project directory and run frontend locally.
cd web
npm install
npm run dev
Exporting bindings
To export bindings to a different directory:
mopro export-bindings --destination <DESTINATION_DIR> --platforms <IOS_AND_OR_ANDROID>
This will the following files, assuming they've been built, to the destination directory:
├── android
│ ├── jniLibs
│ │ └── arm64-v8a
│ │ └── libuniffi_mopro.so
│ └── uniffi
│ └── mopro
│ └── mopro.kt
└── ios
├── Bindings
│ ├── module.modulemap
│ ├── mopro.swift
│ └── moproFFI.h
└── aarch64-apple-ios-sim
└── release
└── libmopro_ffi.a
Use the bindings in iOS
-
Create a XCFramework with
xcodebuild
xcodebuild -create-xcframework \
-library <DESTINATION_DIR>/ios/aarch64-apple-ios-sim/release/libmopro_ffi.a \
-headers <DESTINATION_DIR>/ios/Bindings \
-output "<DESTINATION_DIR>/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()
...
Reference: https://forgen.tech/en/blog/post/building-an-ios-app-with-rust-using-uniffi
Use the bindings in Android
-
Add dependency in
<ANDROID_APP_DIR>/app/build.gradle.kts
dependencies {
...
implementation("net.java.dev.jna:jna:5.13.0@aar")
...
} -
Sync gradle
-
Move the
<DESTINATION_DIR>/android/jniLibs/
folder toapp/src/main/
-
Move the
<DESTINATION_DIR>/android/uniffi/
folder toapp/src/main/java/
-
Use moproFFI in kotlin like
import uniffi.mopro.initializeMopro
...
initializeMopro()
...Reference: https://sal.dev/android/intro-rust-android-uniffi/
Contributing
Contributions to mopro
are welcome. Please feel free to submit issues and pull requests.