revert to using c
This commit is contained in:
parent
c6fc155060
commit
a05211c23c
|
@ -1,3 +1,4 @@
|
|||
lib/
|
||||
*.class
|
||||
*.o
|
||||
*.o
|
||||
*.a
|
|
@ -23,7 +23,7 @@ public class CKzg4844JNI {
|
|||
public static native boolean verifyAggregateKzgProof(byte[] blobs, byte[] commitments, int count,
|
||||
byte[] proof);
|
||||
|
||||
public static native byte[] blobToKzgCommitment(byte[] commitment);
|
||||
public static native byte[] blobToKzgCommitment(byte[] blob);
|
||||
|
||||
public static native boolean verifyKzgProof(byte[] commitment, byte[] z, byte[] y, byte[] proof);
|
||||
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
# Build Shared Library
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* libblst.a is available in ../../blst/ directory. Follow the instructions in the home README.md.
|
||||
* JAVA_HOME environment variable is set.
|
||||
|
||||
## Windows
|
||||
|
||||
```bat
|
||||
g++ -c -I..\..\blst\bindings -I..\..\src\ -I"%JAVA_HOME%\include" -I"%JAVA_HOME%\include\win32" c_kzg_4844_jni.cpp -o c_kzg_4844_jni.o
|
||||
g++ -shared -o lib/ckzg4844jni.dll c_kzg_4844.o c_kzg_4844_jni.o -Wl,--add-stdcall-alias
|
||||
TBC
|
||||
```
|
||||
|
||||
## Linux
|
||||
|
||||
```bash
|
||||
g++ -c -fPIC -I../../blst/bindings -I../../src/ -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux c_kzg_4844_jni.cpp -o c_kzg_4844_jni.o
|
||||
g++ -shared -fPIC -o lib/libckzg4844jni.so c_kzg_4844.o c_kzg_4844_jni.o -lc
|
||||
clang -O -Wall -shared -fPIC -I../../blst/bindings -I../../src/ -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux -o lib/libckzg4844jni.so c_kzg_4844_jni.c ../../src/c_kzg_4844.c ../../blst/libblst.a
|
||||
```
|
||||
|
||||
## Mac-OS
|
||||
|
||||
```bash
|
||||
g++ -c -fPIC -I../../blst/bindings -I../../src/ -I${JAVA_HOME}/include -I${JAVA_HOME}/include/darwin c_kzg_4844_jni.cpp -o c_kzg_4844_jni.o
|
||||
g++ -dynamiclib -o lib/libckzg4844jni.dylib c_kzg_4844.o c_kzg_4844_jni.o -lc
|
||||
TBC
|
||||
```
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <stdlib.h>
|
||||
#include "c_kzg_4844_jni.h"
|
||||
#include "c_kzg_4844.h"
|
||||
|
||||
|
@ -7,15 +8,14 @@ JNIEXPORT void JNICALL Java_CKzg4844JNI_loadTrustedSetup(JNIEnv *env, jclass thi
|
|||
{
|
||||
settings = malloc(sizeof(KZGSettings));
|
||||
|
||||
const char *file_native = env->GetStringUTFChars(file, 0);
|
||||
const char *file_native = (*env)->GetStringUTFChars(env, file, 0);
|
||||
|
||||
FILE *f = fopen(file_native, "r");
|
||||
|
||||
if (f == NULL)
|
||||
{
|
||||
free(settings);
|
||||
env->ReleaseStringUTFChars(file, file_native);
|
||||
// need to throw an exception
|
||||
(*env)->ReleaseStringUTFChars(env, file, file_native);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -23,44 +23,47 @@ JNIEXPORT void JNICALL Java_CKzg4844JNI_loadTrustedSetup(JNIEnv *env, jclass thi
|
|||
{
|
||||
free(settings);
|
||||
fclose(f);
|
||||
env->ReleaseStringUTFChars(file, file_native);
|
||||
// need to throw an exception
|
||||
(*env)->ReleaseStringUTFChars(env, file, file_native);
|
||||
return;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
env->ReleaseStringUTFChars(file, file_native);
|
||||
|
||||
printf("Loaded Trusted Setup");
|
||||
printf("Loaded Trusted Setup from %s\n", file_native);
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, file, file_native);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_CKzg4844JNI_freeTrustedSetup(JNIEnv *env, jclass thisCls)
|
||||
{
|
||||
free_trusted_setup(settings);
|
||||
free(settings);
|
||||
printf("Trusted Setup was unloaded\n");
|
||||
}
|
||||
|
||||
JNIEXPORT jbyteArray JNICALL Java_CKzg4844JNI_computeAggregateKzgProof(JNIEnv *env, jclass thisCls, jbyteArray blobs, jint count)
|
||||
{
|
||||
jbyte *blobs_native = env->GetByteArrayElements(blobs, NULL);
|
||||
jbyteArray proof = env->NewByteArray(48);
|
||||
g1_t *out;
|
||||
bytes_to_g1(out, (uint8_t *)blobs_native);
|
||||
// NOT YET IMPLEMENTED
|
||||
// jbyte *blobs_native = (*env)->GetByteArrayElements(env, blobs, NULL);
|
||||
jbyteArray proof = (*env)->NewByteArray(env, 48);
|
||||
return proof;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_CKzg4844JNI_verifyAggregateKzgProof(JNIEnv *env, jclass thisCls, jbyteArray blobs, jbyteArray commitments, jint count, jbyteArray proof)
|
||||
{
|
||||
// NOT YET IMPLEMENTED
|
||||
return false;
|
||||
}
|
||||
|
||||
JNIEXPORT jbyteArray JNICALL Java_CKzg4844JNI_blobToKzgCommitment(JNIEnv *env, jclass thisCls, jbyteArray commitment)
|
||||
JNIEXPORT jbyteArray JNICALL Java_CKzg4844JNI_blobToKzgCommitment(JNIEnv *env, jclass thisCls, jbyteArray blob)
|
||||
{
|
||||
jbyteArray ret = env->NewByteArray(48);
|
||||
// NOT YET IMPLEMENTED
|
||||
jbyteArray ret = (*env)->NewByteArray(env, 48);
|
||||
return ret;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_CKzg4844JNI_verifyKzgProof(JNIEnv *env, jclass thisCls, jbyteArray commitment, jbyteArray z, jbyteArray y, jbyteArray proof)
|
||||
{
|
||||
// NOT YET IMPLEMENTED
|
||||
return false;
|
||||
}
|
Loading…
Reference in New Issue