File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -794,13 +794,16 @@ void run_ecmult_chain(void) {
794794}
795795
796796void test_point_times_order (const secp256k1_gej_t * point ) {
797- /* multiplying a point by the order results in O */
798- const secp256k1_num_t * order = & secp256k1_ge_consts -> order ;
799- secp256k1_num_t zero ;
800- secp256k1_num_set_int (& zero , 0 );
801- secp256k1_gej_t res ;
802- secp256k1_ecmult (& res , point , order , order ); /* calc res = order * point + order * G; */
803- CHECK (secp256k1_gej_is_infinity (& res ));
797+ /* X * (point + G) + (order-X) * (pointer + G) = 0 */
798+ secp256k1_num_t x ;
799+ random_num_order_test (& x );
800+ secp256k1_num_t nx ;
801+ secp256k1_num_sub (& nx , & secp256k1_ge_consts -> order , & x );
802+ secp256k1_gej_t res1 , res2 ;
803+ secp256k1_ecmult (& res1 , point , & x , & x ); /* calc res1 = x * point + x * G; */
804+ secp256k1_ecmult (& res2 , point , & nx , & nx ); /* calc res2 = (order - x) * point + (order - x) * G; */
805+ secp256k1_gej_add_var (& res1 , & res1 , & res2 );
806+ CHECK (secp256k1_gej_is_infinity (& res1 ));
804807}
805808
806809void run_point_times_order (void ) {
You can’t perform that action at this time.
0 commit comments