Merge commits 'b314cf28 1f1bb78b 40f50d0f c891c5c2 ea47c82e e7210393 c1b49664 5814d848 07687e81 10e6d29b d3e29db8 e2c9888e 4197d667 5e9a4d7a 77af1da9 1a81df82 1ad5185c efe85c70 79e09451 d373bf6d 74b7c3b5 a9db9f2d 44378867 3bf4d68f e4af41c6 ' into temp-merge-1249
This commit is contained in:
@@ -258,36 +258,25 @@ static SECP256K1_INLINE void secp256k1_declassify(const secp256k1_context* ctx,
|
||||
}
|
||||
|
||||
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], sizeof(s));
|
||||
secp256k1_ge_from_storage(ge, &s);
|
||||
} else {
|
||||
/* Otherwise, fall back to 32-byte big endian for X and Y. */
|
||||
secp256k1_fe x, y;
|
||||
ARG_CHECK(secp256k1_fe_set_b32_limit(&x, pubkey->data));
|
||||
ARG_CHECK(secp256k1_fe_set_b32_limit(&y, pubkey->data + 32));
|
||||
secp256k1_ge_set_xy(ge, &x, &y);
|
||||
}
|
||||
secp256k1_ge_storage s;
|
||||
|
||||
/* We require that the secp256k1_ge_storage type is exactly 64 bytes.
|
||||
* This is formally not guaranteed by the C standard, but should hold on any
|
||||
* sane compiler in the real world. */
|
||||
STATIC_ASSERT(sizeof(secp256k1_ge_storage) == 64);
|
||||
memcpy(&s, &pubkey->data[0], 64);
|
||||
secp256k1_ge_from_storage(ge, &s);
|
||||
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, sizeof(s));
|
||||
} 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);
|
||||
}
|
||||
secp256k1_ge_storage s;
|
||||
|
||||
STATIC_ASSERT(sizeof(secp256k1_ge_storage) == 64);
|
||||
VERIFY_CHECK(!secp256k1_ge_is_infinity(ge));
|
||||
secp256k1_ge_to_storage(&s, ge);
|
||||
memcpy(&pubkey->data[0], &s, 64);
|
||||
}
|
||||
|
||||
int secp256k1_ec_pubkey_parse(const secp256k1_context* ctx, secp256k1_pubkey* pubkey, const unsigned char *input, size_t inputlen) {
|
||||
@@ -855,8 +844,12 @@ static void secp256k1_ge_serialize_ext(unsigned char *out33, secp256k1_ge* ge) {
|
||||
int ret;
|
||||
size_t size = 33;
|
||||
ret = secp256k1_eckey_pubkey_serialize(ge, out33, &size, 1);
|
||||
#ifdef VERIFY
|
||||
/* Serialize must succeed because the point is not at infinity */
|
||||
VERIFY_CHECK(ret && size == 33);
|
||||
#else
|
||||
(void) ret;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user