Skip to content

Commit

Permalink
Clear warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunovo committed Nov 7, 2024
1 parent d6439f2 commit 43a4768
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
20 changes: 12 additions & 8 deletions src/modules/batch/tests_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ void test_batch_sha256_tagged(void) {
#define N_TWK_CHECKS 10
#define N_TERMS (N_TWK_CHECKS + 2*N_SIGS)
void test_batch_api(void) {
secp256k1_batch *batch_none;
secp256k1_batch *batch_sign;
secp256k1_batch *batch_vrfy;
secp256k1_batch *batch_both;
secp256k1_batch *batch_sttc;
unsigned char aux_rand16[32];
int ecount;

#ifdef ENABLE_MODULE_EXTRAKEYS
unsigned char sk[32];
Expand Down Expand Up @@ -65,9 +72,6 @@ void test_batch_api(void) {
secp256k1_context *sttc = malloc(sizeof(*secp256k1_context_no_precomp));
memcpy(sttc, secp256k1_context_no_precomp, sizeof(secp256k1_context));

unsigned char aux_rand16[32];
int ecount;

secp256k1_context_set_error_callback(none, counting_callback_fn, &ecount);
secp256k1_context_set_error_callback(sign, counting_callback_fn, &ecount);
secp256k1_context_set_error_callback(vrfy, counting_callback_fn, &ecount);
Expand Down Expand Up @@ -111,21 +115,21 @@ void test_batch_api(void) {
/** main test body **/
/* batch_create tests */
ecount = 0;
secp256k1_batch *batch_none = secp256k1_batch_create(none, 1, NULL);
batch_none = secp256k1_batch_create(none, 1, NULL);
CHECK(batch_none != NULL);
CHECK(ecount == 0);
/* 2*N_SIGS since one schnorrsig creates two scalar-point pair in batch */
secp256k1_batch *batch_sign = secp256k1_batch_create(sign, 2*N_SIGS, NULL);
batch_sign = secp256k1_batch_create(sign, 2*N_SIGS, NULL);
CHECK(batch_sign != NULL);
CHECK(ecount == 0);
secp256k1_batch *batch_vrfy = secp256k1_batch_create(vrfy, N_TWK_CHECKS - 1, aux_rand16);
batch_vrfy = secp256k1_batch_create(vrfy, N_TWK_CHECKS - 1, aux_rand16);
CHECK(batch_vrfy != NULL);
CHECK(ecount == 0);
secp256k1_batch *batch_both = secp256k1_batch_create(both, N_TERMS/4, aux_rand16);
batch_both = secp256k1_batch_create(both, N_TERMS/4, aux_rand16);
CHECK(batch_both != NULL);
CHECK(ecount == 0);
/* ARG_CHECK(max_terms != 0) in `batch_create` should fail*/
secp256k1_batch *batch_sttc = secp256k1_batch_create(sttc, 0, NULL);
batch_sttc = secp256k1_batch_create(sttc, 0, NULL);
CHECK(batch_sttc == NULL);
CHECK(ecount == 1);

Expand Down
11 changes: 3 additions & 8 deletions src/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -4837,11 +4837,6 @@ void ecmult_multi_random_generate_inp(secp256k1_gej *expected, secp256k1_scalar
secp256k1_ge ge_tmp;

int i;
/* Which multiplication function to use */
int fn = testrand_int(3);
secp256k1_ecmult_multi_func ecmult_multi = fn == 0 ? secp256k1_ecmult_multi_var :
fn == 1 ? secp256k1_ecmult_strauss_batch_single :
secp256k1_ecmult_pippenger_batch_single;
int filled = 0;
/* Simulate exponentially distributed num. */
int num_bits = 2 + testrand_int(6);
Expand All @@ -4857,7 +4852,7 @@ void ecmult_multi_random_generate_inp(secp256k1_gej *expected, secp256k1_scalar
num_nonzero == 1 && !nonzero_result ? 1 :
(int)testrand_bits(1);
/* Which g_scalar pointer to pass into ecmult_multi(). */
const secp256k1_scalar* g_scalar_ptr = (g_nonzero || testrand_bits(1)) ? &g_scalar : NULL;
secp256k1_scalar* g_scalar_ptr = (g_nonzero || testrand_bits(1)) ? g_scalar : NULL;
/* How many EC multiplications were performed in this function. */
int mults = 0;
/* How many randomization steps to apply to the input list. */
Expand All @@ -4870,12 +4865,12 @@ void ecmult_multi_random_generate_inp(secp256k1_gej *expected, secp256k1_scalar

if (g_nonzero) {
/* If g_nonzero, set g_scalar to nonzero value r. */
testutil_random_scalar_order_test(&g_scalar);
testutil_random_scalar_order_test(g_scalar);
if (!nonzero_result) {
/* If expected=0 is desired, add a (a*r, -(1/a)*g) term to compensate. */
CHECK(num_nonzero > filled);
testutil_random_scalar_order_test(&sc_tmp);
secp256k1_scalar_mul(&scalars[filled], &sc_tmp, &g_scalar);
secp256k1_scalar_mul(&scalars[filled], &sc_tmp, g_scalar);
secp256k1_scalar_inverse_var(&sc_tmp, &sc_tmp);
secp256k1_scalar_negate(&sc_tmp, &sc_tmp);
secp256k1_ecmult_gen(&CTX->ecmult_gen_ctx, &gejs[filled], &sc_tmp);
Expand Down

0 comments on commit 43a4768

Please sign in to comment.