7#ifndef SECP256K1_MODULE_EXTRAKEYS_MAIN_H
8#define SECP256K1_MODULE_EXTRAKEYS_MAIN_H
28 memset(pubkey, 0,
sizeof(*pubkey));
34 if (!secp256k1_ge_set_xo_var(&pk, &x, 0)) {
49 memset(output32, 0, 32);
60 unsigned char out[2][32];
65 pk[0] = pk0; pk[1] = pk1;
66 for (i = 0; i < 2; i++) {
79 memset(out[i], 0,
sizeof(out[i]));
107 if (!secp256k1_pubkey_load(ctx, &pk, pubkey)) {
111 if (pk_parity != NULL) {
123 memset(output_pubkey, 0,
sizeof(*output_pubkey));
128 || !secp256k1_ec_pubkey_tweak_add_helper(&pk, tweak32)) {
131 secp256k1_pubkey_save(output_pubkey, &pk);
137 unsigned char pk_expected32[32];
145 || !secp256k1_ec_pubkey_tweak_add_helper(&pk, tweak32)) {
157 secp256k1_scalar_get_b32(&keypair->
data[0], sk);
165 ret = secp256k1_scalar_set_b32_seckey(sk, &keypair->
data[0]);
168 secp256k1_declassify(ctx, &
ret,
sizeof(
ret));
182 secp256k1_declassify(ctx, pubkey,
sizeof(*pubkey));
183 ret = secp256k1_pubkey_load(ctx, pk, pubkey);
188 *pk = secp256k1_ge_const_g;
190 *sk = secp256k1_scalar_one;
202 memset(keypair, 0,
sizeof(*keypair));
206 ret = secp256k1_ec_pubkey_create_helper(&ctx->
ecmult_gen_ctx, &sk, &pk, seckey32);
210 secp256k1_scalar_clear(&sk);
217 memset(seckey, 0, 32);
220 memcpy(seckey, &keypair->
data[0], 32);
227 memset(pubkey, 0,
sizeof(*pubkey));
230 memcpy(pubkey->
data, &keypair->
data[32],
sizeof(*pubkey));
240 memset(pubkey, 0,
sizeof(*pubkey));
247 if (pk_parity != NULL) {
266 memset(keypair, 0,
sizeof(*keypair));
270 secp256k1_scalar_negate(&sk, &sk);
273 ret &= secp256k1_ec_seckey_tweak_add_helper(&sk, tweak32);
274 ret &= secp256k1_ec_pubkey_tweak_add_helper(&pk, tweak32);
276 secp256k1_declassify(ctx, &
ret,
sizeof(
ret));
281 secp256k1_scalar_clear(&sk);
static int secp256k1_ecmult_gen_context_is_built(const secp256k1_ecmult_gen_context *ctx)
static int secp256k1_keypair_load(const secp256k1_context *ctx, secp256k1_scalar *sk, secp256k1_ge *pk, const secp256k1_keypair *keypair)
static void secp256k1_keypair_save(secp256k1_keypair *keypair, const secp256k1_scalar *sk, secp256k1_ge *pk)
static int secp256k1_keypair_seckey_load(const secp256k1_context *ctx, secp256k1_scalar *sk, const secp256k1_keypair *keypair)
static SECP256K1_INLINE void secp256k1_xonly_pubkey_save(secp256k1_xonly_pubkey *pubkey, secp256k1_ge *ge)
static SECP256K1_INLINE int secp256k1_xonly_pubkey_load(const secp256k1_context *ctx, secp256k1_ge *ge, const secp256k1_xonly_pubkey *pubkey)
static int secp256k1_extrakeys_ge_even_y(secp256k1_ge *r)
Keeps a group element as is if it has an even Y and otherwise negates it.
#define secp256k1_fe_negate(r, a, m)
Negate a field element.
#define secp256k1_fe_is_odd
#define secp256k1_fe_normalize_var
#define secp256k1_fe_set_b32_limit
#define secp256k1_fe_get_b32
static int secp256k1_ge_is_in_correct_subgroup(const secp256k1_ge *ge)
Determine if a point (which is assumed to be on the curve) is in the correct (sub)group of the curve.
static SECP256K1_INLINE int secp256k1_memcmp_var(const void *s1, const void *s2, size_t n)
Semantics like memcmp.
#define VERIFY_CHECK(cond)
static SECP256K1_INLINE void secp256k1_memczero(void *s, size_t len, int flag)
struct secp256k1_context_struct secp256k1_context
Unless explicitly stated all pointer arguments must not be NULL.
secp256k1_ecmult_gen_context ecmult_gen_ctx
This field implementation represents the value as 10 uint32_t limbs in base 2^26.
A group element in affine coordinates on the secp256k1 curve, or occasionally on an isomorphic curve ...
Opaque data structure that holds a keypair consisting of a secret and a public key.
Opaque data structure that holds a parsed and valid public key.
A scalar modulo the group order of the secp256k1 curve.
Opaque data structure that holds a parsed and valid "x-only" public key.