mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
feat(secp256k1 JNI): improve context management, error handling, and portability
This commit is contained in:
parent
fb2f47a2a0
commit
dc062db153
1 changed files with 15 additions and 3 deletions
|
|
@ -8,8 +8,20 @@ SECP256K1_API jlong JNICALL Java_org_bitcoin_Secp256k1Context_secp256k1_1init_1c
|
|||
{
|
||||
secp256k1_context *ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
|
||||
|
||||
(void)classObject;(void)env;
|
||||
if (ctx == NULL) {
|
||||
(*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"), "Failed to initialize secp256k1 context");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (uintptr_t)ctx;
|
||||
(void)classObject; (void)env;
|
||||
return (jlong)(intptr_t)ctx;
|
||||
}
|
||||
|
||||
SECP256K1_API void JNICALL Java_org_bitcoin_Secp256k1Context_secp256k1_1destroy_1context
|
||||
(JNIEnv* env, jclass classObject, jlong ctx_l)
|
||||
{
|
||||
secp256k1_context *ctx = (secp256k1_context*) (intptr_t) ctx_l;
|
||||
secp256k1_context_destroy(ctx);
|
||||
|
||||
(void)classObject; (void)env;
|
||||
}
|
||||
Loading…
Reference in a new issue