mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-06 20:41:14 +00:00
methods to convert a StaticSecret to and from bytes
This commit is contained in:
parent
4caffdcca0
commit
ad670a4d03
1 changed files with 12 additions and 0 deletions
|
|
@ -110,6 +110,18 @@ impl StaticSecret {
|
||||||
StaticSecret(clamp_scalar(bytes))
|
StaticSecret(clamp_scalar(bytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert a x25519 `StaticSecret` key to its underlying sequence of bytes.
|
||||||
|
pub fn to_bytes(&self) -> [u8; 32] {
|
||||||
|
self.0.to_bytes()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<[u8; 32]> for StaticSecret {
|
||||||
|
/// Given a byte array, construct a x25519 `StaticSecret`.
|
||||||
|
fn from(bytes: [u8; 32]) -> StaticSecret {
|
||||||
|
StaticSecret(Scalar::from_bits(bytes))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a StaticSecret> for PublicKey {
|
impl<'a> From<&'a StaticSecret> for PublicKey {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue