diff --git a/keypair/src/key_pair.rs b/keypair/src/key_pair.rs index 5b14d8c..2238e54 100644 --- a/keypair/src/key_pair.rs +++ b/keypair/src/key_pair.rs @@ -48,6 +48,7 @@ use std::str::FromStr; /// ``` /// +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum KeyFormat { Ed25519, #[cfg(not(target_arch = "wasm32"))] @@ -168,6 +169,18 @@ impl KeyPair { } } + /// Get the key format of this keypair. + pub fn key_format(&self) -> KeyFormat { + use KeyPair::*; + + match self { + Ed25519(_) => KeyFormat::Ed25519, + #[cfg(not(target_arch = "wasm32"))] + Rsa(_) => KeyFormat::Rsa, + Secp256k1(_) => KeyFormat::Secp256k1, + } + } + /// Get the public key of this keypair. pub fn public(&self) -> PublicKey { use KeyPair::*;