Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: real-or-random/secp256k1
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 944760128c22e374a04d7cee654420b6cd399de0
Choose a base ref
..
head repository: real-or-random/secp256k1
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0965b2fd0a67bfd3c682298d4e2c84a6b8663311
Choose a head ref
Showing with 22 additions and 6 deletions.
  1. +3 −4 src/ecmult_impl.h
  2. +19 −2 src/util.h
7 changes: 3 additions & 4 deletions src/ecmult_impl.h
Original file line number Diff line number Diff line change
@@ -417,12 +417,11 @@ static int secp256k1_ecmult_wnaf(int *wnaf, int len, const secp256k1_scalar *a,

bit += now;
}
#ifdef VERIFY
CHECK(carry == 0);
VERIFY_CHECK(carry == 0);
while (bit < 256) {
CHECK(secp256k1_scalar_get_bits(&s, bit++, 1) == 0);
VERIFY_CHECK(secp256k1_scalar_get_bits(&s, bit, 1) == 0);
bit++;
}
#endif
return last_set_bit + 1;
}

21 changes: 19 additions & 2 deletions src/util.h
Original file line number Diff line number Diff line change
@@ -47,7 +47,17 @@ static SECP256K1_INLINE void secp256k1_callback_call(const secp256k1_callback *
#define EXPECT(x,c) (x)
#endif

#ifdef DETERMINISTIC
/* CHECK() is like assert(). We use it only in the tests. */
#if defined(COVERAGE)
/* Don't abort in coverage mode.
This avoids branches which are not expected to be taken.
We still use cond as usual to avoid unused variable warnings. */
#define CHECK(cond) do { \
if (EXPECT(!(cond), 0)) { \
; \
} \
} while (0)
#elif defined(DETERMINISTIC)
#define CHECK(cond) do { \
if (EXPECT(!(cond), 0)) { \
TEST_FAILURE("test condition failed"); \
@@ -62,7 +72,14 @@ static SECP256K1_INLINE void secp256k1_callback_call(const secp256k1_callback *
#endif

/* Like assert(), but when VERIFY is defined, and side-effect safe. */
#if defined(VERIFY)
#if defined(COVERAGE)
/* Do nothing in coverage mode but try to stay syntactically correct.
This suppresses a lot of implicit branches introduced by shortcutting
operators at the cost of not being side-effect safe in coverage mode.
We rely on the compiler to eliminate the if (0) statement entirely. */
#define VERIFY_CHECK(cond) do { if (0) (void)(cond); } while(0)
#define VERIFY_SETUP(stmt)
#elif defined(VERIFY)
#define VERIFY_CHECK CHECK
#define VERIFY_SETUP(stmt) do { stmt; } while(0)
#else