Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mopro Kotlin Package

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).

Getting mopro 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: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")

Usage Example

Import the package

import uniffi.mopro.generateNoirProof
import uniffi.mopro.verifyNoirProof
import uniffi.mopro.getNoirVerificationKey

Load circuit and srs

Please 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")

getNoirVerificationKey

val onChain = true  // Use Keccak for Solidity compatibility
val lowMemoryMode = false
val vk = getNoirVerificationKey(circuitFile, srsFile, onChain, lowMemoryMode)

generateNoirProof

val inputs = listOf("3", "5")
val proof = generateNoirProof(
    circuitFile,
    srsFile,
    inputs,
    onChain,
    vk,
    lowMemoryMode
)

verifyNoirProof

val result = verifyNoirProof(
    circuitFile,
    proof,
    onChain,
    vk,
    lowMemoryMode
)

How to Build the Package

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 init

choose noir

mopro build

choose 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/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

Community

  • X account:
  • Telegram group:

Acknowledgements

This work was initially sponsored by a joint grant from PSE and 0xPARC. It is currently incubated by PSE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages