mirror of
https://github.com/fluencelabs/trust-graph
synced 2024-12-04 15:20:19 +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 {
|
pub enum KeyFormat {
|
||||||
Ed25519,
|
Ed25519,
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[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.
|
/// Get the public key of this keypair.
|
||||||
pub fn public(&self) -> PublicKey {
|
pub fn public(&self) -> PublicKey {
|
||||||
use KeyPair::*;
|
use KeyPair::*;
|
||||||
|
Loading…
Reference in New Issue
Block a user