Skip to content

Commit 7e2f7fe

Browse files
committed
Adding KeyPair::serialize_sec. Closes #298
1 parent 05f4278 commit 7e2f7fe

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "CC0-1.0"
77
homepage = "https://github.com/rust-bitcoin/rust-secp256k1/"
88
repository = "https://github.com/rust-bitcoin/rust-secp256k1/"
99
documentation = "https://docs.rs/secp256k1/"
10-
description = "Rust bindings for Pieter Wuille's `libsecp256k1` library. Implements ECDSA for the SECG elliptic curve group secp256k1 and related utilities."
10+
description = "Rust wrapper library for Pieter Wuille's `libsecp256k1`. Implements ECDSA and BIP 340 signatures for the SECG elliptic curve group secp256k1 and related utilities."
1111
keywords = [ "crypto", "ECDSA", "secp256k1", "libsecp256k1", "bitcoin" ]
1212
readme = "README.md"
1313
autoexamples = false # Remove when edition 2018 https://github.com/rust-lang/cargo/issues/5330

src/schnorrsig.rs

+6
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ impl KeyPair {
211211
}
212212
}
213213

214+
/// Serialize the key pair as a secret key byte value
215+
#[inline]
216+
pub fn serialize_sec<V: Verification>(&self, secp: &Secp256k1<V>) -> [u8; constants::SECRET_KEY_SIZE] {
217+
*SecretKey::from_keypair(secp, self).as_ref()
218+
}
219+
214220
/// Tweak a keypair by adding the given tweak to the secret key and updating the
215221
/// public key accordingly.
216222
/// Will return an error if the resulting key would be invalid or if

0 commit comments

Comments
 (0)