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
@@ -381,7 +381,7 @@ static void secp256k1_ecmult(secp256k1_gej *r, const secp256k1_gej *a, const sec
381
381
}
382
382
383
383
static size_t secp256k1_strauss_scratch_size (size_t n_points ) {
384
- 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 ) ;
384
+ static const size_t point_size = (sizeof (secp256k1_ge ) + sizeof (secp256k1_fe )) * ECMULT_TABLE_SIZE (WINDOW_A ) + sizeof (struct secp256k1_strauss_point_state );
385
385
return n_points * point_size ;
386
386
}
387
387
@@ -403,8 +403,6 @@ static int secp256k1_ecmult_adaptor_cb(secp256k1_scalar *sc, secp256k1_gej *pt,
403
403
}
404
404
405
405
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 ) {
406
- secp256k1_gej * points ;
407
- secp256k1_scalar * scalars ;
408
406
struct secp256k1_ecmult_adaptor_cb_data adaptor_data ;
409
407
struct secp256k1_strauss_state state ;
410
408
const size_t scratch_checkpoint = secp256k1_scratch_checkpoint (error_callback , scratch );
@@ -417,20 +415,14 @@ static int secp256k1_ecmult_strauss_batch(const secp256k1_callback* error_callba
417
415
/* We allocate STRAUSS_SCRATCH_OBJECTS objects on the scratch space. If these
418
416
* allocations change, make sure to update the STRAUSS_SCRATCH_OBJECTS
419
417
* constant and strauss_scratch_size accordingly. */
420
- points = (secp256k1_gej * )secp256k1_scratch_alloc (error_callback , scratch , n_points * sizeof (secp256k1_gej ));
421
- scalars = (secp256k1_scalar * )secp256k1_scratch_alloc (error_callback , scratch , n_points * sizeof (secp256k1_scalar ));
422
418
adaptor_data .cb = cb ;
423
419
adaptor_data .data = cbdata ;
424
420
state .aux = (secp256k1_fe * )secp256k1_scratch_alloc (error_callback , scratch , n_points * ECMULT_TABLE_SIZE (WINDOW_A ) * sizeof (secp256k1_fe ));
425
421
state .pre_a = (secp256k1_ge * )secp256k1_scratch_alloc (error_callback , scratch , n_points * ECMULT_TABLE_SIZE (WINDOW_A ) * sizeof (secp256k1_ge ));
426
422
state .ps = (struct secp256k1_strauss_point_state * )secp256k1_scratch_alloc (error_callback , scratch , n_points * sizeof (struct secp256k1_strauss_point_state ));
427
423
428
- if (points == NULL || scalars == NULL || state .aux == NULL || state .pre_a == NULL || state .ps == NULL ) {
429
- secp256k1_scratch_apply_checkpoint (error_callback , scratch , scratch_checkpoint );
430
- return 0 ;
431
- }
432
-
433
- if (!secp256k1_ecmult_strauss_wnaf (& state , r , n_points , & secp256k1_ecmult_adaptor_cb , & adaptor_data , cb_offset , inp_g_sc )) {
424
+ if (state .aux == NULL || state .pre_a == NULL || state .ps == NULL ||
425
+ !secp256k1_ecmult_strauss_wnaf (& state , r , n_points , & secp256k1_ecmult_adaptor_cb , & adaptor_data , cb_offset , inp_g_sc )) {
434
426
secp256k1_scratch_apply_checkpoint (error_callback , scratch , scratch_checkpoint );
435
427
return 0 ;
436
428
}
0 commit comments