pub struct KeyPair { /* private fields */ }Expand description
An Ed25519 keypair for signing documents.
Implementations§
Source§impl KeyPair
impl KeyPair
Sourcepub fn from_bytes(secret_bytes: &[u8; 32]) -> Self
pub fn from_bytes(secret_bytes: &[u8; 32]) -> Self
Create a keypair from raw secret key bytes (32 bytes).
Sourcepub fn secret_bytes(&self) -> [u8; 32]
pub fn secret_bytes(&self) -> [u8; 32]
Get the secret key bytes.
Sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Get the public key.
Sourcepub fn save_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn save_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
Save the keypair to a file.
The file format is:
- Line 1: “RUST-SIGN PRIVATE KEY”
- Line 2: Base64-encoded secret key
- Line 3: Base64-encoded public key
Sourcepub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self>
Load a keypair from a file.
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 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