pub struct RecipientPrivateKey(/* private fields */);Expand description
A 32-byte X25519 recipient private key.
The bytes are zeroed on drop. The type implements a sanitizing Debug
impl that only prints RecipientPrivateKey(<redacted>) — the raw bytes
are never disclosed via formatting. Display is intentionally not
implemented for the same reason.
Implementations§
Source§impl RecipientPrivateKey
impl RecipientPrivateKey
Sourcepub fn generate() -> (RecipientPrivateKey, RecipientPublicKey)
pub fn generate() -> (RecipientPrivateKey, RecipientPublicKey)
Generate a fresh X25519 keypair using the operating system RNG.
Sourcepub fn from_bytes(b: [u8; 32]) -> Self
pub fn from_bytes(b: [u8; 32]) -> Self
Construct a recipient private key directly from its 32 raw bytes.
Sourcepub fn from_base64(s: &str) -> Result<Self, SealedError>
pub fn from_base64(s: &str) -> Result<Self, SealedError>
Decode a recipient private key from a standard-base64 (padded) string.
§Errors
Returns SealedError::Decode if the string is not valid base64, or
SealedError::InvalidLength if it does not decode to exactly 32 bytes.
Sourcepub fn to_base64(&self) -> String
pub fn to_base64(&self) -> String
Encode this private key as standard-base64 (with padding).
Use with extreme care — exposing this string is equivalent to disclosing the key. Prefer keeping the key in memory and zeroing it on drop.
Sourcepub fn public_key(&self) -> RecipientPublicKey
pub fn public_key(&self) -> RecipientPublicKey
Derive the matching X25519 public key for this private key.
Trait Implementations§
Source§impl Clone for RecipientPrivateKey
impl Clone for RecipientPrivateKey
Source§fn clone(&self) -> RecipientPrivateKey
fn clone(&self) -> RecipientPrivateKey
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RecipientPrivateKey
impl Debug for RecipientPrivateKey
Source§impl Drop for RecipientPrivateKey
impl Drop for RecipientPrivateKey
Auto Trait Implementations§
impl Freeze for RecipientPrivateKey
impl RefUnwindSafe for RecipientPrivateKey
impl Send for RecipientPrivateKey
impl Sync for RecipientPrivateKey
impl Unpin for RecipientPrivateKey
impl UnsafeUnpin for RecipientPrivateKey
impl UnwindSafe for RecipientPrivateKey
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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