47
47
48
48
/* The number of objects allocated on the scratch space for ecmult_multi algorithms */
49
49
#define PIPPENGER_SCRATCH_OBJECTS 6
50
- #define STRAUSS_SCRATCH_OBJECTS 5
50
+ #define STRAUSS_SCRATCH_OBJECTS 3
51
51
52
52
#define PIPPENGER_MAX_BUCKET_WINDOW 12
53
53
@@ -385,7 +385,7 @@ static void secp256k1_ecmult(secp256k1_gej *r, const secp256k1_gej *a, const sec
385
385
}
386
386
387
387
static size_t secp256k1_strauss_scratch_size (size_t n_points ) {
388
- static const size_t point_size = (sizeof (secp256k1_ge ) + sizeof (secp256k1_fe )) * ECMULT_TABLE_SIZE (WINDOW_A ) + sizeof (struct secp256k1_strauss_point_state ) + sizeof ( secp256k1_gej ) + sizeof ( secp256k1_scalar ) ;
388
+ static const size_t point_size = (sizeof (secp256k1_ge ) + sizeof (secp256k1_fe )) * ECMULT_TABLE_SIZE (WINDOW_A ) + sizeof (struct secp256k1_strauss_point_state );
389
389
return n_points * point_size ;
390
390
}
391
391
@@ -407,8 +407,6 @@ static int secp256k1_ecmult_adaptor_cb(secp256k1_scalar *sc, secp256k1_gej *pt,
407
407
}
408
408
409
409
static int secp256k1_ecmult_strauss_batch (const secp256k1_callback * error_callback , secp256k1_scratch * scratch , secp256k1_gej * r , const secp256k1_scalar * inp_g_sc , secp256k1_ecmult_multi_callback cb , void * cbdata , size_t n_points , size_t cb_offset ) {
410
- secp256k1_gej * points ;
411
- secp256k1_scalar * scalars ;
412
410
struct secp256k1_ecmult_adaptor_cb_data adaptor_data ;
413
411
struct secp256k1_strauss_state state ;
414
412
const size_t scratch_checkpoint = secp256k1_scratch_checkpoint (error_callback , scratch );
@@ -418,20 +416,14 @@ static int secp256k1_ecmult_strauss_batch(const secp256k1_callback* error_callba
418
416
return 1 ;
419
417
}
420
418
421
- points = (secp256k1_gej * )secp256k1_scratch_alloc (error_callback , scratch , n_points * sizeof (secp256k1_gej ));
422
- scalars = (secp256k1_scalar * )secp256k1_scratch_alloc (error_callback , scratch , n_points * sizeof (secp256k1_scalar ));
423
419
adaptor_data .cb = cb ;
424
420
adaptor_data .data = cbdata ;
425
421
state .aux = (secp256k1_fe * )secp256k1_scratch_alloc (error_callback , scratch , n_points * ECMULT_TABLE_SIZE (WINDOW_A ) * sizeof (secp256k1_fe ));
426
422
state .pre_a = (secp256k1_ge * )secp256k1_scratch_alloc (error_callback , scratch , n_points * ECMULT_TABLE_SIZE (WINDOW_A ) * sizeof (secp256k1_ge ));
427
423
state .ps = (struct secp256k1_strauss_point_state * )secp256k1_scratch_alloc (error_callback , scratch , n_points * sizeof (struct secp256k1_strauss_point_state ));
428
424
429
- if (points == NULL || scalars == NULL || state .aux == NULL || state .pre_a == NULL || state .ps == NULL ) {
430
- secp256k1_scratch_apply_checkpoint (error_callback , scratch , scratch_checkpoint );
431
- return 0 ;
432
- }
433
-
434
- if (!secp256k1_ecmult_strauss_wnaf (& state , r , n_points , & secp256k1_ecmult_adaptor_cb , & adaptor_data , cb_offset , inp_g_sc )) {
425
+ if (state .aux == NULL || state .pre_a == NULL || state .ps == NULL ||
426
+ !secp256k1_ecmult_strauss_wnaf (& state , r , n_points , & secp256k1_ecmult_adaptor_cb , & adaptor_data , cb_offset , inp_g_sc )) {
435
427
secp256k1_scratch_apply_checkpoint (error_callback , scratch , scratch_checkpoint );
436
428
return 0 ;
437
429
}
0 commit comments