mirror of
https://github.com/fluencelabs/trust-graph
synced 2024-12-12 10:55:33 +00:00
feat(keypair): Make KeyFormat
more convenient (#91)
* feat(keypair): Make `KeyFormat` more convenient 1. Make `KeyFormat` implement `Debug`, `Clone` and `Eq`. 2. Add `KeyPair::key_format(&self) -> KeyFormat` method.
This commit is contained in:
parent
c85fb16de3
commit
9b942eacca
@ -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::*;
|
||||
|
Loading…
Reference in New Issue
Block a user