File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,26 @@ impl KeyPair {
113
113
& mut self . 0
114
114
}
115
115
116
+ /// Creates a Schnorr KeyPair directly from generic Secp256k1 secret key
117
+ ///
118
+ /// Panics if internal representation of the provided [`SecretKey`] does not
119
+ /// holds correct secret key value obtained from Secp256k1 library
120
+ /// previously
121
+ #[ inline]
122
+ pub fn from_secret_key < C : Signing > (
123
+ secp : & Secp256k1 < C > ,
124
+ sk : :: key:: SecretKey ,
125
+ ) -> KeyPair {
126
+ unsafe {
127
+ let mut kp = ffi:: KeyPair :: new ( ) ;
128
+ if ffi:: secp256k1_keypair_create ( secp. ctx , & mut kp, sk. as_c_ptr ( ) ) == 1 {
129
+ KeyPair ( kp)
130
+ } else {
131
+ panic ! ( "the provided secret key is invalid: it is corrupted or was not produced by Secp256k1 library" )
132
+ }
133
+ }
134
+ }
135
+
116
136
/// Creates a Schnorr KeyPair directly from a secret key slice
117
137
#[ inline]
118
138
pub fn from_seckey_slice < C : Signing > (
You can’t perform that action at this time.
0 commit comments