@@ -117,26 +117,56 @@ impl<C: Signing> Secp256k1<C> {
117
117
/// generator to generate the auxiliary random data.
118
118
/// Requires compilation with "rand-std" feature.
119
119
#[ cfg( any( test, feature = "rand-std" ) ) ]
120
+ #[ deprecated( since = "0.21.0" , note = "Use sign_schnorr instead." ) ]
120
121
pub fn schnorrsig_sign ( & self , msg : & Message , keypair : & KeyPair ) -> Signature {
122
+ self . sign_schnorr ( msg, keypair)
123
+ }
124
+
125
+ /// Create a schnorr signature internally using the ThreadRng random number
126
+ /// generator to generate the auxiliary random data.
127
+ /// Requires compilation with "rand-std" feature.
128
+ #[ cfg( any( test, feature = "rand-std" ) ) ]
129
+ pub fn sign_schnorr ( & self , msg : & Message , keypair : & KeyPair ) -> Signature {
121
130
let mut rng = thread_rng ( ) ;
122
- self . schnorrsig_sign_with_rng ( msg, keypair, & mut rng)
131
+ self . sign_schnorr_with_rng ( msg, keypair, & mut rng)
123
132
}
124
133
125
134
/// Create a schnorr signature without using any auxiliary random data.
135
+ #[ deprecated( since = "0.21.0" , note = "Use sign_schnorr_no_aux_rand instead." ) ]
126
136
pub fn schnorrsig_sign_no_aux_rand (
127
137
& self ,
128
138
msg : & Message ,
129
139
keypair : & KeyPair ,
140
+ ) -> Signature {
141
+ self . sign_schnorr_no_aux_rand ( msg, keypair)
142
+ }
143
+
144
+ /// Create a schnorr signature without using any auxiliary random data.
145
+ pub fn sign_schnorr_no_aux_rand (
146
+ & self ,
147
+ msg : & Message ,
148
+ keypair : & KeyPair ,
130
149
) -> Signature {
131
150
self . schnorrsig_sign_helper ( msg, keypair, ptr:: null ( ) )
132
151
}
133
152
134
153
/// Create a Schnorr signature using the given auxiliary random data.
154
+ #[ deprecated( since = "0.21.0" , note = "Use sign_schnorr_with_aux_rand instead." ) ]
135
155
pub fn schnorrsig_sign_with_aux_rand (
136
156
& self ,
137
157
msg : & Message ,
138
158
keypair : & KeyPair ,
139
159
aux_rand : & [ u8 ; 32 ] ,
160
+ ) -> Signature {
161
+ self . sign_schnorr_with_aux_rand ( msg, keypair, aux_rand)
162
+ }
163
+
164
+ /// Create a Schnorr signature using the given auxiliary random data.
165
+ pub fn sign_schnorr_with_aux_rand (
166
+ & self ,
167
+ msg : & Message ,
168
+ keypair : & KeyPair ,
169
+ aux_rand : & [ u8 ; 32 ] ,
140
170
) -> Signature {
141
171
self . schnorrsig_sign_helper (
142
172
msg,
@@ -149,23 +179,48 @@ impl<C: Signing> Secp256k1<C> {
149
179
/// generate the auxiliary random data. Requires compilation with "rand"
150
180
/// feature.
151
181
#[ cfg( any( test, feature = "rand" ) ) ]
182
+ #[ deprecated( since = "0.21.0" , note = "Use sign_schnorr_with_rng instead." ) ]
152
183
pub fn schnorrsig_sign_with_rng < R : Rng + CryptoRng > (
153
184
& self ,
154
185
msg : & Message ,
155
186
keypair : & KeyPair ,
156
187
rng : & mut R ,
188
+ ) -> Signature {
189
+ self . sign_schnorr_with_rng ( msg, keypair, rng)
190
+ }
191
+
192
+ /// Create a schnorr signature using the given random number generator to
193
+ /// generate the auxiliary random data. Requires compilation with "rand"
194
+ /// feature.
195
+ #[ cfg( any( test, feature = "rand" ) ) ]
196
+ pub fn sign_schnorr_with_rng < R : Rng + CryptoRng > (
197
+ & self ,
198
+ msg : & Message ,
199
+ keypair : & KeyPair ,
200
+ rng : & mut R ,
157
201
) -> Signature {
158
202
let mut aux = [ 0u8 ; 32 ] ;
159
203
rng. fill_bytes ( & mut aux) ;
160
204
self . schnorrsig_sign_helper ( msg, keypair, aux. as_c_ptr ( ) as * const ffi:: types:: c_void )
161
205
}
162
206
163
207
/// Verify a Schnorr signature.
208
+ #[ deprecated( since = "0.21.0" , note = "Use verify_schnorr instead." ) ]
164
209
pub fn schnorrsig_verify (
165
210
& self ,
166
211
sig : & Signature ,
167
212
msg : & Message ,
168
213
pubkey : & XOnlyPublicKey ,
214
+ ) -> Result < ( ) , Error > {
215
+ self . verify_schnorr ( sig, msg, pubkey)
216
+ }
217
+
218
+ /// Verify a Schnorr signature.
219
+ pub fn verify_schnorr (
220
+ & self ,
221
+ sig : & Signature ,
222
+ msg : & Message ,
223
+ pubkey : & XOnlyPublicKey ,
169
224
) -> Result < ( ) , Error > {
170
225
unsafe {
171
226
let ret = ffi:: secp256k1_schnorrsig_verify (
@@ -237,7 +292,7 @@ mod tests {
237
292
238
293
let sig = sign ( & secp, & msg, & seckey, & mut rng) ;
239
294
240
- assert ! ( secp. schnorrsig_verify ( & sig, & msg, & pubkey) . is_ok( ) ) ;
295
+ assert ! ( secp. verify_schnorr ( & sig, & msg, & pubkey) . is_ok( ) ) ;
241
296
}
242
297
}
243
298
@@ -246,28 +301,28 @@ mod tests {
246
301
test_schnorrsig_sign_helper ( |secp, msg, seckey, rng| {
247
302
let mut aux_rand = [ 0u8 ; 32 ] ;
248
303
rng. fill_bytes ( & mut aux_rand) ;
249
- secp. schnorrsig_sign_with_aux_rand ( msg, seckey, & aux_rand)
304
+ secp. sign_schnorr_with_aux_rand ( msg, seckey, & aux_rand)
250
305
} )
251
306
}
252
307
253
308
#[ test]
254
309
fn test_schnorrsig_sign_with_rng_verify ( ) {
255
310
test_schnorrsig_sign_helper ( |secp, msg, seckey, mut rng| {
256
- secp. schnorrsig_sign_with_rng ( msg, seckey, & mut rng)
311
+ secp. sign_schnorr_with_rng ( msg, seckey, & mut rng)
257
312
} )
258
313
}
259
314
260
315
#[ test]
261
316
fn test_schnorrsig_sign_verify ( ) {
262
317
test_schnorrsig_sign_helper ( |secp, msg, seckey, _| {
263
- secp. schnorrsig_sign ( msg, seckey)
318
+ secp. sign_schnorr ( msg, seckey)
264
319
} )
265
320
}
266
321
267
322
#[ test]
268
323
fn test_schnorrsig_sign_no_aux_rand_verify ( ) {
269
324
test_schnorrsig_sign_helper ( |secp, msg, seckey, _| {
270
- secp. schnorrsig_sign_no_aux_rand ( msg, seckey)
325
+ secp. sign_schnorr_no_aux_rand ( msg, seckey)
271
326
} )
272
327
}
273
328
@@ -288,7 +343,7 @@ mod tests {
288
343
let expected_sig = Signature :: from_str ( "6470FD1303DDA4FDA717B9837153C24A6EAB377183FC438F939E0ED2B620E9EE5077C4A8B8DCA28963D772A94F5F0DDF598E1C47C137F91933274C7C3EDADCE8" ) . unwrap ( ) ;
289
344
290
345
let sig = secp
291
- . schnorrsig_sign_with_aux_rand ( & msg, & sk, & aux_rand) ;
346
+ . sign_schnorr_with_aux_rand ( & msg, & sk, & aux_rand) ;
292
347
293
348
assert_eq ! ( expected_sig, sig) ;
294
349
}
@@ -305,7 +360,7 @@ mod tests {
305
360
XOnlyPublicKey :: from_str ( "B33CC9EDC096D0A83416964BD3C6247B8FECD256E4EFA7870D2C854BDEB33390" )
306
361
. unwrap ( ) ;
307
362
308
- assert ! ( secp. schnorrsig_verify ( & sig, & msg, & pubkey) . is_ok( ) ) ;
363
+ assert ! ( secp. verify_schnorr ( & sig, & msg, & pubkey) . is_ok( ) ) ;
309
364
}
310
365
311
366
#[ test]
@@ -469,7 +524,7 @@ mod tests {
469
524
let keypair = KeyPair :: from_seckey_slice ( & s, & [ 2 ; 32 ] ) . unwrap ( ) ;
470
525
let aux = [ 3u8 ; 32 ] ;
471
526
let sig = s
472
- . schnorrsig_sign_with_aux_rand ( & msg, & keypair, & aux) ;
527
+ . sign_schnorr_with_aux_rand ( & msg, & keypair, & aux) ;
473
528
static SIG_BYTES : [ u8 ; constants:: SCHNORRSIG_SIGNATURE_SIZE ] = [
474
529
0x14 , 0xd0 , 0xbf , 0x1a , 0x89 , 0x53 , 0x50 , 0x6f , 0xb4 , 0x60 , 0xf5 , 0x8b , 0xe1 , 0x41 ,
475
530
0xaf , 0x76 , 0x7f , 0xd1 , 0x12 , 0x53 , 0x5f , 0xb3 , 0x92 , 0x2e , 0xf2 , 0x17 , 0x30 , 0x8e ,
0 commit comments