Skip to content

Latest commit

 

History

History
104 lines (63 loc) · 3.63 KB

README.md

File metadata and controls

104 lines (63 loc) · 3.63 KB

Cross-Platform Mobile ZKPs

Flutter is a popular cross-platform mobile app development framework. Mopro Flutter shows an example of integrating ZK-proving into a Flutter app, allowing for streamlined creation of ZK-enabled mobile apps.

Running The Example App

Prerequisites

  1. Install Flutter

    If Flutter is not already installed, you can follow the official Flutter installation guide for your operating system.

  2. Check Flutter Environment

    After installing Flutter, verify that your development environment is properly set up by running the following command in your terminal:

    flutter doctor

    This command will identify any missing dependencies or required configurations.

  3. Install Flutter Dependencies

    Navigate to the root directory of the project in your terminal and run:

    flutter pub get

    This will install the necessary dependencies for the project.

Running the App via VS Code

  1. Open the project in VS Code.
  2. Open the "Run and Debug" panel.
  3. Start an emulator (iOS/Android) or connect your physical device.
  4. Select "example" in the run menu and press "Run".

Running the App via Console

If you prefer using the terminal to run the app, use the following steps:

  1. For Android:

    Ensure you have an Android emulator running or a device connected. Then run:

    flutter run
  2. For iOS:

    Make sure you have an iOS simulator running or a device connected. Then run:

    flutter run

Integrating Your ZKP

The example app comes with a simple prover generated from a Circom circuit. To integrate your own prover, follow the steps below.

Setup

Follow the Rust Setup steps from the MoPro official docs to generate the platform-specific libraries.

Copying The Generated Libraries

iOS

  1. Replace mopro.swift at mopro_flutter_plugin/ios/Classes/mopro.swift with the file generated during the Setup.
  2. Replace the directory mopro_flutter_plugin/ios/MoproBindings.xcframework with the one generated during the Setup.

Android

  1. Replace the directory mopro_flutter_plugin/android/src/main/jniLibs with the one generated during the Setup.
  2. Replace mopro.kt at mopro_flutter_plugin/android/src/main/kotlin/uniffi/mopro/mopro.kt with the file generated during the Setup.

zKey

  1. Place your .zkey file in your app's assets folder. For example, to run the included example app, you need to replace the .zkey at assets/multiplier2_final.zkey with your file. If you change the .zkey file name, don't forget to update the asset definition in your app's pubspec.yaml:

    assets:
      - assets/your_new_zkey_file.zkey
  2. Load the new .zkey file properly in your Dart code. For example, update the file path in lib/main.dart:

    var inputs = <String, List<String>>{};
    inputs["a"] = ["3"];
    inputs["b"] = ["5"];
    proofResult = await _moproFlutterPlugin.generateProof("assets/multiplier2_final.zkey", inputs);

Don't forget to modify the input values for your specific case!

Developing The Plugin

Android

Open the ./android directory in Android Studio. You will be able to browse to the plugin code in Android and Project view.