@@ -72,17 +72,21 @@ void test_schnorrsig_api(secp256k1_scratch_space *scratch) {
72
72
CHECK (ecount == 2 );
73
73
CHECK (secp256k1_schnorrsig_sign (sign , NULL , & s2c_opening , msg , sk1 , s2c_data32 , NULL , NULL ) == 0 );
74
74
CHECK (ecount == 3 );
75
- CHECK (secp256k1_schnorrsig_sign (sign , & sig , NULL , msg , sk1 , s2c_data32 , NULL , NULL ) == 1 );
76
- CHECK (ecount == 3 );
77
- CHECK (secp256k1_schnorrsig_sign (sign , & sig , & s2c_opening , NULL , sk1 , s2c_data32 , NULL , NULL ) == 0 );
75
+ CHECK (secp256k1_schnorrsig_sign (sign , & sig , NULL , msg , sk1 , s2c_data32 , NULL , NULL ) == 0 );
78
76
CHECK (ecount == 4 );
79
- CHECK (secp256k1_schnorrsig_sign (sign , & sig , & s2c_opening , msg , NULL , s2c_data32 , NULL , NULL ) == 0 );
80
- CHECK (ecount == 5 );
81
- CHECK (secp256k1_schnorrsig_sign (sign , & sig , & s2c_opening , msg , sk1 , NULL , NULL , NULL ) == 1 );
77
+ CHECK (secp256k1_schnorrsig_sign (sign , & sig , & s2c_opening , NULL , sk1 , s2c_data32 , NULL , NULL ) == 0 );
82
78
CHECK (ecount == 5 );
79
+ CHECK (secp256k1_schnorrsig_sign (sign , & sig , & s2c_opening , msg , NULL , s2c_data32 , NULL , NULL ) == 0 );
80
+ CHECK (ecount == 6 );
81
+ CHECK (secp256k1_schnorrsig_sign (sign , & sig , & s2c_opening , msg , sk1 , NULL , NULL , NULL ) == 0 );
82
+ CHECK (ecount == 7 );
83
+ /* It's okay if both s2c_opening and s2c_data32 are NULL. It's just not okay if
84
+ * only a single one of them is NULL. */
85
+ CHECK (secp256k1_schnorrsig_sign (sign , & sig , NULL , msg , sk1 , NULL , NULL , NULL ) == 1 );
86
+ CHECK (ecount == 7 );
83
87
/* s2c commitments with a different nonce function than bipschnorr are not allowed */
84
88
CHECK (secp256k1_schnorrsig_sign (sign , & sig , & s2c_opening , msg , sk1 , s2c_data32 , secp256k1_nonce_function_rfc6979 , NULL ) == 0 );
85
- CHECK (ecount == 6 );
89
+ CHECK (ecount == 8 );
86
90
87
91
ecount = 0 ;
88
92
CHECK (secp256k1_schnorrsig_serialize (none , sig64 , & sig ) == 1 );
@@ -170,14 +174,12 @@ void test_schnorrsig_api(secp256k1_scratch_space *scratch) {
170
174
171
175
/* Helper function for schnorrsig_bip_vectors
172
176
* Signs the message and checks that it's the same as expected_sig. */
173
- void test_schnorrsig_bip_vectors_check_signing (const unsigned char * sk , const unsigned char * pk_serialized , const unsigned char * msg , const unsigned char * expected_sig , const int expected_nonce_is_negated ) {
177
+ void test_schnorrsig_bip_vectors_check_signing (const unsigned char * sk , const unsigned char * pk_serialized , const unsigned char * msg , const unsigned char * expected_sig ) {
174
178
secp256k1_schnorrsig sig ;
175
179
unsigned char serialized_sig [64 ];
176
180
secp256k1_pubkey pk ;
177
- secp256k1_s2c_opening s2c_opening ;
178
181
179
- CHECK (secp256k1_schnorrsig_sign (ctx , & sig , & s2c_opening , msg , sk , NULL , NULL , NULL ));
180
- CHECK (s2c_opening .nonce_is_negated == expected_nonce_is_negated );
182
+ CHECK (secp256k1_schnorrsig_sign (ctx , & sig , NULL , msg , sk , NULL , NULL , NULL ));
181
183
CHECK (secp256k1_schnorrsig_serialize (ctx , serialized_sig , & sig ));
182
184
CHECK (memcmp (serialized_sig , expected_sig , 64 ) == 0 );
183
185
@@ -240,7 +242,7 @@ void test_schnorrsig_bip_vectors(secp256k1_scratch_space *scratch) {
240
242
0x2C , 0xCD , 0x00 , 0x79 , 0xE1 , 0xF9 , 0x2A , 0xF1 ,
241
243
0x77 , 0xF7 , 0xF2 , 0x2C , 0xC1 , 0xDC , 0xED , 0x05
242
244
};
243
- test_schnorrsig_bip_vectors_check_signing (sk1 , pk1 , msg1 , sig1 , 1 );
245
+ test_schnorrsig_bip_vectors_check_signing (sk1 , pk1 , msg1 , sig1 );
244
246
test_schnorrsig_bip_vectors_check_verify (scratch , pk1 , msg1 , sig1 , 1 );
245
247
}
246
248
{
@@ -274,7 +276,7 @@ void test_schnorrsig_bip_vectors(secp256k1_scratch_space *scratch) {
274
276
0x5F , 0xFC , 0x2D , 0x03 , 0x5A , 0x23 , 0x04 , 0x34 ,
275
277
0xA1 , 0xA6 , 0x4D , 0xC5 , 0x9F , 0x70 , 0x13 , 0xFD
276
278
};
277
- test_schnorrsig_bip_vectors_check_signing (sk2 , pk2 , msg2 , sig2 , 0 );
279
+ test_schnorrsig_bip_vectors_check_signing (sk2 , pk2 , msg2 , sig2 );
278
280
test_schnorrsig_bip_vectors_check_verify (scratch , pk2 , msg2 , sig2 , 1 );
279
281
}
280
282
{
@@ -308,7 +310,7 @@ void test_schnorrsig_bip_vectors(secp256k1_scratch_space *scratch) {
308
310
0xA5 , 0x83 , 0x7E , 0xC5 , 0x7F , 0xED , 0x76 , 0x60 ,
309
311
0x77 , 0x3A , 0x05 , 0xF0 , 0xDE , 0x14 , 0x23 , 0x80
310
312
};
311
- test_schnorrsig_bip_vectors_check_signing (sk3 , pk3 , msg3 , sig3 , 0 );
313
+ test_schnorrsig_bip_vectors_check_signing (sk3 , pk3 , msg3 , sig3 );
312
314
test_schnorrsig_bip_vectors_check_verify (scratch , pk3 , msg3 , sig3 , 1 );
313
315
}
314
316
{
0 commit comments