pub struct PublicKeyBytes(pub [u8; 32]);
Available on crate feature pkcs8 only.
Expand description

Ed25519 public key serialized as bytes.

This type is primarily useful for decoding/encoding SPKI public key files (either DER or PEM) encoded using the following traits:

SPKI public key files encoded with PEM begin with:

-----BEGIN PUBLIC KEY-----

Note that this type operates on raw bytes and performs no validation that public keys represent valid compressed Ed25519 y-coordinates.

Tuple Fields§

§0: [u8; 32]

Implementations§

source§

impl PublicKeyBytes

source

pub fn to_bytes(&self) -> [u8; 32]

Returns the raw bytes of the public key.

Trait Implementations§

source§

impl AsRef<[u8; 32]> for PublicKeyBytes

source§

fn as_ref(&self) -> &[u8; 32]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for PublicKeyBytes

source§

fn clone(&self) -> PublicKeyBytes

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for PublicKeyBytes

source§

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

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

impl EncodePublicKey for PublicKeyBytes

Available on crate feature alloc only.
source§

fn to_public_key_der(&self) -> Result<Document, Error>

Serialize a Document containing a SPKI-encoded public key.
§

fn to_public_key_pem(&self, line_ending: LineEnding) -> Result<String, Error>

Available on crate feature pem only.
Serialize this public key as PEM-encoded SPKI with the given LineEnding.
§

fn write_public_key_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>

Available on crate feature std only.
Write ASN.1 DER-encoded public key to the given path
§

fn write_public_key_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding ) -> Result<(), Error>

Available on crate features pem and std only.
Write ASN.1 DER-encoded public key to the given path
source§

impl From<&VerifyingKey> for PublicKeyBytes

source§

fn from(verifying_key: &VerifyingKey) -> PublicKeyBytes

Converts to this type from the input type.
source§

impl From<VerifyingKey> for PublicKeyBytes

source§

fn from(verifying_key: VerifyingKey) -> PublicKeyBytes

Converts to this type from the input type.
source§

impl FromStr for PublicKeyBytes

Available on crate feature pem only.
§

type Err = Error

The associated error which can be returned from parsing.
source§

fn from_str(pem: &str) -> Result<PublicKeyBytes, Error>

Parses a string s to return a value of this type. Read more
source§

impl PartialEq for PublicKeyBytes

source§

fn eq(&self, other: &PublicKeyBytes) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ToString for PublicKeyBytes

Available on crate feature pem only.
source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl TryFrom<&[u8]> for PublicKeyBytes

§

type Error = Error

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

fn try_from(der_bytes: &[u8]) -> Result<PublicKeyBytes, 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<&PublicKeyBytes> for VerifyingKey

§

type Error = Error

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

fn try_from(pkcs8_key: &PublicKeyBytes) -> 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<PublicKeyBytes> for VerifyingKey

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<SubjectPublicKeyInfo<AnyRef<'_>, BitStringRef<'_>>> for PublicKeyBytes

§

type Error = Error

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

fn try_from( spki: SubjectPublicKeyInfo<AnyRef<'_>, BitStringRef<'_>> ) -> Result<PublicKeyBytes, Error>

Performs the conversion.
source§

impl Copy for PublicKeyBytes

source§

impl Eq for PublicKeyBytes

source§

impl StructuralPartialEq for PublicKeyBytes

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> DecodePublicKey for T
where T: for<'a> TryFrom<SubjectPublicKeyInfo<AnyRef<'a>, BitStringRef<'a>>, Error = Error>,

§

fn from_public_key_der(bytes: &[u8]) -> Result<T, Error>

Deserialize object from ASN.1 DER-encoded [SubjectPublicKeyInfo] (binary format).
§

fn from_public_key_pem(s: &str) -> Result<Self, Error>

Available on crate feature pem only.
Deserialize PEM-encoded [SubjectPublicKeyInfo]. Read more
§

fn read_public_key_der_file(path: impl AsRef<Path>) -> Result<Self, Error>

Available on crate feature std only.
Load public key object from an ASN.1 DER-encoded file on the local filesystem (binary format).
§

fn read_public_key_pem_file(path: impl AsRef<Path>) -> Result<Self, Error>

Available on crate features pem and std only.
Load public key object from a PEM-encoded file on the local filesystem.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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 for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

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

§

type Error = Infallible

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

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

Performs the conversion.
source§

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

§

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

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

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

Performs the conversion.