20
20
use core:: fmt;
21
21
use prelude:: * ;
22
22
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
+
25
25
use secp256k1:: { self , Secp256k1 , Verification , constants} ;
26
26
use hashes:: Hash ;
27
27
use util:: taproot:: { TapBranchHash , TapTweakHash } ;
28
28
use SchnorrSigHashType ;
29
29
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
+
30
38
/// Untweaked BIP-340 X-coord-only public key
31
- pub type UntweakedPublicKey = XOnlyPublicKey ;
39
+ pub type UntweakedPublicKey = :: XOnlyPublicKey ;
32
40
33
41
/// Tweaked BIP-340 X-coord-only public key
34
42
#[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
35
- pub struct TweakedPublicKey ( XOnlyPublicKey ) ;
43
+ pub struct TweakedPublicKey ( :: XOnlyPublicKey ) ;
36
44
37
45
impl fmt:: LowerHex for TweakedPublicKey {
38
46
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
@@ -47,13 +55,13 @@ impl fmt::Display for TweakedPublicKey {
47
55
}
48
56
49
57
/// Untweaked BIP-340 key pair
50
- pub type UntweakedKeyPair = KeyPair ;
58
+ pub type UntweakedKeyPair = :: KeyPair ;
51
59
52
60
/// Tweaked BIP-340 key pair
53
61
#[ derive( Clone ) ]
54
62
#[ cfg_attr( feature = "std" , derive( Debug ) ) ]
55
63
// TODO: Add other derives once secp256k1 v0.21.3 released
56
- pub struct TweakedKeyPair ( KeyPair ) ;
64
+ pub struct TweakedKeyPair ( :: KeyPair ) ;
57
65
58
66
/// A trait for tweaking BIP340 key types (x-only public keys and key pairs).
59
67
pub trait TapTweak {
@@ -130,7 +138,7 @@ impl TapTweak for UntweakedKeyPair {
130
138
/// # Returns
131
139
/// The tweaked key and its parity.
132
140
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 ) ;
134
142
let tweak_value = TapTweakHash :: from_key_and_tweak ( pubkey, merkle_root) . into_inner ( ) ;
135
143
self . tweak_add_assign ( & secp, & tweak_value) . expect ( "Tap tweak failed" ) ;
136
144
TweakedKeyPair ( self )
@@ -148,17 +156,17 @@ impl TweakedPublicKey {
148
156
/// This method is dangerous and can lead to loss of funds if used incorrectly.
149
157
/// Specifically, in multi-party protocols a peer can provide a value that allows them to steal.
150
158
#[ inline]
151
- pub fn dangerous_assume_tweaked ( key : XOnlyPublicKey ) -> TweakedPublicKey {
159
+ pub fn dangerous_assume_tweaked ( key : :: XOnlyPublicKey ) -> TweakedPublicKey {
152
160
TweakedPublicKey ( key)
153
161
}
154
162
155
163
/// Returns the underlying public key.
156
- pub fn into_inner ( self ) -> XOnlyPublicKey {
164
+ pub fn into_inner ( self ) -> :: XOnlyPublicKey {
157
165
self . 0
158
166
}
159
167
160
168
/// Returns a reference to underlying public key.
161
- pub fn as_inner ( & self ) -> & XOnlyPublicKey {
169
+ pub fn as_inner ( & self ) -> & :: XOnlyPublicKey {
162
170
& self . 0
163
171
}
164
172
@@ -178,25 +186,25 @@ impl TweakedKeyPair {
178
186
/// This method is dangerous and can lead to loss of funds if used incorrectly.
179
187
/// Specifically, in multi-party protocols a peer can provide a value that allows them to steal.
180
188
#[ inline]
181
- pub fn dangerous_assume_tweaked ( pair : KeyPair ) -> TweakedKeyPair {
189
+ pub fn dangerous_assume_tweaked ( pair : :: KeyPair ) -> TweakedKeyPair {
182
190
TweakedKeyPair ( pair)
183
191
}
184
192
185
193
/// Returns the underlying key pair
186
194
#[ inline]
187
- pub fn into_inner ( self ) -> KeyPair {
195
+ pub fn into_inner ( self ) -> :: KeyPair {
188
196
self . 0
189
197
}
190
198
}
191
199
192
- impl From < TweakedPublicKey > for XOnlyPublicKey {
200
+ impl From < TweakedPublicKey > for :: XOnlyPublicKey {
193
201
#[ inline]
194
202
fn from ( pair : TweakedPublicKey ) -> Self {
195
203
pair. 0
196
204
}
197
205
}
198
206
199
- impl From < TweakedKeyPair > for KeyPair {
207
+ impl From < TweakedKeyPair > for :: KeyPair {
200
208
#[ inline]
201
209
fn from ( pair : TweakedKeyPair ) -> Self {
202
210
pair. 0
0 commit comments