Skip to content

Commit

Permalink
Fixed Android build.
Browse files Browse the repository at this point in the history
  • Loading branch information
5eeman committed Dec 20, 2024
1 parent 45215d9 commit 37a288d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ dependencies {
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

implementation "io.iden3.circomwitnesscalc:0.0.1-alpha.1"
implementation "io.iden3:circomwitnesscalc:0.0.1-alpha.1"
}

if (isNewArchitectureEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.circomwitnesscalc

import android.util.Base64
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.Promise
import io.iden3.circomwitnesscalc.CircomWitnesscalc
import io.iden3.circomwitnesscalc.WitnesscalcError
import io.iden3.circomwitnesscalc.calculateWitness

class CircomWitnesscalcModule(reactContext: ReactApplicationContext) :
ReactContextBaseJavaModule(reactContext) {
Expand All @@ -19,22 +21,20 @@ class CircomWitnesscalcModule(reactContext: ReactApplicationContext) :
fun calculateWitness(inputs: String, graph: String, promise: Promise) {
try {
// Decode base64
byte[] zkeyBytes = Base64.decode(graph, Base64.DEFAULT);
val graphBytes = Base64.decode(graph, Base64.DEFAULT);

ByteArray witness = CircomWitnesscalc.calculateWitness(
val witness = calculateWitness(
inputs,
graph
);
graphBytes
)

// Encode base64
String witnessBase64 = Base64.encodeToString(witness, Base64.DEFAULT);
val witnessBase64 = Base64.encodeToString(witness, Base64.DEFAULT);

promise.resolve(witnessBase64);
} catch (RapidsnarkError e) {
promise.reject(String.valueOf(e.getCode()), e.getMessage());
} catch (e: WitnesscalcError) {
promise.reject(e.code.toString(), e.message);
}

promise.resolve(a * b)
}

companion object {
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 23
minSdkVersion = 24
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "26.1.10909125"
Expand Down

0 comments on commit 37a288d

Please sign in to comment.