@@ -2258,6 +2258,39 @@ void test_ge(void) {
2258
2258
free (zinv );
2259
2259
}
2260
2260
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
+
2261
2294
void test_add_neg_y_diff_x (void ) {
2262
2295
/* The point of this test is to check that we can add two points
2263
2296
* whose y-coordinates are negatives of each other but whose x
@@ -2331,6 +2364,7 @@ void run_ge(void) {
2331
2364
test_ge ();
2332
2365
}
2333
2366
test_add_neg_y_diff_x ();
2367
+ test_intialized_inf ();
2334
2368
}
2335
2369
2336
2370
void test_ec_combine (void ) {
0 commit comments