Warning
This code was submitted as an internal PSE hackathon project and is not maintained anymore. The development continues here in the official mopro org repo.
Flutter, now the most popular cross-platform framework, has surpassed React Native in popularity over the past few years. Mopro Flutter shows an example of integrating the mobile ZK-proving into a Flutter app, allowing to streamline the creation of ZK-enabled mobile apps.
- Open the project in VS Code
- Open "Run and Debug"
- Start an emulator (iOS/Android) or connect your phone
- Select "example" in the run menu and press run
The example app comes with a simple prover generated from a Circom circuit. To integrate your own prover, follow the steps below.
- Follow the Rust Setup steps from the MoPro official docs to generate the platform-specific libraries.
- Replace
mopro.swiftatios/Classes/mopro.swiftwith the file generated during the Setup - Replace the directory
ios/MoproBindings.xcframeworkwith the one generated during the Setup
- Replace the directory
android/src/main/jniLibswith the one generated during the Setup - Replace
mopro.ktatandroid/src/main/kotlin/uniffi/mopro/mopro.ktwith the file generated during the Setup
- Put your zKey file in your app assets. For example, to run the included example app, you need to replace the zKey at
example/assets/multiplier2_final.zkeywith your file. If you change the zKey file name, don't forget to change the asset definition in your app'spubspec.yaml. For example, here:example/pubspec.yaml
assets:
- assets/multiplier2_final.zkeyIf you have changed the zKey asset name, don't forget to also correctly load it. For example, here: 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!