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> DecodePublicKey for VerifyingKey<C>
where C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression, AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>, FieldSize<C>: ModulusSize,

§

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

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

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

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

impl<'de, C> Deserialize<'de> for VerifyingKey<C>
where C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression, AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>, FieldSize<C>: ModulusSize,

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. 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> EncodePublicKey for VerifyingKey<C>
where C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression, AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>, FieldSize<C>: ModulusSize,

source§

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

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

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

Serialize this public key as PEM-encoded SPKI with the given LineEnding.
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> FromStr for VerifyingKey<C>
where C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression, AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>, FieldSize<C>: ModulusSize,

§

type Err = Error

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

fn from_str(s: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
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) -> Self
where Self: Sized,

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

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

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

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

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

impl<C> PartialEq 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 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> Serialize for VerifyingKey<C>
where C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression, AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>, FieldSize<C>: ModulusSize,

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. 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> TryFrom<SubjectPublicKeyInfo<'_>> for VerifyingKey<C>
where C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression, 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(spki: SubjectPublicKeyInfo<'_>) -> 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§

§

impl<C> Freeze for VerifyingKey<C>
where C: AffineArithmetic + ScalarArithmetic + Curve + Sync + Send + Ord + PartialOrd + PartialEq + Eq + Default + Debug + Clone + Copy + 'static, <C as AffineArithmetic>::AffinePoint: Freeze,

§

impl<C> RefUnwindSafe for VerifyingKey<C>
where C: AffineArithmetic + ScalarArithmetic + Curve + Sync + Send + Ord + PartialOrd + PartialEq + Eq + Default + Debug + Clone + Copy + 'static, <C as AffineArithmetic>::AffinePoint: RefUnwindSafe,

§

impl<C> Send for VerifyingKey<C>
where C: AffineArithmetic + ScalarArithmetic + Curve + Sync + Send + Ord + PartialOrd + PartialEq + Eq + Default + Debug + Clone + Copy + 'static,

§

impl<C> Sync for VerifyingKey<C>
where C: AffineArithmetic + ScalarArithmetic + Curve + Sync + Send + Ord + PartialOrd + PartialEq + Eq + Default + Debug + Clone + Copy + 'static,

§

impl<C> Unpin for VerifyingKey<C>
where C: AffineArithmetic + ScalarArithmetic + Curve + Sync + Send + Ord + PartialOrd + PartialEq + Eq + Default + Debug + Clone + Copy + 'static, <C as AffineArithmetic>::AffinePoint: Unpin,

§

impl<C> UnwindSafe for VerifyingKey<C>
where C: AffineArithmetic + ScalarArithmetic + Curve + Sync + Send + Ord + PartialOrd + PartialEq + Eq + Default + Debug + Clone + Copy + 'static, <C as AffineArithmetic>::AffinePoint: UnwindSafe,

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
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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,