void ecc_start(void) { secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); assert(secp256k1_ctx != NULL); uint8_t seed[32]; random_bytes(seed, 32, 0); int ret = secp256k1_context_randomize(secp256k1_ctx, seed); assert(ret); }
SECP256K1_API jint JNICALL Java_org_commercium_NativeSecp256k1_secp256k1_1context_1randomize (JNIEnv* env, jclass classObject, jobject byteBufferObject, jlong ctx_l) { secp256k1_context *ctx = (secp256k1_context*)(uintptr_t)ctx_l; const unsigned char* seed = (unsigned char*) (*env)->GetDirectBufferAddress(env, byteBufferObject); (void)classObject; return secp256k1_context_randomize(ctx, seed); }
secp256k1_context *get_secp256k1_context() { if (!s_context) { secp256k1_context *ctx = secp256k1_context_create( SECP256K1_CONTEXT_VERIFY | SECP256K1_CONTEXT_SIGN); if (!ctx) { return NULL; } uint8_t seed[32]; if (!RAND_bytes(seed, sizeof(seed)) || !secp256k1_context_randomize(ctx, seed)) { secp256k1_context_destroy(ctx); return NULL; } s_context = ctx; } return s_context; }