@@ -60,7 +60,7 @@ void test_ecdh_generator_basepoint(void) {
6060
6161 s_one [31 ] = 1 ;
6262 /* Check against pubkey creation when the basepoint is the generator */
63- for (i = 0 ; i < 2 * count ; ++ i ) {
63+ for (i = 0 ; i < 2 * COUNT ; ++ i ) {
6464 secp256k1_sha256 sha ;
6565 unsigned char s_b32 [32 ];
6666 unsigned char output_ecdh [65 ];
@@ -72,20 +72,20 @@ void test_ecdh_generator_basepoint(void) {
7272 random_scalar_order (& s );
7373 secp256k1_scalar_get_b32 (s_b32 , & s );
7474
75- CHECK (secp256k1_ec_pubkey_create (ctx , & point [0 ], s_one ) == 1 );
76- CHECK (secp256k1_ec_pubkey_create (ctx , & point [1 ], s_b32 ) == 1 );
75+ CHECK (secp256k1_ec_pubkey_create (CTX , & point [0 ], s_one ) == 1 );
76+ CHECK (secp256k1_ec_pubkey_create (CTX , & point [1 ], s_b32 ) == 1 );
7777
7878 /* compute using ECDH function with custom hash function */
79- CHECK (secp256k1_ecdh (ctx , output_ecdh , & point [0 ], s_b32 , ecdh_hash_function_custom , NULL ) == 1 );
79+ CHECK (secp256k1_ecdh (CTX , output_ecdh , & point [0 ], s_b32 , ecdh_hash_function_custom , NULL ) == 1 );
8080 /* compute "explicitly" */
81- CHECK (secp256k1_ec_pubkey_serialize (ctx , point_ser , & point_ser_len , & point [1 ], SECP256K1_EC_UNCOMPRESSED ) == 1 );
81+ CHECK (secp256k1_ec_pubkey_serialize (CTX , point_ser , & point_ser_len , & point [1 ], SECP256K1_EC_UNCOMPRESSED ) == 1 );
8282 /* compare */
8383 CHECK (secp256k1_memcmp_var (output_ecdh , point_ser , 65 ) == 0 );
8484
8585 /* compute using ECDH function with default hash function */
86- CHECK (secp256k1_ecdh (ctx , output_ecdh , & point [0 ], s_b32 , NULL , NULL ) == 1 );
86+ CHECK (secp256k1_ecdh (CTX , output_ecdh , & point [0 ], s_b32 , NULL , NULL ) == 1 );
8787 /* compute "explicitly" */
88- CHECK (secp256k1_ec_pubkey_serialize (ctx , point_ser , & point_ser_len , & point [1 ], SECP256K1_EC_COMPRESSED ) == 1 );
88+ CHECK (secp256k1_ec_pubkey_serialize (CTX , point_ser , & point_ser_len , & point [1 ], SECP256K1_EC_COMPRESSED ) == 1 );
8989 secp256k1_sha256_initialize (& sha );
9090 secp256k1_sha256_write (& sha , point_ser , point_ser_len );
9191 secp256k1_sha256_finalize (& sha , output_ser );
@@ -110,17 +110,17 @@ void test_bad_scalar(void) {
110110 /* Create random point */
111111 random_scalar_order (& rand );
112112 secp256k1_scalar_get_b32 (s_rand , & rand );
113- CHECK (secp256k1_ec_pubkey_create (ctx , & point , s_rand ) == 1 );
113+ CHECK (secp256k1_ec_pubkey_create (CTX , & point , s_rand ) == 1 );
114114
115115 /* Try to multiply it by bad values */
116- CHECK (secp256k1_ecdh (ctx , output , & point , s_zero , NULL , NULL ) == 0 );
117- CHECK (secp256k1_ecdh (ctx , output , & point , s_overflow , NULL , NULL ) == 0 );
116+ CHECK (secp256k1_ecdh (CTX , output , & point , s_zero , NULL , NULL ) == 0 );
117+ CHECK (secp256k1_ecdh (CTX , output , & point , s_overflow , NULL , NULL ) == 0 );
118118 /* ...and a good one */
119119 s_overflow [31 ] -= 1 ;
120- CHECK (secp256k1_ecdh (ctx , output , & point , s_overflow , NULL , NULL ) == 1 );
120+ CHECK (secp256k1_ecdh (CTX , output , & point , s_overflow , NULL , NULL ) == 1 );
121121
122122 /* Hash function failure results in ecdh failure */
123- CHECK (secp256k1_ecdh (ctx , output , & point , s_overflow , ecdh_hash_function_test_fail , NULL ) == 0 );
123+ CHECK (secp256k1_ecdh (CTX , output , & point , s_overflow , ecdh_hash_function_test_fail , NULL ) == 0 );
124124}
125125
126126/** Test that ECDH(sG, 1/s) == ECDH((1/s)G, s) == ECDH(G, 1) for a few random s. */
@@ -136,21 +136,21 @@ void test_result_basepoint(void) {
136136
137137 unsigned char s_one [32 ] = { 0 };
138138 s_one [31 ] = 1 ;
139- CHECK (secp256k1_ec_pubkey_create (ctx , & point , s_one ) == 1 );
140- CHECK (secp256k1_ecdh (ctx , out_base , & point , s_one , NULL , NULL ) == 1 );
139+ CHECK (secp256k1_ec_pubkey_create (CTX , & point , s_one ) == 1 );
140+ CHECK (secp256k1_ecdh (CTX , out_base , & point , s_one , NULL , NULL ) == 1 );
141141
142- for (i = 0 ; i < 2 * count ; i ++ ) {
142+ for (i = 0 ; i < 2 * COUNT ; i ++ ) {
143143 random_scalar_order (& rand );
144144 secp256k1_scalar_get_b32 (s , & rand );
145145 secp256k1_scalar_inverse (& rand , & rand );
146146 secp256k1_scalar_get_b32 (s_inv , & rand );
147147
148- CHECK (secp256k1_ec_pubkey_create (ctx , & point , s ) == 1 );
149- CHECK (secp256k1_ecdh (ctx , out , & point , s_inv , NULL , NULL ) == 1 );
148+ CHECK (secp256k1_ec_pubkey_create (CTX , & point , s ) == 1 );
149+ CHECK (secp256k1_ecdh (CTX , out , & point , s_inv , NULL , NULL ) == 1 );
150150 CHECK (secp256k1_memcmp_var (out , out_base , 32 ) == 0 );
151151
152- CHECK (secp256k1_ec_pubkey_create (ctx , & point , s_inv ) == 1 );
153- CHECK (secp256k1_ecdh (ctx , out_inv , & point , s , NULL , NULL ) == 1 );
152+ CHECK (secp256k1_ec_pubkey_create (CTX , & point , s_inv ) == 1 );
153+ CHECK (secp256k1_ecdh (CTX , out_inv , & point , s , NULL , NULL ) == 1 );
154154 CHECK (secp256k1_memcmp_var (out_inv , out_base , 32 ) == 0 );
155155 }
156156}
0 commit comments