Skip to content

Commit 60bf889

Browse files
committed
ecmult: fix definition of STRAUSS_SCRATCH_OBJECTS
This bug was introduced in 7506e06 by adding an allocation but not updating the constant.
1 parent 8fa4120 commit 60bf889

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/ecmult_impl.h

+9-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
/* The number of objects allocated on the scratch space for ecmult_multi algorithms */
4949
#define PIPPENGER_SCRATCH_OBJECTS 6
50-
#define STRAUSS_SCRATCH_OBJECTS 6
50+
#define STRAUSS_SCRATCH_OBJECTS 7
5151

5252
#define PIPPENGER_MAX_BUCKET_WINDOW 12
5353

@@ -365,6 +365,9 @@ static int secp256k1_ecmult_strauss_batch(const secp256k1_callback* error_callba
365365
return 1;
366366
}
367367

368+
/* We allocate STRAUSS_SCRATCH_OBJECTS objects on the scratch space. If these
369+
* allocations change, make sure to update the STRAUSS_SCRATCH_OBJECTS
370+
* constant and strauss_scratch_size accordingly. */
368371
points = (secp256k1_gej*)secp256k1_scratch_alloc(error_callback, scratch, n_points * sizeof(secp256k1_gej));
369372
scalars = (secp256k1_scalar*)secp256k1_scratch_alloc(error_callback, scratch, n_points * sizeof(secp256k1_scalar));
370373
state.prej = (secp256k1_gej*)secp256k1_scratch_alloc(error_callback, scratch, n_points * ECMULT_TABLE_SIZE(WINDOW_A) * sizeof(secp256k1_gej));
@@ -659,16 +662,19 @@ static int secp256k1_ecmult_pippenger_batch(const secp256k1_callback* error_call
659662
if (inp_g_sc == NULL && n_points == 0) {
660663
return 1;
661664
}
662-
663665
bucket_window = secp256k1_pippenger_bucket_window(n_points);
666+
667+
/* We allocate PIPPENGER_SCRATCH_OBJECTS objects on the scratch space. If
668+
* these allocations change, make sure to update the
669+
* PIPPENGER_SCRATCH_OBJECTS constant and pippenger_scratch_size
670+
* accordingly. */
664671
points = (secp256k1_ge *) secp256k1_scratch_alloc(error_callback, scratch, entries * sizeof(*points));
665672
scalars = (secp256k1_scalar *) secp256k1_scratch_alloc(error_callback, scratch, entries * sizeof(*scalars));
666673
state_space = (struct secp256k1_pippenger_state *) secp256k1_scratch_alloc(error_callback, scratch, sizeof(*state_space));
667674
if (points == NULL || scalars == NULL || state_space == NULL) {
668675
secp256k1_scratch_apply_checkpoint(error_callback, scratch, scratch_checkpoint);
669676
return 0;
670677
}
671-
672678
state_space->ps = (struct secp256k1_pippenger_point_state *) secp256k1_scratch_alloc(error_callback, scratch, entries * sizeof(*state_space->ps));
673679
state_space->wnaf_na = (int *) secp256k1_scratch_alloc(error_callback, scratch, entries*(WNAF_SIZE(bucket_window+1)) * sizeof(int));
674680
buckets = (secp256k1_gej *) secp256k1_scratch_alloc(error_callback, scratch, (1<<bucket_window) * sizeof(*buckets));

0 commit comments

Comments
 (0)