11#include <stdlib.h>
2+ #include <stdint.h>
23#include <string.h>
34#include "org_bitcoin_NativeSecp256k1.h"
45#include "include/secp256k1.h"
1011SECP256K1_API jlong JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ctx_1clone
1112 (JNIEnv * env , jclass classObject , jlong ctx_l )
1213{
13- const secp256k1_context * ctx = (secp256k1_context * )ctx_l ;
14+ const secp256k1_context * ctx = (secp256k1_context * )( uintptr_t ) ctx_l ;
1415
15- jlong ctx_clone_l = (jlong ) secp256k1_context_clone (ctx );
16+ jlong ctx_clone_l = (uintptr_t ) secp256k1_context_clone (ctx );
1617
1718 (void )classObject ;(void )env ;
1819
19- return ( jlong ) ctx_clone_l ;
20+ return ctx_clone_l ;
2021
2122}
2223
2324SECP256K1_API jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1context_1randomize
2425 (JNIEnv * env , jclass classObject , jobject byteBufferObject , jlong ctx_l )
2526{
26- secp256k1_context * ctx = (secp256k1_context * )ctx_l ;
27+ secp256k1_context * ctx = (secp256k1_context * )( uintptr_t ) ctx_l ;
2728
2829 const unsigned char * seed = (unsigned char * ) (* env )-> GetDirectBufferAddress (env , byteBufferObject );
2930
@@ -36,7 +37,7 @@ SECP256K1_API jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1context_1
3637SECP256K1_API void JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1destroy_1context
3738 (JNIEnv * env , jclass classObject , jlong ctx_l )
3839{
39- secp256k1_context * ctx = (secp256k1_context * )ctx_l ;
40+ secp256k1_context * ctx = (secp256k1_context * )( uintptr_t ) ctx_l ;
4041
4142 secp256k1_context_destroy (ctx );
4243
@@ -46,7 +47,7 @@ SECP256K1_API void JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1destroy_1
4647SECP256K1_API jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1verify
4748 (JNIEnv * env , jclass classObject , jobject byteBufferObject , jlong ctx_l , jint siglen , jint publen )
4849{
49- secp256k1_context * ctx = (secp256k1_context * )ctx_l ;
50+ secp256k1_context * ctx = (secp256k1_context * )( uintptr_t ) ctx_l ;
5051
5152 int result ;
5253 unsigned char * data = (unsigned char * ) (* env )-> GetDirectBufferAddress (env , byteBufferObject );
@@ -72,7 +73,7 @@ SECP256K1_API jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1ve
7273SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1sign
7374 (JNIEnv * env , jclass classObject , jobject byteBufferObject , jlong ctx_l )
7475{
75- secp256k1_context * ctx = (secp256k1_context * )ctx_l ;
76+ secp256k1_context * ctx = (secp256k1_context * )( uintptr_t ) ctx_l ;
7677 unsigned char * data = (unsigned char * ) (* env )-> GetDirectBufferAddress (env , byteBufferObject );
7778 unsigned char * secKey = (unsigned char * ) (data + 32 );
7879
@@ -114,7 +115,7 @@ SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1e
114115SECP256K1_API jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ec_1seckey_1verify
115116 (JNIEnv * env , jclass classObject , jobject byteBufferObject , jlong ctx_l )
116117{
117- secp256k1_context * ctx = (secp256k1_context * )ctx_l ;
118+ secp256k1_context * ctx = (secp256k1_context * )( uintptr_t ) ctx_l ;
118119 unsigned char * secKey = (unsigned char * ) (* env )-> GetDirectBufferAddress (env , byteBufferObject );
119120
120121 (void )classObject ;
@@ -125,7 +126,7 @@ SECP256K1_API jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ec_1secke
125126SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ec_1pubkey_1create
126127 (JNIEnv * env , jclass classObject , jobject byteBufferObject , jlong ctx_l )
127128{
128- secp256k1_context * ctx = (secp256k1_context * )ctx_l ;
129+ secp256k1_context * ctx = (secp256k1_context * )( uintptr_t ) ctx_l ;
129130 const unsigned char * secKey = (unsigned char * ) (* env )-> GetDirectBufferAddress (env , byteBufferObject );
130131
131132 secp256k1_pubkey pubkey ;
@@ -167,7 +168,7 @@ SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1e
167168SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1privkey_1tweak_1add
168169 (JNIEnv * env , jclass classObject , jobject byteBufferObject , jlong ctx_l )
169170{
170- secp256k1_context * ctx = (secp256k1_context * )ctx_l ;
171+ secp256k1_context * ctx = (secp256k1_context * )( uintptr_t ) ctx_l ;
171172 unsigned char * privkey = (unsigned char * ) (* env )-> GetDirectBufferAddress (env , byteBufferObject );
172173 const unsigned char * tweak = (unsigned char * ) (privkey + 32 );
173174
@@ -202,7 +203,7 @@ SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1p
202203SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1privkey_1tweak_1mul
203204 (JNIEnv * env , jclass classObject , jobject byteBufferObject , jlong ctx_l )
204205{
205- secp256k1_context * ctx = (secp256k1_context * )ctx_l ;
206+ secp256k1_context * ctx = (secp256k1_context * )( uintptr_t ) ctx_l ;
206207 unsigned char * privkey = (unsigned char * ) (* env )-> GetDirectBufferAddress (env , byteBufferObject );
207208 const unsigned char * tweak = (unsigned char * ) (privkey + 32 );
208209
@@ -237,7 +238,7 @@ SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1p
237238SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1pubkey_1tweak_1add
238239 (JNIEnv * env , jclass classObject , jobject byteBufferObject , jlong ctx_l , jint publen )
239240{
240- secp256k1_context * ctx = (secp256k1_context * )ctx_l ;
241+ secp256k1_context * ctx = (secp256k1_context * )( uintptr_t ) ctx_l ;
241242/* secp256k1_pubkey* pubkey = (secp256k1_pubkey*) (*env)->GetDirectBufferAddress(env, byteBufferObject);*/
242243 unsigned char * pkey = (* env )-> GetDirectBufferAddress (env , byteBufferObject );
243244 const unsigned char * tweak = (unsigned char * ) (pkey + publen );
@@ -282,7 +283,7 @@ SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1p
282283SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1pubkey_1tweak_1mul
283284 (JNIEnv * env , jclass classObject , jobject byteBufferObject , jlong ctx_l , jint publen )
284285{
285- secp256k1_context * ctx = (secp256k1_context * )ctx_l ;
286+ secp256k1_context * ctx = (secp256k1_context * )( uintptr_t ) ctx_l ;
286287 unsigned char * pkey = (* env )-> GetDirectBufferAddress (env , byteBufferObject );
287288 const unsigned char * tweak = (unsigned char * ) (pkey + publen );
288289
@@ -334,7 +335,7 @@ SECP256K1_API jlong JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1p
334335SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1schnorr_1sign
335336 (JNIEnv * env , jclass classObject , jobject byteBufferObject , jlong ctx_l )
336337{
337- secp256k1_context * ctx = (secp256k1_context * )ctx_l ;
338+ secp256k1_context * ctx = (secp256k1_context * )( uintptr_t ) ctx_l ;
338339 unsigned char * data = (unsigned char * ) (* env )-> GetDirectBufferAddress (env , byteBufferObject );
339340 unsigned char * secKey = (unsigned char * ) (data + 32 );
340341
@@ -367,7 +368,7 @@ SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1s
367368SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdh
368369 (JNIEnv * env , jclass classObject , jobject byteBufferObject , jlong ctx_l , jint publen )
369370{
370- secp256k1_context * ctx = (secp256k1_context * )ctx_l ;
371+ secp256k1_context * ctx = (secp256k1_context * )( uintptr_t ) ctx_l ;
371372 const unsigned char * secdata = (* env )-> GetDirectBufferAddress (env , byteBufferObject );
372373 const unsigned char * pubdata = (const unsigned char * ) (secdata + 32 );
373374
0 commit comments