Skip to content

Kotlin end-to-end

This guide uses the Verity Kotlin SDK, which wraps the JNI bridge, shared dispatcher, and ProveKit backend for Android.

dependencies {
implementation("xyz.atheon:verity:0.3.2")
}
import xyz.atheon.verity.*
val verity = Verity(Backend.PROVEKIT)
val prover = verity.loadProver("scheme.pkp")
val verifier = verity.loadVerifier("scheme.pkv")
prover.use { p ->
verifier.use { v ->
val witness = Witness.of(mapOf("age" to "25", "threshold" to "18"))
val proof = p.prove(witness)
check(v.verify(proof)) { "proof did not verify" }
}
}

Use loadProver(ByteArray) and loadVerifier(ByteArray) when artifacts live in Android assets, are downloaded, or are managed through encrypted storage. Witness.of(...) accepts a flat Map<String, String> of field-element strings, a TOML file, or a JSON string.

  • Call Verity.configureMemory(...) before constructing Verity when large ProveKit circuits need Android RAM limits or file-backed memory.
  • The use { ... } blocks above are not optional; Prover and Verifier hold native JNI handles. Letting them go out of scope without close() leaks until GC runs (if ever).
  • The snippet assumes scheme.pkp and scheme.pkv are readable from the app’s filesystem. If they’re packaged as assets, copy them to a readable path or load them as a ByteArray instead.