Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/src/ecmult_impl.h
Show First 20 Lines • Show All 437 Lines • ▼ Show 20 Lines | |||||
struct secp256k1_strauss_state { | struct secp256k1_strauss_state { | ||||
secp256k1_gej* prej; | secp256k1_gej* prej; | ||||
secp256k1_fe* zr; | secp256k1_fe* zr; | ||||
secp256k1_ge* pre_a; | secp256k1_ge* pre_a; | ||||
secp256k1_ge* pre_a_lam; | secp256k1_ge* pre_a_lam; | ||||
struct secp256k1_strauss_point_state* ps; | struct secp256k1_strauss_point_state* ps; | ||||
}; | }; | ||||
static void secp256k1_ecmult_strauss_wnaf(const secp256k1_ecmult_context *ctx, const struct secp256k1_strauss_state *state, secp256k1_gej *r, int num, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng) { | static void secp256k1_ecmult_strauss_wnaf(const secp256k1_ecmult_context *ctx, const struct secp256k1_strauss_state *state, secp256k1_gej *r, size_t num, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng) { | ||||
secp256k1_ge tmpa; | secp256k1_ge tmpa; | ||||
secp256k1_fe Z; | secp256k1_fe Z; | ||||
/* Splitted G factors. */ | /* Splitted G factors. */ | ||||
secp256k1_scalar ng_1, ng_128; | secp256k1_scalar ng_1, ng_128; | ||||
int wnaf_ng_1[129]; | int wnaf_ng_1[129]; | ||||
int bits_ng_1 = 0; | int bits_ng_1 = 0; | ||||
int wnaf_ng_128[129]; | int wnaf_ng_128[129]; | ||||
int bits_ng_128 = 0; | int bits_ng_128 = 0; | ||||
int i; | int i; | ||||
int bits = 0; | int bits = 0; | ||||
int np; | size_t np; | ||||
int no = 0; | size_t no = 0; | ||||
for (np = 0; np < num; ++np) { | for (np = 0; np < num; ++np) { | ||||
if (secp256k1_scalar_is_zero(&na[np]) || secp256k1_gej_is_infinity(&a[np])) { | if (secp256k1_scalar_is_zero(&na[np]) || secp256k1_gej_is_infinity(&a[np])) { | ||||
continue; | continue; | ||||
} | } | ||||
state->ps[no].input_pos = np; | state->ps[no].input_pos = np; | ||||
/* split na into na_1 and na_lam (where na = na_1 + na_lam*lambda, and na_1 and na_lam are ~128 bit) */ | /* split na into na_1 and na_lam (where na = na_1 + na_lam*lambda, and na_1 and na_lam are ~128 bit) */ | ||||
secp256k1_scalar_split_lambda(&state->ps[no].na_1, &state->ps[no].na_lam, &na[np]); | secp256k1_scalar_split_lambda(&state->ps[no].na_1, &state->ps[no].na_lam, &na[np]); | ||||
▲ Show 20 Lines • Show All 617 Lines • Show Last 20 Lines |