package expo.modules.zkexpo import expo.modules.kotlin.modules.Module import expo.modules.kotlin.modules.ModuleDefinition import java.io.File class ZkExpoModule : Module() { companion object { init { System.loadLibrary("native_rust_lib") } } external fun groth16Prove(a: String, b: String, c: String): String external fun groth16ProveV2(a: String, b: String, c: String): String external fun noirProve(a: String, b: String, c: String): String external fun halo2Prove(a: String, b: String): String external fun addToCache(a: String, b: String, c: String): Void external fun clearCache(): Void override fun definition() = ModuleDefinition { Name("ZkExpo") AsyncFunction("groth16Prove") { a: String, b: String, c: String -> groth16Prove(a, b, c) } AsyncFunction("groth16ProveV2") { a: String, b: String, c: String -> groth16ProveV2(a, b, c) } AsyncFunction("halo2Prove") { a: String, b: String -> if (File(a).exists()) { println("File exists at path: $a") } else { println("File does not exist at path: $a") throw Exception("File not found at path: $a") } halo2Prove(a, b) } AsyncFunction("noirProve") { a: String, b: String, c: String -> if (File(a).exists()) { println("File exists at path: $a") } else { println("File does not exist at path: $a") throw Exception("File not found at path: $a") } noirProve(a, b, c) } AsyncFunction("addToCache") { a: String, b: String, c: String -> if (File(b).exists()) { println("File exists at path: $a") } else { println("File does not exist at path: $a") throw Exception("File not found at path: $a") } if (File(c).exists()) { println("File exists at path: $b") } else { println("File does not exist at path: $b") throw Exception("File not found at path: $b") } addToCache(a, b, c) } AsyncFunction("clearCache") { -> clearCache() } } }