Rip out non-endomorphism code
This commit is contained in:
29
src/tests.c
29
src/tests.c
@@ -2102,17 +2102,12 @@ void ge_equals_gej(const secp256k1_ge *a, const secp256k1_gej *b) {
|
||||
|
||||
void test_ge(void) {
|
||||
int i, i1;
|
||||
#ifdef USE_ENDOMORPHISM
|
||||
int runs = 6;
|
||||
#else
|
||||
int runs = 4;
|
||||
#endif
|
||||
/* Points: (infinity, p1, p1, -p1, -p1, p2, p2, -p2, -p2, p3, p3, -p3, -p3, p4, p4, -p4, -p4).
|
||||
* The second in each pair of identical points uses a random Z coordinate in the Jacobian form.
|
||||
* All magnitudes are randomized.
|
||||
* All 17*17 combinations of points are added to each other, using all applicable methods.
|
||||
*
|
||||
* When the endomorphism code is compiled in, p5 = lambda*p1 and p6 = lambda^2*p1 are added as well.
|
||||
/* 25 points are used:
|
||||
* - infinity
|
||||
* - for each of four random points p1 p2 p3 p4, we add the point, its
|
||||
* negation, and then those two again but with randomized Z coordinate.
|
||||
* - The same is then done for lambda*p1 and lambda^2*p1.
|
||||
*/
|
||||
secp256k1_ge *ge = (secp256k1_ge *)checked_malloc(&ctx->error_callback, sizeof(secp256k1_ge) * (1 + 4 * runs));
|
||||
secp256k1_gej *gej = (secp256k1_gej *)checked_malloc(&ctx->error_callback, sizeof(secp256k1_gej) * (1 + 4 * runs));
|
||||
@@ -2127,14 +2122,12 @@ void test_ge(void) {
|
||||
int j;
|
||||
secp256k1_ge g;
|
||||
random_group_element_test(&g);
|
||||
#ifdef USE_ENDOMORPHISM
|
||||
if (i >= runs - 2) {
|
||||
secp256k1_ge_mul_lambda(&g, &ge[1]);
|
||||
}
|
||||
if (i >= runs - 1) {
|
||||
secp256k1_ge_mul_lambda(&g, &g);
|
||||
}
|
||||
#endif
|
||||
ge[1 + 4 * i] = g;
|
||||
ge[2 + 4 * i] = g;
|
||||
secp256k1_ge_neg(&ge[3 + 4 * i], &g);
|
||||
@@ -3122,12 +3115,10 @@ void test_secp256k1_pippenger_bucket_window_inv(void) {
|
||||
|
||||
CHECK(secp256k1_pippenger_bucket_window_inv(0) == 0);
|
||||
for(i = 1; i <= PIPPENGER_MAX_BUCKET_WINDOW; i++) {
|
||||
#ifdef USE_ENDOMORPHISM
|
||||
/* Bucket_window of 8 is not used with endo */
|
||||
if (i == 8) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
CHECK(secp256k1_pippenger_bucket_window(secp256k1_pippenger_bucket_window_inv(i)) == i);
|
||||
if (i != PIPPENGER_MAX_BUCKET_WINDOW) {
|
||||
CHECK(secp256k1_pippenger_bucket_window(secp256k1_pippenger_bucket_window_inv(i)+1) > i);
|
||||
@@ -3370,13 +3361,10 @@ void test_constant_wnaf(const secp256k1_scalar *number, int w) {
|
||||
|
||||
secp256k1_scalar_set_int(&x, 0);
|
||||
secp256k1_scalar_set_int(&shift, 1 << w);
|
||||
/* With USE_ENDOMORPHISM on we only consider 128-bit numbers */
|
||||
#ifdef USE_ENDOMORPHISM
|
||||
for (i = 0; i < 16; ++i) {
|
||||
secp256k1_scalar_shr_int(&num, 8);
|
||||
}
|
||||
bits = 128;
|
||||
#endif
|
||||
skew = secp256k1_wnaf_const(wnaf, &num, w, bits);
|
||||
|
||||
for (i = WNAF_SIZE_BITS(bits, w); i >= 0; --i) {
|
||||
@@ -3411,12 +3399,9 @@ void test_fixed_wnaf(const secp256k1_scalar *number, int w) {
|
||||
|
||||
secp256k1_scalar_set_int(&x, 0);
|
||||
secp256k1_scalar_set_int(&shift, 1 << w);
|
||||
/* With USE_ENDOMORPHISM on we only consider 128-bit numbers */
|
||||
#ifdef USE_ENDOMORPHISM
|
||||
for (i = 0; i < 16; ++i) {
|
||||
secp256k1_scalar_shr_int(&num, 8);
|
||||
}
|
||||
#endif
|
||||
skew = secp256k1_wnaf_fixed(wnaf, &num, w);
|
||||
|
||||
for (i = WNAF_SIZE(w)-1; i >= 0; --i) {
|
||||
@@ -3632,7 +3617,6 @@ void run_ecmult_gen_blind(void) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_ENDOMORPHISM
|
||||
/***** ENDOMORPHISH TESTS *****/
|
||||
void test_scalar_split(const secp256k1_scalar* full) {
|
||||
secp256k1_scalar s, s1, slam;
|
||||
@@ -3681,7 +3665,6 @@ void run_endomorphism_tests(void) {
|
||||
test_scalar_split(&scalars_near_split_bounds[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void ec_pubkey_parse_pointtest(const unsigned char *input, int xvalid, int yvalid) {
|
||||
unsigned char pubkeyc[65];
|
||||
@@ -5700,9 +5683,7 @@ int main(int argc, char **argv) {
|
||||
run_ec_combine();
|
||||
|
||||
/* endomorphism tests */
|
||||
#ifdef USE_ENDOMORPHISM
|
||||
run_endomorphism_tests();
|
||||
#endif
|
||||
|
||||
/* EC point parser test */
|
||||
run_ec_pubkey_parse_test();
|
||||
|
||||
Reference in New Issue
Block a user