pub struct KeyPair { /* private fields */ }Expand description
An Ed25519 key pair with secure memory handling.
The secret key is zeroized on drop to prevent leaking sensitive material.
Implementations§
Source§impl KeyPair
impl KeyPair
Sourcepub fn from_secret_key(bytes: &[u8]) -> CryptoResult<Self>
pub fn from_secret_key(bytes: &[u8]) -> CryptoResult<Self>
Create from a secret key (32 bytes).
§Errors
Returns CryptoError::InvalidKeyLength if the slice is not exactly 32 bytes.
Sourcepub fn public_key_bytes(&self) -> &[u8; 32]
pub fn public_key_bytes(&self) -> &[u8; 32]
Get the public key bytes (32 bytes).
Sourcepub fn key_id(&self) -> [u8; 8]
pub fn key_id(&self) -> [u8; 8]
Get a short key ID (first 8 bytes of public key).
Useful for identifying keys in logs without exposing the full key.
Sourcepub fn key_id_hex(&self) -> String
pub fn key_id_hex(&self) -> String
Get the key ID as a hex string.
Sourcepub fn verify(&self, message: &[u8], signature: &Signature) -> CryptoResult<()>
pub fn verify(&self, message: &[u8], signature: &Signature) -> CryptoResult<()>
Verify a signature (convenience method using our public key).
§Errors
Returns CryptoError::SignatureVerificationFailed if verification fails.
Sourcepub fn export_public_key(&self) -> PublicKey
pub fn export_public_key(&self) -> PublicKey
Export the public key for serialization.
Sourcepub fn secret_key_bytes(&self) -> [u8; 32]
pub fn secret_key_bytes(&self) -> [u8; 32]
Export the secret key bytes (careful - sensitive!).
This should only be used for secure storage.
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