Skip to content

Commit 84740ac

Browse files
committed
ecmult_impl: save one fe_inv_var
1 parent 4704527 commit 84740ac

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/ecmult_impl.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ static void secp256k1_ecmult_odd_multiples_table_storage_var(const int n, secp25
183183
}
184184

185185
/* Map `pj` back to our curve by multiplying its z-coordinate by `d.z`. */
186+
zr = pj.z; /* save pj.z so we can use it to extract (d.z)^-1 from zi */
186187
secp256k1_fe_mul(&pj.z, &pj.z, &d.z);
187188
/* Directly set `pre[n - 1]` to `pj`, saving the inverted z-coordinate so
188189
* that we can combine it with the saved z-ratios to compute the other zs
@@ -193,7 +194,7 @@ static void secp256k1_ecmult_odd_multiples_table_storage_var(const int n, secp25
193194
secp256k1_ge_to_storage(&pre[n - 1], &p_ge);
194195

195196
/* Compute the actual x-coordinate of D, which will be needed below. */
196-
secp256k1_fe_inv_var(&d.z, &d.z);
197+
secp256k1_fe_mul(&d.z, &zi, &zr); /* d.z = 1/d.z */
197198
secp256k1_fe_sqr(&dx_over_dz_squared, &d.z);
198199
secp256k1_fe_mul(&dx_over_dz_squared, &dx_over_dz_squared, &d.x);
199200

0 commit comments

Comments
 (0)