mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 08:51:09 +00:00
Expose secret_key method for ecdsa::Keypair and eth::Keypair (#1628)
* Expose `secret_key` method for `ecdsa::Keypair` and `eth::Keypair` * cargo fmt * fix eth::secret_key --------- Co-authored-by: James Wilson <james@jsdw.me>
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user