diff --git a/src/group_impl.h b/src/group_impl.h index d52bba45d..29c765e4f 100644 --- a/src/group_impl.h +++ b/src/group_impl.h @@ -669,6 +669,36 @@ static int secp256k1_gej_has_quad_y_var(const secp256k1_gej *a) { return secp256k1_fe_is_quad_var(&yz); } +static void secp256k1_point_save(unsigned char *data, secp256k1_ge *ge) { + if (sizeof(secp256k1_ge_storage) == 64) { + secp256k1_ge_storage s; + secp256k1_ge_to_storage(&s, ge); + memcpy(data, &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(data, &ge->x); + secp256k1_fe_get_b32(data + 32, &ge->y); + } +} + +static void secp256k1_point_load(secp256k1_ge *ge, const unsigned char *data) { + if (sizeof(secp256k1_ge_storage) == 64) { + /* When the secp256k1_ge_storage type is exactly 64 byte, use its + * representation as conversion is very fast. */ + secp256k1_ge_storage s; + memcpy(&s, data, 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; + secp256k1_fe_set_b32(&x, data); + secp256k1_fe_set_b32(&y, data + 32); + secp256k1_ge_set_xy(ge, &x, &y); + } +} + static int secp256k1_ge_is_in_correct_subgroup(const secp256k1_ge* ge) { #ifdef EXHAUSTIVE_TEST_ORDER secp256k1_gej out; diff --git a/src/modules/frost/keygen_impl.h b/src/modules/frost/keygen_impl.h index c2e711ccd..a170addd4 100644 --- a/src/modules/frost/keygen_impl.h +++ b/src/modules/frost/keygen_impl.h @@ -8,6 +8,11 @@ #define SECP256K1_MODULE_FROST_KEYGEN_IMPL_H #include "keygen.h" +#include "../../ecmult.h" +#include "../../field.h" +#include "../../group.h" +#include "../../scalar.h" +#include "../../hash.h" /* Generate polynomial coefficients, coefficient commitments, and shares, from * a seed and a secret key. */ diff --git a/src/modules/frost/session_impl.h b/src/modules/frost/session_impl.h index c34c1a2e0..7078acd93 100644 --- a/src/modules/frost/session_impl.h +++ b/src/modules/frost/session_impl.h @@ -7,7 +7,16 @@ #ifndef SECP256K1_MODULE_FROST_SESSION_IMPL_H #define SECP256K1_MODULE_FROST_SESSION_IMPL_H +#include + #include "session.h" +#include "../../eckey.h" +#include "../../ecmult.h" +#include "../../field.h" +#include "../../group.h" +#include "../../hash.h" +#include "../../scalar.h" +#include "../../util.h" static const unsigned char secp256k1_frost_secnonce_magic[4] = { 0x84, 0x7d, 0x46, 0x25 }; diff --git a/src/modules/musig/keyagg_impl.h b/src/modules/musig/keyagg_impl.h index 33cdec2a9..181357c15 100644 --- a/src/modules/musig/keyagg_impl.h +++ b/src/modules/musig/keyagg_impl.h @@ -17,36 +17,6 @@ #include "../../hash.h" #include "../../util.h" -static void secp256k1_point_save(unsigned char *data, secp256k1_ge *ge) { - if (sizeof(secp256k1_ge_storage) == 64) { - secp256k1_ge_storage s; - secp256k1_ge_to_storage(&s, ge); - memcpy(data, &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(data, &ge->x); - secp256k1_fe_get_b32(data + 32, &ge->y); - } -} - -static void secp256k1_point_load(secp256k1_ge *ge, const unsigned char *data) { - if (sizeof(secp256k1_ge_storage) == 64) { - /* When the secp256k1_ge_storage type is exactly 64 byte, use its - * representation as conversion is very fast. */ - secp256k1_ge_storage s; - memcpy(&s, data, 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; - secp256k1_fe_set_b32(&x, data); - secp256k1_fe_set_b32(&y, data + 32); - secp256k1_ge_set_xy(ge, &x, &y); - } -} - static const unsigned char secp256k1_musig_keyagg_cache_magic[4] = { 0xf4, 0xad, 0xbb, 0xdf }; /* A keyagg cache consists of