Skip to content

zkmopro/flutter-plugin

Repository files navigation

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. Navigate to the example directory of the project:

    cd example
  2. For Android:

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

    flutter run
  3. 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 ios/Classes/mopro.swift with the file generated during the Setup.
  2. Replace the directory ios/MoproBindings.xcframework with the one generated during the Setup.

Android

  1. Replace the directory android/src/main/jniLibs with the one generated during the Setup.
  2. Replace mopro.kt at 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 example/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 example/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!

About

No description, website, or topics provided.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published