@@ -2258,6 +2258,39 @@ void test_ge(void) {
22582258 free (zinv );
22592259}
22602260
2261+
2262+ void test_intialized_inf (void ) {
2263+ secp256k1_ge p ;
2264+ secp256k1_gej pj , npj , infj1 , infj2 , infj3 ;
2265+ secp256k1_fe zinv ;
2266+
2267+ /* Test that adding P+(-P) results in a fully initalized infinity*/
2268+ random_group_element_test (& p );
2269+ secp256k1_gej_set_ge (& pj , & p );
2270+ secp256k1_gej_neg (& npj , & pj );
2271+
2272+ secp256k1_gej_add_var (& infj1 , & pj , & npj , NULL );
2273+ CHECK (secp256k1_gej_is_infinity (& infj1 ));
2274+ CHECK (secp256k1_fe_is_zero (& infj1 .x ));
2275+ CHECK (secp256k1_fe_is_zero (& infj1 .y ));
2276+ CHECK (secp256k1_fe_is_zero (& infj1 .z ));
2277+
2278+ secp256k1_gej_add_ge_var (& infj2 , & npj , & p , NULL );
2279+ CHECK (secp256k1_gej_is_infinity (& infj2 ));
2280+ CHECK (secp256k1_fe_is_zero (& infj2 .x ));
2281+ CHECK (secp256k1_fe_is_zero (& infj2 .y ));
2282+ CHECK (secp256k1_fe_is_zero (& infj2 .z ));
2283+
2284+ secp256k1_fe_set_int (& zinv , 1 );
2285+ secp256k1_gej_add_zinv_var (& infj3 , & npj , & p , & zinv );
2286+ CHECK (secp256k1_gej_is_infinity (& infj3 ));
2287+ CHECK (secp256k1_fe_is_zero (& infj3 .x ));
2288+ CHECK (secp256k1_fe_is_zero (& infj3 .y ));
2289+ CHECK (secp256k1_fe_is_zero (& infj3 .z ));
2290+
2291+
2292+ }
2293+
22612294void test_add_neg_y_diff_x (void ) {
22622295 /* The point of this test is to check that we can add two points
22632296 * whose y-coordinates are negatives of each other but whose x
@@ -2331,6 +2364,7 @@ void run_ge(void) {
23312364 test_ge ();
23322365 }
23332366 test_add_neg_y_diff_x ();
2367+ test_intialized_inf ();
23342368}
23352369
23362370void test_ec_combine (void ) {
0 commit comments