mopro-ffi
Thin wrapper around mopro-core
, exposes UniFFI bindings to be used by rust-ios
, etc.
Overview
TBD.
Development
Prerequisites
- Ensure you have Rust installed
- Add platform targets
rustup target add x86_64-apple-ios aarch64-apple-ios aarch64-apple-ios-sim
- Install
uniffi-bindgen
locally withcargo install --bin uniffi-bindgen --path .
- In order to locally run the bindings tests, you will need
- Kotlin:
kotlinc
, the Kotlin command-line compiler.ktlint
, the Kotlin linter used to format the generated bindings.- The Java Native Access JAR downloaded and its path
added to your
$CLASSPATH
environment variable.
- Swift:
swift
andswiftc
, the Swift command-line tools.- The Swift
Foundation
package.
- Kotlin:
Platforms supported
Currently iOS is the main target, but Android will soon follow. PRs welcome.
Building
Run make
to build debug and release static libraries for supported platforms.
Generate UniFFI bindings
The following command generates Swift bindings:
uniffi-bindgen generate src/mopro.udl --language swift --out-dir target/SwiftBindings
Test bindings
To test bindings:
cargo test --test test_generated_bindings
To test bindings in release mode without warning:
cargo test --test test_generated_bindings --release 2>/dev/null
Generate MSM benchmark report in swift on laptop
- Comment
default=[]
and uncommentdefault=["gpu-benchmarks"]
to enablegpu-benchmarks
feature flag - run
RUSTFLAGS="-C opt-level=3" cargo test --test test_generated_bindings --release
- The benchmark result will be shown in the console log
The above report was conducted on an M1 Pro MacBook Pro.
For more information, read this report we have completed, which compares the time performance of MSM running in rust and swift.
To use circom-witness-rs (Experimental)
- Comment
default=[]
and uncommentdefault = ["calc-native-witness"]
to enablecalc-native-witness
feature flag - Test with
# Run all tests
cargo test --features calc-native-witness
# Run bindings tests
cargo test --test test_generated_bindings --features calc-native-witness