@@ -117,26 +117,56 @@ impl<C: Signing> Secp256k1<C> {
117117 /// generator to generate the auxiliary random data.
118118 /// Requires compilation with "rand-std" feature.
119119 #[ cfg( any( test, feature = "rand-std" ) ) ]
120+ #[ deprecated( since = "0.21.0" , note = "Use sign_schnorr instead." ) ]
120121 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 {
121130 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)
123132 }
124133
125134 /// Create a schnorr signature without using any auxiliary random data.
135+ #[ deprecated( since = "0.21.0" , note = "Use sign_schnorr_no_aux_rand instead." ) ]
126136 pub fn schnorrsig_sign_no_aux_rand (
127137 & self ,
128138 msg : & Message ,
129139 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 ,
130149 ) -> Signature {
131150 self . schnorrsig_sign_helper ( msg, keypair, ptr:: null ( ) )
132151 }
133152
134153 /// Create a Schnorr signature using the given auxiliary random data.
154+ #[ deprecated( since = "0.21.0" , note = "Use sign_schnorr_with_aux_rand instead." ) ]
135155 pub fn schnorrsig_sign_with_aux_rand (
136156 & self ,
137157 msg : & Message ,
138158 keypair : & KeyPair ,
139159 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 ] ,
140170 ) -> Signature {
141171 self . schnorrsig_sign_helper (
142172 msg,
@@ -149,23 +179,48 @@ impl<C: Signing> Secp256k1<C> {
149179 /// generate the auxiliary random data. Requires compilation with "rand"
150180 /// feature.
151181 #[ cfg( any( test, feature = "rand" ) ) ]
182+ #[ deprecated( since = "0.21.0" , note = "Use sign_schnorr_with_rng instead." ) ]
152183 pub fn schnorrsig_sign_with_rng < R : Rng + CryptoRng > (
153184 & self ,
154185 msg : & Message ,
155186 keypair : & KeyPair ,
156187 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 ,
157201 ) -> Signature {
158202 let mut aux = [ 0u8 ; 32 ] ;
159203 rng. fill_bytes ( & mut aux) ;
160204 self . schnorrsig_sign_helper ( msg, keypair, aux. as_c_ptr ( ) as * const ffi:: types:: c_void )
161205 }
162206
163207 /// Verify a Schnorr signature.
208+ #[ deprecated( since = "0.21.0" , note = "Use verify_schnorr instead." ) ]
164209 pub fn schnorrsig_verify (
165210 & self ,
166211 sig : & Signature ,
167212 msg : & Message ,
168213 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 ,
169224 ) -> Result < ( ) , Error > {
170225 unsafe {
171226 let ret = ffi:: secp256k1_schnorrsig_verify (
@@ -237,7 +292,7 @@ mod tests {
237292
238293 let sig = sign ( & secp, & msg, & seckey, & mut rng) ;
239294
240- assert ! ( secp. schnorrsig_verify ( & sig, & msg, & pubkey) . is_ok( ) ) ;
295+ assert ! ( secp. verify_schnorr ( & sig, & msg, & pubkey) . is_ok( ) ) ;
241296 }
242297 }
243298
@@ -246,28 +301,28 @@ mod tests {
246301 test_schnorrsig_sign_helper ( |secp, msg, seckey, rng| {
247302 let mut aux_rand = [ 0u8 ; 32 ] ;
248303 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)
250305 } )
251306 }
252307
253308 #[ test]
254309 fn test_schnorrsig_sign_with_rng_verify ( ) {
255310 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)
257312 } )
258313 }
259314
260315 #[ test]
261316 fn test_schnorrsig_sign_verify ( ) {
262317 test_schnorrsig_sign_helper ( |secp, msg, seckey, _| {
263- secp. schnorrsig_sign ( msg, seckey)
318+ secp. sign_schnorr ( msg, seckey)
264319 } )
265320 }
266321
267322 #[ test]
268323 fn test_schnorrsig_sign_no_aux_rand_verify ( ) {
269324 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)
271326 } )
272327 }
273328
@@ -288,7 +343,7 @@ mod tests {
288343 let expected_sig = Signature :: from_str ( "6470FD1303DDA4FDA717B9837153C24A6EAB377183FC438F939E0ED2B620E9EE5077C4A8B8DCA28963D772A94F5F0DDF598E1C47C137F91933274C7C3EDADCE8" ) . unwrap ( ) ;
289344
290345 let sig = secp
291- . schnorrsig_sign_with_aux_rand ( & msg, & sk, & aux_rand) ;
346+ . sign_schnorr_with_aux_rand ( & msg, & sk, & aux_rand) ;
292347
293348 assert_eq ! ( expected_sig, sig) ;
294349 }
@@ -305,7 +360,7 @@ mod tests {
305360 XOnlyPublicKey :: from_str ( "B33CC9EDC096D0A83416964BD3C6247B8FECD256E4EFA7870D2C854BDEB33390" )
306361 . unwrap ( ) ;
307362
308- assert ! ( secp. schnorrsig_verify ( & sig, & msg, & pubkey) . is_ok( ) ) ;
363+ assert ! ( secp. verify_schnorr ( & sig, & msg, & pubkey) . is_ok( ) ) ;
309364 }
310365
311366 #[ test]
@@ -469,7 +524,7 @@ mod tests {
469524 let keypair = KeyPair :: from_seckey_slice ( & s, & [ 2 ; 32 ] ) . unwrap ( ) ;
470525 let aux = [ 3u8 ; 32 ] ;
471526 let sig = s
472- . schnorrsig_sign_with_aux_rand ( & msg, & keypair, & aux) ;
527+ . sign_schnorr_with_aux_rand ( & msg, & keypair, & aux) ;
473528 static SIG_BYTES : [ u8 ; constants:: SCHNORRSIG_SIGNATURE_SIZE ] = [
474529 0x14 , 0xd0 , 0xbf , 0x1a , 0x89 , 0x53 , 0x50 , 0x6f , 0xb4 , 0x60 , 0xf5 , 0x8b , 0xe1 , 0x41 ,
475530 0xaf , 0x76 , 0x7f , 0xd1 , 0x12 , 0x53 , 0x5f , 0xb3 , 0x92 , 0x2e , 0xf2 , 0x17 , 0x30 , 0x8e ,
0 commit comments