mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-06 20:41:14 +00:00
Merge pull request #43 from peat/master
Add .to_bytes() to PublicKey, SharedSecret
This commit is contained in:
commit
5d245dcefa
1 changed files with 12 additions and 0 deletions
|
|
@ -41,6 +41,12 @@ impl From<[u8; 32]> for PublicKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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.
|
/// View this public key as a byte array.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn as_bytes(&self) -> &[u8; 32] {
|
pub fn as_bytes(&self) -> &[u8; 32] {
|
||||||
|
|
@ -143,6 +149,12 @@ impl<'a> From<&'a StaticSecret> for PublicKey {
|
||||||
pub struct SharedSecret(pub(crate) MontgomeryPoint);
|
pub struct SharedSecret(pub(crate) MontgomeryPoint);
|
||||||
|
|
||||||
impl 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.
|
/// 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] {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue