7#ifndef SECP256K1_MODULE_EXTRAKEYS_MAIN_H
8#define SECP256K1_MODULE_EXTRAKEYS_MAIN_H
35 memset(pubkey, 0,
sizeof(*pubkey));
41 if (!secp256k1_ge_set_xo_var(&pk, &x, 0)) {
56 memset(output32, 0, 32);
67 unsigned char out[2][32];
72 pk[0] = pk0; pk[1] = pk1;
73 for (i = 0; i < 2; i++) {
86 memset(out[i], 0,
sizeof(out[i]));
114 if (!secp256k1_pubkey_load(ctx, &pk, pubkey)) {
118 if (pk_parity != NULL) {
130 memset(output_pubkey, 0,
sizeof(*output_pubkey));
135 || !secp256k1_ec_pubkey_tweak_add_helper(&pk, tweak32)) {
138 secp256k1_pubkey_save(output_pubkey, &pk);
144 unsigned char pk_expected32[32];
152 || !secp256k1_ec_pubkey_tweak_add_helper(&pk, tweak32)) {
164 secp256k1_scalar_get_b32(&keypair->
data[0], sk);
172 ret = secp256k1_scalar_set_b32_seckey(sk, &keypair->
data[0]);
175 secp256k1_declassify(ctx, &
ret,
sizeof(
ret));
189 secp256k1_declassify(ctx, pubkey,
sizeof(*pubkey));
190 ret = secp256k1_pubkey_load(ctx, pk, pubkey);
195 *pk = secp256k1_ge_const_g;
197 *sk = secp256k1_scalar_one;
209 memset(keypair, 0,
sizeof(*keypair));
213 ret = secp256k1_ec_pubkey_create_helper(&ctx->
ecmult_gen_ctx, &sk, &pk, seckey32);
217 secp256k1_scalar_clear(&sk);
224 memset(seckey, 0, 32);
227 memcpy(seckey, &keypair->
data[0], 32);
234 memset(pubkey, 0,
sizeof(*pubkey));
237 memcpy(pubkey->
data, &keypair->
data[32],
sizeof(*pubkey));
247 memset(pubkey, 0,
sizeof(*pubkey));
254 if (pk_parity != NULL) {
273 memset(keypair, 0,
sizeof(*keypair));
277 secp256k1_scalar_negate(&sk, &sk);
280 ret &= secp256k1_ec_seckey_tweak_add_helper(&sk, tweak32);
281 ret &= secp256k1_ec_pubkey_tweak_add_helper(&pk, tweak32);
283 secp256k1_declassify(ctx, &
ret,
sizeof(
ret));
288 secp256k1_scalar_clear(&sk);
static int secp256k1_ecmult_gen_context_is_built(const secp256k1_ecmult_gen_context *ecmult_gen_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.
struct secp256k1_context_struct secp256k1_context
Unless explicitly stated all pointer arguments must not be NULL.
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)
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.