starkware-libs / stwo

Apache License 2.0
224 stars 68 forks source link

Create bindings for Kotlin Multiplatform #774

Open vitorpamplona opened 1 month ago

vitorpamplona commented 1 month ago

Amethyst, a Nostr Client for Android, is looking to call the prover and verifier locally on Android. The goal is to verify external computing power offered by service providers via Data Vending Machines. Amethyst will request some computation, receive the result and proofs, and locally verify on the phone.

For that, we need to re-package each of STWO's binary targets and their respective dependencies to each of the potential Kotlin targets in a new Kotlin Multiplatform project. We can use the Kotlin bindings for Secp256k1 from ACINQ as a design reference for the work to be done. It uses a mix between JNI and native bindings to get the job done. The new library should be a one-stop-shop for STWO to run on Android, Java Desktop (Windows, Linux, MacOS), iOS, and even Kotlin-written WASM.

At a minimum, the new project must offer entry points to the prove and verify functions here: https://github.com/starkware-libs/stwo/blob/dev/crates/prover/src/core/prover/mod.rs . Ideally, dependencies that are not relevant to those functions should be removed to minimize the binary size and the amount of dependencies. Hopefully, the new project doesn't need to do much more than just calling STWO functions, but utilities to facilitate the use of STWO are welcome.