7 #ifndef _SECP256K1_ECMULT_CONST_IMPL_ 8 #define _SECP256K1_ECMULT_CONST_IMPL_ 15 #ifdef USE_ENDOMORPHISM 20 #define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w)) 23 #define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \ 25 int abs_n = (n) * (((n) > 0) * 2 - 1); \ 26 int idx_n = abs_n / 2; \ 28 VERIFY_CHECK(((n) & 1) == 1); \ 29 VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \ 30 VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1)); \ 31 VERIFY_SETUP(secp256k1_fe_clear(&(r)->x)); \ 32 VERIFY_SETUP(secp256k1_fe_clear(&(r)->y)); \ 33 for (m = 0; m < ECMULT_TABLE_SIZE(w); m++) { \ 36 secp256k1_fe_cmov(&(r)->x, &(pre)[m].x, m == idx_n); \ 37 secp256k1_fe_cmov(&(r)->y, &(pre)[m].y, m == idx_n); \ 40 secp256k1_fe_negate(&neg_y, &(r)->y, 1); \ 41 secp256k1_fe_cmov(&(r)->y, &neg_y, (n) != abs_n); \ 65 #ifdef USE_ENDOMORPHISM 79 bit = flip ^ (s.
d[0] & 1);
90 global_sign *= not_neg_one * 2 - 1;
107 even = ((u & 1) == 0);
108 sign = 2 * (u_last > 0) - 1;
110 u_last -= sign * even * (1 << w);
113 wnaf[word++] = u_last * global_sign;
117 wnaf[word] = u * global_sign;
130 #ifdef USE_ENDOMORPHISM 145 #ifdef USE_ENDOMORPHISM 147 secp256k1_scalar_split_lambda(&q_1, &q_lam, &sc);
173 #ifdef USE_ENDOMORPHISM 175 secp256k1_ge_mul_lambda(&pre_a_lam[i], &pre_a[i]);
182 #ifdef USE_ENDOMORPHISM 202 for (j = 0; j <
WINDOW_A - 1; ++j) {
205 #ifdef USE_ENDOMORPHISM 225 #ifdef USE_ENDOMORPHISM 251 secp256k1_ge_mul_lambda(&correction, &correction);
#define VERIFY_CHECK(cond)
static int secp256k1_scalar_is_even(const secp256k1_scalar *a)
static void secp256k1_ge_neg(secp256k1_ge *r, const secp256k1_ge *a)
static void secp256k1_fe_mul(secp256k1_fe *r, const secp256k1_fe *a, const secp256k1_fe *SECP256K1_RESTRICT b)
static void secp256k1_gej_double_nonzero(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr)
static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a)
static int secp256k1_scalar_is_zero(const secp256k1_scalar *a)
#define ECMULT_TABLE_SIZE(w)
static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n)
static void secp256k1_gej_double_var(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr)
static void secp256k1_ecmult_odd_multiples_table_globalz_windowa(secp256k1_ge *pre, secp256k1_fe *globalz, const secp256k1_gej *a)
#define ECMULT_CONST_TABLE_GET_GE(r, pre, n, w)
static void secp256k1_ge_set_gej(secp256k1_ge *r, secp256k1_gej *a)
static int secp256k1_scalar_is_high(const secp256k1_scalar *a)
static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag)
static void secp256k1_fe_normalize_weak(secp256k1_fe *r)
static void secp256k1_ge_storage_cmov(secp256k1_ge_storage *r, const secp256k1_ge_storage *a, int flag)
static int secp256k1_scalar_cond_negate(secp256k1_scalar *a, int flag)
static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b)
static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *scalar)
static void secp256k1_ge_from_storage(secp256k1_ge *r, const secp256k1_ge_storage *a)
static void secp256k1_gej_set_ge(secp256k1_gej *r, const secp256k1_ge *a)
static void secp256k1_ge_to_storage(secp256k1_ge_storage *r, const secp256k1_ge *a)
static int secp256k1_wnaf_const(int *wnaf, secp256k1_scalar s, int w)
static int secp256k1_scalar_is_one(const secp256k1_scalar *a)