pub struct PublicKey { /* private fields */ }Expand description
X25519 Diffie-Hellman key exchange public key (RFC 7748).
§Deserializing from bytes
ⓘ
use crypto::curve25519::x25519::PublicKey;
let bytes = [0u8; 32]; // replace with a peer's public key
let pub_key = PublicKey::from_bytes(&bytes);§Conversion from Ed25519
An Ed25519 PublicKey can be
converted to an X25519 public key via TryFrom<&ed25519::PublicKey>.
Implementations§
Source§impl PublicKey
impl PublicKey
pub fn from_bytes(bytes: &[u8; 32]) -> Self
pub fn to_bytes(&self) -> [u8; 32]
Sourcepub fn is_low_order(&self) -> bool
pub fn is_low_order(&self) -> bool
Returns true if this public key is a low-order point on Curve25519.
Low-order public keys are never produced by honest key generation.
Passing one to SecretKey::ecdh produces an all-zero, publicly known
shared secret, so it must be rejected or otherwise neutralized. The
comparison is constant-time with respect to the key bytes.
Trait Implementations§
impl Eq for PublicKey
impl StructuralPartialEq for PublicKey
Auto Trait Implementations§
impl Freeze for PublicKey
impl RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnsafeUnpin for PublicKey
impl UnwindSafe for PublicKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more