pub struct SecretKey(/* private fields */);Expand description
A crypto_box private key - the DSTU 9041 scalar e.
Implementations§
Source§impl SecretKey
impl SecretKey
Sourcepub fn from_bytes(e: &[u8; 32]) -> Option<Self>
pub fn from_bytes(e: &[u8; 32]) -> Option<Self>
Builds a secret key from a big-endian 32-byte scalar. Returns None if it’s outside the
valid range {2, ..., n-2} (hazmat::dstu9041::curve256::is_valid_scalar).
Sourcepub fn generate() -> Result<Self, RandomError>
pub fn generate() -> Result<Self, RandomError>
Generates a fresh secret key from the OS CSPRNG - libsodium’s crypto_box_keypair()
equivalent (its public-key half is Self::public_key).
§Errors
Returns RandomError if the OS CSPRNG fails while drawing a candidate.
Sourcepub fn to_bytes(&self) -> [u8; 32]
pub fn to_bytes(&self) -> [u8; 32]
Returns e’s big-endian 32-byte encoding, so a generated key can be persisted and later
reloaded via Self::from_bytes. The caller becomes responsible for zeroizing the
returned array once done with it.
pub fn public_key(&self) -> PublicKey
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SecretKey
impl RefUnwindSafe for SecretKey
impl Send for SecretKey
impl Sync for SecretKey
impl Unpin for SecretKey
impl UnsafeUnpin for SecretKey
impl UnwindSafe for SecretKey
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