Struct ecdsa::VerifyingKey

source ·
pub struct VerifyingKey<C>where
    C: PrimeCurve + ProjectiveArithmetic,{ /* private fields */ }
Expand description

ECDSA verification key (i.e. public key). Generic over elliptic curves.

Requires an elliptic_curve::ProjectiveArithmetic impl on the curve, and a VerifyPrimitive impl on its associated AffinePoint type.

serde support

When the serde feature of this crate is enabled, it provides support for serializing and deserializing ECDSA signatures using the Serialize and Deserialize traits.

The serialization leverages the encoding used by the PublicKey type, which is a binary-oriented ASN.1 DER encoding.

Implementations§

source§

impl<C> VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic, AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>, FieldSize<C>: ModulusSize,

source

pub fn from_sec1_bytes(bytes: &[u8]) -> Result<Self>

Initialize VerifyingKey from a SEC1-encoded public key.

source

pub fn from_affine(affine: AffinePoint<C>) -> Result<Self>

Initialize VerifyingKey from an affine point.

Returns an Error if the given affine point is the additive identity (a.k.a. point at infinity).

source

pub fn from_encoded_point(public_key: &EncodedPoint<C>) -> Result<Self>

Initialize VerifyingKey from an EncodedPoint.

source

pub fn to_encoded_point(&self, compress: bool) -> EncodedPoint<C>

Serialize this VerifyingKey as a SEC1 EncodedPoint, optionally applying point compression.

source

pub fn as_affine(&self) -> &AffinePoint<C>

Borrow the inner AffinePoint for this public key.

Trait Implementations§

source§

impl<C> AsRef<<C as AffineArithmetic>::AffinePoint> for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic, AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>, FieldSize<C>: ModulusSize,

source§

fn as_ref(&self) -> &AffinePoint<C>

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

impl<C> AsRef<VerifyingKey<C>> for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,

source§

fn as_ref(&self) -> &VerifyingKey<C>

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

impl<C> Clone for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic + Clone,

source§

fn clone(&self) -> VerifyingKey<C>

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<C> Debug for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic + Debug,

source§

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

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

impl<C, D> DigestVerifier<D, Signature<C>> for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic, D: Digest + FixedOutput<OutputSize = FieldSize<C>>, AffinePoint<C>: VerifyPrimitive<C>, Scalar<C>: Reduce<C::UInt>, SignatureSize<C>: ArrayLength<u8>,

source§

fn verify_digest(&self, msg_digest: D, signature: &Signature<C>) -> Result<()>

Verify the signature against the given Digest output.
source§

impl<C> From<&PublicKey<C>> for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic,

source§

fn from(public_key: &PublicKey<C>) -> VerifyingKey<C>

Converts to this type from the input type.
source§

impl<C> From<&SigningKey<C>> for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,

source§

fn from(signing_key: &SigningKey<C>) -> VerifyingKey<C>

Converts to this type from the input type.
source§

impl<C> From<&VerifyingKey<C>> for EncodedPoint<C>where C: PrimeCurve + ProjectiveArithmetic + PointCompression, AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>, FieldSize<C>: ModulusSize,

source§

fn from(verifying_key: &VerifyingKey<C>) -> EncodedPoint<C>

Converts to this type from the input type.
source§

impl<C> From<&VerifyingKey<C>> for PublicKey<C>where C: PrimeCurve + ProjectiveArithmetic,

source§

fn from(verifying_key: &VerifyingKey<C>) -> PublicKey<C>

Converts to this type from the input type.
source§

impl<C> From<PublicKey<C>> for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic,

source§

fn from(public_key: PublicKey<C>) -> VerifyingKey<C>

Converts to this type from the input type.
source§

impl<C> From<VerifyingKey<C>> for PublicKey<C>where C: PrimeCurve + ProjectiveArithmetic,

source§

fn from(verifying_key: VerifyingKey<C>) -> PublicKey<C>

Converts to this type from the input type.
source§

impl<C> Ord for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic, AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>, FieldSize<C>: ModulusSize,

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<C> PartialEq<VerifyingKey<C>> for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic,

source§

fn eq(&self, other: &Self) -> 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<C> PartialOrd<VerifyingKey<C>> for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic, AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>, FieldSize<C>: ModulusSize,

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<C> PrehashVerifier<Signature<C>> for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic + DigestPrimitive, AffinePoint<C>: VerifyPrimitive<C>, Scalar<C>: Reduce<C::UInt>, SignatureSize<C>: ArrayLength<u8>,

source§

fn verify_prehash(&self, prehash: &[u8], signature: &Signature<C>) -> Result<()>

Use Self to verify that the provided signature for a given message prehash is authentic. Read more
source§

impl<C> TryFrom<&[u8]> for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic, AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>, FieldSize<C>: ModulusSize,

§

type Error = Error

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

fn try_from(bytes: &[u8]) -> Result<Self>

Performs the conversion.
source§

impl<C> Verifier<Signature<C>> for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic + DigestPrimitive, C::Digest: FixedOutput<OutputSize = FieldSize<C>>, AffinePoint<C>: VerifyPrimitive<C>, Scalar<C>: Reduce<C::UInt>, SignatureSize<C>: ArrayLength<u8>,

source§

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

Use Self to verify that the provided signature for a given message bytestring is authentic. Read more
source§

impl<C> Copy for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic,

source§

impl<C> Eq for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic,

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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.