pub struct Ed25519SecretKey(/* private fields */);hmac or hkdf or kmac or ed25519 or x25519 or phc-strings or argon2 or scrypt) and crate feature ed25519 only.Expand description
Ed25519 secret key bytes.
Provides typed signing and public-key derivation instead of vague &[u8]
parameters at the call site.
Implementations§
Source§impl Ed25519SecretKey
impl Ed25519SecretKey
Sourcepub const fn from_bytes(bytes: [u8; 32]) -> Self
pub const fn from_bytes(bytes: [u8; 32]) -> Self
Construct a secret key from its byte representation.
Sourcepub fn expose_secret(&self) -> SecretBytes<{ Self::LENGTH }>
pub fn expose_secret(&self) -> SecretBytes<{ Self::LENGTH }>
Explicitly extract the secret key bytes into a zeroizing wrapper.
Sourcepub fn public_key(&self) -> Ed25519PublicKey
pub fn public_key(&self) -> Ed25519PublicKey
Derive the matching Ed25519 public key.
Sourcepub fn sign(&self, message: &[u8]) -> Ed25519Signature
pub fn sign(&self, message: &[u8]) -> Ed25519Signature
Sign a message with this secret key.
Source§impl Ed25519SecretKey
impl Ed25519SecretKey
Sourcepub fn generate(fill: impl FnOnce(&mut [u8; 32])) -> Self
pub fn generate(fill: impl FnOnce(&mut [u8; 32])) -> Self
Construct a secret key by filling bytes from the provided closure.
let sk = Ed25519SecretKey::generate(|buf| buf.fill(0xA5));
assert_eq!(sk.as_bytes(), &[0xA5; Ed25519SecretKey::LENGTH]);Sourcepub fn random() -> Self
Available on crate feature getrandom only.
pub fn random() -> Self
getrandom only.Generate a random instance using the operating system’s CSPRNG.
§Panics
Panics if the platform entropy source is unavailable.
Sourcepub fn try_random() -> Result<Self, Error>
Available on crate feature getrandom only.
pub fn try_random() -> Result<Self, Error>
getrandom only.Try to generate a random instance from the platform entropy source.
§Errors
Returns a getrandom error if the platform entropy source is unavailable.
Source§impl Ed25519SecretKey
impl Ed25519SecretKey
Sourcepub fn display_secret(&self) -> DisplaySecret<'_>
pub fn display_secret(&self) -> DisplaySecret<'_>
Returns a wrapper that displays the key bytes as lowercase hex.
This is an explicit opt-in for showing secret key material.
The wrapper implements Display.
Trait Implementations§
Source§impl Clone for Ed25519SecretKey
impl Clone for Ed25519SecretKey
Source§fn clone(&self) -> Ed25519SecretKey
fn clone(&self) -> Ed25519SecretKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConstantTimeEq for Ed25519SecretKey
impl ConstantTimeEq for Ed25519SecretKey
Source§impl Debug for Ed25519SecretKey
impl Debug for Ed25519SecretKey
Source§impl<'de> Deserialize<'de> for Ed25519SecretKey
Available on crate feature serde-secrets only.
impl<'de> Deserialize<'de> for Ed25519SecretKey
serde-secrets only.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 Drop for Ed25519SecretKey
impl Drop for Ed25519SecretKey
Source§impl FromStr for Ed25519SecretKey
impl FromStr for Ed25519SecretKey
Source§impl PartialEq for Ed25519SecretKey
impl PartialEq for Ed25519SecretKey
Source§impl Serialize for Ed25519SecretKey
Available on crate feature serde-secrets only.
impl Serialize for Ed25519SecretKey
serde-secrets only.impl Eq for Ed25519SecretKey
Auto Trait Implementations§
impl Freeze for Ed25519SecretKey
impl RefUnwindSafe for Ed25519SecretKey
impl Send for Ed25519SecretKey
impl Sync for Ed25519SecretKey
impl Unpin for Ed25519SecretKey
impl UnsafeUnpin for Ed25519SecretKey
impl UnwindSafe for Ed25519SecretKey
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,
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