Merge pull request #29 from dalek-cryptography/as_bytes_for_ephemeral_public

Add EphemeralPublic::as_bytes
This commit is contained in:
Henry de Valence 2019-01-22 14:14:27 -08:00 committed by GitHub
commit 759d35b8c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,7 +31,14 @@ impl From<[u8; 32]> for EphemeralPublic {
fn from(bytes: [u8; 32]) -> EphemeralPublic { fn from(bytes: [u8; 32]) -> EphemeralPublic {
EphemeralPublic(MontgomeryPoint(bytes)) EphemeralPublic(MontgomeryPoint(bytes))
} }
}
impl EphemeralPublic {
/// View this ephemeral public key as a byte array.
#[inline]
pub fn as_bytes(&self) -> &[u8; 32] {
self.0.as_bytes()
}
} }
/// A DH ephemeral secret key. /// A DH ephemeral secret key.
@ -85,11 +92,10 @@ impl Drop for SharedSecret {
} }
impl SharedSecret { impl SharedSecret {
/// View this shared secret key as a byte array. /// View this shared secret key as a byte array.
#[inline] #[inline]
pub fn as_bytes(&self) -> &[u8; 32] { pub fn as_bytes(&self) -> &[u8; 32] {
&self.0.as_bytes() self.0.as_bytes()
} }
} }