Skip to content

Commit 3bc866b

Browse files
committed
Merge pull request #20
d7fd4d0 Use endomorphism in precomputations (Peter Dettman)
2 parents 255ca38 + d7fd4d0 commit 3bc866b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/ecmult_impl.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,6 @@ void static secp256k1_ecmult(secp256k1_gej_t *r, const secp256k1_gej_t *a, const
206206
int wnaf_na_lam[129]; int bits_na_lam = secp256k1_ecmult_wnaf(wnaf_na_lam, &na_lam, WINDOW_A);
207207
int bits = bits_na_1;
208208
if (bits_na_lam > bits) bits = bits_na_lam;
209-
210-
// calculate a_lam = a*lambda
211-
secp256k1_gej_t a_lam; secp256k1_gej_mul_lambda(&a_lam, a);
212-
213-
// calculate odd multiples of a_lam
214-
secp256k1_gej_t pre_a_lam[ECMULT_TABLE_SIZE(WINDOW_A)];
215-
secp256k1_ecmult_table_precomp_gej(pre_a_lam, &a_lam, WINDOW_A);
216209
#else
217210
// build wnaf representation for na.
218211
int wnaf_na[257]; int bits_na = secp256k1_ecmult_wnaf(wnaf_na, na, WINDOW_A);
@@ -223,6 +216,12 @@ void static secp256k1_ecmult(secp256k1_gej_t *r, const secp256k1_gej_t *a, const
223216
secp256k1_gej_t pre_a[ECMULT_TABLE_SIZE(WINDOW_A)];
224217
secp256k1_ecmult_table_precomp_gej(pre_a, a, WINDOW_A);
225218

219+
#ifdef USE_ENDOMORPHISM
220+
secp256k1_gej_t pre_a_lam[ECMULT_TABLE_SIZE(WINDOW_A)];
221+
for (int i=0; i<ECMULT_TABLE_SIZE(WINDOW_A); i++)
222+
secp256k1_gej_mul_lambda(&pre_a_lam[i], &pre_a[i]);
223+
#endif
224+
226225
// Splitted G factors.
227226
secp256k1_num_t ng_1, ng_128;
228227
secp256k1_num_init(&ng_1);

0 commit comments

Comments
 (0)