[][src]Struct ring::signature::Ed25519KeyPair

pub struct Ed25519KeyPair { /* fields omitted */ }

An Ed25519 key pair, for signing.

Methods

impl<'a> KeyPair[src]

pub fn generate_pkcs8(rng: &dyn SecureRandom) -> Result<Document, Unspecified>[src]

Generates a new key pair and returns the key pair serialized as a PKCS#8 document.

The PKCS#8 document will be a v2 OneAsymmetricKey with the public key, as described in RFC 5958 Section 2. See also https://tools.ietf.org/html/draft-ietf-curdle-pkix-04.

pub fn from_pkcs8(input: Input) -> Result<Self, KeyRejected>[src]

Constructs an Ed25519 key pair by parsing an unencrypted PKCS#8 v2 Ed25519 private key.

The input must be in PKCS#8 v2 format, and in particular it must contain the public key in addition to the private key. from_pkcs8() will verify that the public key and the private key are consistent with each other.

If you need to parse PKCS#8 v1 files (without the public key) then use Ed25519KeyPair::from_pkcs8_maybe_unchecked() instead.

pub fn from_pkcs8_maybe_unchecked(input: Input) -> Result<Self, KeyRejected>[src]

Constructs an Ed25519 key pair by parsing an unencrypted PKCS#8 v1 or v2 Ed25519 private key.

It is recommended to use Ed25519KeyPair::from_pkcs8(), which accepts only PKCS#8 v2 files that contain the public key. from_pkcs8_maybe_unchecked() parses PKCS#2 files exactly like from_pkcs8(). It also accepts v1 files. PKCS#8 v1 files do not contain the public key, so when a v1 file is parsed the public key will be computed from the private key, and there will be no consistency check between the public key and the private key.

PKCS#8 v2 files are parsed exactly like Ed25519KeyPair::from_pkcs8().

pub fn from_seed_and_public_key(
    seed: Input,
    public_key: Input
) -> Result<Self, KeyRejected>
[src]

Constructs an Ed25519 key pair from the private key seed seed and its public key public_key.

It is recommended to use Ed25519KeyPair::from_pkcs8() instead.

The private and public keys will be verified to be consistent with each other. This helps avoid misuse of the key (e.g. accidentally swapping the private key and public key, or using the wrong private key for the public key). This also detects any corruption of the public or private key.

pub fn from_seed_unchecked(seed: Input) -> Result<Self, KeyRejected>[src]

Constructs a Ed25519 key pair from the private key seed seed.

It is recommended to use Ed25519KeyPair::from_pkcs8() instead. When that is not practical, it is recommended to use Ed25519KeyPair::from_seed_and_public_key() instead.

Since the public key is not given, the public key will be computed from the private key. It is not possible to detect misuse or corruption of the private key since the public key isn't given as input.

pub fn sign(&self, msg: &[u8]) -> Signature[src]

Returns the signature of the message msg.

Trait Implementations

impl KeyPair for KeyPair[src]

type PublicKey = PublicKey

The type of the public key.

impl Debug for KeyPair[src]

Auto Trait Implementations

impl Send for KeyPair

impl Sync for KeyPair

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

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

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]