Android
Getting started with a new project
- Install
mopro-cli
. See Getting Started. - Create a new project
mopro init --platforms android \
cd mopro-example-app
- Prepare circuits
mopro prepare
- Build the project
mopro build --platforms android
- Open the project in Android Studio
open android -a Android\ Studio
Getting started with exported bindings
- Install
mopro-cli
. See Getting Started. - Prepare circuits
mopro prepare
- Build the project
mopro build --platforms android
- Export bindings
mopro export-bindings --platforms android --destination out
- Add dependencies in
app/build.gradle.kts
dependencies {
...
implementation("net.java.dev.jna:jna:5.13.0@aar")
...
}
- Sync gradle (shift+command+O)
- Drag and drop folders.
Move theout/android/jniLibs/
folder intoapp/src/main/jniLibs/
.
Move theout/android/uniffi/mopro/mopro.kts
file intoapp/src/main/java/uniffi/mopro/mopro.kt
.
- 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.
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.
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