7#ifndef SECP256K1_ECMULT_GEN_IMPL_H
8#define SECP256K1_ECMULT_GEN_IMPL_H
41 secp256k1_scalar_half(&neghalf, &secp256k1_scalar_one);
42 secp256k1_scalar_negate(&neghalf, &neghalf);
45 *diff = secp256k1_scalar_one;
47 secp256k1_scalar_add(diff, diff, diff);
51 secp256k1_scalar_add(diff, diff, &neghalf);
63 uint32_t recoded[(
COMB_BITS + 31) >> 5] = {0};
66 memset(&adds, 0,
sizeof(adds));
112 for (i = 0; i < 8 && i < ((
COMB_BITS + 31) >> 5); ++i) {
113 recoded[i] = secp256k1_scalar_get_bits_limb32(&d, 32 * i, 32);
115 secp256k1_scalar_clear(&d);
195 uint32_t bit_pos = comb_off;
200 uint32_t bits = 0,
sign, abs, index, tooth;
209 for (tooth = 0; tooth <
COMB_TEETH; ++tooth) {
222 uint32_t
volatile vmask = ~(1 << tooth);
226 bits ^= bitdata << tooth;
252 secp256k1_ge_from_storage(&add, &adds);
259 secp256k1_gej_set_ge(r, &add);
264 secp256k1_gej_add_ge(r, r, &add);
269 if (comb_off-- == 0)
break;
270 secp256k1_gej_double(r, r);
275 secp256k1_gej_add_ge(r, r, &ctx->
ge_offset);
278 secp256k1_fe_clear(&neg);
279 secp256k1_ge_clear(&add);
290 unsigned char nonce32[32];
292 unsigned char keydata[64];
297 if (seed32 == NULL) {
299 secp256k1_ge_neg(&ctx->
ge_offset, &secp256k1_ge_const_g);
300 secp256k1_scalar_add(&ctx->
scalar_offset, &secp256k1_scalar_one, &diff);
311 memcpy(keydata + 32, seed32, 32);
323 secp256k1_scalar_set_b32(&b, nonce32, NULL);
326 secp256k1_scalar_cmov(&b, &secp256k1_scalar_one, secp256k1_scalar_is_zero(&b));
329 secp256k1_scalar_negate(&b, &b);
331 secp256k1_ge_set_gej(&ctx->
ge_offset, &gb);
335 secp256k1_scalar_clear(&b);
336 secp256k1_gej_clear(&gb);
337 secp256k1_fe_clear(&f);
static void secp256k1_ecmult_gen_context_clear(secp256k1_ecmult_gen_context *ctx)
static void secp256k1_ecmult_gen_context_build(secp256k1_ecmult_gen_context *ctx)
static void secp256k1_ecmult_gen_blind(secp256k1_ecmult_gen_context *ctx, const unsigned char *seed32)
static void secp256k1_ecmult_gen(const secp256k1_ecmult_gen_context *ctx, secp256k1_gej *r, const secp256k1_scalar *gn)
static int secp256k1_ecmult_gen_context_is_built(const secp256k1_ecmult_gen_context *ctx)
static void secp256k1_ecmult_gen_scalar_diff(secp256k1_scalar *diff)
#define secp256k1_fe_cmov
#define secp256k1_fe_negate(r, a, m)
Negate a field element.
#define secp256k1_fe_set_b32_mod
#define secp256k1_fe_normalizes_to_zero
static int sign(const secp256k1_context *ctx, struct signer_secrets *signer_secrets, struct signer *signer, const secp256k1_musig_keyagg_cache *cache, const unsigned char *msg32, unsigned char *sig64)
const secp256k1_ge_storage secp256k1_ecmult_gen_prec_table[COMB_BLOCKS][COMB_POINTS]
static void secp256k1_rfc6979_hmac_sha256_generate(secp256k1_rfc6979_hmac_sha256 *rng, unsigned char *out, size_t outlen)
static void secp256k1_rfc6979_hmac_sha256_clear(secp256k1_rfc6979_hmac_sha256 *rng)
static void secp256k1_rfc6979_hmac_sha256_initialize(secp256k1_rfc6979_hmac_sha256 *rng, const unsigned char *key, size_t keylen)
static void secp256k1_rfc6979_hmac_sha256_finalize(secp256k1_rfc6979_hmac_sha256 *rng)
static SECP256K1_INLINE void secp256k1_memclear_explicit(void *ptr, size_t len)
static SECP256K1_INLINE uint32_t secp256k1_rotr32(const uint32_t x, const unsigned int by)
#define VERIFY_CHECK(cond)
secp256k1_scalar scalar_offset
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 ...
A group element of the secp256k1 curve, in jacobian coordinates.
A scalar modulo the group order of the secp256k1 curve.