Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/src/secp256k1.c
Show All 11 Lines | |||||
#include "scalar_impl.h" | #include "scalar_impl.h" | ||||
#include "group_impl.h" | #include "group_impl.h" | ||||
#include "ecmult_impl.h" | #include "ecmult_impl.h" | ||||
#include "ecmult_const_impl.h" | #include "ecmult_const_impl.h" | ||||
#include "ecmult_gen_impl.h" | #include "ecmult_gen_impl.h" | ||||
#include "ecdsa_impl.h" | #include "ecdsa_impl.h" | ||||
#include "eckey_impl.h" | #include "eckey_impl.h" | ||||
#include "hash_impl.h" | #include "hash_impl.h" | ||||
#include "scratch_impl.h" | |||||
#define ARG_CHECK(cond) do { \ | #define ARG_CHECK(cond) do { \ | ||||
if (EXPECT(!(cond), 0)) { \ | if (EXPECT(!(cond), 0)) { \ | ||||
secp256k1_callback_call(&ctx->illegal_callback, #cond); \ | secp256k1_callback_call(&ctx->illegal_callback, #cond); \ | ||||
return 0; \ | return 0; \ | ||||
} \ | } \ | ||||
} while(0) | } while(0) | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) { | void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) { | ||||
if (fun == NULL) { | if (fun == NULL) { | ||||
fun = default_error_callback_fn; | fun = default_error_callback_fn; | ||||
} | } | ||||
ctx->error_callback.fn = fun; | ctx->error_callback.fn = fun; | ||||
ctx->error_callback.data = data; | ctx->error_callback.data = data; | ||||
} | } | ||||
secp256k1_scratch_space* secp256k1_scratch_space_create(const secp256k1_context* ctx, size_t init_size, size_t max_size) { | |||||
VERIFY_CHECK(ctx != NULL); | |||||
ARG_CHECK(max_size >= init_size); | |||||
return secp256k1_scratch_create(&ctx->error_callback, init_size, max_size); | |||||
} | |||||
void secp256k1_scratch_space_destroy(secp256k1_scratch_space* scratch) { | |||||
secp256k1_scratch_destroy(scratch); | |||||
} | |||||
static int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { | static int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { | ||||
if (sizeof(secp256k1_ge_storage) == 64) { | if (sizeof(secp256k1_ge_storage) == 64) { | ||||
/* When the secp256k1_ge_storage type is exactly 64 byte, use its | /* When the secp256k1_ge_storage type is exactly 64 byte, use its | ||||
* representation inside secp256k1_pubkey, as conversion is very fast. | * representation inside secp256k1_pubkey, as conversion is very fast. | ||||
* Note that secp256k1_pubkey_save must use the same representation. */ | * Note that secp256k1_pubkey_save must use the same representation. */ | ||||
secp256k1_ge_storage s; | secp256k1_ge_storage s; | ||||
memcpy(&s, &pubkey->data[0], sizeof(s)); | memcpy(&s, &pubkey->data[0], sizeof(s)); | ||||
secp256k1_ge_from_storage(ge, &s); | secp256k1_ge_from_storage(ge, &s); | ||||
▲ Show 20 Lines • Show All 472 Lines • Show Last 20 Lines |