@@ -4271,14 +4271,8 @@ void test_ecmult_multi_batching(void) {
4271
4271
secp256k1_scratch_destroy (& ctx -> error_callback , scratch );
4272
4272
4273
4273
for (i = 1 ; i <= n_points ; i ++ ) {
4274
- if (i >= ECMULT_PIPPENGER_THRESHOLD ) {
4275
- int bucket_window = secp256k1_pippenger_bucket_window (i );
4276
- size_t scratch_size = secp256k1_pippenger_scratch_size (i , bucket_window );
4277
- scratch = secp256k1_scratch_create (& ctx -> error_callback , scratch_size );
4278
- } else {
4279
- size_t scratch_size = secp256k1_strauss_scratch_size (i );
4280
- scratch = secp256k1_scratch_create (& ctx -> error_callback , scratch_size );
4281
- }
4274
+ size_t scratch_size = secp256k1_ecmult_multi_scratch_size (i );
4275
+ scratch = secp256k1_scratch_create (& ctx -> error_callback , scratch_size );
4282
4276
CHECK (secp256k1_ecmult_multi_var (& ctx -> error_callback , scratch , & r , & scG , ecmult_multi_callback , & data , n_points ));
4283
4277
secp256k1_gej_add_var (& r , & r , & r2 , NULL );
4284
4278
CHECK (secp256k1_gej_is_infinity (& r ));
@@ -4288,6 +4282,15 @@ void test_ecmult_multi_batching(void) {
4288
4282
free (pt );
4289
4283
}
4290
4284
4285
+ void test_ecmult_multi_scratch_size (void ) {
4286
+ /* test ECMULT_MAX_POINTS_PER_BATCH limit */
4287
+ size_t n_points = ECMULT_MAX_POINTS_PER_BATCH + 1 ;
4288
+ size_t scratch_size = secp256k1_ecmult_multi_scratch_size (n_points );
4289
+ int expected_bucket_window = secp256k1_pippenger_bucket_window (n_points - 1 );
4290
+ size_t expected_scratch_size = secp256k1_pippenger_scratch_size (n_points - 1 , expected_bucket_window );
4291
+ CHECK (expected_scratch_size == scratch_size );
4292
+ }
4293
+
4291
4294
void run_ecmult_multi_tests (void ) {
4292
4295
secp256k1_scratch * scratch ;
4293
4296
@@ -4311,6 +4314,7 @@ void run_ecmult_multi_tests(void) {
4311
4314
4312
4315
test_ecmult_multi_batch_size_helper ();
4313
4316
test_ecmult_multi_batching ();
4317
+ test_ecmult_multi_scratch_size ();
4314
4318
}
4315
4319
4316
4320
void test_wnaf (const secp256k1_scalar * number , int w ) {
0 commit comments