Skip to content

Commit a3828d7

Browse files
committed
Remove unnecessary #ifdef VERIFY guards
1 parent 1880593 commit a3828d7

6 files changed

+0
-26
lines changed

src/field_10x26_impl.h

-4
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,7 @@ void secp256k1_fe_sqr_inner(uint32_t *r, const uint32_t *a);
454454

455455
#else
456456

457-
#ifdef VERIFY
458457
#define VERIFY_BITS(x, n) VERIFY_CHECK(((x) >> (n)) == 0)
459-
#else
460-
#define VERIFY_BITS(x, n) do { } while(0)
461-
#endif
462458

463459
SECP256K1_INLINE static void secp256k1_fe_mul_inner(uint32_t *r, const uint32_t *a, const uint32_t * SECP256K1_RESTRICT b) {
464460
uint64_t c, d;

src/field_5x52_impl.h

-4
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,7 @@ static void secp256k1_fe_inv(secp256k1_fe *r, const secp256k1_fe *x) {
550550
secp256k1_modinv64(&s, &secp256k1_const_modinfo_fe);
551551
secp256k1_fe_from_signed62(r, &s);
552552

553-
#ifdef VERIFY
554553
VERIFY_CHECK(secp256k1_fe_normalizes_to_zero(r) == secp256k1_fe_normalizes_to_zero(&tmp));
555-
#endif
556554
}
557555

558556
static void secp256k1_fe_inv_var(secp256k1_fe *r, const secp256k1_fe *x) {
@@ -565,9 +563,7 @@ static void secp256k1_fe_inv_var(secp256k1_fe *r, const secp256k1_fe *x) {
565563
secp256k1_modinv64_var(&s, &secp256k1_const_modinfo_fe);
566564
secp256k1_fe_from_signed62(r, &s);
567565

568-
#ifdef VERIFY
569566
VERIFY_CHECK(secp256k1_fe_normalizes_to_zero(r) == secp256k1_fe_normalizes_to_zero(&tmp));
570-
#endif
571567
}
572568

573569
#endif /* SECP256K1_FIELD_REPR_IMPL_H */

src/field_5x52_int128_impl.h

-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99

1010
#include <stdint.h>
1111

12-
#ifdef VERIFY
1312
#define VERIFY_BITS(x, n) VERIFY_CHECK(((x) >> (n)) == 0)
14-
#else
15-
#define VERIFY_BITS(x, n) do { } while(0)
16-
#endif
1713

1814
SECP256K1_INLINE static void secp256k1_fe_mul_inner(uint64_t *r, const uint64_t *a, const uint64_t * SECP256K1_RESTRICT b) {
1915
uint128_t c, d;

src/scalar_4x64_impl.h

-6
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,8 @@ static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int
110110
r->d[2] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64;
111111
t += (uint128_t)r->d[3] + (((uint64_t)((bit >> 6) == 3)) << (bit & 0x3F));
112112
r->d[3] = t & 0xFFFFFFFFFFFFFFFFULL;
113-
#ifdef VERIFY
114113
VERIFY_CHECK((t >> 64) == 0);
115114
VERIFY_CHECK(secp256k1_scalar_check_overflow(r) == 0);
116-
#endif
117115
}
118116

119117
static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *b32, int *overflow) {
@@ -808,18 +806,14 @@ static void secp256k1_scalar_from_signed62(secp256k1_scalar *r, const secp256k1_
808806
r->d[2] = a2 >> 4 | a3 << 58;
809807
r->d[3] = a3 >> 6 | a4 << 56;
810808

811-
#ifdef VERIFY
812809
VERIFY_CHECK(secp256k1_scalar_check_overflow(r) == 0);
813-
#endif
814810
}
815811

816812
static void secp256k1_scalar_to_signed62(secp256k1_modinv64_signed62 *r, const secp256k1_scalar *a) {
817813
const uint64_t M62 = UINT64_MAX >> 2;
818814
const uint64_t a0 = a->d[0], a1 = a->d[1], a2 = a->d[2], a3 = a->d[3];
819815

820-
#ifdef VERIFY
821816
VERIFY_CHECK(secp256k1_scalar_check_overflow(a) == 0);
822-
#endif
823817

824818
r->v[0] = a0 & M62;
825819
r->v[1] = (a0 >> 62 | a1 << 2) & M62;

src/scalar_8x32_impl.h

-6
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,8 @@ static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int
158158
r->d[6] = t & 0xFFFFFFFFULL; t >>= 32;
159159
t += (uint64_t)r->d[7] + (((uint32_t)((bit >> 5) == 7)) << (bit & 0x1F));
160160
r->d[7] = t & 0xFFFFFFFFULL;
161-
#ifdef VERIFY
162161
VERIFY_CHECK((t >> 32) == 0);
163162
VERIFY_CHECK(secp256k1_scalar_check_overflow(r) == 0);
164-
#endif
165163
}
166164

167165
static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *b32, int *overflow) {
@@ -670,19 +668,15 @@ static void secp256k1_scalar_from_signed30(secp256k1_scalar *r, const secp256k1_
670668
r->d[6] = a6 >> 12 | a7 << 18;
671669
r->d[7] = a7 >> 14 | a8 << 16;
672670

673-
#ifdef VERIFY
674671
VERIFY_CHECK(secp256k1_scalar_check_overflow(r) == 0);
675-
#endif
676672
}
677673

678674
static void secp256k1_scalar_to_signed30(secp256k1_modinv32_signed30 *r, const secp256k1_scalar *a) {
679675
const uint32_t M30 = UINT32_MAX >> 2;
680676
const uint32_t a0 = a->d[0], a1 = a->d[1], a2 = a->d[2], a3 = a->d[3],
681677
a4 = a->d[4], a5 = a->d[5], a6 = a->d[6], a7 = a->d[7];
682678

683-
#ifdef VERIFY
684679
VERIFY_CHECK(secp256k1_scalar_check_overflow(a) == 0);
685-
#endif
686680

687681
r->v[0] = a0 & M30;
688682
r->v[1] = (a0 >> 30 | a1 << 2) & M30;

src/scalar_low_impl.h

-2
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@ static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a,
3939
static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag) {
4040
if (flag && bit < 32)
4141
*r += ((uint32_t)1 << bit);
42-
#ifdef VERIFY
4342
VERIFY_CHECK(bit < 32);
4443
/* Verify that adding (1 << bit) will not overflow any in-range scalar *r by overflowing the underlying uint32_t. */
4544
VERIFY_CHECK(((uint32_t)1 << bit) - 1 <= UINT32_MAX - EXHAUSTIVE_TEST_ORDER);
4645
VERIFY_CHECK(secp256k1_scalar_check_overflow(r) == 0);
47-
#endif
4846
}
4947

5048
static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *b32, int *overflow) {

0 commit comments

Comments
 (0)