Skip to main content
Version: 0.0.1

Android

Getting started with a new project

  1. Install mopro-cli. See Getting Started.
  2. Create a new project
mopro init --platforms android \
cd mopro-example-app
  1. Prepare circuits
mopro prepare
  1. Build the project
mopro build --platforms android
  1. Open the project in Android Studio
open android -a Android\ Studio

Getting started with exported bindings

  1. Install mopro-cli. See Getting Started.
  2. Prepare circuits
mopro prepare
  1. Build the project
mopro build --platforms android
  1. Export bindings
mopro export-bindings --platforms android --destination out
  1. Add dependencies in app/build.gradle.kts
dependencies {
...
implementation("net.java.dev.jna:jna:5.13.0@aar")
...
}
  1. Sync gradle (shift+command+O)
  2. Drag and drop folders.
    Move the out/android/jniLibs/ folder into app/src/main/jniLibs/.
    Move the out/android/uniffi/mopro/mopro.kts file into app/src/main/java/uniffi/mopro/mopro.kt.
    android bindings
  3. Use the generated mopro library by
import uniffi.mopro.initializeMopro

func initialize(){
initializeMopro()
}

Kotlin API

MoproCircom

Initialize a MoproCircom object.

Usage:

var moproCircom = MoproCircom()

initialize

Initializes the instance with the given zkeyPath and wasmPath.

@Throws(MoproException::class)
fun `initialize`(
`zkeyPath`: String,
`wasmPath`: String,
)

Usage:

moproCircom.initialize(zkeyPath, wasmPath)

generateProof

Generates a proof based on the provided circuit inputs.

@Throws(MoproException::class)
fun `generateProof`(`circuitInputs`: Map<String, List<String>>): GenerateProofResult

Usage:

val inputs = mutableMapOf<String, List<String>>()
inputs["a"] = listOf("3")
inputs["b"] = listOf("5")
var generateProofResult = moproCircom.generateProof(inputs)

verifyProof

Verifies the provided proof against the given inputs.

@Throws(MoproException::class)
fun `verifyProof`(
`proof`: ByteArray,
`publicInput`: ByteArray,
): Boolean

Usage:

var isValid = moproCircom.verifyProof(
generateProofResult.proof,
generateProofResult.inputs
)

generateProofStatic

Generates a proof based on the provided circuit inputs.

warning

Note: The function is different from generateProof.
In this function, the zkey and wasm are precompiled during cargo build.
You can specify the mopro-config.toml to build the default circuits.

@Throws(MoproException::class)
fun `generateProofStatic`(`circuitInputs`: Map<String, List<String>>): GenerateProofResult

verifyProofStatic

Verifies the provided proof against the given inputs.

warning

Note: The function is different from verifyProof.
In this function, the zkey and wasm are precompiled during cargo build.
You can specify the mopro-config.toml to build the default circuits.

@Throws(MoproException::class)
fun `verifyProofStatic`(
`proof`: ByteArray,
`publicInput`: ByteArray,
): Boolean

toEthereumInputs

Convert public inputs data to a string array.

fun `toEthereumInputs`(`inputs`: ByteArray): List<String>

toEthereumProof

Convert proof data to a proof structure which can be submitted to a verifier contract.

fun `toEthereumProof`(`proof`: ByteArray): ProofCalldata