Skip to content

zkmopro/mopro-react-native-package

Repository files navigation

Mopro React Native Package

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.

How to Import the Package

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",
}

How to Use the 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

Running on a real device

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

iOS

To run on a connected iOS simulator:

npm run ios:device

To run on a connected iOS device:

npm run ios

Android

Set the ANDROID_HOME environment variable.

export ANDROID_HOME=~/Library/Android/sdk/

To run on Android emulator/device (if connected):

npm run android

How to Build the Package

iOS

Android

React Native Module

React Native Example App

  • Open the example app that uses the defined react native package in the example/ folder

    cd 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

Community

  • X account:
  • Telegram group:

Acknowledgements

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •