Skip to content

Commit

Permalink
harmonize namespace + convert remaining Java code to Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
madztheo committed Jul 25, 2024
1 parent 4533586 commit 95364b5
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ circuit.setupSrs(srsPath)
To generate a proof, you can call the `prove` method and pass in the inputs for the proof and the proof type. It will return a `Proof` object containing the proof with its public inputs and the verification key.

```kotlin
import noir.Proof
import com.noirandroid.lib.Proof
import java.util.HashMap
import android.util.Log

Expand Down
4 changes: 2 additions & 2 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ afterEvaluate {
from(components["release"])
groupId = "com.github.madztheo"
artifactId = "noir_android"
version = "v0.30.0-8"
version = "v0.30.0-9"
}
}
}
Expand Down Expand Up @@ -114,7 +114,7 @@ tasks.register<Copy>("copyRustLibs") {
} else {
// Download the .so file from the GitHub release
download.run {
src("https://github.com/madztheo/noir_android/releases/download/v0.30.0-8/libnoir_java_arm64-v8a.so")
src("https://github.com/madztheo/noir_android/releases/download/v0.30.0-9/libnoir_java_arm64-v8a.so")
dest("src/main/jniLibs/arm64-v8a/libnoir_java.so")
overwrite(false)
}
Expand Down
2 changes: 0 additions & 2 deletions lib/src/main/java/com/noirandroid/lib/Circuit.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.noirandroid.lib

import com.google.gson.Gson
import noir.Noir
import noir.Proof
import android.util.Log

data class CircuitManifest(
Expand Down
15 changes: 0 additions & 15 deletions lib/src/main/java/com/noirandroid/lib/Noir.java

This file was deleted.

11 changes: 11 additions & 0 deletions lib/src/main/java/com/noirandroid/lib/Noir.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.noirandroid.lib

class Noir {
companion object {
external fun prove(circuitBytecode: String, initialWitness: Map<String, String>, proofType: String, numPoints: String): Proof

external fun verify(circuitBytecode: String, proof: Proof, proofType: String, numPoints: String): Boolean

external fun setup_srs(circuitBytecode: String, srsPath: String?): Int
}
}
11 changes: 0 additions & 11 deletions lib/src/main/java/com/noirandroid/lib/Proof.java

This file was deleted.

3 changes: 3 additions & 0 deletions lib/src/main/java/com/noirandroid/lib/Proof.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.noirandroid.lib

class Proof(val proof: String, val vk: String)
8 changes: 4 additions & 4 deletions lib/src/main/java/noir_java/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use noir_rs::{
};

#[no_mangle]
pub extern "system" fn Java_noir_Noir_setup_1srs<'local>(
pub extern "system" fn Java_com_noirandroid_lib_Noir_00024Companion_setup_1srs<'local>(
mut env: JNIEnv<'local>,
_class: JClass<'local>,
circuit_bytecode_jstr: JString<'local>,
Expand Down Expand Up @@ -45,7 +45,7 @@ pub extern "system" fn Java_noir_Noir_setup_1srs<'local>(


#[no_mangle]
pub extern "system" fn Java_noir_Noir_prove<'local>(
pub extern "system" fn Java_com_noirandroid_lib_Noir_00024Companion_prove<'local>(
mut env: JNIEnv<'local>,
_class: JClass<'local>,
circuit_bytecode_jstr: JString<'local>,
Expand Down Expand Up @@ -125,7 +125,7 @@ pub extern "system" fn Java_noir_Noir_prove<'local>(
.expect("Failed to create Java string for vk");

let proof_class = env
.find_class("noir/Proof")
.find_class("com/noirandroid/lib/Proof")
.expect("Failed to find Proof class");
env.new_object(
proof_class,
Expand All @@ -137,7 +137,7 @@ pub extern "system" fn Java_noir_Noir_prove<'local>(
}

#[no_mangle]
pub extern "system" fn Java_noir_Noir_verify<'local>(
pub extern "system" fn Java_com_noirandroid_lib_Noir_00024Companion_verify<'local>(
mut env: JNIEnv<'local>,
_class: JClass<'local>,
circuit_bytecode_jstr: JString<'local>,
Expand Down

0 comments on commit 95364b5

Please sign in to comment.