@@ -60,7 +60,7 @@ void test_ecdh_generator_basepoint(void) {
60
60
61
61
s_one [31 ] = 1 ;
62
62
/* 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 ) {
64
64
secp256k1_sha256 sha ;
65
65
unsigned char s_b32 [32 ];
66
66
unsigned char output_ecdh [65 ];
@@ -72,20 +72,20 @@ void test_ecdh_generator_basepoint(void) {
72
72
random_scalar_order (& s );
73
73
secp256k1_scalar_get_b32 (s_b32 , & s );
74
74
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 );
77
77
78
78
/* 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 );
80
80
/* 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 );
82
82
/* compare */
83
83
CHECK (secp256k1_memcmp_var (output_ecdh , point_ser , 65 ) == 0 );
84
84
85
85
/* 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 );
87
87
/* 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 );
89
89
secp256k1_sha256_initialize (& sha );
90
90
secp256k1_sha256_write (& sha , point_ser , point_ser_len );
91
91
secp256k1_sha256_finalize (& sha , output_ser );
@@ -110,17 +110,17 @@ void test_bad_scalar(void) {
110
110
/* Create random point */
111
111
random_scalar_order (& rand );
112
112
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 );
114
114
115
115
/* 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 );
118
118
/* ...and a good one */
119
119
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 );
121
121
122
122
/* 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 );
124
124
}
125
125
126
126
/** 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) {
136
136
137
137
unsigned char s_one [32 ] = { 0 };
138
138
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 );
141
141
142
- for (i = 0 ; i < 2 * count ; i ++ ) {
142
+ for (i = 0 ; i < 2 * COUNT ; i ++ ) {
143
143
random_scalar_order (& rand );
144
144
secp256k1_scalar_get_b32 (s , & rand );
145
145
secp256k1_scalar_inverse (& rand , & rand );
146
146
secp256k1_scalar_get_b32 (s_inv , & rand );
147
147
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 );
150
150
CHECK (secp256k1_memcmp_var (out , out_base , 32 ) == 0 );
151
151
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 );
154
154
CHECK (secp256k1_memcmp_var (out_inv , out_base , 32 ) == 0 );
155
155
}
156
156
}
0 commit comments