Skip to main content
Version: 0.2.0

Kotlin SDK

In this section, you'll learn how to build a Kotlin SDK using Mopro's native bindings. The process includes the following steps:

  1. Generate the binding using the Mopro CLI
  2. Integrate the binding into a Kotlin Package
  3. How to install the Kotlin SDK via JitPack
  4. How to use the package

Generate the bindings using the Mopro CLI

To get started with building Mopro bindings, refer to the Getting Started section. If you’d like to generate custom bindings for your own circuits or proving schemes, see the guide: Rust Setup for Android/iOS Bindings.

Then you will have a MoproAndroidBindings in the project directory.

Integrate the bindings into a Kotlin Package

  1. Clone the SDK template repository:
git clone https://github.com/zkmopro/mopro-kotlin-package
  1. Replace the generated bindings:

Replace the bindings directory MoproAndroidBindings/uniffi and MoproAndroidBindings/jniLibs with your generated files in the following location:

  • android/app/src/main/java/uniffi
  • android/app/src/main/jniLibs

Alternatively, you can run the following commands to copy your generated bindings into the correct location:

cp -r PATH/TO/MoproAndroidBindings/uniffi android/app/src/main/java
cp -r PATH/TO/MoproAndroidBindings/jniLibs android/app/src/main

How to install the Kotlin SDK via JitPack

To get this library from GitHub using JitPack:

Step 1. Add the JitPack repository to your settings.gradle.kts at the end of repositories:

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}

Step 2. Add the dependency to your build.gradle.kts:

  dependencies {
implementation("com.github.zkmopro:mopro-kotlin-package:Tag") // Or change to your own URL
}

Replace Tag with the desired release version, e.g. v0.1.0. See the JitPack page for available versions.

Note: If you're using an Android template from mopro create, comment out these UniFFI dependencies in your build file to prevent duplicate class errors.

  // // Uniffi
// implementation("net.java.dev.jna:jna:5.13.0@aar")
// implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")

How to use the package

Here is an example of how to integrate and use this example package

import uniffi.mopro.generateCircomProof
import uniffi.mopro.verifyCircomProof
import uniffi.mopro.ProofLib

val inputStr = "{\"b\":[\"5\"],\"a\":[\"3\"]}"
val zkeyPath = "/path/to/multiplier2_final.zkey"
val proof = generateCircomProof(zkeyPath, inputStr, ProofLib.ARKWORKS)
val isValid = verifyCircomProof(zkeyPath, proof, ProofLib.ARKWORKS)

Or checkout the test-e2e app.