Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/include/secp256k1.h
Show All 36 Lines | |||||
* need exclusive access to it. In particular this is the case for | * need exclusive access to it. In particular this is the case for | ||||
* secp256k1_context_destroy and secp256k1_context_randomize. | * secp256k1_context_destroy and secp256k1_context_randomize. | ||||
* | * | ||||
* Regarding randomization, either do it once at creation time (in which case | * Regarding randomization, either do it once at creation time (in which case | ||||
* you do not need any locking for the other calls), or use a read-write lock. | * you do not need any locking for the other calls), or use a read-write lock. | ||||
*/ | */ | ||||
typedef struct secp256k1_context_struct secp256k1_context; | typedef struct secp256k1_context_struct secp256k1_context; | ||||
/** Opaque data structure that holds rewriteable "scratch space" | |||||
* | |||||
* The purpose of this structure is to replace dynamic memory allocations, | |||||
* because we target architectures where this may not be available. It is | |||||
* essentially a resizable (within specified parameters) block of bytes, | |||||
* which is initially created either by memory allocation or TODO as a pointer | |||||
* into some fixed rewritable space. | |||||
* | |||||
* Unlike the context object, this cannot safely be shared between threads | |||||
* without additional synchronization logic. | |||||
*/ | |||||
typedef struct secp256k1_scratch_space_struct secp256k1_scratch_space; | |||||
/** Opaque data structure that holds a parsed and valid public key. | /** Opaque data structure that holds a parsed and valid public key. | ||||
* | * | ||||
* The exact representation of data inside is implementation defined and not | * The exact representation of data inside is implementation defined and not | ||||
* guaranteed to be portable between different platforms or versions. It is | * guaranteed to be portable between different platforms or versions. It is | ||||
* however guaranteed to be 64 bytes in size, and can be safely copied/moved. | * however guaranteed to be 64 bytes in size, and can be safely copied/moved. | ||||
* If you need to convert to a format suitable for storage, transmission, or | * If you need to convert to a format suitable for storage, transmission, or | ||||
* comparison, use secp256k1_ec_pubkey_serialize and secp256k1_ec_pubkey_parse. | * comparison, use secp256k1_ec_pubkey_serialize and secp256k1_ec_pubkey_parse. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | |||||
* data: the opaque pointer to pass to fun above. | * data: the opaque pointer to pass to fun above. | ||||
*/ | */ | ||||
SECP256K1_API void secp256k1_context_set_error_callback( | SECP256K1_API void secp256k1_context_set_error_callback( | ||||
secp256k1_context* ctx, | secp256k1_context* ctx, | ||||
void (*fun)(const char* message, void* data), | void (*fun)(const char* message, void* data), | ||||
const void* data | const void* data | ||||
) SECP256K1_ARG_NONNULL(1); | ) SECP256K1_ARG_NONNULL(1); | ||||
/** Create a secp256k1 scratch space object. | |||||
* | |||||
* Returns: a newly created scratch space. | |||||
* Args: ctx: an existing context object (cannot be NULL) | |||||
* In: init_size: initial amount of memory to allocate | |||||
* max_size: maximum amount of memory to allocate | |||||
*/ | |||||
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT secp256k1_scratch_space* secp256k1_scratch_space_create( | |||||
const secp256k1_context* ctx, | |||||
size_t init_size, | |||||
size_t max_size | |||||
) SECP256K1_ARG_NONNULL(1); | |||||
/** Destroy a secp256k1 scratch space. | |||||
* | |||||
* The pointer may not be used afterwards. | |||||
* Args: scratch: space to destroy | |||||
*/ | |||||
SECP256K1_API void secp256k1_scratch_space_destroy( | |||||
secp256k1_scratch_space* scratch | |||||
); | |||||
/** Parse a variable-length public key into the pubkey object. | /** Parse a variable-length public key into the pubkey object. | ||||
* | * | ||||
* Returns: 1 if the public key was fully valid. | * Returns: 1 if the public key was fully valid. | ||||
* 0 if the public key could not be parsed or is invalid. | * 0 if the public key could not be parsed or is invalid. | ||||
* Args: ctx: a secp256k1 context object. | * Args: ctx: a secp256k1 context object. | ||||
* Out: pubkey: pointer to a pubkey object. If 1 is returned, it is set to a | * Out: pubkey: pointer to a pubkey object. If 1 is returned, it is set to a | ||||
* parsed version of input. If not, its value is undefined. | * parsed version of input. If not, its value is undefined. | ||||
* In: input: pointer to a serialized public key | * In: input: pointer to a serialized public key | ||||
▲ Show 20 Lines • Show All 368 Lines • Show Last 20 Lines |