|
|
@ -585,39 +585,6 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey * |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
static int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { |
|
|
|
if (sizeof(secp256k1_ge_storage) == 64) { |
|
|
|
/* When the secp256k1_ge_storage type is exactly 64 byte, use its
|
|
|
|
* representation inside secp256k1_pubkey, as conversion is very fast. |
|
|
|
* Note that secp256k1_pubkey_save must use the same representation. */ |
|
|
|
secp256k1_ge_storage s; |
|
|
|
memcpy(&s, &pubkey->data[0], 64); |
|
|
|
secp256k1_ge_from_storage(ge, &s); |
|
|
|
} else { |
|
|
|
/* Otherwise, fall back to 32-byte big endian for X and Y. */ |
|
|
|
secp256k1_fe x, y; |
|
|
|
secp256k1_fe_set_b32(&x, pubkey->data); |
|
|
|
secp256k1_fe_set_b32(&y, pubkey->data + 32); |
|
|
|
secp256k1_ge_set_xy(ge, &x, &y); |
|
|
|
} |
|
|
|
ARG_CHECK(!secp256k1_fe_is_zero(&ge->x)); |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
static void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge) { |
|
|
|
if (sizeof(secp256k1_ge_storage) == 64) { |
|
|
|
secp256k1_ge_storage s; |
|
|
|
secp256k1_ge_to_storage(&s, ge); |
|
|
|
memcpy(&pubkey->data[0], &s, 64); |
|
|
|
} else { |
|
|
|
VERIFY_CHECK(!secp256k1_ge_is_infinity(ge)); |
|
|
|
secp256k1_fe_normalize_var(&ge->x); |
|
|
|
secp256k1_fe_normalize_var(&ge->y); |
|
|
|
secp256k1_fe_get_b32(pubkey->data, &ge->x); |
|
|
|
secp256k1_fe_get_b32(pubkey->data + 32, &ge->y); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#ifdef ENABLE_MODULE_SCHNORR |
|
|
|
# include "modules/schnorr/main_impl.h" |
|
|
|
#endif |
|
|
|