Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/include/secp256k1_extrakeys.h
Show All 17 Lines | |||||
* 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_xonly_pubkey_serialize and | * comparison, use secp256k1_xonly_pubkey_serialize and | ||||
* secp256k1_xonly_pubkey_parse. | * secp256k1_xonly_pubkey_parse. | ||||
*/ | */ | ||||
typedef struct { | typedef struct { | ||||
unsigned char data[64]; | unsigned char data[64]; | ||||
} secp256k1_xonly_pubkey; | } secp256k1_xonly_pubkey; | ||||
/** Opaque data structure that holds a keypair consisting of a secret and a | |||||
* public key. | |||||
* | |||||
* The exact representation of data inside is implementation defined and not | |||||
* guaranteed to be portable between different platforms or versions. It is | |||||
* however guaranteed to be 96 bytes in size, and can be safely copied/moved. | |||||
*/ | |||||
typedef struct { | |||||
unsigned char data[96]; | |||||
} secp256k1_keypair; | |||||
/** Parse a 32-byte sequence into a xonly_pubkey object. | /** Parse a 32-byte sequence into a xonly_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 (cannot be NULL). | * Args: ctx: a secp256k1 context object (cannot be NULL). | ||||
* 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, it's set to an invalid value. | * parsed version of input. If not, it's set to an invalid value. | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | |||||
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_xonly_pubkey_tweak_add_check( | SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_xonly_pubkey_tweak_add_check( | ||||
const secp256k1_context* ctx, | const secp256k1_context* ctx, | ||||
const unsigned char *tweaked_pubkey32, | const unsigned char *tweaked_pubkey32, | ||||
int tweaked_pk_parity, | int tweaked_pk_parity, | ||||
const secp256k1_xonly_pubkey *internal_pubkey, | const secp256k1_xonly_pubkey *internal_pubkey, | ||||
const unsigned char *tweak32 | const unsigned char *tweak32 | ||||
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5); | ) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5); | ||||
/** Compute the keypair for a secret key. | |||||
* | |||||
* Returns: 1: secret was valid, keypair is ready to use | |||||
* 0: secret was invalid, try again with a different secret | |||||
* Args: ctx: pointer to a context object, initialized for signing (cannot be NULL) | |||||
* Out: keypair: pointer to the created keypair (cannot be NULL) | |||||
* In: seckey: pointer to a 32-byte secret key (cannot be NULL) | |||||
*/ | |||||
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_keypair_create( | |||||
const secp256k1_context* ctx, | |||||
secp256k1_keypair *keypair, | |||||
const unsigned char *seckey | |||||
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); | |||||
/** Get the public key from a keypair. | |||||
* | |||||
* Returns: 0 if the arguments are invalid. 1 otherwise. | |||||
* Args: ctx: pointer to a context object (cannot be NULL) | |||||
* Out: pubkey: pointer to a pubkey object. If 1 is returned, it is set to | |||||
* the keypair public key. If not, it's set to an invalid value. | |||||
* (cannot be NULL) | |||||
* In: keypair: pointer to a keypair (cannot be NULL) | |||||
*/ | |||||
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_keypair_pub( | |||||
const secp256k1_context* ctx, | |||||
secp256k1_pubkey *pubkey, | |||||
const secp256k1_keypair *keypair | |||||
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); | |||||
/** Get the x-only public key from a keypair. | |||||
* | |||||
* This is the same as calling secp256k1_keypair_pub and then | |||||
* secp256k1_xonly_pubkey_from_pubkey. | |||||
* | |||||
* Returns: 0 if the arguments are invalid. 1 otherwise. | |||||
* Args: ctx: pointer to a context object (cannot be NULL) | |||||
* Out: pubkey: pointer to an xonly_pubkey object. If 1 is returned, it is set | |||||
* to the keypair public key after converting it to an | |||||
* xonly_pubkey. If not, it's set to an invalid value (cannot be | |||||
* NULL). | |||||
* pk_parity: pointer to an integer that will be set to the pk_parity | |||||
* argument of secp256k1_xonly_pubkey_from_pubkey (can be NULL). | |||||
* In: keypair: pointer to a keypair (cannot be NULL) | |||||
*/ | |||||
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_keypair_xonly_pub( | |||||
const secp256k1_context* ctx, | |||||
secp256k1_xonly_pubkey *pubkey, | |||||
int *pk_parity, | |||||
const secp256k1_keypair *keypair | |||||
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(4); | |||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
} | } | ||||
#endif | #endif | ||||
#endif /* SECP256K1_EXTRAKEYS_H */ | #endif /* SECP256K1_EXTRAKEYS_H */ |