pub struct MlDsaSecretKey { /* private fields */ }Expand description
ML-DSA secret key
Contains the private signing key for ML-DSA signatures. This key must be kept secret and is automatically zeroized when dropped.
§Security Considerations
- Never expose secret keys in logs or error messages
- Store securely (encrypted at rest)
- Use secure channels for transmission
- Consider hardware security modules (HSMs) for production
§Examples
use saorsa_pqc::api::sig::{ml_dsa_65, MlDsaSecretKey, MlDsaVariant};
let dsa = ml_dsa_65();
let (_, secret_key) = dsa.generate_keypair()?;
// Serialize for secure storage
let key_bytes = secret_key.to_bytes();
// Store key_bytes securely (encrypted)
// Later, restore from secure storage
let restored = MlDsaSecretKey::from_bytes(MlDsaVariant::MlDsa65, &key_bytes)?;Implementations§
Source§impl MlDsaSecretKey
impl MlDsaSecretKey
Sourcepub const fn variant(&self) -> MlDsaVariant
pub const fn variant(&self) -> MlDsaVariant
Get the variant of this key
Sourcepub fn from_bytes(
variant: MlDsaVariant,
bytes: &[u8],
) -> Result<MlDsaSecretKey, PqcError>
pub fn from_bytes( variant: MlDsaVariant, bytes: &[u8], ) -> Result<MlDsaSecretKey, PqcError>
Import a secret key from bytes
§Errors
Returns an error if the byte slice has an incorrect length for the specified variant.
Trait Implementations§
Source§impl Clone for MlDsaSecretKey
impl Clone for MlDsaSecretKey
Source§fn clone(&self) -> MlDsaSecretKey
fn clone(&self) -> MlDsaSecretKey
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Drop for MlDsaSecretKey
impl Drop for MlDsaSecretKey
Auto Trait Implementations§
impl Freeze for MlDsaSecretKey
impl RefUnwindSafe for MlDsaSecretKey
impl Send for MlDsaSecretKey
impl Sync for MlDsaSecretKey
impl Unpin for MlDsaSecretKey
impl UnsafeUnpin for MlDsaSecretKey
impl UnwindSafe for MlDsaSecretKey
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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