pub struct PrivateKey(/* private fields */);
Expand description
Private key
Wrapper around x25519_dalek::StaticSecret
with some traits.
§Implements
- Implements
Zeroize
andZeroizeOnDrop
for clearing secrets from memory. - Implements
TryFrom<&str>
orTryFrom<String>
for importing key from Base64 format. - Implements
fmt::Display
for exporting key in Wireguard’s format. - Implements
fmt::Debug
.
§Examples
// generate new random key:
let key = PrivateKey::random();
// import key:
let imported_key = PrivateKey::try_from("sJkP2oorqrq49P6Ln25MWo3X04PxhB8k+RnJJnZ4gEo=")?;
// export key via `fmt::Display` trait:
let exported_key = imported_key.to_string();
assert_eq!(exported_key, "sJkP2oorqrq49P6Ln25MWo3X04PxhB8k+RnJJnZ4gEo=".to_string());
Implementations§
Source§impl PrivateKey
impl PrivateKey
Sourcepub fn random() -> PrivateKey
pub fn random() -> PrivateKey
Generate new a random PrivateKey
Trait Implementations§
Source§impl Clone for PrivateKey
impl Clone for PrivateKey
Source§fn clone(&self) -> PrivateKey
fn clone(&self) -> PrivateKey
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for PrivateKey
impl Debug for PrivateKey
Source§impl Display for PrivateKey
Exporting key as base64 for Wireguard.
impl Display for PrivateKey
Exporting key as base64 for Wireguard.
Source§impl Drop for PrivateKey
impl Drop for PrivateKey
Source§impl From<&PrivateKey> for PublicKey
impl From<&PrivateKey> for PublicKey
Source§fn from(value: &PrivateKey) -> Self
fn from(value: &PrivateKey) -> Self
Converts to this type from the input type.
Source§impl PartialEq for PrivateKey
impl PartialEq for PrivateKey
Source§impl TryFrom<&str> for PrivateKey
impl TryFrom<&str> for PrivateKey
Source§impl TryFrom<String> for PrivateKey
impl TryFrom<String> for PrivateKey
Auto Trait Implementations§
impl Freeze for PrivateKey
impl RefUnwindSafe for PrivateKey
impl Send for PrivateKey
impl Sync for PrivateKey
impl Unpin for PrivateKey
impl UnwindSafe for PrivateKey
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more