Skip to content

Commit

Permalink
chore(android): add android bindings tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vivianjeng committed Jan 3, 2024
1 parent 31fbb0d commit e810258
Show file tree
Hide file tree
Showing 4 changed files with 420 additions and 3 deletions.
21 changes: 21 additions & 0 deletions mopro-ffi/tests/bindings/test_mopro.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import uniffi.mopro.*

var wasmPath = "../mopro-core/examples/circom/multiplier2/target/multiplier2_js/multiplier2.wasm"
var r1csPath = "../mopro-core/examples/circom/multiplier2/target/multiplier2.r1cs"

try {
var moproCircom = MoproCircom()
var setupResult = moproCircom.setup(wasmPath, r1csPath)
assert(setupResult.provingKey.size > 0) { "Proving key should not be empty" }

val inputs = mutableMapOf<String, List<String>>()
inputs["a"] = listOf("3")
inputs["b"] = listOf("5")

var generateProofResult = moproCircom.generateProof(inputs)
assert(generateProofResult.proof.size > 0) { "Proof is empty" }
var isValid = moproCircom.verifyProof(generateProofResult.proof, generateProofResult.inputs)
assert(isValid) { "Proof is invalid" }
} catch (e: Exception) {
println(e)
}
279 changes: 279 additions & 0 deletions mopro-ffi/tests/bindings/test_mopro_keccak.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
import uniffi.mopro.*

var wasmPath =
"../mopro-core/examples/circom/keccak256/target/keccak256_256_test_js/keccak256_256_test.wasm"
var r1csPath = "../mopro-core/examples/circom/keccak256/target/keccak256_256_test.r1cs"

try {
var moproCircom = MoproCircom()
var setupResult = moproCircom.setup(wasmPath, r1csPath)
assert(setupResult.provingKey.size > 0) { "Proving key should not be empty" }

val inputs = mutableMapOf<String, List<String>>()
inputs["in"] =
listOf(
"0",
"0",
"1",
"0",
"1",
"1",
"1",
"0",
"1",
"0",
"1",
"0",
"0",
"1",
"1",
"0",
"1",
"1",
"0",
"0",
"1",
"1",
"1",
"0",
"0",
"0",
"1",
"0",
"1",
"1",
"1",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0"
)

var generateProofResult = moproCircom.generateProof(inputs)
assert(generateProofResult.proof.size > 0) { "Proof is empty" }
var isValid = moproCircom.verifyProof(generateProofResult.proof, generateProofResult.inputs)
assert(isValid) { "Proof is invalid" }
} catch (e: Exception) {
println(e)
}
Loading

0 comments on commit e810258

Please sign in to comment.