// Example: consuming the pvtcoms UniFFI bindings from an Android (Kotlin/Compose) app. // Generated binding: uniffi.pvtcoms_ffi; loads libpvtcoms_ffi.so from jniLibs. package com.pvtcoms.example import uniffi.pvtcoms_ffi.Identity import uniffi.pvtcoms_ffi.safetyNumber import uniffi.pvtcoms_ffi.verify import uniffi.pvtcoms_ffi.version fun demo(deviceKey: ByteArray, sessionKey: ByteArray) { val v = version() // e.g. "0.1.8" // Identity is OPAQUE — the secret key stays inside Rust. Identity.generate().use { id -> // AutoCloseable val pub = id.publicKey() // ByteArray (32 bytes) println("my id ${id.fingerprint()}") val sig = id.sign("hello".toByteArray()) val ok = verify(pub, "hello".toByteArray(), sig) // true (throws on bad length) // Persist: seal under the device key (from Android Keystore), restore later. val blob = id.toSealed(deviceKey) Identity.fromSealed(deviceKey, blob).use { /* restored, same public key */ } } val emoji = safetyNumber(sessionKey) // 16-emoji safety number for the verify screen }