Skip to content

Commit e452e0d

Browse files
committed
Properly deprecate util::ecdsa key re-exports
1 parent ccb1649 commit e452e0d

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/util/schnorr.rs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,27 @@
2020
use core::fmt;
2121
use prelude::*;
2222

23-
#[deprecated(since = "0.28.0", note = "Please use `util::key` instead")]
24-
pub use secp256k1::{XOnlyPublicKey, KeyPair};
23+
use secp256k1::{XOnlyPublicKey as _XOnlyPublicKey, KeyPair as _KeyPair};
24+
2525
use secp256k1::{self, Secp256k1, Verification, constants};
2626
use hashes::Hash;
2727
use util::taproot::{TapBranchHash, TapTweakHash};
2828
use SchnorrSigHashType;
2929

30+
/// Deprecated re-export of [`secp256k1::XOnlyPublicKey`]
31+
#[deprecated(since = "0.28.0", note = "Please use `util::key::XOnlyPublicKey` instead")]
32+
pub type XOnlyPublicKey = _XOnlyPublicKey;
33+
34+
/// Deprecated re-export of [`secp256k1::KeyPair`]
35+
#[deprecated(since = "0.28.0", note = "Please use `util::key::KeyPair` instead")]
36+
pub type KeyPair = _KeyPair;
37+
3038
/// Untweaked BIP-340 X-coord-only public key
31-
pub type UntweakedPublicKey = XOnlyPublicKey;
39+
pub type UntweakedPublicKey = ::XOnlyPublicKey;
3240

3341
/// Tweaked BIP-340 X-coord-only public key
3442
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
35-
pub struct TweakedPublicKey(XOnlyPublicKey);
43+
pub struct TweakedPublicKey(::XOnlyPublicKey);
3644

3745
impl fmt::LowerHex for TweakedPublicKey {
3846
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -47,13 +55,13 @@ impl fmt::Display for TweakedPublicKey {
4755
}
4856

4957
/// Untweaked BIP-340 key pair
50-
pub type UntweakedKeyPair = KeyPair;
58+
pub type UntweakedKeyPair = ::KeyPair;
5159

5260
/// Tweaked BIP-340 key pair
5361
#[derive(Clone)]
5462
#[cfg_attr(feature = "std", derive(Debug))]
5563
// TODO: Add other derives once secp256k1 v0.21.3 released
56-
pub struct TweakedKeyPair(KeyPair);
64+
pub struct TweakedKeyPair(::KeyPair);
5765

5866
/// A trait for tweaking BIP340 key types (x-only public keys and key pairs).
5967
pub trait TapTweak {
@@ -130,7 +138,7 @@ impl TapTweak for UntweakedKeyPair {
130138
/// # Returns
131139
/// The tweaked key and its parity.
132140
fn tap_tweak<C: Verification>(mut self, secp: &Secp256k1<C>, merkle_root: Option<TapBranchHash>) -> TweakedKeyPair {
133-
let pubkey = XOnlyPublicKey::from_keypair(&self);
141+
let pubkey = ::XOnlyPublicKey::from_keypair(&self);
134142
let tweak_value = TapTweakHash::from_key_and_tweak(pubkey, merkle_root).into_inner();
135143
self.tweak_add_assign(&secp, &tweak_value).expect("Tap tweak failed");
136144
TweakedKeyPair(self)
@@ -148,17 +156,17 @@ impl TweakedPublicKey {
148156
/// This method is dangerous and can lead to loss of funds if used incorrectly.
149157
/// Specifically, in multi-party protocols a peer can provide a value that allows them to steal.
150158
#[inline]
151-
pub fn dangerous_assume_tweaked(key: XOnlyPublicKey) -> TweakedPublicKey {
159+
pub fn dangerous_assume_tweaked(key: ::XOnlyPublicKey) -> TweakedPublicKey {
152160
TweakedPublicKey(key)
153161
}
154162

155163
/// Returns the underlying public key.
156-
pub fn into_inner(self) -> XOnlyPublicKey {
164+
pub fn into_inner(self) -> ::XOnlyPublicKey {
157165
self.0
158166
}
159167

160168
/// Returns a reference to underlying public key.
161-
pub fn as_inner(&self) -> &XOnlyPublicKey {
169+
pub fn as_inner(&self) -> &::XOnlyPublicKey {
162170
&self.0
163171
}
164172

@@ -178,25 +186,25 @@ impl TweakedKeyPair {
178186
/// This method is dangerous and can lead to loss of funds if used incorrectly.
179187
/// Specifically, in multi-party protocols a peer can provide a value that allows them to steal.
180188
#[inline]
181-
pub fn dangerous_assume_tweaked(pair: KeyPair) -> TweakedKeyPair {
189+
pub fn dangerous_assume_tweaked(pair: ::KeyPair) -> TweakedKeyPair {
182190
TweakedKeyPair(pair)
183191
}
184192

185193
/// Returns the underlying key pair
186194
#[inline]
187-
pub fn into_inner(self) -> KeyPair {
195+
pub fn into_inner(self) -> ::KeyPair {
188196
self.0
189197
}
190198
}
191199

192-
impl From<TweakedPublicKey> for XOnlyPublicKey {
200+
impl From<TweakedPublicKey> for ::XOnlyPublicKey {
193201
#[inline]
194202
fn from(pair: TweakedPublicKey) -> Self {
195203
pair.0
196204
}
197205
}
198206

199-
impl From<TweakedKeyPair> for KeyPair {
207+
impl From<TweakedKeyPair> for ::KeyPair {
200208
#[inline]
201209
fn from(pair: TweakedKeyPair) -> Self {
202210
pair.0

0 commit comments

Comments
 (0)