Skip to content

Commit

Permalink
Add .to_bytes() to PublicKey, so that it has similar capabilities to …
Browse files Browse the repository at this point in the history
…the ed25519 PublicKey impl. Also to SharedSecret for consistency.
  • Loading branch information
peat authored and Peat Bakke committed Jun 5, 2019
1 parent 9567e02 commit 1d61e1b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/x25519.rs
Expand Up @@ -36,6 +36,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] {
Expand Down Expand Up @@ -149,6 +155,12 @@ impl Drop for SharedSecret {
}

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] {
Expand Down

0 comments on commit 1d61e1b

Please sign in to comment.