@@ -4271,14 +4271,8 @@ void test_ecmult_multi_batching(void) {
42714271 secp256k1_scratch_destroy (& ctx -> error_callback , scratch );
42724272
42734273 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 );
42824276 CHECK (secp256k1_ecmult_multi_var (& ctx -> error_callback , scratch , & r , & scG , ecmult_multi_callback , & data , n_points ));
42834277 secp256k1_gej_add_var (& r , & r , & r2 , NULL );
42844278 CHECK (secp256k1_gej_is_infinity (& r ));
@@ -4288,6 +4282,15 @@ void test_ecmult_multi_batching(void) {
42884282 free (pt );
42894283}
42904284
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+
42914294void run_ecmult_multi_tests (void ) {
42924295 secp256k1_scratch * scratch ;
42934296
@@ -4311,6 +4314,7 @@ void run_ecmult_multi_tests(void) {
43114314
43124315 test_ecmult_multi_batch_size_helper ();
43134316 test_ecmult_multi_batching ();
4317+ test_ecmult_multi_scratch_size ();
43144318}
43154319
43164320void test_wnaf (const secp256k1_scalar * number , int w ) {
0 commit comments