motemotech / nico_mopro

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mopro

Making client-side proving on mobile simple (and fast).

Overview

  • mopro-core - core mobile Rust library.
  • mopro-ffi - wraps mopro-core and exposes UniFFI bindings.
  • mopro-ios - iOS CocoaPod library exposing native Swift bindings.
  • mopro-android - Android library exposing native Kotlin bindings.
  • mopro-example-app - example iOS app using mopro-ios.
  • ark-zkey - helper utility to make zkey more usable and faster in arkworks.

Architecture

The following illustration shows how mopro and its components fit together into the wider ZKP ecosystem:

mopro architecture (full)

Zooming in a bit:

mopro architecture

How to use

Prepare circuits

  • Install circom and snarkjs
  • Run ./scripts/prepare.sh to check all prerequisites are set.

iOS

Prepare

Build Bindings

To build bindings for iOS simulator debug mode, run

./scripts/build_ios.sh simulator debug

Open the mopro-ios/MoproKit/Example/MoproKit.xcworkspace in Xcode.

Update Bindings

To update bindings, run ./scripts/update_bindings.sh simulator|device debug|release.

  • simulator is for building library to run on iOS simulator, device is for running on a real device
  • debug is for Rust library to be in debug mode and release for release mode

Android

Prepare

  • Install Android Studio
  • Open Android Studio, and navigate to SDK Manager > SDK Tools > NDK (Side by Side) as laid out on the Android Developer site.
  • Export $ANDROID_HOME and change {USER_NAME} to your username
    export ANDROID_HOME="/Users/{USER_NAME}/Library/Android/sdk"
  • Locate which NDK version you have by
    ls $ANDROID_HOME/ndk
    # 26.1.10909125
    and set it to your NDK_PATH environment variable. e.g.
    NDK_PATH=$ANDROID_HOME/ndk/26.1.10909125

    Reference: Running Rust on Android with UniFFI

Build and Update Bindings

To build bindings for android simulator debug mode, run

./scripts/build_android.sh arm64 debug
  • Device types: x86_64, x86, arm, arm64 Check your device architecture here: https://doc.e.foundation/devices For Android Studio simulator (Pixel series), choose arm64
  • Mode: debug, release

Community and Talks

Join the Telegram group here.

Talk by @oskarth at ProgCrypto/Devconnect (Istanbul, November 2023): Slides (video pending)

Performance

Preliminary benchmarks on an iPhone 14 Max Pro:

  • Keccak256 (150k constraints): 1.5s
    • ~x10-20 faster vs comparable circuit in browser
  • anon-aadhaar / RSA Verify: ~6.5s
    • ~5s for witness generation (still in WASM), ~2s prover time
    • 80% of time on witness generation
    • ~x10 faster vs browser on phone
  • Bottlenecks: loading zkey and wasm witness generation

Acknowledgements

This work is sponsored by a joint grant from PSE and 0xPARC.

About

License:Apache License 2.0


Languages

Language:Swift 36.7%Language:Rust 23.3%Language:Circom 18.0%Language:Kotlin 6.2%Language:Shell 6.2%Language:C 5.7%Language:TypeScript 2.7%Language:Ruby 0.7%Language:CSS 0.2%Language:Makefile 0.1%Language:JavaScript 0.1%