Struct ecdsa::VerifyingKey
source · [−]pub struct VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,{ /* private fields */ }
verify
only.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
sourceimpl<C> VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
impl<C> VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
sourcepub fn from_sec1_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_sec1_bytes(bytes: &[u8]) -> Result<Self>
Initialize VerifyingKey
from a SEC1-encoded public key.
sourcepub fn from_affine(affine: AffinePoint<C>) -> Result<Self>
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).
sourcepub fn from_encoded_point(public_key: &EncodedPoint<C>) -> Result<Self>
pub fn from_encoded_point(public_key: &EncodedPoint<C>) -> Result<Self>
Initialize VerifyingKey
from an EncodedPoint
.
sourcepub fn to_encoded_point(&self, compress: bool) -> EncodedPoint<C>
pub fn to_encoded_point(&self, compress: bool) -> EncodedPoint<C>
Serialize this VerifyingKey
as a SEC1 EncodedPoint
, optionally
applying point compression.
sourcepub fn as_affine(&self) -> &AffinePoint<C>
pub fn as_affine(&self) -> &AffinePoint<C>
Borrow the inner AffinePoint
for this public key.
Trait Implementations
sourceimpl<C> AsRef<<C as AffineArithmetic>::AffinePoint> for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
impl<C> AsRef<<C as AffineArithmetic>::AffinePoint> for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
sourcefn as_ref(&self) -> &AffinePoint<C>
fn as_ref(&self) -> &AffinePoint<C>
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl<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>,
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>,
sourcefn as_ref(&self) -> &VerifyingKey<C>
fn as_ref(&self) -> &VerifyingKey<C>
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl<C: Clone> Clone for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
impl<C: Clone> Clone for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
sourcefn clone(&self) -> VerifyingKey<C>
fn clone(&self) -> VerifyingKey<C>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<C: Debug> Debug for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
impl<C: Debug> Debug for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
sourceimpl<C> DecodePublicKey for VerifyingKey<C>where
C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature pkcs8
only.
impl<C> DecodePublicKey for VerifyingKey<C>where
C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
pkcs8
only.fn from_public_key_der(bytes: &[u8]) -> Result<Self, Error>
fn from_public_key_der(bytes: &[u8]) -> Result<Self, Error>
Deserialize object from ASN.1 DER-encoded [SubjectPublicKeyInfo
]
(binary format). Read more
fn from_public_key_pem(s: &str) -> Result<Self, Error>
fn from_public_key_pem(s: &str) -> Result<Self, Error>
Deserialize PEM-encoded [SubjectPublicKeyInfo
]. Read more
sourceimpl<'de, C> Deserialize<'de> for VerifyingKey<C>where
C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate features pem
and serde
only.
impl<'de, C> Deserialize<'de> for VerifyingKey<C>where
C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
pem
and serde
only.sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<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>,
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>,
sourceimpl<C> EncodePublicKey for VerifyingKey<C>where
C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature pem
only.
impl<C> EncodePublicKey for VerifyingKey<C>where
C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
pem
only.sourcefn to_public_key_der(&self) -> Result<Document>
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>
fn to_public_key_pem(&self, line_ending: LineEnding) -> Result<String, Error>
Serialize this public key as PEM-encoded SPKI with the given [LineEnding
].
sourceimpl<C> From<&PublicKey<C>> for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
impl<C> From<&PublicKey<C>> for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
sourcefn from(public_key: &PublicKey<C>) -> VerifyingKey<C>
fn from(public_key: &PublicKey<C>) -> VerifyingKey<C>
Converts to this type from the input type.
sourceimpl<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>,
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>,
sourcefn from(signing_key: &SigningKey<C>) -> VerifyingKey<C>
fn from(signing_key: &SigningKey<C>) -> VerifyingKey<C>
Converts to this type from the input type.
sourceimpl<C> From<&VerifyingKey<C>> for EncodedPoint<C>where
C: PrimeCurve + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
impl<C> From<&VerifyingKey<C>> for EncodedPoint<C>where
C: PrimeCurve + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
sourcefn from(verifying_key: &VerifyingKey<C>) -> EncodedPoint<C>
fn from(verifying_key: &VerifyingKey<C>) -> EncodedPoint<C>
Converts to this type from the input type.
sourceimpl<C> From<&VerifyingKey<C>> for PublicKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
impl<C> From<&VerifyingKey<C>> for PublicKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
sourcefn from(verifying_key: &VerifyingKey<C>) -> PublicKey<C>
fn from(verifying_key: &VerifyingKey<C>) -> PublicKey<C>
Converts to this type from the input type.
sourceimpl<C> From<PublicKey<C>> for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
impl<C> From<PublicKey<C>> for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
sourcefn from(public_key: PublicKey<C>) -> VerifyingKey<C>
fn from(public_key: PublicKey<C>) -> VerifyingKey<C>
Converts to this type from the input type.
sourceimpl<C> From<VerifyingKey<C>> for PublicKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
impl<C> From<VerifyingKey<C>> for PublicKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
sourcefn from(verifying_key: VerifyingKey<C>) -> PublicKey<C>
fn from(verifying_key: VerifyingKey<C>) -> PublicKey<C>
Converts to this type from the input type.
sourceimpl<C> FromStr for VerifyingKey<C>where
C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature pem
only.
impl<C> FromStr for VerifyingKey<C>where
C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
pem
only.sourceimpl<C> Ord for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
impl<C> Ord for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<C> PartialEq<VerifyingKey<C>> for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
impl<C> PartialEq<VerifyingKey<C>> for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
sourceimpl<C> PartialOrd<VerifyingKey<C>> for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
impl<C> PartialOrd<VerifyingKey<C>> for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
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 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
sourceimpl<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>,
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>,
sourceimpl<C> Serialize for VerifyingKey<C>where
C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate features pem
and serde
only.
impl<C> Serialize for VerifyingKey<C>where
C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
pem
and serde
only.sourceimpl<C> TryFrom<&[u8]> for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
impl<C> TryFrom<&[u8]> for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
sourceimpl<C> TryFrom<SubjectPublicKeyInfo<'_>> for VerifyingKey<C>where
C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature pkcs8
only.
impl<C> TryFrom<SubjectPublicKeyInfo<'_>> for VerifyingKey<C>where
C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
pkcs8
only.sourceimpl<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>,
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>,
impl<C> Copy for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
impl<C> Eq for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
Auto Trait Implementations
impl<C> RefUnwindSafe for VerifyingKey<C>where
<C as AffineArithmetic>::AffinePoint: RefUnwindSafe,
impl<C> Send for VerifyingKey<C>
impl<C> Sync for VerifyingKey<C>
impl<C> Unpin for VerifyingKey<C>where
<C as AffineArithmetic>::AffinePoint: Unpin,
impl<C> UnwindSafe for VerifyingKey<C>where
<C as AffineArithmetic>::AffinePoint: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more