Skip to content

Commit fcb614a

Browse files
Remove the unused points and scalars allocation from secp256k1_ecmult_strauss_batch.
1 parent ac2620d commit fcb614a

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/ecmult_impl.h

+3-11
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,11 @@ static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej
614614
}
615615

616616
static size_t secp256k1_strauss_scratch_size(size_t n_points) {
617-
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);
617+
static const size_t point_size = (sizeof(secp256k1_ge) + sizeof(secp256k1_fe)) * ECMULT_TABLE_SIZE(WINDOW_A) + sizeof(struct secp256k1_strauss_point_state);
618618
return n_points*point_size;
619619
}
620620

621621
static int secp256k1_ecmult_strauss_batch(const secp256k1_callback* error_callback, const secp256k1_ecmult_context *ctx, 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) {
622-
secp256k1_gej* points;
623-
secp256k1_scalar* scalars;
624622
struct secp256k1_strauss_state state;
625623
const size_t scratch_checkpoint = secp256k1_scratch_checkpoint(error_callback, scratch);
626624

@@ -629,18 +627,12 @@ static int secp256k1_ecmult_strauss_batch(const secp256k1_callback* error_callba
629627
return 1;
630628
}
631629

632-
points = (secp256k1_gej*)secp256k1_scratch_alloc(error_callback, scratch, n_points * sizeof(secp256k1_gej));
633-
scalars = (secp256k1_scalar*)secp256k1_scratch_alloc(error_callback, scratch, n_points * sizeof(secp256k1_scalar));
634630
state.aux = (secp256k1_fe*)secp256k1_scratch_alloc(error_callback, scratch, n_points * ECMULT_TABLE_SIZE(WINDOW_A) * sizeof(secp256k1_fe));
635631
state.pre_a = (secp256k1_ge*)secp256k1_scratch_alloc(error_callback, scratch, n_points * ECMULT_TABLE_SIZE(WINDOW_A) * sizeof(secp256k1_ge));
636632
state.ps = (struct secp256k1_strauss_point_state*)secp256k1_scratch_alloc(error_callback, scratch, n_points * sizeof(struct secp256k1_strauss_point_state));
637633

638-
if (points == NULL || scalars == NULL || state.aux == NULL || state.pre_a == NULL || state.ps == NULL) {
639-
secp256k1_scratch_apply_checkpoint(error_callback, scratch, scratch_checkpoint);
640-
return 0;
641-
}
642-
643-
if (!secp256k1_ecmult_strauss_wnaf(ctx, &state, r, n_points, cb, cbdata, cb_offset, NULL, inp_g_sc)) {
634+
if (state.aux == NULL || state.pre_a == NULL || state.ps == NULL ||
635+
!secp256k1_ecmult_strauss_wnaf(ctx, &state, r, n_points, cb, cbdata, cb_offset, NULL, inp_g_sc)) {
644636
secp256k1_scratch_apply_checkpoint(error_callback, scratch, scratch_checkpoint);
645637
return 0;
646638
}

0 commit comments

Comments
 (0)