@@ -563,15 +563,11 @@ static size_t secp256k1_strauss_max_points(secp256k1_scratch *scratch) {
563
563
* It has the following guarantees:
564
564
* - each wnaf[i] is either 0 or an odd integer between -(1 << w) and (1 << w)
565
565
* - the number of words set is always WNAF_SIZE(w)
566
- * - the returned skew is 0 without endomorphism, or 0 or 1 with endomorphism
566
+ * - the returned skew is 0 or 1
567
567
*/
568
568
static int secp256k1_wnaf_fixed (int * wnaf , const secp256k1_scalar * s , int w ) {
569
- int sign = 0 ;
570
569
int skew = 0 ;
571
570
int pos = 1 ;
572
- #ifndef USE_ENDOMORPHISM
573
- secp256k1_scalar neg_s ;
574
- #endif
575
571
const secp256k1_scalar * work = s ;
576
572
577
573
if (secp256k1_scalar_is_zero (s )) {
@@ -583,16 +579,10 @@ static int secp256k1_wnaf_fixed(int *wnaf, const secp256k1_scalar *s, int w) {
583
579
}
584
580
585
581
if (secp256k1_scalar_is_even (s )) {
586
- #ifdef USE_ENDOMORPHISM
587
582
skew = 1 ;
588
- #else
589
- secp256k1_scalar_negate (& neg_s , s );
590
- work = & neg_s ;
591
- sign = -1 ;
592
- #endif
593
583
}
594
584
595
- wnaf [0 ] = ( secp256k1_scalar_get_bits_var (work , 0 , w ) + skew + sign ) ^ sign ;
585
+ wnaf [0 ] = secp256k1_scalar_get_bits_var (work , 0 , w ) + skew ;
596
586
597
587
while (pos * w < WNAF_BITS ) {
598
588
int now = w ;
@@ -602,10 +592,10 @@ static int secp256k1_wnaf_fixed(int *wnaf, const secp256k1_scalar *s, int w) {
602
592
}
603
593
val = secp256k1_scalar_get_bits_var (work , pos * w , now );
604
594
if ((val & 1 ) == 0 ) {
605
- wnaf [pos - 1 ] -= (( 1 << w ) + sign ) ^ sign ;
606
- wnaf [pos ] = (val + 1 + sign ) ^ sign ;
595
+ wnaf [pos - 1 ] -= (1 << w );
596
+ wnaf [pos ] = (val + 1 ) ;
607
597
} else {
608
- wnaf [pos ] = ( val + sign ) ^ sign ;
598
+ wnaf [pos ] = val ;
609
599
}
610
600
/* Set a coefficient to zero if it is 1 or -1 and the proceeding digit
611
601
* is strictly negative or strictly positive respectively. Only change
@@ -678,7 +668,6 @@ static int secp256k1_ecmult_pippenger_wnaf(secp256k1_gej *buckets, int bucket_wi
678
668
secp256k1_ge tmp ;
679
669
int idx ;
680
670
681
- #ifdef USE_ENDOMORPHISM
682
671
if (i == 0 ) {
683
672
/* correct for wnaf skew */
684
673
int skew = point_state .skew_na ;
@@ -687,7 +676,6 @@ static int secp256k1_ecmult_pippenger_wnaf(secp256k1_gej *buckets, int bucket_wi
687
676
secp256k1_gej_add_ge_var (& buckets [0 ], & buckets [0 ], & tmp , NULL );
688
677
}
689
678
}
690
- #endif
691
679
if (n > 0 ) {
692
680
idx = (n - 1 )/2 ;
693
681
secp256k1_gej_add_ge_var (& buckets [idx ], & buckets [idx ], & pt [point_state .input_pos ], NULL );
0 commit comments