Skip to content

Commit 1911845

Browse files
committed
Merge #511: Remove deprecated code
8c7c5e7 Remove deprecated code (Tobin C. Harding) e779e5d doc: Use add_tweak in example code (Tobin C. Harding) eedbd0b secp256k1-sys: Remove deprecated code (Tobin C. Harding) Pull request description: Remove deprecated code from `secp256k1-sys` and `secp256k1`. ACKs for top commit: apoelstra: ACK 8c7c5e7 Tree-SHA512: 830d4459cf21fba98e75e1c099c96316c9db1c1fb87dd28343cea066544ac8568685ec9fc85969caee3d35014f64c3f42b5a5afbf4f4d16221a57a204e6a3524
2 parents 72918bf + 8c7c5e7 commit 1911845

File tree

7 files changed

+2
-287
lines changed

7 files changed

+2
-287
lines changed

secp256k1-sys/src/lib.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -346,35 +346,15 @@ extern "C" {
346346
pub fn secp256k1_ec_seckey_verify(cx: *const Context,
347347
sk: *const c_uchar) -> c_int;
348348

349-
#[deprecated(since = "0.2.0",note = "Please use the secp256k1_ec_seckey_tweak_add function instead")]
350-
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_6_1_ec_privkey_negate")]
351-
pub fn secp256k1_ec_privkey_negate(cx: *const Context,
352-
sk: *mut c_uchar) -> c_int;
353-
354349
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_6_1_ec_seckey_negate")]
355350
pub fn secp256k1_ec_seckey_negate(cx: *const Context,
356351
sk: *mut c_uchar) -> c_int;
357352

358-
#[deprecated(since = "0.2.0",note = "Please use the secp256k1_ec_seckey_tweak_add function instead")]
359-
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_6_1_ec_privkey_tweak_add")]
360-
pub fn secp256k1_ec_privkey_tweak_add(cx: *const Context,
361-
sk: *mut c_uchar,
362-
tweak: *const c_uchar)
363-
-> c_int;
364-
365353
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_6_1_ec_seckey_tweak_add")]
366354
pub fn secp256k1_ec_seckey_tweak_add(cx: *const Context,
367355
sk: *mut c_uchar,
368356
tweak: *const c_uchar)
369357
-> c_int;
370-
371-
#[deprecated(since = "0.2.0",note = "Please use the secp256k1_ec_seckey_tweak_mul function instead")]
372-
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_6_1_ec_privkey_tweak_mul")]
373-
pub fn secp256k1_ec_privkey_tweak_mul(cx: *const Context,
374-
sk: *mut c_uchar,
375-
tweak: *const c_uchar)
376-
-> c_int;
377-
378358
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_6_1_ec_seckey_tweak_mul")]
379359
pub fn secp256k1_ec_seckey_tweak_mul(cx: *const Context,
380360
sk: *mut c_uchar,

src/constants.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,9 @@ pub const COMPACT_SIGNATURE_SIZE: usize = 64;
3737
/// The size of a Schnorr signature.
3838
pub const SCHNORR_SIGNATURE_SIZE: usize = 64;
3939

40-
/// The size of a Schnorr signature.
41-
#[deprecated(since = "0.22.0", note = "Use SCHNORR_SIGNATURE_SIZE instead.")]
42-
pub const SCHNORRSIG_SIGNATURE_SIZE: usize = SCHNORR_SIGNATURE_SIZE;
43-
4440
/// The size of a Schnorr public key.
4541
pub const SCHNORR_PUBLIC_KEY_SIZE: usize = 32;
4642

47-
/// The size of a Schnorr public key.
48-
#[deprecated(since = "0.22.0", note = "Use SCHNORR_PUBLIC_KEY_SIZE instead.")]
49-
pub const SCHNORRSIG_PUBLIC_KEY_SIZE: usize = SCHNORR_PUBLIC_KEY_SIZE;
50-
5143
/// The size of a key pair.
5244
pub const KEY_PAIR_SIZE: usize = 96;
5345

src/ecdsa/mod.rs

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,6 @@ impl<'de> serde::Deserialize<'de> for Signature {
245245
}
246246

247247
impl<C: Signing> Secp256k1<C> {
248-
249-
/// Constructs a signature for `msg` using the secret key `sk` and RFC6979 nonce
250-
/// Requires a signing-capable context.
251-
#[deprecated(since = "0.21.0", note = "Use sign_ecdsa instead.")]
252-
pub fn sign(&self, msg: &Message, sk: &SecretKey) -> Signature {
253-
self.sign_ecdsa(msg, sk)
254-
}
255-
256248
fn sign_ecdsa_with_noncedata_pointer(
257249
&self,
258250
msg: &Message,
@@ -324,17 +316,6 @@ impl<C: Signing> Secp256k1<C> {
324316
}
325317
}
326318

327-
/// Constructs a signature for `msg` using the secret key `sk`, RFC6979 nonce
328-
/// and "grinds" the nonce by passing extra entropy if necessary to produce
329-
/// a signature that is less than 71 - `bytes_to_grind` bytes. The number
330-
/// of signing operation performed by this function is exponential in the
331-
/// number of bytes grinded.
332-
/// Requires a signing capable context.
333-
#[deprecated(since = "0.21.0", note = "Use sign_ecdsa_grind_r instead.")]
334-
pub fn sign_grind_r(&self, msg: &Message, sk: &SecretKey, bytes_to_grind: usize) -> Signature {
335-
self.sign_ecdsa_grind_r(msg, sk, bytes_to_grind)
336-
}
337-
338319
/// Constructs a signature for `msg` using the secret key `sk`, RFC6979 nonce
339320
/// and "grinds" the nonce by passing extra entropy if necessary to produce
340321
/// a signature that is less than 71 - `bytes_to_grind` bytes. The number
@@ -346,17 +327,6 @@ impl<C: Signing> Secp256k1<C> {
346327
self.sign_grind_with_check(msg, sk, len_check)
347328
}
348329

349-
/// Constructs a signature for `msg` using the secret key `sk`, RFC6979 nonce
350-
/// and "grinds" the nonce by passing extra entropy if necessary to produce
351-
/// a signature that is less than 71 bytes and compatible with the low r
352-
/// signature implementation of bitcoin core. In average, this function
353-
/// will perform two signing operations.
354-
/// Requires a signing capable context.
355-
#[deprecated(since = "0.21.0", note = "Use sign_ecdsa_low_r instead.")]
356-
pub fn sign_low_r(&self, msg: &Message, sk: &SecretKey) -> Signature {
357-
self.sign_grind_with_check(msg, sk, compact_sig_has_zero_first_bit)
358-
}
359-
360330
/// Constructs a signature for `msg` using the secret key `sk`, RFC6979 nonce
361331
/// and "grinds" the nonce by passing extra entropy if necessary to produce
362332
/// a signature that is less than 71 bytes and compatible with the low r
@@ -369,34 +339,6 @@ impl<C: Signing> Secp256k1<C> {
369339
}
370340

371341
impl<C: Verification> Secp256k1<C> {
372-
/// Checks that `sig` is a valid ECDSA signature for `msg` using the public
373-
/// key `pubkey`. Returns `Ok(())` on success. Note that this function cannot
374-
/// be used for Bitcoin consensus checking since there may exist signatures
375-
/// which OpenSSL would verify but not libsecp256k1, or vice-versa. Requires a
376-
/// verify-capable context.
377-
///
378-
/// ```rust
379-
/// # #[cfg(all(feature = "std", feature = "rand-std"))] {
380-
/// # use secp256k1::rand::thread_rng;
381-
/// # use secp256k1::{Secp256k1, Message, Error};
382-
/// #
383-
/// # let secp = Secp256k1::new();
384-
/// # let (secret_key, public_key) = secp.generate_keypair(&mut thread_rng());
385-
/// #
386-
/// let message = Message::from_slice(&[0xab; 32]).expect("32 bytes");
387-
/// let sig = secp.sign(&message, &secret_key);
388-
/// assert_eq!(secp.verify(&message, &sig, &public_key), Ok(()));
389-
///
390-
/// let message = Message::from_slice(&[0xcd; 32]).expect("32 bytes");
391-
/// assert_eq!(secp.verify(&message, &sig, &public_key), Err(Error::IncorrectSignature));
392-
/// # }
393-
/// ```
394-
#[inline]
395-
#[deprecated(since = "0.21.0", note = "Use verify_ecdsa instead")]
396-
pub fn verify(&self, msg: &Message, sig: &Signature, pk: &PublicKey) -> Result<(), Error> {
397-
self.verify_ecdsa(msg, sig, pk)
398-
}
399-
400342
/// Checks that `sig` is a valid ECDSA signature for `msg` using the public
401343
/// key `pubkey`. Returns `Ok(())` on success. Note that this function cannot
402344
/// be used for Bitcoin consensus checking since there may exist signatures

src/ecdsa/recovery.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,6 @@ impl From<ffi::RecoverableSignature> for RecoverableSignature {
150150
}
151151

152152
impl<C: Signing> Secp256k1<C> {
153-
/// Constructs a signature for `msg` using the secret key `sk` and RFC6979 nonce.
154-
/// Requires a signing-capable context.
155-
#[deprecated(since = "0.21.0", note = "Use sign_ecdsa_recoverable instead.")]
156-
pub fn sign_recoverable(&self, msg: &Message, sk: &key::SecretKey) -> RecoverableSignature {
157-
self.sign_ecdsa_recoverable(msg, sk)
158-
}
159-
160153
fn sign_ecdsa_recoverable_with_noncedata_pointer(
161154
&self,
162155
msg: &Message,
@@ -206,13 +199,6 @@ impl<C: Signing> Secp256k1<C> {
206199
}
207200

208201
impl<C: Verification> Secp256k1<C> {
209-
/// Determines the public key for which `sig` is a valid signature for
210-
/// `msg`. Requires a verify-capable context.
211-
#[deprecated(since = "0.21.0", note = "Use recover_ecdsa instead.")]
212-
pub fn recover(&self, msg: &Message, sig: &RecoverableSignature) -> Result<key::PublicKey, Error> {
213-
self.recover_ecdsa(msg, sig)
214-
}
215-
216202
/// Determines the public key for which `sig` is a valid signature for
217203
/// `msg`. Requires a verify-capable context.
218204
pub fn recover_ecdsa(&self, msg: &Message, sig: &RecoverableSignature)

src/key.rs

Lines changed: 2 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,6 @@ impl SecretKey {
259259
self.0
260260
}
261261

262-
/// Negates the secret key.
263-
#[inline]
264-
#[deprecated(since = "0.23.0", note = "Use negate instead")]
265-
pub fn negate_assign(&mut self) {
266-
*self = self.negate()
267-
}
268-
269262
/// Negates the secret key.
270263
#[inline]
271264
#[must_use = "you forgot to use the negated secret key"]
@@ -280,18 +273,6 @@ impl SecretKey {
280273
self
281274
}
282275

283-
/// Adds one secret key to another, modulo the curve order.
284-
///
285-
/// # Errors
286-
///
287-
/// Returns an error if the resulting key would be invalid.
288-
#[inline]
289-
#[deprecated(since = "0.23.0", note = "Use add_tweak instead")]
290-
pub fn add_assign(&mut self, other: &Scalar) -> Result<(), Error> {
291-
*self = self.add_tweak(other)?;
292-
Ok(())
293-
}
294-
295276
/// Tweaks a [`SecretKey`] by adding `tweak` modulo the curve order.
296277
///
297278
/// # Errors
@@ -313,15 +294,6 @@ impl SecretKey {
313294
}
314295
}
315296

316-
/// Multiplies one secret key by another, modulo the curve order. Will
317-
/// return an error if the resulting key would be invalid.
318-
#[inline]
319-
#[deprecated(since = "0.23.0", note = "Use mul_tweak instead")]
320-
pub fn mul_assign(&mut self, other: &Scalar) -> Result<(), Error> {
321-
*self = self.mul_tweak(other)?;
322-
Ok(())
323-
}
324-
325297
/// Tweaks a [`SecretKey`] by multiplying by `tweak` modulo the curve order.
326298
///
327299
/// # Errors
@@ -561,13 +533,6 @@ impl PublicKey {
561533
debug_assert_eq!(ret_len, ret.len());
562534
}
563535

564-
/// Negates the public key in place.
565-
#[inline]
566-
#[deprecated(since = "0.23.0", note = "Use negate instead")]
567-
pub fn negate_assign<C: Verification>(&mut self, secp: &Secp256k1<C>) {
568-
*self = self.negate(secp)
569-
}
570-
571536
/// Negates the public key.
572537
#[inline]
573538
#[must_use = "you forgot to use the negated public key"]
@@ -579,22 +544,6 @@ impl PublicKey {
579544
self
580545
}
581546

582-
/// Adds `other * G` to `self` in place.
583-
///
584-
/// # Errors
585-
///
586-
/// Returns an error if the resulting key would be invalid.
587-
#[inline]
588-
#[deprecated(since = "0.23.0", note = "Use add_exp_tweak instead")]
589-
pub fn add_exp_assign<C: Verification>(
590-
&mut self,
591-
secp: &Secp256k1<C>,
592-
other: &Scalar
593-
) -> Result<(), Error> {
594-
*self = self.add_exp_tweak(secp, other)?;
595-
Ok(())
596-
}
597-
598547
/// Tweaks a [`PublicKey`] by adding `tweak * G` modulo the curve order.
599548
///
600549
/// # Errors
@@ -615,22 +564,6 @@ impl PublicKey {
615564
}
616565
}
617566

618-
/// Muliplies the public key in place by the scalar `other`.
619-
///
620-
/// # Errors
621-
///
622-
/// Returns an error if the resulting key would be invalid.
623-
#[deprecated(since = "0.23.0", note = "Use mul_tweak instead")]
624-
#[inline]
625-
pub fn mul_assign<C: Verification>(
626-
&mut self,
627-
secp: &Secp256k1<C>,
628-
other: &Scalar,
629-
) -> Result<(), Error> {
630-
*self = self.mul_tweak(secp, other)?;
631-
Ok(())
632-
}
633-
634567
/// Tweaks a [`PublicKey`] by multiplying by `tweak` modulo the curve order.
635568
///
636569
/// # Errors
@@ -986,19 +919,6 @@ impl KeyPair {
986919
*SecretKey::from_keypair(self).as_ref()
987920
}
988921

989-
/// Tweaks a keypair by adding the given tweak to the secret key and updating the public key
990-
/// accordingly.
991-
#[inline]
992-
#[deprecated(since = "0.23.0", note = "Use add_xonly_tweak instead")]
993-
pub fn tweak_add_assign<C: Verification>(
994-
&mut self,
995-
secp: &Secp256k1<C>,
996-
tweak: &Scalar,
997-
) -> Result<(), Error> {
998-
*self = self.add_xonly_tweak(secp, tweak)?;
999-
Ok(())
1000-
}
1001-
1002922
/// Tweaks a keypair by first converting the public key to an xonly key and tweaking it.
1003923
///
1004924
/// # Errors
@@ -1300,18 +1220,6 @@ impl XOnlyPublicKey {
13001220
ret
13011221
}
13021222

1303-
/// Tweaks an x-only PublicKey by adding the generator multiplied with the given tweak to it.
1304-
#[deprecated(since = "0.23.0", note = "Use add_tweak instead")]
1305-
pub fn tweak_add_assign<V: Verification>(
1306-
&mut self,
1307-
secp: &Secp256k1<V>,
1308-
tweak: &Scalar,
1309-
) -> Result<Parity, Error> {
1310-
let (tweaked, parity) = self.add_tweak(secp, tweak)?;
1311-
*self = tweaked;
1312-
Ok(parity)
1313-
}
1314-
13151223
/// Tweaks an [`XOnlyPublicKey`] by adding the generator multiplied with the given tweak to it.
13161224
///
13171225
/// # Returns
@@ -1398,8 +1306,8 @@ impl XOnlyPublicKey {
13981306
/// let mut key_pair = KeyPair::new(&secp, &mut thread_rng());
13991307
/// let (mut public_key, _) = key_pair.x_only_public_key();
14001308
/// let original = public_key;
1401-
/// let parity = public_key.tweak_add_assign(&secp, &tweak).expect("Improbable to fail with a randomly generated tweak");
1402-
/// assert!(original.tweak_add_check(&secp, &public_key, parity, tweak));
1309+
/// let (tweaked, parity) = public_key.add_tweak(&secp, &tweak).expect("Improbable to fail with a randomly generated tweak");
1310+
/// assert!(original.tweak_add_check(&secp, &tweaked, parity, tweak));
14031311
/// # }
14041312
/// ```
14051313
pub fn tweak_add_check<V: Verification>(

src/lib.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -206,25 +206,6 @@ use crate::ffi::{CPtr, impl_array_newtype, types::AlignedType};
206206
#[cfg(feature = "bitcoin_hashes")]
207207
use crate::hashes::Hash;
208208

209-
// Backwards compatible changes
210-
/// Schnorr Signature related methods.
211-
#[deprecated(since = "0.21.0", note = "Use schnorr instead.")]
212-
pub mod schnorrsig {
213-
#[deprecated(since = "0.21.0", note = "Use crate::XOnlyPublicKey instead.")]
214-
/// backwards compatible re-export of xonly key
215-
pub type PublicKey = crate::key::XOnlyPublicKey;
216-
/// backwards compatible re-export of keypair
217-
#[deprecated(since = "0.21.0", note = "Use crate::KeyPair instead.")]
218-
pub type KeyPair = crate::key::KeyPair;
219-
/// backwards compatible re-export of schnorr signatures
220-
#[deprecated(since = "0.21.0", note = "Use schnorr::Signature instead.")]
221-
pub type Signature = crate::schnorr::Signature;
222-
}
223-
224-
#[deprecated(since = "0.21.0", note = "Use ecdsa::Signature instead.")]
225-
/// backwards compatible re-export of ecdsa signatures
226-
pub type Signature = ecdsa::Signature;
227-
228209
/// Trait describing something that promises to be a 32-byte random number; in particular,
229210
/// it has negligible probability of being zero or overflowing the group order. Such objects
230211
/// may be converted to `Message`s without any error paths.

0 commit comments

Comments
 (0)