mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-24 08:14:19 +01:00
Import secp256k1 (schnorr version)
Imported from: git@github.com:sipa/secp256k1.git schnorr3 (0ab0b47) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
23
secp256k1/src/java/org_bitcoin_NativeSecp256k1.c
Normal file
23
secp256k1/src/java/org_bitcoin_NativeSecp256k1.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "org_bitcoin_NativeSecp256k1.h"
|
||||
#include "include/secp256k1.h"
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1verify
|
||||
(JNIEnv* env, jclass classObject, jobject byteBufferObject)
|
||||
{
|
||||
unsigned char* data = (unsigned char*) (*env)->GetDirectBufferAddress(env, byteBufferObject);
|
||||
int sigLen = *((int*)(data + 32));
|
||||
int pubLen = *((int*)(data + 32 + 4));
|
||||
|
||||
return secp256k1_ecdsa_verify(data, 32, data+32+8, sigLen, data+32+8+sigLen, pubLen);
|
||||
}
|
||||
|
||||
static void __javasecp256k1_attach(void) __attribute__((constructor));
|
||||
static void __javasecp256k1_detach(void) __attribute__((destructor));
|
||||
|
||||
static void __javasecp256k1_attach(void) {
|
||||
secp256k1_start(SECP256K1_START_VERIFY);
|
||||
}
|
||||
|
||||
static void __javasecp256k1_detach(void) {
|
||||
secp256k1_stop();
|
||||
}
|
||||
Reference in New Issue
Block a user