Remove deprecated code

We are currently on version 0.24.1 (i.e., next release is 0.25.0), we
can comfortably remove any code deprecated in 0.23.x or earlier.
This commit is contained in:
Tobin C. Harding 2022-11-10 11:28:04 +11:00
parent e779e5dc05
commit 8c7c5e7394
6 changed files with 0 additions and 265 deletions

View File

@ -37,17 +37,9 @@ pub const COMPACT_SIGNATURE_SIZE: usize = 64;
/// The size of a Schnorr signature. /// The size of a Schnorr signature.
pub const SCHNORR_SIGNATURE_SIZE: usize = 64; pub const SCHNORR_SIGNATURE_SIZE: usize = 64;
/// The size of a Schnorr signature.
#[deprecated(since = "0.22.0", note = "Use SCHNORR_SIGNATURE_SIZE instead.")]
pub const SCHNORRSIG_SIGNATURE_SIZE: usize = SCHNORR_SIGNATURE_SIZE;
/// The size of a Schnorr public key. /// The size of a Schnorr public key.
pub const SCHNORR_PUBLIC_KEY_SIZE: usize = 32; pub const SCHNORR_PUBLIC_KEY_SIZE: usize = 32;
/// The size of a Schnorr public key.
#[deprecated(since = "0.22.0", note = "Use SCHNORR_PUBLIC_KEY_SIZE instead.")]
pub const SCHNORRSIG_PUBLIC_KEY_SIZE: usize = SCHNORR_PUBLIC_KEY_SIZE;
/// The size of a key pair. /// The size of a key pair.
pub const KEY_PAIR_SIZE: usize = 96; pub const KEY_PAIR_SIZE: usize = 96;

View File

@ -245,14 +245,6 @@ impl<'de> serde::Deserialize<'de> for Signature {
} }
impl<C: Signing> Secp256k1<C> { impl<C: Signing> Secp256k1<C> {
/// Constructs a signature for `msg` using the secret key `sk` and RFC6979 nonce
/// Requires a signing-capable context.
#[deprecated(since = "0.21.0", note = "Use sign_ecdsa instead.")]
pub fn sign(&self, msg: &Message, sk: &SecretKey) -> Signature {
self.sign_ecdsa(msg, sk)
}
fn sign_ecdsa_with_noncedata_pointer( fn sign_ecdsa_with_noncedata_pointer(
&self, &self,
msg: &Message, msg: &Message,
@ -324,17 +316,6 @@ impl<C: Signing> Secp256k1<C> {
} }
} }
/// Constructs a signature for `msg` using the secret key `sk`, RFC6979 nonce
/// and "grinds" the nonce by passing extra entropy if necessary to produce
/// a signature that is less than 71 - `bytes_to_grind` bytes. The number
/// of signing operation performed by this function is exponential in the
/// number of bytes grinded.
/// Requires a signing capable context.
#[deprecated(since = "0.21.0", note = "Use sign_ecdsa_grind_r instead.")]
pub fn sign_grind_r(&self, msg: &Message, sk: &SecretKey, bytes_to_grind: usize) -> Signature {
self.sign_ecdsa_grind_r(msg, sk, bytes_to_grind)
}
/// Constructs a signature for `msg` using the secret key `sk`, RFC6979 nonce /// Constructs a signature for `msg` using the secret key `sk`, RFC6979 nonce
/// and "grinds" the nonce by passing extra entropy if necessary to produce /// and "grinds" the nonce by passing extra entropy if necessary to produce
/// a signature that is less than 71 - `bytes_to_grind` bytes. The number /// a signature that is less than 71 - `bytes_to_grind` bytes. The number
@ -346,17 +327,6 @@ impl<C: Signing> Secp256k1<C> {
self.sign_grind_with_check(msg, sk, len_check) self.sign_grind_with_check(msg, sk, len_check)
} }
/// Constructs a signature for `msg` using the secret key `sk`, RFC6979 nonce
/// and "grinds" the nonce by passing extra entropy if necessary to produce
/// a signature that is less than 71 bytes and compatible with the low r
/// signature implementation of bitcoin core. In average, this function
/// will perform two signing operations.
/// Requires a signing capable context.
#[deprecated(since = "0.21.0", note = "Use sign_ecdsa_low_r instead.")]
pub fn sign_low_r(&self, msg: &Message, sk: &SecretKey) -> Signature {
self.sign_grind_with_check(msg, sk, compact_sig_has_zero_first_bit)
}
/// Constructs a signature for `msg` using the secret key `sk`, RFC6979 nonce /// Constructs a signature for `msg` using the secret key `sk`, RFC6979 nonce
/// and "grinds" the nonce by passing extra entropy if necessary to produce /// and "grinds" the nonce by passing extra entropy if necessary to produce
/// a signature that is less than 71 bytes and compatible with the low r /// a signature that is less than 71 bytes and compatible with the low r
@ -369,34 +339,6 @@ impl<C: Signing> Secp256k1<C> {
} }
impl<C: Verification> Secp256k1<C> { impl<C: Verification> Secp256k1<C> {
/// Checks that `sig` is a valid ECDSA signature for `msg` using the public
/// key `pubkey`. Returns `Ok(())` on success. Note that this function cannot
/// be used for Bitcoin consensus checking since there may exist signatures
/// which OpenSSL would verify but not libsecp256k1, or vice-versa. Requires a
/// verify-capable context.
///
/// ```rust
/// # #[cfg(all(feature = "std", feature = "rand-std"))] {
/// # use secp256k1::rand::thread_rng;
/// # use secp256k1::{Secp256k1, Message, Error};
/// #
/// # let secp = Secp256k1::new();
/// # let (secret_key, public_key) = secp.generate_keypair(&mut thread_rng());
/// #
/// let message = Message::from_slice(&[0xab; 32]).expect("32 bytes");
/// let sig = secp.sign(&message, &secret_key);
/// assert_eq!(secp.verify(&message, &sig, &public_key), Ok(()));
///
/// let message = Message::from_slice(&[0xcd; 32]).expect("32 bytes");
/// assert_eq!(secp.verify(&message, &sig, &public_key), Err(Error::IncorrectSignature));
/// # }
/// ```
#[inline]
#[deprecated(since = "0.21.0", note = "Use verify_ecdsa instead")]
pub fn verify(&self, msg: &Message, sig: &Signature, pk: &PublicKey) -> Result<(), Error> {
self.verify_ecdsa(msg, sig, pk)
}
/// Checks that `sig` is a valid ECDSA signature for `msg` using the public /// Checks that `sig` is a valid ECDSA signature for `msg` using the public
/// key `pubkey`. Returns `Ok(())` on success. Note that this function cannot /// key `pubkey`. Returns `Ok(())` on success. Note that this function cannot
/// be used for Bitcoin consensus checking since there may exist signatures /// be used for Bitcoin consensus checking since there may exist signatures

View File

@ -150,13 +150,6 @@ impl From<ffi::RecoverableSignature> for RecoverableSignature {
} }
impl<C: Signing> Secp256k1<C> { impl<C: Signing> Secp256k1<C> {
/// Constructs a signature for `msg` using the secret key `sk` and RFC6979 nonce.
/// Requires a signing-capable context.
#[deprecated(since = "0.21.0", note = "Use sign_ecdsa_recoverable instead.")]
pub fn sign_recoverable(&self, msg: &Message, sk: &key::SecretKey) -> RecoverableSignature {
self.sign_ecdsa_recoverable(msg, sk)
}
fn sign_ecdsa_recoverable_with_noncedata_pointer( fn sign_ecdsa_recoverable_with_noncedata_pointer(
&self, &self,
msg: &Message, msg: &Message,
@ -206,13 +199,6 @@ impl<C: Signing> Secp256k1<C> {
} }
impl<C: Verification> Secp256k1<C> { impl<C: Verification> Secp256k1<C> {
/// Determines the public key for which `sig` is a valid signature for
/// `msg`. Requires a verify-capable context.
#[deprecated(since = "0.21.0", note = "Use recover_ecdsa instead.")]
pub fn recover(&self, msg: &Message, sig: &RecoverableSignature) -> Result<key::PublicKey, Error> {
self.recover_ecdsa(msg, sig)
}
/// Determines the public key for which `sig` is a valid signature for /// Determines the public key for which `sig` is a valid signature for
/// `msg`. Requires a verify-capable context. /// `msg`. Requires a verify-capable context.
pub fn recover_ecdsa(&self, msg: &Message, sig: &RecoverableSignature) pub fn recover_ecdsa(&self, msg: &Message, sig: &RecoverableSignature)

View File

@ -259,13 +259,6 @@ impl SecretKey {
self.0 self.0
} }
/// Negates the secret key.
#[inline]
#[deprecated(since = "0.23.0", note = "Use negate instead")]
pub fn negate_assign(&mut self) {
*self = self.negate()
}
/// Negates the secret key. /// Negates the secret key.
#[inline] #[inline]
#[must_use = "you forgot to use the negated secret key"] #[must_use = "you forgot to use the negated secret key"]
@ -280,18 +273,6 @@ impl SecretKey {
self self
} }
/// Adds one secret key to another, modulo the curve order.
///
/// # Errors
///
/// Returns an error if the resulting key would be invalid.
#[inline]
#[deprecated(since = "0.23.0", note = "Use add_tweak instead")]
pub fn add_assign(&mut self, other: &Scalar) -> Result<(), Error> {
*self = self.add_tweak(other)?;
Ok(())
}
/// Tweaks a [`SecretKey`] by adding `tweak` modulo the curve order. /// Tweaks a [`SecretKey`] by adding `tweak` modulo the curve order.
/// ///
/// # Errors /// # Errors
@ -313,15 +294,6 @@ impl SecretKey {
} }
} }
/// Multiplies one secret key by another, modulo the curve order. Will
/// return an error if the resulting key would be invalid.
#[inline]
#[deprecated(since = "0.23.0", note = "Use mul_tweak instead")]
pub fn mul_assign(&mut self, other: &Scalar) -> Result<(), Error> {
*self = self.mul_tweak(other)?;
Ok(())
}
/// Tweaks a [`SecretKey`] by multiplying by `tweak` modulo the curve order. /// Tweaks a [`SecretKey`] by multiplying by `tweak` modulo the curve order.
/// ///
/// # Errors /// # Errors
@ -561,13 +533,6 @@ impl PublicKey {
debug_assert_eq!(ret_len, ret.len()); debug_assert_eq!(ret_len, ret.len());
} }
/// Negates the public key in place.
#[inline]
#[deprecated(since = "0.23.0", note = "Use negate instead")]
pub fn negate_assign<C: Verification>(&mut self, secp: &Secp256k1<C>) {
*self = self.negate(secp)
}
/// Negates the public key. /// Negates the public key.
#[inline] #[inline]
#[must_use = "you forgot to use the negated public key"] #[must_use = "you forgot to use the negated public key"]
@ -579,22 +544,6 @@ impl PublicKey {
self self
} }
/// Adds `other * G` to `self` in place.
///
/// # Errors
///
/// Returns an error if the resulting key would be invalid.
#[inline]
#[deprecated(since = "0.23.0", note = "Use add_exp_tweak instead")]
pub fn add_exp_assign<C: Verification>(
&mut self,
secp: &Secp256k1<C>,
other: &Scalar
) -> Result<(), Error> {
*self = self.add_exp_tweak(secp, other)?;
Ok(())
}
/// Tweaks a [`PublicKey`] by adding `tweak * G` modulo the curve order. /// Tweaks a [`PublicKey`] by adding `tweak * G` modulo the curve order.
/// ///
/// # Errors /// # Errors
@ -615,22 +564,6 @@ impl PublicKey {
} }
} }
/// Muliplies the public key in place by the scalar `other`.
///
/// # Errors
///
/// Returns an error if the resulting key would be invalid.
#[deprecated(since = "0.23.0", note = "Use mul_tweak instead")]
#[inline]
pub fn mul_assign<C: Verification>(
&mut self,
secp: &Secp256k1<C>,
other: &Scalar,
) -> Result<(), Error> {
*self = self.mul_tweak(secp, other)?;
Ok(())
}
/// Tweaks a [`PublicKey`] by multiplying by `tweak` modulo the curve order. /// Tweaks a [`PublicKey`] by multiplying by `tweak` modulo the curve order.
/// ///
/// # Errors /// # Errors
@ -968,19 +901,6 @@ impl KeyPair {
*SecretKey::from_keypair(self).as_ref() *SecretKey::from_keypair(self).as_ref()
} }
/// Tweaks a keypair by adding the given tweak to the secret key and updating the public key
/// accordingly.
#[inline]
#[deprecated(since = "0.23.0", note = "Use add_xonly_tweak instead")]
pub fn tweak_add_assign<C: Verification>(
&mut self,
secp: &Secp256k1<C>,
tweak: &Scalar,
) -> Result<(), Error> {
*self = self.add_xonly_tweak(secp, tweak)?;
Ok(())
}
/// Tweaks a keypair by first converting the public key to an xonly key and tweaking it. /// Tweaks a keypair by first converting the public key to an xonly key and tweaking it.
/// ///
/// # Errors /// # Errors
@ -1282,18 +1202,6 @@ impl XOnlyPublicKey {
ret ret
} }
/// Tweaks an x-only PublicKey by adding the generator multiplied with the given tweak to it.
#[deprecated(since = "0.23.0", note = "Use add_tweak instead")]
pub fn tweak_add_assign<V: Verification>(
&mut self,
secp: &Secp256k1<V>,
tweak: &Scalar,
) -> Result<Parity, Error> {
let (tweaked, parity) = self.add_tweak(secp, tweak)?;
*self = tweaked;
Ok(parity)
}
/// Tweaks an [`XOnlyPublicKey`] by adding the generator multiplied with the given tweak to it. /// Tweaks an [`XOnlyPublicKey`] by adding the generator multiplied with the given tweak to it.
/// ///
/// # Returns /// # Returns

View File

@ -206,25 +206,6 @@ use crate::ffi::{CPtr, impl_array_newtype, types::AlignedType};
#[cfg(feature = "bitcoin_hashes")] #[cfg(feature = "bitcoin_hashes")]
use crate::hashes::Hash; use crate::hashes::Hash;
// Backwards compatible changes
/// Schnorr Signature related methods.
#[deprecated(since = "0.21.0", note = "Use schnorr instead.")]
pub mod schnorrsig {
#[deprecated(since = "0.21.0", note = "Use crate::XOnlyPublicKey instead.")]
/// backwards compatible re-export of xonly key
pub type PublicKey = crate::key::XOnlyPublicKey;
/// backwards compatible re-export of keypair
#[deprecated(since = "0.21.0", note = "Use crate::KeyPair instead.")]
pub type KeyPair = crate::key::KeyPair;
/// backwards compatible re-export of schnorr signatures
#[deprecated(since = "0.21.0", note = "Use schnorr::Signature instead.")]
pub type Signature = crate::schnorr::Signature;
}
#[deprecated(since = "0.21.0", note = "Use ecdsa::Signature instead.")]
/// backwards compatible re-export of ecdsa signatures
pub type Signature = ecdsa::Signature;
/// Trait describing something that promises to be a 32-byte random number; in particular, /// Trait describing something that promises to be a 32-byte random number; in particular,
/// it has negligible probability of being zero or overflowing the group order. Such objects /// it has negligible probability of being zero or overflowing the group order. Such objects
/// may be converted to `Message`s without any error paths. /// may be converted to `Message`s without any error paths.

View File

@ -121,15 +121,6 @@ impl<C: Signing> Secp256k1<C> {
} }
} }
/// Create a schnorr signature internally using the ThreadRng random number
/// generator to generate the auxiliary random data.
#[cfg(any(test, feature = "rand-std"))]
#[cfg_attr(docsrs, doc(cfg(feature = "rand-std")))]
#[deprecated(since = "0.21.0", note = "Use sign_schnorr instead.")]
pub fn schnorrsig_sign(&self, msg: &Message, keypair: &KeyPair) -> Signature {
self.sign_schnorr(msg, keypair)
}
/// Create a schnorr signature internally using the ThreadRng random number /// Create a schnorr signature internally using the ThreadRng random number
/// generator to generate the auxiliary random data. /// generator to generate the auxiliary random data.
#[cfg(any(test, feature = "rand-std"))] #[cfg(any(test, feature = "rand-std"))]
@ -138,16 +129,6 @@ impl<C: Signing> Secp256k1<C> {
self.sign_schnorr_with_rng(msg, keypair, &mut rand::thread_rng()) self.sign_schnorr_with_rng(msg, keypair, &mut rand::thread_rng())
} }
/// Create a schnorr signature without using any auxiliary random data.
#[deprecated(since = "0.21.0", note = "Use sign_schnorr_no_aux_rand instead.")]
pub fn schnorrsig_sign_no_aux_rand(
&self,
msg: &Message,
keypair: &KeyPair,
) -> Signature {
self.sign_schnorr_no_aux_rand(msg, keypair)
}
/// Create a schnorr signature without using any auxiliary random data. /// Create a schnorr signature without using any auxiliary random data.
pub fn sign_schnorr_no_aux_rand( pub fn sign_schnorr_no_aux_rand(
&self, &self,
@ -157,17 +138,6 @@ impl<C: Signing> Secp256k1<C> {
self.sign_schnorr_helper(msg, keypair, ptr::null()) self.sign_schnorr_helper(msg, keypair, ptr::null())
} }
/// Create a Schnorr signature using the given auxiliary random data.
#[deprecated(since = "0.21.0", note = "Use sign_schnorr_with_aux_rand instead.")]
pub fn schnorrsig_sign_with_aux_rand(
&self,
msg: &Message,
keypair: &KeyPair,
aux_rand: &[u8; 32],
) -> Signature {
self.sign_schnorr_with_aux_rand(msg, keypair, aux_rand)
}
/// Create a Schnorr signature using the given auxiliary random data. /// Create a Schnorr signature using the given auxiliary random data.
pub fn sign_schnorr_with_aux_rand( pub fn sign_schnorr_with_aux_rand(
&self, &self,
@ -182,20 +152,6 @@ impl<C: Signing> Secp256k1<C> {
) )
} }
/// Create a schnorr signature using the given random number generator to
/// generate the auxiliary random data.
#[cfg(any(test, feature = "rand"))]
#[cfg_attr(docsrs, doc(cfg(feature = "rand")))]
#[deprecated(since = "0.21.0", note = "Use sign_schnorr_with_rng instead.")]
pub fn schnorrsig_sign_with_rng<R: Rng + CryptoRng>(
&self,
msg: &Message,
keypair: &KeyPair,
rng: &mut R,
) -> Signature {
self.sign_schnorr_with_rng(msg, keypair, rng)
}
/// Create a schnorr signature using the given random number generator to /// Create a schnorr signature using the given random number generator to
/// generate the auxiliary random data. /// generate the auxiliary random data.
#[cfg(any(test, feature = "rand"))] #[cfg(any(test, feature = "rand"))]
@ -213,17 +169,6 @@ impl<C: Signing> Secp256k1<C> {
} }
impl<C: Verification> Secp256k1<C> { impl<C: Verification> Secp256k1<C> {
/// Verify a Schnorr signature.
#[deprecated(since = "0.21.0", note = "Use verify_schnorr instead.")]
pub fn schnorrsig_verify(
&self,
sig: &Signature,
msg: &Message,
pubkey: &XOnlyPublicKey,
) -> Result<(), Error> {
self.verify_schnorr(sig, msg, pubkey)
}
/// Verify a Schnorr signature. /// Verify a Schnorr signature.
pub fn verify_schnorr( pub fn verify_schnorr(
&self, &self,
@ -249,25 +194,6 @@ impl<C: Verification> Secp256k1<C> {
} }
} }
impl <C: Signing> Secp256k1<C> {
/// Generates a random Schnorr `KeyPair` and its associated Schnorr `XOnlyPublicKey`.
///
/// Convenience function for [KeyPair::new] and [KeyPair::public_key].
/// Requires a signing-capable context.
#[inline]
#[cfg(any(test, feature = "rand"))]
#[cfg_attr(docsrs, doc(cfg(feature = "rand")))]
#[deprecated(since = "0.21.0", note = "Use kp = KeyPair::new() and kp.x_only_public_key().0")]
pub fn generate_schnorrsig_keypair<R: Rng + ?Sized>(
&self,
rng: &mut R,
) -> (KeyPair, XOnlyPublicKey) {
let sk = KeyPair::new(self, rng);
let (pubkey, _parity) = XOnlyPublicKey::from_keypair(&sk);
(sk, pubkey)
}
}
#[cfg(test)] #[cfg(test)]
#[allow(unused_imports)] #[allow(unused_imports)]
mod tests { mod tests {