mirror of
https://github.com/arnaucube/arkeddsa.git
synced 2026-01-11 16:01:27 +01:00
export secret
This commit is contained in:
10
src/eddsa.rs
10
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<D: Digest>(bytes: [u8; 32]) -> Result<Self, Error> {
|
||||
pub fn from_bytes<D: Digest>(bytes: &[u8; 32]) -> Result<Self, Error> {
|
||||
let secret_key = SecretKey::from_bytes(bytes);
|
||||
Self::new::<D>(&secret_key)
|
||||
}
|
||||
|
||||
pub fn to_bytes(&self) -> [u8; 32] {
|
||||
self.secret_key.to_bytes()
|
||||
}
|
||||
|
||||
pub fn generate<D: Digest>(rng: &mut impl CryptoRngCore) -> Result<Self, Error> {
|
||||
let mut secret_key = SecretKey([0; 32]);
|
||||
rng.fill_bytes(&mut secret_key.0);
|
||||
|
||||
Reference in New Issue
Block a user