Skip to content

Commit

Permalink
Merge pull request #1 from real-or-random/20210504_ge_set_gej_var
Browse files Browse the repository at this point in the history
20210504 ge set gej var
  • Loading branch information
roconnor-blockstream committed May 5, 2021
2 parents 45b6468 + ebdb8f4 commit d5c10f8
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -3103,8 +3103,13 @@ void test_ge(void) {
for (i = 0; i < 4 * runs + 1; i++) {
random_group_element_test(&ge[i]);
/* randomly set half the points to infinity */
if(secp256k1_fe_is_odd(&ge[i].x)) {
secp256k1_ge_set_infinity(&ge[i]);
if (secp256k1_fe_is_odd(&ge[i].x) == i % 2) {
secp256k1_ge_set_infinity(&ge[i]);
}
int odd = secp256k1_fe_is_odd(&ge[i].x);
CHECK(odd == 0 || odd == 1);
if (!!secp256k1_fe_is_odd(&ge[i].x) == i % 2) {
secp256k1_ge_set_infinity(&ge[i]);
}
secp256k1_gej_set_ge(&gej[i], &ge[i]);
}
Expand All @@ -3115,6 +3120,17 @@ void test_ge(void) {
ge_equals_gej(&ge[i], &gej[i]);
}

/* Test batch gej -> ge conversion with all infinities. */
for (i = 0; i < 4 * runs + 1; i++) {
secp256k1_gej_set_infinity(&gej[i]);
}
/* batch invert */
secp256k1_ge_set_all_gej_var(ge, gej, 4 * runs + 1);
/* check result */
for (i = 0; i < 4 * runs + 1; i++) {
ge_equals_gej(&ge[i], &gej[i]);
}

free(ge);
free(gej);
}
Expand Down

0 comments on commit d5c10f8

Please sign in to comment.