Skip to main content

VerifyingKey

Struct VerifyingKey 

Source
pub struct VerifyingKey {
    pub(crate) compressed: CompressedEdwardsY,
    pub(crate) point: EdwardsPoint,
}
Expand description

Ed448 public key as defined in [RFC8032 § 5.2.5]

Fields§

§compressed: CompressedEdwardsY§point: EdwardsPoint

Implementations§

Source§

impl VerifyingKey

Source

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

Convert this verifying key into byte slice

Source

pub fn as_bytes(&self) -> &[u8; 57]

View this public key as a byte slice.

Source

pub fn from_bytes(bytes: &[u8; 57]) -> Result<Self, Error>

Construct a VerifyingKey from a slice of bytes.

Source

pub fn with_context<'k, 'v>( &'k self, context: &'v [u8], ) -> Context<'k, 'v, Self>

Create a context for this verifying key that can be used with signature::DigestVerifier.

Source

pub fn to_edwards(self) -> EdwardsPoint

Return the verifying key in Edwards form.

Source

pub fn verify_raw( &self, signature: &Signature, message: &[u8], ) -> Result<(), Error>

Verifies a signature on a message.

This is the “Ed448” mode of RFC 8032 (no pre-hashing, a context is provided). This is equivalent to verify_ctx() with an empty (zero-length) context.

Note: this function is not constant-time; it assumes that the public key and signature value are public data.

Source

pub fn verify_ctx( self, sig: &Signature, ctx: &[u8], message: &[u8], ) -> Result<(), Error>

Verifies a signature on a message (with context).

This is the “Ed448” mode of RFC 8032 (no pre-hashing, a context is provided). The context string MUST have length at most 255 bytes. Return value is Ok on a valid signature, Error otherwise.

Note: this function is not constant-time; it assumes that the public key and signature value are public data.

Source

pub fn verify_prehashed<D>( self, sig: &Signature, ctx: Option<&[u8]>, prehashed_message: D, ) -> Result<(), Error>
where D: PreHash,

Verifies a signature on a hashed message.

This is the “Ed448ph” mode of RFC 8032 (message is pre-hashed), also known as “HashEdDSA on Curve448”. The hashed message prehashed_message is provided (presumably, that hash value was obtained with SHAKE256 and a 64-byte output; the caller does the hashing itself). A context string ctx is also provided; it MUST have length at most 255 bytes. Return value is Ok on a valid signature, Error otherwise.

Note: this function is not constant-time; it assumes that the public key and signature value are public data.

Source

fn verify_inner( &self, signature: &Signature, phflag: u8, ctx: &[u8], m: &[u8], ) -> Result<(), Error>

Trait Implementations§

Source§

impl AsRef<[u8]> for VerifyingKey

Source§

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

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

impl Clone for VerifyingKey

Source§

fn clone(&self) -> VerifyingKey

Returns a duplicate 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 VerifyingKey

Source§

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

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

impl Default for VerifyingKey

Source§

fn default() -> VerifyingKey

Returns the “default value” for a type. Read more
Source§

impl<D> DigestVerifier<D, Signature> for VerifyingKey

Source§

fn verify_digest<F: Fn(&mut D) -> Result<(), Error>>( &self, f: F, signature: &Signature, ) -> Result<(), Error>

Verify the signature against the received Digest output, by updating it with the message. Read more
Source§

impl DynSignatureAlgorithmIdentifier for VerifyingKey

Available on crate features alloc and pkcs8 only.
Source§

fn signature_algorithm_identifier(&self) -> Result<AlgorithmIdentifierOwned>

AlgorithmIdentifier for the corresponding signature system. Read more
Source§

impl EncodePublicKey for VerifyingKey

Available on crate features alloc and pkcs8 only.
Source§

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

Serialize a Document containing a SPKI-encoded public key. Read more
Source§

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

Serialize this public key as PEM-encoded SPKI with the given LineEnding. Read more
Source§

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

Write ASN.1 DER-encoded public key to the given path. Read more
Source§

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

Write ASN.1 PEM-encoded public key to the given path. Read more
Source§

impl From<VerifyingKey> for PublicKeyBytes

Available on crate feature pkcs8 only.
Source§

fn from(key: VerifyingKey) -> Self

Converts to this type from the input type.
Source§

impl Hash for VerifyingKey

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for VerifyingKey

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<&PublicKeyBytes> for VerifyingKey

Available on crate feature pkcs8 only.
Source§

type Error = Error

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

fn try_from(value: &PublicKeyBytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PublicKeyBytes> for VerifyingKey

Available on crate feature pkcs8 only.
Source§

type Error = Error

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

fn try_from(value: PublicKeyBytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

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

Available on crate feature pkcs8 only.
Source§

type Error = Error

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

fn try_from(public_key: SubjectPublicKeyInfoRef<'_>) -> Result<Self>

Performs the conversion.
Source§

impl Verifier<Signature> for VerifyingKey

Source§

fn verify(&self, msg: &[u8], signature: &Signature) -> Result<(), Error>

Use Self (e.g. a verifying key) to verify that the provided signature is authentic for a given message bytestring. Read more
Source§

impl Copy for VerifyingKey

Source§

impl Eq for VerifyingKey

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<S, T> AsyncVerifier<S> for T
where T: Verifier<S>,

Source§

async fn verify_async(&self, msg: &[u8], signature: &S) -> Result<(), Error>

Asynchronously verify that the provided signature for a given message bytestring is authentic. 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
Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

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

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

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

Deserialize PEM-encoded [SubjectPublicKeyInfo]. Read more
Source§

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

Load public key object from an ASN.1 DER-encoded file on the local filesystem (binary format). Read more
Source§

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

Load public key object from a PEM-encoded file on the local filesystem. Read more
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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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>,

Source§

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.