@@ -13,7 +13,9 @@ use core::{fmt, ptr, str};
1313pub use self :: recovery:: { RecoverableSignature , RecoveryId } ;
1414pub use self :: serialized_signature:: SerializedSignature ;
1515use crate :: ffi:: CPtr ;
16- use crate :: { ecdsa, ffi, from_hex, Error , Message , PublicKey , Secp256k1 , SecretKey } ;
16+ use crate :: {
17+ ecdsa, ffi, from_hex, Error , Message , PublicKey , Secp256k1 , SecretKey , Signing , Verification ,
18+ } ;
1719
1820/// An ECDSA signature
1921#[ derive( Copy , Clone , PartialOrd , Ord , PartialEq , Eq , Hash ) ]
@@ -341,6 +343,91 @@ pub fn sign_low_r(msg: impl Into<Message>, sk: &SecretKey) -> Signature {
341343 sign_grind_with_check ( msg, sk, compact_sig_has_zero_first_bit)
342344}
343345
346+ impl < C : Signing > Secp256k1 < C > {
347+ /// Constructs a signature for `msg` using the secret key `sk` and RFC6979 nonce
348+ /// Requires a signing-capable context.
349+ #[ deprecated( since = "0.32.0" , note = "use ecdsa::sign instead" ) ]
350+ pub fn sign_ecdsa ( & self , msg : impl Into < Message > , sk : & SecretKey ) -> Signature {
351+ self :: sign ( msg, sk)
352+ }
353+
354+ /// Constructs a signature for `msg` using the secret key `sk` and RFC6979 nonce
355+ /// and includes 32 bytes of noncedata in the nonce generation via inclusion in
356+ /// one of the hash operations during nonce generation. This is useful when multiple
357+ /// signatures are needed for the same Message and SecretKey while still using RFC6979.
358+ /// Requires a signing-capable context.
359+ #[ deprecated( since = "0.32.0" , note = "use ecdsa::sign_with_noncedata instead" ) ]
360+ pub fn sign_ecdsa_with_noncedata (
361+ & self ,
362+ msg : impl Into < Message > ,
363+ sk : & SecretKey ,
364+ noncedata : & [ u8 ; 32 ] ,
365+ ) -> Signature {
366+ self :: sign_with_noncedata ( msg, sk, noncedata)
367+ }
368+
369+ /// Constructs a signature for `msg` using the secret key `sk`, RFC6979 nonce
370+ /// and "grinds" the nonce by passing extra entropy if necessary to produce
371+ /// a signature that is less than 71 - `bytes_to_grind` bytes. The number
372+ /// of signing operation performed by this function is exponential in the
373+ /// number of bytes grinded.
374+ /// Requires a signing capable context.
375+ #[ deprecated( since = "0.32.0" , note = "use ecdsa::sign_grind_r instead" ) ]
376+ pub fn sign_ecdsa_grind_r (
377+ & self ,
378+ msg : impl Into < Message > ,
379+ sk : & SecretKey ,
380+ bytes_to_grind : usize ,
381+ ) -> Signature {
382+ self :: sign_grind_r ( msg, sk, bytes_to_grind)
383+ }
384+
385+ /// Constructs a signature for `msg` using the secret key `sk`, RFC6979 nonce
386+ /// and "grinds" the nonce by passing extra entropy if necessary to produce
387+ /// a signature that is less than 71 bytes and compatible with the low r
388+ /// signature implementation of bitcoin core. In average, this function
389+ /// will perform two signing operations.
390+ /// Requires a signing capable context.
391+ #[ deprecated( since = "0.32.0" , note = "use ecdsa::sign_low_r instead" ) ]
392+ pub fn sign_ecdsa_low_r ( & self , msg : impl Into < Message > , sk : & SecretKey ) -> Signature {
393+ self :: sign_low_r ( msg, sk)
394+ }
395+ }
396+
397+ impl < C : Verification > Secp256k1 < C > {
398+ /// Checks that `sig` is a valid ECDSA signature for `msg` using the public
399+ /// key `pubkey`. Returns `Ok(())` on success. Note that this function cannot
400+ /// be used for Bitcoin consensus checking since there may exist signatures
401+ /// which OpenSSL would verify but not libsecp256k1, or vice-versa. Requires a
402+ /// verify-capable context.
403+ ///
404+ /// ```rust
405+ /// # #[cfg(all(feature = "rand", feature = "std"))] {
406+ /// # use secp256k1::{rand, Secp256k1, Message, Error};
407+ /// #
408+ /// # let secp = Secp256k1::new();
409+ /// # let (secret_key, public_key) = secp.generate_keypair(&mut rand::rng());
410+ /// #
411+ /// let message = Message::from_digest_slice(&[0xab; 32]).expect("32 bytes");
412+ /// let sig = secp.sign_ecdsa(message, &secret_key);
413+ /// assert_eq!(secp.verify_ecdsa(&sig, message, &public_key), Ok(()));
414+ ///
415+ /// let message = Message::from_digest_slice(&[0xcd; 32]).expect("32 bytes");
416+ /// assert_eq!(secp.verify_ecdsa(&sig, message, &public_key), Err(Error::IncorrectSignature));
417+ /// # }
418+ /// ```
419+ #[ inline]
420+ #[ deprecated( since = "0.32.0" , note = "use ecdsa::verify instead" ) ]
421+ pub fn verify_ecdsa (
422+ & self ,
423+ sig : & Signature ,
424+ msg : impl Into < Message > ,
425+ pk : & PublicKey ,
426+ ) -> Result < ( ) , Error > {
427+ self :: verify ( sig, msg, pk)
428+ }
429+ }
430+
344431/// Checks that `sig` is a valid ECDSA signature for `msg` using the public
345432/// key `pubkey`. Returns `Ok(())` on success. Note that this function cannot
346433/// be used for Bitcoin consensus checking since there may exist signatures
0 commit comments