From 14c9739a1fb485bb56dbe3447132a37bcbef4e22 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Wed, 5 May 2021 09:38:22 +0200 Subject: [PATCH] tests: Improve secp256k1_ge_set_all_gej_var for some infinity inputs --- src/tests.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tests.c b/src/tests.c index 4078600..2764bc6 100644 --- a/src/tests.c +++ b/src/tests.c @@ -3101,14 +3101,17 @@ void test_ge(void) { /* Test batch gej -> ge conversion with many infinities. */ for (i = 0; i < 4 * runs + 1; i++) { + int odd; random_group_element_test(&ge[i]); + odd = secp256k1_fe_is_odd(&ge[i].x); + CHECK(odd == 0 || odd == 1); /* randomly set half the points to infinity */ - if(secp256k1_fe_is_odd(&ge[i].x)) { + if (odd == i % 2) { secp256k1_ge_set_infinity(&ge[i]); } secp256k1_gej_set_ge(&gej[i], &ge[i]); } - /* batch invert */ + /* batch convert */ secp256k1_ge_set_all_gej_var(ge, gej, 4 * runs + 1); /* check result */ for (i = 0; i < 4 * runs + 1; i++) {