pub enum KeyPair {
Ed25519(Keypair),
Rsa(Keypair),
Secp256k1(Keypair),
}Variants§
Ed25519(Keypair)
An Ed25519 keypair.
Rsa(Keypair)
An RSA keypair.
Secp256k1(Keypair)
A Secp256k1 keypair.
Implementations§
Source§impl KeyPair
impl KeyPair
pub fn generate(format: KeyFormat) -> KeyPair
Sourcepub fn generate_ed25519() -> KeyPair
pub fn generate_ed25519() -> KeyPair
Generate a new Ed25519 keypair.
Sourcepub fn generate_secp256k1() -> KeyPair
pub fn generate_secp256k1() -> KeyPair
Generate a new Secp256k1 keypair.
Sourcepub fn rsa_from_pkcs8(pkcs8_der: &mut [u8]) -> Result<KeyPair, DecodingError>
pub fn rsa_from_pkcs8(pkcs8_der: &mut [u8]) -> Result<KeyPair, DecodingError>
Decode an keypair from a DER-encoded secret key in PKCS#8 PrivateKeyInfo format (i.e. unencrypted) as defined in RFC5208.
Sourcepub fn secp256k1_from_der(der: &mut [u8]) -> Result<KeyPair, DecodingError>
pub fn secp256k1_from_der(der: &mut [u8]) -> Result<KeyPair, DecodingError>
Decode a keypair from a DER-encoded Secp256k1 secret key in an ECPrivateKey structure as defined in RFC5915.
Sourcepub fn sign(&self, msg: &[u8]) -> Result<Signature, SigningError>
pub fn sign(&self, msg: &[u8]) -> Result<Signature, SigningError>
Sign a message using the private key of this keypair, producing a signature that can be verified using the corresponding public key.
Sourcepub fn verify(
pk: &PublicKey,
msg: &[u8],
signature: &Signature,
) -> Result<(), SigningError>
pub fn verify( pk: &PublicKey, msg: &[u8], signature: &Signature, ) -> Result<(), SigningError>
Verify the signature on a message using the public key.
pub fn to_vec(&self) -> Vec<u8> ⓘ
pub fn from_vec( bytes: Vec<u8>, format: KeyFormat, ) -> Result<Self, DecodingError>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more