This library exposes the native Rust bindings generated by Mopro. You get cross-platform mobile proving and verification with a slim, type‑safe JS/TS API.
Mopro handles circuit compilation, Rust ↔︎ mobile bindings, and multi‑proof back‑ends so you can focus on building privacy‑preserving features.
Use a Node.js package manager in your React Native app to install dependencies. For example:
# npm
npm install https://github.com/zkmopro/mopro-react-native-package
# yarn / pnpm
yarn add https://github.com/zkmopro/mopro-react-native-package
Alternatively, you can manually add it to your package.json:
"dependencies": {
"mopro-react-native-package": "github:zkmopro/mopro-react-native-package",
}
Here is an example of how to integrate and use this package
import MoproReactNativePackage, { Result } from "mopro-react-native-package";
const circuitInputs = {
a: [a],
b: [b],
};
const proofResult: CircomProofResult =
MoproReactNativePackage.generateCircomProof(
ZKEY_PATH,
JSON.stringify(circuitInputs)
);
const isValid: boolean = await MoproReactNativePackage.verifyProof(
ZKEY_PATH,
parsedProofResult
);
console.log("Proof verification result:", isValid);
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
Since this is a native module, you'll need to use Expo's build commands to run it on a device. Notice that, it is not available for Web yet. We've included an example app in the example folder to help you get started and test:
cd example
To run on a connected iOS simulator:
npm run ios:device
To run on a connected iOS device:
npm run ios
Set the ANDROID_HOME
environment variable.
export ANDROID_HOME=~/Library/Android/sdk/
To run on Android emulator/device (if connected):
npm run android
- Follow the instructions in the
mopro-swift-package
README to build the package. - Copy the bindings to the path
ios/MoproiOSBindings
. - Then define the native module API in ios/MoproReactNativePackageModule.swift to match the React Native type. Please refer to Expo - Argument Types
- Follow the instructions in the
mopro-kotlin-package
README to build the package, then runnpm run android
again. - Copy the
jniLibs
folder toandroid/src/main/jniLibs
and copy theuniffi
folder toandroid/src/main/java/uniffi
. - Then define the native module API in android/src/main/java/expo/modules/moproreactnativepackage/MoproReactNativePackageModule.kt to match the React Native type. Please refer to Expo - Argument Types
- Define React Native's module APIs to pass messages between React Native and your desired platforms.
-
Open the example app that uses the defined react native package in the
example/
foldercd example
-
Install the dependencies
npm install
-
Run on iOS simulator
npm run ios
Run on iOS device
npm run ios:device
-
Run on Android emulator/device (if connected) Set the
ANDROID_HOME
environment variable.export ANDROID_HOME=~/Library/Android/sdk/
Run on Android emulator/device (if connected)
npm run android
This 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.