pub trait KeyPair: Signer {
// Required methods
fn generate() -> Result<Self, <Self as Signer>::Error>
where Self: Sized;
fn from_bytes(private_key: &[u8]) -> Result<Self, <Self as Signer>::Error>
where Self: Sized;
fn private_key_bytes(&self) -> Zeroizing<Vec<u8>>;
// Provided methods
fn from_keypair_bytes(
keypair: &[u8],
) -> Result<Self, <Self as Signer>::Error>
where Self: Sized { ... }
fn keypair_bytes(&self) -> Zeroizing<Vec<u8>> { ... }
}Expand description
A type that represents a cryptographic key pair capable of signing.
Required Methods§
Sourcefn generate() -> Result<Self, <Self as Signer>::Error>where
Self: Sized,
fn generate() -> Result<Self, <Self as Signer>::Error>where
Self: Sized,
Generate a new random key pair using OS entropy (CSPRNG).
Sourcefn from_bytes(private_key: &[u8]) -> Result<Self, <Self as Signer>::Error>where
Self: Sized,
fn from_bytes(private_key: &[u8]) -> Result<Self, <Self as Signer>::Error>where
Self: Sized,
Reconstruct a key pair from raw private key bytes (32 bytes).
Sourcefn private_key_bytes(&self) -> Zeroizing<Vec<u8>>
fn private_key_bytes(&self) -> Zeroizing<Vec<u8>>
Export the private key as auto-zeroizing bytes.
The returned Zeroizing<Vec<u8>> will scrub the memory on drop.
Provided Methods§
Sourcefn from_keypair_bytes(keypair: &[u8]) -> Result<Self, <Self as Signer>::Error>where
Self: Sized,
fn from_keypair_bytes(keypair: &[u8]) -> Result<Self, <Self as Signer>::Error>where
Self: Sized,
Reconstruct a key pair from a 64-byte expanded keypair (seed ∥ pubkey). Default impl uses only the first 32 bytes (seed).
Sourcefn keypair_bytes(&self) -> Zeroizing<Vec<u8>>
fn keypair_bytes(&self) -> Zeroizing<Vec<u8>>
Export the full keypair as private_key ∥ public_key.
Default: 32B seed + compressed pubkey.