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-packageAlternatively, you can manually add it to your package.json:
"dependencies": {
"mopro-ffi": "github:zkmopro/mopro-react-native-package"
}Here is an example of how to integrate and use this package
import {
CircomProofResult,
generateCircomProof,
ProofLib,
verifyCircomProof,
} from 'mopro-ffi';
const circuitInputs = {
a: [a],
b: [b],
};
const res: CircomProofResult = await generateCircomProof(
ZKEY_PATH,
JSON.stringify(circuitInputs),
ProofLib.Arkworks
);
const res: boolean = await verifyCircomProof(
ZKEY_PATH,
circomProofResult,
ProofLib.Arkworks
);
console.log('Proof verification result:', isValid);Note
To learn how to read a .zkey file from an app, please refer to the loadAssets function in the React Native 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
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 exampleTo run on a connected iOS simulator:
npm run iosTo run on a connected iOS device:
npm run ios:deviceSet the ANDROID_HOME environment variable.
export ANDROID_HOME=~/Library/Android/sdk/To run on Android emulator/device (if connected):
npm run androidThis 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.
Choose React Native to build the bindings, or run
mopro build --platforms react-nativeto generate the React Native package.
Then, replace the entire bindings directory MoproReactNativeBindings with your generated files in the current folder:
├── android
├── babel.config.js
├── cpp
├── example # Optional: keep this folder
├── ios
├── lib
├── MoproFfiFramework.xcframework
├── node_modules
├── package-lock.json
├── package.json
├── README.md
├── src
├── tsconfig.build.json
├── tsconfig.json
├── turbo.json
└── ubrn.config.yamlor running e.g.
cp -R \
MoproReactNativeBindings/android \
MoproReactNativeBindings/ios \
MoproReactNativeBindings/src \
MoproReactNativeBindings/lib \
MoproReactNativeBindings/MoproFfiFramework.xcframework \
MoproReactNativeBindings/package.json \
mopro-react-native-package/-
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_HOMEenvironment 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.