Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix android tests #52

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,27 @@ fun ProofComponent() {
"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"
)

Expand Down
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)
}
30 changes: 25 additions & 5 deletions mopro-ffi/tests/bindings/test_mopro_keccak2.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import uniffi.mopro.*;
import uniffi.mopro.*

try {
initializeMopro()
Expand Down Expand Up @@ -240,14 +240,34 @@ try {
"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 = generateProof2(inputs)
assert(generateProofResult.proof.size > 0) { "Proof is empty"}
assert(generateProofResult.proof.size > 0) { "Proof is empty" }
var isValid = verifyProof2(generateProofResult.proof, generateProofResult.inputs)
// FIXME: assert(isValid) { "Proof is invalid"}
println("Proof is invalid: $isValid")
assert(isValid) { "Proof is invalid" }
} catch (e: Exception) {
println(e);
println(e)
}
Loading