pub struct KeypairBytes {
    pub secret_key: [u8; 32],
    pub public_key: Option<PublicKeyBytes>,
}
Available on crate feature pkcs8 only.
Expand description

Ed25519 keypair serialized as bytes.

This type is primarily useful for decoding/encoding PKCS#8 private key files (either DER or PEM) encoded using the following traits:

PKCS#8 private key files encoded with PEM begin with:

-----BEGIN PRIVATE KEY-----

Note that this type operates on raw bytes and performs no validation that keys represent valid Ed25519 field elements.

Fields§

§secret_key: [u8; 32]

Ed25519 secret key.

Little endian serialization of an element of the Curve25519 scalar field, prior to “clamping” (i.e. setting/clearing bits to ensure the scalar is actually a valid field element)

§public_key: Option<PublicKeyBytes>

Ed25519 public key (if available).

Compressed Edwards-y encoded curve point.

Implementations§

source§

impl KeypairBytes

source

pub fn from_bytes(bytes: &[u8; 64]) -> KeypairBytes

Parse raw keypair from a 64-byte input.

source

pub fn to_bytes(&self) -> Option<[u8; 64]>

Serialize as a 64-byte keypair.

Returns
  • Some(bytes) if the public_key is present.
  • None if the public_key is absent (i.e. None).

Trait Implementations§

source§

impl Debug for KeypairBytes

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl DecodePrivateKey for KeypairBytes

source§

fn from_pkcs8_der(bytes: &[u8]) -> Result<Self, Error>

Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary format).
source§

impl Drop for KeypairBytes

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl EncodePrivateKey for KeypairBytes

Available on crate feature alloc only.
source§

fn to_pkcs8_der(&self) -> Result<SecretDocument, Error>

Serialize a SecretDocument containing a PKCS#8-encoded private key.
source§

impl From<&SigningKey> for KeypairBytes

source§

fn from(signing_key: &SigningKey) -> KeypairBytes

Converts to this type from the input type.
source§

impl From<SigningKey> for KeypairBytes

source§

fn from(signing_key: SigningKey) -> KeypairBytes

Converts to this type from the input type.
source§

impl TryFrom<&[u8]> for KeypairBytes

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(der_bytes: &[u8]) -> Result<KeypairBytes, Error>

Performs the conversion.
source§

impl TryFrom<&KeypairBytes> for PublicKeyBytes

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(keypair: &KeypairBytes) -> Result<PublicKeyBytes, Error>

Performs the conversion.
source§

impl TryFrom<&KeypairBytes> for SigningKey

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(pkcs8_key: &KeypairBytes) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<KeypairBytes> for PublicKeyBytes

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(keypair: KeypairBytes) -> Result<PublicKeyBytes, Error>

Performs the conversion.
source§

impl TryFrom<KeypairBytes> for SigningKey

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(pkcs8_key: KeypairBytes) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<PrivateKeyInfo<'_>> for KeypairBytes

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(private_key: PrivateKeyInfo<'_>) -> Result<KeypairBytes, Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.