A Kotlin/Android library for generating and verifying zero-knowledge proofs (ZKPs) using native Rust code via UniFFI and JNI. This package provides a simple interface to interact with proof systems such as Circom and Halo2, supporting multiple proof libraries (e.g., Arkworks, Rapidsnark).
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")
}
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")
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)
Warning
The default bindings are built specifically for the multiplier2
circom circuit. If you'd like to update the circuit or switch to a different proving scheme, please refer to the How to Build the Package section.
Circuit source code: https://github.com/zkmopro/circuit-registry/tree/main/multiplier2
Example .zkey file for the circuit: http://ci-keys.zkmopro.org/multiplier2_final.zkey
This package relies on bindings generated by the Mopro CLI. To learn how to build Mopro bindings, refer to the Getting Started section. If you'd like to generate custom bindings for your own circuits or proving schemes, check out the guide on how to use the Mopro CLI: Rust Setup for Android/iOS Bindings.
Then, replace the entire bindings directory 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 MoproAndroidBindings/uniffi android/app/src/main/java
cp -r MoproAndroidBindings/jniLibs android/app/src/main
This work was initially sponsored by a joint grant from PSE and 0xPARC. It is currently incubated by PSE.