Skip to content

Commit 82995ff

Browse files
committed
remove redundant checks in scalar_inverse and scalar_cadd_bit
`secp256k1_scalar_verify` in VERIFY mode already performs this check in scalar_cadd_bit and scalar_inverse.
1 parent c53faec commit 82995ff

File tree

3 files changed

+0
-18
lines changed

3 files changed

+0
-18
lines changed

src/scalar_4x64_impl.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -840,20 +840,12 @@ static void secp256k1_scalar_from_signed62(secp256k1_scalar *r, const secp256k1_
840840
r->d[1] = a1 >> 2 | a2 << 60;
841841
r->d[2] = a2 >> 4 | a3 << 58;
842842
r->d[3] = a3 >> 6 | a4 << 56;
843-
844-
#ifdef VERIFY
845-
VERIFY_CHECK(secp256k1_scalar_impl_check_overflow(r) == 0);
846-
#endif
847843
}
848844

849845
static void secp256k1_scalar_to_signed62(secp256k1_modinv64_signed62 *r, const secp256k1_scalar *a) {
850846
const uint64_t M62 = UINT64_MAX >> 2;
851847
const uint64_t a0 = a->d[0], a1 = a->d[1], a2 = a->d[2], a3 = a->d[3];
852848

853-
#ifdef VERIFY
854-
VERIFY_CHECK(secp256k1_scalar_impl_check_overflow(a) == 0);
855-
#endif
856-
857849
r->v[0] = a0 & M62;
858850
r->v[1] = (a0 >> 62 | a1 << 2) & M62;
859851
r->v[2] = (a1 >> 60 | a2 << 4) & M62;

src/scalar_8x32_impl.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ static void secp256k1_scalar_impl_cadd_bit(secp256k1_scalar *r, unsigned int bit
163163
r->d[7] = t & 0xFFFFFFFFULL;
164164
#ifdef VERIFY
165165
VERIFY_CHECK((t >> 32) == 0);
166-
VERIFY_CHECK(secp256k1_scalar_impl_check_overflow(r) == 0);
167166
#endif
168167
}
169168

@@ -674,21 +673,13 @@ static void secp256k1_scalar_from_signed30(secp256k1_scalar *r, const secp256k1_
674673
r->d[5] = a5 >> 10 | a6 << 20;
675674
r->d[6] = a6 >> 12 | a7 << 18;
676675
r->d[7] = a7 >> 14 | a8 << 16;
677-
678-
#ifdef VERIFY
679-
VERIFY_CHECK(secp256k1_scalar_impl_check_overflow(r) == 0);
680-
#endif
681676
}
682677

683678
static void secp256k1_scalar_to_signed30(secp256k1_modinv32_signed30 *r, const secp256k1_scalar *a) {
684679
const uint32_t M30 = UINT32_MAX >> 2;
685680
const uint32_t a0 = a->d[0], a1 = a->d[1], a2 = a->d[2], a3 = a->d[3],
686681
a4 = a->d[4], a5 = a->d[5], a6 = a->d[6], a7 = a->d[7];
687682

688-
#ifdef VERIFY
689-
VERIFY_CHECK(secp256k1_scalar_impl_check_overflow(a) == 0);
690-
#endif
691-
692683
r->v[0] = a0 & M30;
693684
r->v[1] = (a0 >> 30 | a1 << 2) & M30;
694685
r->v[2] = (a1 >> 28 | a2 << 4) & M30;

src/scalar_low_impl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ static void secp256k1_scalar_impl_cadd_bit(secp256k1_scalar *r, unsigned int bit
4545
VERIFY_CHECK(bit < 32);
4646
/* Verify that adding (1 << bit) will not overflow any in-range scalar *r by overflowing the underlying uint32_t. */
4747
VERIFY_CHECK(((uint32_t)1 << bit) - 1 <= UINT32_MAX - EXHAUSTIVE_TEST_ORDER);
48-
VERIFY_CHECK(secp256k1_scalar_impl_check_overflow(r) == 0);
4948
#endif
5049
}
5150

0 commit comments

Comments
 (0)