From ffd3b346fe7250c488e6d3c8653c314cb00722a0 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Wed, 17 Oct 2018 19:50:37 +0000 Subject: [PATCH] add `secp256k1_ge_set_all_gej_var` test which deals with many infinite points --- src/tests.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/tests.c b/src/tests.c index 3414a0f4cee3c..61bb7fce8727e 100644 --- a/src/tests.c +++ b/src/tests.c @@ -2113,6 +2113,22 @@ void test_ge(void) { free(zr); } + /* Test batch gej -> ge conversion with many infinities. */ + for (i = 0; i < 4 * runs + 1; i++) { + random_group_element_test(&ge[i]); + /* randomly set half the points to infinitiy */ + if(secp256k1_fe_is_odd(&ge[i].x)) { + secp256k1_ge_set_infinity(&ge[i]); + } + secp256k1_gej_set_ge(&gej[i], &ge[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); free(zinv);