Add .to_bytes() to PublicKey, so that it has similar capabilities to the ed25519 PublicKey impl. Also to SharedSecret for consistency.

This commit is contained in:
Peat Bakke 2019-06-05 12:20:02 -07:00 committed by Peat Bakke
parent 9567e021c5
commit 1d61e1ba46

View file

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