Skip to content

Commit 0fc73f3

Browse files
pippenger/geh step 3: Go back to gej for doublings
1 parent 867fe34 commit 0fc73f3

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/ecmult_impl.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,23 @@ static int secp256k1_ecmult_pippenger_wnaf(secp256k1_gej *buckets, int bucket_wi
551551
}
552552
}
553553

554-
for(j = 0; j < bucket_window; j++) {
555-
secp256k1_geh_double_var(&r, &r);
554+
/* TODO these tricks seem to make things slower in practice. */
555+
/* if ((size_t)i != n_wnaf - 1) { /\* No reason to double infinity *\/ */
556+
/* if (bucket_window >= 3) { /\* Switch to gej for many doublings *\/ */
557+
{
558+
secp256k1_gej rj_tmp;
559+
secp256k1_gej_set_geh_var(&rj_tmp, &r);
560+
for (j = 0; j < bucket_window; j++) {
561+
secp256k1_gej_double_var(&rj_tmp, &rj_tmp, NULL);
562+
}
563+
secp256k1_geh_set_gej_var(&r, &rj_tmp);
556564
}
565+
/* } else { */
566+
/* for (j = 0; j < bucket_window; j++) { */
567+
/* secp256k1_geh_double_var(&r, &r); */
568+
/* } */
569+
/* } */
570+
/* } */
557571

558572
secp256k1_geh_set_infinity(&running_sum);
559573
/* Accumulate the sum: bucket[0] + 3*bucket[1] + 5*bucket[2] + 7*bucket[3] + ...

0 commit comments

Comments
 (0)