From cf85d10055559d78118939ffd4b1b087a3c3d8e3 Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Tue, 2 Apr 2019 15:15:28 -0400 Subject: [PATCH] method added to construct keypair from raw bytes --- libcitadel/src/keys.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libcitadel/src/keys.rs b/libcitadel/src/keys.rs index f6b1bb5..3308b21 100644 --- a/libcitadel/src/keys.rs +++ b/libcitadel/src/keys.rs @@ -50,8 +50,12 @@ impl KeyPair { pub fn from_hex(hex: &str) -> Result { let bytes = hex::decode(hex)?; + KeyPair::from_bytes(&bytes) + } + + pub fn from_bytes(bytes: &[u8]) -> Result { if bytes.len() != SEEDBYTES { - bail!("Hex encoded keypair has incorrect length"); + bail!("Hex encoded keypair has incorrect length"); } let seed = sign::Seed::from_slice(&bytes).expect("Seed::from_slice() failed"); Ok(KeyPair(seed))