diff --git a/src/x25519.rs b/src/x25519.rs index e95d0e3..75d9eeb 100644 --- a/src/x25519.rs +++ b/src/x25519.rs @@ -41,6 +41,12 @@ impl From<[u8; 32]> for PublicKey { } impl PublicKey { + /// Convert this public key to a byte array. + #[inline] + pub fn to_bytes(&self) -> [u8; 32] { + self.0.to_bytes() + } + /// View this public key as a byte array. #[inline] pub fn as_bytes(&self) -> &[u8; 32] { @@ -143,6 +149,12 @@ impl<'a> From<&'a StaticSecret> for PublicKey { pub struct SharedSecret(pub(crate) MontgomeryPoint); impl SharedSecret { + /// Convert this shared secret to a byte array. + #[inline] + pub fn to_bytes(&self) -> [u8; 32] { + self.0.to_bytes() + } + /// View this shared secret key as a byte array. #[inline] pub fn as_bytes(&self) -> &[u8; 32] {