From d7fd4d0f6b7001a5c1805600bedf68648c4a4a44 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 22 May 2014 10:17:30 +0700 Subject: [PATCH] Use endomorphism in precomputations --- src/ecmult_impl.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ecmult_impl.h b/src/ecmult_impl.h index cf8781100f..80793db4b2 100644 --- a/src/ecmult_impl.h +++ b/src/ecmult_impl.h @@ -206,13 +206,6 @@ void static secp256k1_ecmult(secp256k1_gej_t *r, const secp256k1_gej_t *a, const int wnaf_na_lam[129]; int bits_na_lam = secp256k1_ecmult_wnaf(wnaf_na_lam, &na_lam, WINDOW_A); int bits = bits_na_1; if (bits_na_lam > bits) bits = bits_na_lam; - - // calculate a_lam = a*lambda - secp256k1_gej_t a_lam; secp256k1_gej_mul_lambda(&a_lam, a); - - // calculate odd multiples of a_lam - secp256k1_gej_t pre_a_lam[ECMULT_TABLE_SIZE(WINDOW_A)]; - secp256k1_ecmult_table_precomp_gej(pre_a_lam, &a_lam, WINDOW_A); #else // build wnaf representation for na. 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 secp256k1_gej_t pre_a[ECMULT_TABLE_SIZE(WINDOW_A)]; secp256k1_ecmult_table_precomp_gej(pre_a, a, WINDOW_A); +#ifdef USE_ENDOMORPHISM + secp256k1_gej_t pre_a_lam[ECMULT_TABLE_SIZE(WINDOW_A)]; + for (int i=0; i