Skip to content

Commit

Permalink
Have secp256k1_ge_set_all_gej_var initialize all fields.
Browse files Browse the repository at this point in the history
Previous behaviour would not initialize r->y values in the case where infinity is passed in.
Furthermore, the previous behaviour wouldn't initialize anything in the case where all inputs were infinity.
  • Loading branch information
roconnor-blockstream committed May 4, 2021
1 parent 31c0f6d commit 45b6468
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/group_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ static void secp256k1_ge_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a
size_t last_i = SIZE_MAX;

for (i = 0; i < len; i++) {
if (!a[i].infinity) {
if (a[i].infinity) {
secp256k1_ge_set_infinity(&r[i]);
} else {
/* Use destination's x coordinates as scratch space */
if (last_i == SIZE_MAX) {
r[i].x = a[i].z;
Expand Down Expand Up @@ -147,7 +149,6 @@ static void secp256k1_ge_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a
r[last_i].x = u;

for (i = 0; i < len; i++) {
r[i].infinity = a[i].infinity;
if (!a[i].infinity) {
secp256k1_ge_set_gej_zinv(&r[i], &a[i], &r[i].x);
}
Expand Down

0 comments on commit 45b6468

Please sign in to comment.