pub struct KeyPair { /* private fields */ }Expand description
A complete hybrid keypair: private seeds plus derived key objects.
Create one with KeyPair::generate or restore one from a previous
KeyPair::to_secret_bytes export via KeyPair::from_secret_bytes.
Implementations§
Source§impl KeyPair
impl KeyPair
Sourcepub fn generate() -> Result<Self>
pub fn generate() -> Result<Self>
Generate a fresh keypair from operating-system randomness.
§Errors
Returns Error::RandomnessUnavailable if the OS RNG fails.
Sourcepub fn public_keys(&self) -> &PublicKeyBundle
pub fn public_keys(&self) -> &PublicKeyBundle
The public half of this keypair, for sharing with peers.
Sourcepub fn to_secret_bytes(&self) -> Zeroizing<Vec<u8>>
pub fn to_secret_bytes(&self) -> Zeroizing<Vec<u8>>
Export the private seeds as a v2 secret-key bundle (QSK2).
The returned buffer is zeroized on drop, but the caller is responsible for protecting any copy written to storage.
Sourcepub fn from_secret_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_secret_bytes(bytes: &[u8]) -> Result<Self>
Restore a keypair from a KeyPair::to_secret_bytes export.
§Errors
Returns Error::InvalidKey on malformed input, and version/suite
errors for artifacts from other format versions.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KeyPair
impl RefUnwindSafe for KeyPair
impl Send for KeyPair
impl Sync for KeyPair
impl Unpin for KeyPair
impl UnsafeUnpin for KeyPair
impl UnwindSafe for KeyPair
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