diff --git a/signer/src/ecdsa.rs b/signer/src/ecdsa.rs index 82c4d2f70d..52de73aee6 100644 --- a/signer/src/ecdsa.rs +++ b/signer/src/ecdsa.rs @@ -157,6 +157,11 @@ impl Keypair { PublicKey(self.0.public_key().serialize()) } + /// Obtain the [`SecretKey`] part of this key pair. This should be kept secret. + pub fn secret_key(&self) -> SecretKeyBytes { + *self.0.secret_key().as_ref() + } + /// Sign some message. These bytes can be used directly in a Substrate `MultiSignature::Ecdsa(..)`. pub fn sign(&self, message: &[u8]) -> Signature { self.sign_prehashed(&sp_crypto_hashing::blake2_256(message)) diff --git a/signer/src/eth.rs b/signer/src/eth.rs index dec98976a4..bc92d51029 100644 --- a/signer/src/eth.rs +++ b/signer/src/eth.rs @@ -97,6 +97,11 @@ impl Keypair { .map_err(|_| Error::InvalidSeed) } + /// Obtain the [`ecdsa::SecretKeyBytes`] of this keypair. + pub fn secret_key(&self) -> SecretKeyBytes { + self.0.secret_key() + } + /// Obtain the [`eth::PublicKey`] of this keypair. pub fn public_key(&self) -> PublicKey { let uncompressed = self.0 .0.public_key().serialize_uncompressed();