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:NoirKotlin:v1.0.0-beta.19")
}Checkout the JitPack page for more 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.generateNoirProof
import uniffi.mopro.verifyNoirProof
import uniffi.mopro.getNoirVerificationKeyPlease checkout noir-rs to see how to generate the circuit and the srs.
To load the circuit and srs in an Android app, please checkout getFilePathFromAssets to get the path. Then define the file path, e.g.
val circuitFile = getFilePathFromAssets("noir_multiplier2.json")
val srsFile = getFilePathFromAssets("noir_multiplier2.srs")val onChain = true // Use Keccak for Solidity compatibility
val lowMemoryMode = false
val vk = getNoirVerificationKey(circuitFile, srsFile, onChain, lowMemoryMode)val inputs = listOf("3", "5")
val proof = generateNoirProof(
circuitFile,
srsFile,
inputs,
onChain,
vk,
lowMemoryMode
)val result = verifyNoirProof(
circuitFile,
proof,
onChain,
vk,
lowMemoryMode
)This package relies on bindings generated by the Mopro CLI. To learn how to build Mopro bindings, refer to the Getting Started section.
Use mopro-cli and choose noir
mopro initchoose noir
mopro buildchoose android and build for aarch64-linux-android and x86_64-linux-android architectures.
Then, replace the entire bindings directory with your generated files in the following location:
android/app/src/main/java/uniffiandroid/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/mainThis work was initially sponsored by a joint grant from PSE and 0xPARC. It is currently incubated by PSE.