From 27f3058df3ce4aedc394b852e06637968bd73c7f Mon Sep 17 00:00:00 2001 From: kilic Date: Fri, 2 Aug 2024 14:01:59 +0300 Subject: [PATCH] export secret --- src/eddsa.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/eddsa.rs b/src/eddsa.rs index 9c9515b..e83f68b 100644 --- a/src/eddsa.rs +++ b/src/eddsa.rs @@ -38,8 +38,8 @@ impl SecretKey { self.0 } - pub fn from_bytes(bytes: [u8; 32]) -> Self { - Self(bytes) + pub fn from_bytes(bytes: &[u8; 32]) -> Self { + Self(bytes.clone()) } } @@ -91,11 +91,15 @@ where Ok(signing_key) } - pub fn from_bytes(bytes: [u8; 32]) -> Result { + pub fn from_bytes(bytes: &[u8; 32]) -> Result { let secret_key = SecretKey::from_bytes(bytes); Self::new::(&secret_key) } + pub fn to_bytes(&self) -> [u8; 32] { + self.secret_key.to_bytes() + } + pub fn generate(rng: &mut impl CryptoRngCore) -> Result { let mut secret_key = SecretKey([0; 32]); rng.fill_bytes(&mut secret_key.0);