don't expose KZGSettings
This commit is contained in:
parent
3136083139
commit
c50f52108d
|
@ -14,34 +14,17 @@ public class CKzg4844JNI {
|
|||
}
|
||||
}
|
||||
|
||||
public static native KZGSettings loadTrustedSetup(String file);
|
||||
public static native void loadTrustedSetup(String file);
|
||||
|
||||
public static native void freeTrustedSetup(KZGSettings settings);
|
||||
public static native void freeTrustedSetup();
|
||||
|
||||
public static native byte[] computeAggregateKzgProof(byte[] blobs, int count, KZGSettings settings);
|
||||
public static native byte[] computeAggregateKzgProof(byte[] blobs, int count);
|
||||
|
||||
public static native boolean verifyAggregateKzgProof(byte[] blobs, byte[] commitments, int count,
|
||||
byte[] proof,
|
||||
KZGSettings settings);
|
||||
byte[] proof);
|
||||
|
||||
public static native byte[] blobToKzgCommitment(byte[] commitment, KZGSettings settings);
|
||||
public static native byte[] blobToKzgCommitment(byte[] commitment);
|
||||
|
||||
public static native boolean verifyKzgProof(byte[] commitment, byte[] z, byte[] y, byte[] proof, KZGSettings settings);
|
||||
|
||||
public static class KZGSettings {
|
||||
public FFTSettings fs;
|
||||
public byte[] g1Values;
|
||||
public byte[] g2Values;
|
||||
public int g1ValuesCount;
|
||||
public int g2ValuesCount;
|
||||
}
|
||||
|
||||
public static class FFTSettings {
|
||||
public long maxWidth;
|
||||
public long[] expandedRootsOfUnity;
|
||||
public long[] reverseRootsOfUnity;
|
||||
public long[] rootsOfUnity;
|
||||
|
||||
}
|
||||
public static native boolean verifyKzgProof(byte[] commitment, byte[] z, byte[] y, byte[] proof);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,20 +3,20 @@
|
|||
## Windows
|
||||
|
||||
```bat
|
||||
gcc -c -I..\..\blst\bindings -I..\..\src\ -I"%JAVA_HOME%\include" -I"%JAVA_HOME%\include\win32" c_kzg_4844_jni.c -o c_kzg_4844_jni.o
|
||||
gcc -shared -o lib/ckzg4844jni.dll c_kzg_4844.o c_kzg_4844_jni.o -Wl,--add-stdcall-alias
|
||||
g++ -c -I..\..\blst\bindings -I..\..\src\ -I"%JAVA_HOME%\include" -I"%JAVA_HOME%\include\win32" c_kzg_4844_jni.c -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
|
||||
```
|
||||
|
||||
## Linux
|
||||
|
||||
```bash
|
||||
gcc -c -fPIC -I../../blst/bindings -I../../src/ -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux c_kzg_4844_jni.c -o c_kzg_4844_jni.o
|
||||
gcc -shared -fPIC -o lib/libckzg4844jni.so c_kzg_4844.o c_kzg_4844_jni.o -lc
|
||||
g++ -c -fPIC -I../../blst/bindings -I../../src/ -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux c_kzg_4844_jni.c -o c_kzg_4844_jni.o
|
||||
g++ -shared -fPIC -o lib/libckzg4844jni.so c_kzg_4844.o c_kzg_4844_jni.o -lc
|
||||
```
|
||||
|
||||
## Mac-OS
|
||||
|
||||
```bash
|
||||
gcc -c -fPIC -I../../blst/bindings -I../../src/ -I${JAVA_HOME}/include -I${JAVA_HOME}/include/darwin c_kzg_4844_jni.c -o c_kzg_4844_jni.o
|
||||
gcc -dynamiclib -o lib/libckzg4844jni.dylib c_kzg_4844.o c_kzg_4844_jni.o -lc
|
||||
g++ -c -fPIC -I../../blst/bindings -I../../src/ -I${JAVA_HOME}/include -I${JAVA_HOME}/include/darwin c_kzg_4844_jni.c -o c_kzg_4844_jni.o
|
||||
g++ -dynamiclib -o lib/libckzg4844jni.dylib c_kzg_4844.o c_kzg_4844_jni.o -lc
|
||||
```
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
#include "c_kzg_4844_jni.h"
|
||||
#include "c_kzg_4844.h"
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_CKzg4844JNI_loadTrustedSetup(JNIEnv *env, jclass thisCls, jstring file)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_CKzg4844JNI_freeTrustedSetup(JNIEnv *env, jclass thisCls, jobject settings)
|
||||
{
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
JNIEXPORT jbyteArray JNICALL Java_CKzg4844JNI_computeAggregateKzgProof(JNIEnv *env, jclass thisCls, jbyteArray blobs, jint count, jobject settings)
|
||||
{
|
||||
jbyte *blobs_c = (*env)->GetByteArrayElements(env, blobs, NULL);
|
||||
jbyteArray proof = (*env)->NewByteArray(env, 48);
|
||||
g1_t *out;
|
||||
bytes_to_g1(out, (uint8_t *)blobs_c);
|
||||
return proof;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_CKzg4844JNI_verifyAggregateKzgProof(JNIEnv *env, jclass thisCls, jbyteArray blobs, jbyteArray commitments, jint count, jbyteArray proof, jobject settings)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
JNIEXPORT jbyteArray JNICALL Java_CKzg4844JNI_blobToKzgCommitment(JNIEnv *env, jclass thisCls, jbyteArray commitment, jobject settings)
|
||||
{
|
||||
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, jobject settings)
|
||||
{
|
||||
return false;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
#include "c_kzg_4844_jni.h"
|
||||
#include "c_kzg_4844.h"
|
||||
|
||||
KZGSettings *settings;
|
||||
|
||||
JNIEXPORT void JNICALL Java_CKzg4844JNI_loadTrustedSetup(JNIEnv *env, jclass thisCls, jstring file)
|
||||
{
|
||||
settings = malloc(sizeof(KZGSettings));
|
||||
|
||||
const char *file_native = env->GetStringUTFChars(file, 0);
|
||||
|
||||
FILE *f = fopen(file_native, "r");
|
||||
|
||||
if (f == NULL)
|
||||
{
|
||||
free(settings);
|
||||
env->ReleaseStringUTFChars(file, file_native);
|
||||
// need to throw an exception
|
||||
return;
|
||||
}
|
||||
|
||||
if (load_trusted_setup(settings, f) != C_KZG_OK)
|
||||
{
|
||||
free(settings);
|
||||
fclose(f);
|
||||
env->ReleaseStringUTFChars(file, file_native);
|
||||
// need to throw an exception
|
||||
return;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
env->ReleaseStringUTFChars(file, file_native);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_CKzg4844JNI_freeTrustedSetup(JNIEnv *env, jclass thisCls)
|
||||
{
|
||||
free_trusted_setup(settings);
|
||||
free(settings);
|
||||
}
|
||||
|
||||
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);
|
||||
return proof;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_CKzg4844JNI_verifyAggregateKzgProof(JNIEnv *env, jclass thisCls, jbyteArray blobs, jbyteArray commitments, jint count, jbyteArray proof)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
JNIEXPORT jbyteArray JNICALL Java_CKzg4844JNI_blobToKzgCommitment(JNIEnv *env, jclass thisCls, jbyteArray commitment)
|
||||
{
|
||||
jbyteArray ret = env->NewByteArray(48);
|
||||
return ret;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_CKzg4844JNI_verifyKzgProof(JNIEnv *env, jclass thisCls, jbyteArray commitment, jbyteArray z, jbyteArray y, jbyteArray proof)
|
||||
{
|
||||
return false;
|
||||
}
|
|
@ -10,50 +10,50 @@ extern "C" {
|
|||
/*
|
||||
* Class: CKzg4844JNI
|
||||
* Method: loadTrustedSetup
|
||||
* Signature: (Ljava/lang/String;)LCKzg4844JNI/KZGSettings;
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_CKzg4844JNI_loadTrustedSetup
|
||||
JNIEXPORT void JNICALL Java_CKzg4844JNI_loadTrustedSetup
|
||||
(JNIEnv *, jclass, jstring);
|
||||
|
||||
/*
|
||||
* Class: CKzg4844JNI
|
||||
* Method: freeTrustedSetup
|
||||
* Signature: (LCKzg4844JNI/KZGSettings;)V
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_CKzg4844JNI_freeTrustedSetup
|
||||
(JNIEnv *, jclass, jobject);
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: CKzg4844JNI
|
||||
* Method: computeAggregateKzgProof
|
||||
* Signature: ([BILCKzg4844JNI/KZGSettings;)[B
|
||||
* Signature: ([BI)[B
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL Java_CKzg4844JNI_computeAggregateKzgProof
|
||||
(JNIEnv *, jclass, jbyteArray, jint, jobject);
|
||||
(JNIEnv *, jclass, jbyteArray, jint);
|
||||
|
||||
/*
|
||||
* Class: CKzg4844JNI
|
||||
* Method: verifyAggregateKzgProof
|
||||
* Signature: ([B[BI[BLCKzg4844JNI/KZGSettings;)Z
|
||||
* Signature: ([B[BI[B)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_CKzg4844JNI_verifyAggregateKzgProof
|
||||
(JNIEnv *, jclass, jbyteArray, jbyteArray, jint, jbyteArray, jobject);
|
||||
(JNIEnv *, jclass, jbyteArray, jbyteArray, jint, jbyteArray);
|
||||
|
||||
/*
|
||||
* Class: CKzg4844JNI
|
||||
* Method: blobToKzgCommitment
|
||||
* Signature: ([BLCKzg4844JNI/KZGSettings;)[B
|
||||
* Signature: ([B)[B
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL Java_CKzg4844JNI_blobToKzgCommitment
|
||||
(JNIEnv *, jclass, jbyteArray, jobject);
|
||||
(JNIEnv *, jclass, jbyteArray);
|
||||
|
||||
/*
|
||||
* Class: CKzg4844JNI
|
||||
* Method: verifyKzgProof
|
||||
* Signature: ([B[B[B[BLCKzg4844JNI/KZGSettings;)Z
|
||||
* Signature: ([B[B[B[B)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_CKzg4844JNI_verifyKzgProof
|
||||
(JNIEnv *, jclass, jbyteArray, jbyteArray, jbyteArray, jbyteArray, jobject);
|
||||
(JNIEnv *, jclass, jbyteArray, jbyteArray, jbyteArray, jbyteArray);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue