#[non_exhaustive]pub enum PrivateKey {
Ed25519(SigningKey),
}Expand description
Algorithm-agnostic signing key for creating signatures.
Wraps algorithm-specific signing key types in a single enum.
Secret material is volatile-zeroed on drop via the inner key types’
[ZeroizeOnDrop] implementations.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Ed25519(SigningKey)
Ed25519 signing key (32 bytes)
Implementations§
Source§impl PrivateKey
impl PrivateKey
Sourcepub fn sign(&self, data: &[u8]) -> Vec<u8> ⓘ
pub fn sign(&self, data: &[u8]) -> Vec<u8> ⓘ
Sign the given data and return the raw signature bytes.
Sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Derive the corresponding public key.
Sourcepub fn to_bytes(&self) -> Zeroizing<Vec<u8>>
pub fn to_bytes(&self) -> Zeroizing<Vec<u8>>
Export the raw key bytes (for encryption/storage).
The returned buffer is wrapped in [Zeroizing] so the key material
is automatically cleared from memory when dropped.
Sourcepub fn from_bytes(algorithm: &str, bytes: &[u8]) -> Result<Self, AuthError>
pub fn from_bytes(algorithm: &str, bytes: &[u8]) -> Result<Self, AuthError>
Reconstruct a private key from raw bytes and an algorithm identifier.
Sourcepub fn to_prefixed_string(&self) -> Zeroizing<String>
pub fn to_prefixed_string(&self) -> Zeroizing<String>
Format the private key as a prefixed string (e.g. "ed25519:base64...").
The returned string is wrapped in [Zeroizing] so the key material
is automatically cleared from memory when dropped.
Sourcepub fn from_prefixed_string(s: &str) -> Result<Self, AuthError>
pub fn from_prefixed_string(s: &str) -> Result<Self, AuthError>
Parse a private key from a prefixed string (e.g. "ed25519:base64...").
Trait Implementations§
Source§impl Clone for PrivateKey
impl Clone for PrivateKey
Source§fn clone(&self) -> PrivateKey
fn clone(&self) -> PrivateKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PrivateKey
impl Debug for PrivateKey
Source§impl<'de> Deserialize<'de> for PrivateKey
Deserializes from the prefixed string format (e.g. "ed25519:base64...").
impl<'de> Deserialize<'de> for PrivateKey
Deserializes from the prefixed string format (e.g. "ed25519:base64...").
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl From<PrivateKey> for DatabaseKey
impl From<PrivateKey> for DatabaseKey
Source§fn from(signing_key: PrivateKey) -> Self
fn from(signing_key: PrivateKey) -> Self
Convert a PrivateKey into a DatabaseKey with pubkey-derived identity.
This is equivalent to DatabaseKey::new and covers the most common case
where the key’s identity in auth settings is its own public key.
Source§impl Serialize for PrivateKey
Serializes as the prefixed string format (e.g. "ed25519:base64...").
impl Serialize for PrivateKey
Serializes as the prefixed string format (e.g. "ed25519:base64...").
impl ZeroizeOnDrop for PrivateKey
Zeroization is handled by the inner key types’ Drop impls.
For Ed25519, the zeroize feature on ed25519-dalek ensures
SigningKey::Drop uses volatile writes to clear the secret bytes.
Invariant: all inner key types must implement [ZeroizeOnDrop].
Auto Trait Implementations§
impl Freeze for PrivateKey
impl RefUnwindSafe for PrivateKey
impl Send for PrivateKey
impl Sync for PrivateKey
impl Unpin for PrivateKey
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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