pub struct KeyPair {
pub public: PublicKey,
pub secret: SecretKey,
}Expand description
A cryptographic key pair for the age protocol.
Contains a PublicKey and a SecretKey, both guaranteed to be valid
age keys. The Debug implementation redacts the secret key value while
displaying the public key in full.
§Obtaining a KeyPair
Use build_keypair to generate a fresh key pair:
use age_setup::build_keypair;
let kp = build_keypair()?;
println!("Public: {}", kp.public);§Debug Safety
The debug representation does not leak the secret key:
use age_setup::build_keypair;
let kp = build_keypair()?;
let debug_str = format!("{:?}", kp);
assert!(debug_str.contains(kp.public.expose()));
assert!(!debug_str.contains(kp.secret.expose_secret()));§See Also
build_keypair– Generates a newKeyPair.SecretKey– Zeroizing secret key wrapper.PublicKey– Validated public key wrapper.
Fields§
§public: PublicKeyThe public key component.
secret: SecretKeyThe secret key component (redacted in debug output).
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