Struct sequoia_openpgp::crypto::KeyPair[][src]

pub struct KeyPair { /* fields omitted */ }
Expand description

A cryptographic key pair.

A KeyPair is a combination of public and secret key. If both are available in memory, a KeyPair is a convenient implementation of Signer and Decryptor.

Examples

use sequoia_openpgp as openpgp;
use openpgp::types::Curve;
use openpgp::cert::prelude::*;
use openpgp::packet::prelude::*;

// Conveniently create a KeyPair from a bare key:
let keypair =
    Key4::<_, key::UnspecifiedRole>::generate_ecc(false, Curve::Cv25519)?
        .into_keypair()?;

// Or from a query over a certificate:
let (cert, _) =
    CertBuilder::general_purpose(None, Some("alice@example.org"))
        .generate()?;
let keypair =
    cert.keys().unencrypted_secret().nth(0).unwrap().key().clone()
        .into_keypair()?;

Implementations

Creates a new key pair.

Returns a reference to the public key.

Returns a reference to the secret key.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Returns a reference to the public key.

Decrypts ciphertext, returning the plain session key.

Performs the conversion.

Returns a reference to the public key.

Creates a signature over the digest produced by hash_algo.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.