Merge rust-bitcoin/rust-secp256k1#511: Remove deprecated code
8c7c5e7394
Remove deprecated code (Tobin C. Harding)e779e5dc05
doc: Use add_tweak in example code (Tobin C. Harding)eedbd0b7e4
secp256k1-sys: Remove deprecated code (Tobin C. Harding) Pull request description: Remove deprecated code from `secp256k1-sys` and `secp256k1`. ACKs for top commit: apoelstra: ACK8c7c5e7394
Tree-SHA512: 830d4459cf21fba98e75e1c099c96316c9db1c1fb87dd28343cea066544ac8568685ec9fc85969caee3d35014f64c3f42b5a5afbf4f4d16221a57a204e6a3524
This commit is contained in:
commit
191184539c
|
@ -346,35 +346,15 @@ extern "C" {
|
||||||
pub fn secp256k1_ec_seckey_verify(cx: *const Context,
|
pub fn secp256k1_ec_seckey_verify(cx: *const Context,
|
||||||
sk: *const c_uchar) -> c_int;
|
sk: *const c_uchar) -> c_int;
|
||||||
|
|
||||||
#[deprecated(since = "0.2.0",note = "Please use the secp256k1_ec_seckey_tweak_add function instead")]
|
|
||||||
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_6_1_ec_privkey_negate")]
|
|
||||||
pub fn secp256k1_ec_privkey_negate(cx: *const Context,
|
|
||||||
sk: *mut c_uchar) -> c_int;
|
|
||||||
|
|
||||||
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_6_1_ec_seckey_negate")]
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_6_1_ec_seckey_negate")]
|
||||||
pub fn secp256k1_ec_seckey_negate(cx: *const Context,
|
pub fn secp256k1_ec_seckey_negate(cx: *const Context,
|
||||||
sk: *mut c_uchar) -> c_int;
|
sk: *mut c_uchar) -> c_int;
|
||||||
|
|
||||||
#[deprecated(since = "0.2.0",note = "Please use the secp256k1_ec_seckey_tweak_add function instead")]
|
|
||||||
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_6_1_ec_privkey_tweak_add")]
|
|
||||||
pub fn secp256k1_ec_privkey_tweak_add(cx: *const Context,
|
|
||||||
sk: *mut c_uchar,
|
|
||||||
tweak: *const c_uchar)
|
|
||||||
-> c_int;
|
|
||||||
|
|
||||||
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_6_1_ec_seckey_tweak_add")]
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_6_1_ec_seckey_tweak_add")]
|
||||||
pub fn secp256k1_ec_seckey_tweak_add(cx: *const Context,
|
pub fn secp256k1_ec_seckey_tweak_add(cx: *const Context,
|
||||||
sk: *mut c_uchar,
|
sk: *mut c_uchar,
|
||||||
tweak: *const c_uchar)
|
tweak: *const c_uchar)
|
||||||
-> c_int;
|
-> c_int;
|
||||||
|
|
||||||
#[deprecated(since = "0.2.0",note = "Please use the secp256k1_ec_seckey_tweak_mul function instead")]
|
|
||||||
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_6_1_ec_privkey_tweak_mul")]
|
|
||||||
pub fn secp256k1_ec_privkey_tweak_mul(cx: *const Context,
|
|
||||||
sk: *mut c_uchar,
|
|
||||||
tweak: *const c_uchar)
|
|
||||||
-> c_int;
|
|
||||||
|
|
||||||
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_6_1_ec_seckey_tweak_mul")]
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_6_1_ec_seckey_tweak_mul")]
|
||||||
pub fn secp256k1_ec_seckey_tweak_mul(cx: *const Context,
|
pub fn secp256k1_ec_seckey_tweak_mul(cx: *const Context,
|
||||||
sk: *mut c_uchar,
|
sk: *mut c_uchar,
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
96
src/key.rs
96
src/key.rs
|
@ -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
|
||||||
|
@ -986,19 +919,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
|
||||||
|
@ -1300,18 +1220,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
|
||||||
|
@ -1398,8 +1306,8 @@ impl XOnlyPublicKey {
|
||||||
/// let mut key_pair = KeyPair::new(&secp, &mut thread_rng());
|
/// let mut key_pair = KeyPair::new(&secp, &mut thread_rng());
|
||||||
/// let (mut public_key, _) = key_pair.x_only_public_key();
|
/// let (mut public_key, _) = key_pair.x_only_public_key();
|
||||||
/// let original = public_key;
|
/// let original = public_key;
|
||||||
/// let parity = public_key.tweak_add_assign(&secp, &tweak).expect("Improbable to fail with a randomly generated tweak");
|
/// let (tweaked, parity) = public_key.add_tweak(&secp, &tweak).expect("Improbable to fail with a randomly generated tweak");
|
||||||
/// assert!(original.tweak_add_check(&secp, &public_key, parity, tweak));
|
/// assert!(original.tweak_add_check(&secp, &tweaked, parity, tweak));
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn tweak_add_check<V: Verification>(
|
pub fn tweak_add_check<V: Verification>(
|
||||||
|
|
19
src/lib.rs
19
src/lib.rs
|
@ -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.
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue