Merge pull request #43 from peat/master

Add .to_bytes() to PublicKey, SharedSecret
This commit is contained in:
Henry de Valence 2020-08-17 18:55:18 -07:00 committed by GitHub
commit 5d245dcefa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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] {