Skip to content

Commit 3bb7260

Browse files
Remove the unused prej allocations.
1 parent c531ff8 commit 3bb7260

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/ecmult_impl.h

+7-9
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@
7777

7878
#define ECMULT_MAX_POINTS_PER_BATCH 5000000
7979

80-
/** Fill a table 'prej' with precomputed odd multiples of a. Prej will contain
80+
/** Fill a table 'pre_a' with precomputed odd multiples of a. Pre_a will contain
8181
* the values [1*a,3*a,...,(2*n-1)*a], so it space for n values. zr[0] will
82-
* contain prej[0].z / a.z. The other zr[i] values = prej[i].z / prej[i-1].z.
83-
* Prej's Z values are undefined, except for the last value.
82+
* contain pre_a[0].z / a.z. The other zr[i] values = pre_a[i].z / pre_a[i-1].z.
83+
* The a value will end up equal to pre_a[(2*n-1)].
84+
* The output pre_a array will have their z-coordinate omitted.
85+
* The omitted z-coordinate are implied by the final a value's z-coordinate and the zr array.
8486
*/
8587
static void secp256k1_ecmult_odd_multiples_table(int n, secp256k1_ge *pre_a, secp256k1_fe *zr, secp256k1_gej *a) {
8688
secp256k1_gej d;
@@ -435,7 +437,6 @@ struct secp256k1_strauss_point_state {
435437
};
436438

437439
struct secp256k1_strauss_state {
438-
secp256k1_gej* prej;
439440
secp256k1_fe* zr;
440441
secp256k1_ge* pre_a;
441442
secp256k1_ge* pre_a_lam;
@@ -561,14 +562,12 @@ static void secp256k1_ecmult_strauss_wnaf(const secp256k1_ecmult_context *ctx, c
561562
}
562563

563564
static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng) {
564-
secp256k1_gej prej[ECMULT_TABLE_SIZE(WINDOW_A)];
565565
secp256k1_fe zr[ECMULT_TABLE_SIZE(WINDOW_A)];
566566
secp256k1_ge pre_a[ECMULT_TABLE_SIZE(WINDOW_A)];
567567
struct secp256k1_strauss_point_state ps[1];
568568
secp256k1_ge pre_a_lam[ECMULT_TABLE_SIZE(WINDOW_A)];
569569
struct secp256k1_strauss_state state;
570570

571-
state.prej = prej;
572571
state.zr = zr;
573572
state.pre_a = pre_a;
574573
state.pre_a_lam = pre_a_lam;
@@ -577,7 +576,7 @@ static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej
577576
}
578577

579578
static size_t secp256k1_strauss_scratch_size(size_t n_points) {
580-
static const size_t point_size = (2 * sizeof(secp256k1_ge) + sizeof(secp256k1_gej) + sizeof(secp256k1_fe)) * ECMULT_TABLE_SIZE(WINDOW_A) + sizeof(struct secp256k1_strauss_point_state) + sizeof(secp256k1_gej) + sizeof(secp256k1_scalar);
579+
static const size_t point_size = (2 * sizeof(secp256k1_ge) + sizeof(secp256k1_fe)) * ECMULT_TABLE_SIZE(WINDOW_A) + sizeof(struct secp256k1_strauss_point_state) + sizeof(secp256k1_gej) + sizeof(secp256k1_scalar);
581580
return n_points*point_size;
582581
}
583582

@@ -595,13 +594,12 @@ static int secp256k1_ecmult_strauss_batch(const secp256k1_callback* error_callba
595594

596595
points = (secp256k1_gej*)secp256k1_scratch_alloc(error_callback, scratch, n_points * sizeof(secp256k1_gej));
597596
scalars = (secp256k1_scalar*)secp256k1_scratch_alloc(error_callback, scratch, n_points * sizeof(secp256k1_scalar));
598-
state.prej = (secp256k1_gej*)secp256k1_scratch_alloc(error_callback, scratch, n_points * ECMULT_TABLE_SIZE(WINDOW_A) * sizeof(secp256k1_gej));
599597
state.zr = (secp256k1_fe*)secp256k1_scratch_alloc(error_callback, scratch, n_points * ECMULT_TABLE_SIZE(WINDOW_A) * sizeof(secp256k1_fe));
600598
state.pre_a = (secp256k1_ge*)secp256k1_scratch_alloc(error_callback, scratch, n_points * ECMULT_TABLE_SIZE(WINDOW_A) * sizeof(secp256k1_ge));
601599
state.pre_a_lam = (secp256k1_ge*)secp256k1_scratch_alloc(error_callback, scratch, n_points * ECMULT_TABLE_SIZE(WINDOW_A) * sizeof(secp256k1_ge));
602600
state.ps = (struct secp256k1_strauss_point_state*)secp256k1_scratch_alloc(error_callback, scratch, n_points * sizeof(struct secp256k1_strauss_point_state));
603601

604-
if (points == NULL || scalars == NULL || state.prej == NULL || state.zr == NULL || state.pre_a == NULL || state.pre_a_lam == NULL || state.ps == NULL) {
602+
if (points == NULL || scalars == NULL || state.zr == NULL || state.pre_a == NULL || state.pre_a_lam == NULL || state.ps == NULL) {
605603
secp256k1_scratch_apply_checkpoint(error_callback, scratch, scratch_checkpoint);
606604
return 0;
607605
}

0 commit comments

Comments
 (0)