pub struct VerifyingKey<C>where
C: PrimeCurve + CurveArithmetic,{ /* private fields */ }Expand description
ECDSA public key used for verifying signatures. Generic over prime order elliptic curves (e.g. NIST P-curves)
Requires an elliptic_curve::CurveArithmetic impl on the curve, and a
VerifyPrimitive impl on its associated AffinePoint type.
§Usage
The signature crate defines the following traits which are the
primary API for verifying:
Verifier: verify a message against a provided key and signatureDigestVerifier: verify a messageDigestagainst a provided key and signaturePrehashVerifier: verify the low-level raw output bytes of a message digest
See the p256 crate
for examples of using this type with a concrete elliptic curve.
§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 + CurveArithmetic,
AffinePoint<C>: DecompressPoint<C> + FromEncodedPoint<C> + ToEncodedPoint<C> + VerifyPrimitive<C>,
FieldBytesSize<C>: ModulusSize,
SignatureSize<C>: ArrayLength<u8>,
impl<C> VerifyingKey<C>where
C: PrimeCurve + CurveArithmetic,
AffinePoint<C>: DecompressPoint<C> + FromEncodedPoint<C> + ToEncodedPoint<C> + VerifyPrimitive<C>,
FieldBytesSize<C>: ModulusSize,
SignatureSize<C>: ArrayLength<u8>,
Sourcepub fn recover_from_msg(
msg: &[u8],
signature: &Signature<C>,
recovery_id: RecoveryId,
) -> Result<Self>where
C: DigestPrimitive,
pub fn recover_from_msg(
msg: &[u8],
signature: &Signature<C>,
recovery_id: RecoveryId,
) -> Result<Self>where
C: DigestPrimitive,
Recover a VerifyingKey from the given message, signature, and
RecoveryId.
The message is first hashed using this curve’s DigestPrimitive.
Sourcepub fn recover_from_digest<D>(
msg_digest: D,
signature: &Signature<C>,
recovery_id: RecoveryId,
) -> Result<Self>where
D: Digest,
pub fn recover_from_digest<D>(
msg_digest: D,
signature: &Signature<C>,
recovery_id: RecoveryId,
) -> Result<Self>where
D: Digest,
Recover a VerifyingKey from the given message Digest,
signature, and RecoveryId.
Sourcepub fn recover_from_prehash(
prehash: &[u8],
signature: &Signature<C>,
recovery_id: RecoveryId,
) -> Result<Self>
pub fn recover_from_prehash( prehash: &[u8], signature: &Signature<C>, recovery_id: RecoveryId, ) -> Result<Self>
Recover a VerifyingKey from the given prehash of a message, the
signature over that prehashed message, and a RecoveryId.
Source§impl<C> VerifyingKey<C>where
C: PrimeCurve + CurveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldBytesSize<C>: ModulusSize,
impl<C> VerifyingKey<C>where
C: PrimeCurve + CurveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldBytesSize<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§
Source§impl<C> AsRef<<C as CurveArithmetic>::AffinePoint> for VerifyingKey<C>where
C: PrimeCurve + CurveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldBytesSize<C>: ModulusSize,
impl<C> AsRef<<C as CurveArithmetic>::AffinePoint> for VerifyingKey<C>where
C: PrimeCurve + CurveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldBytesSize<C>: ModulusSize,
Source§fn as_ref(&self) -> &AffinePoint<C>
fn as_ref(&self) -> &AffinePoint<C>
Source§impl<C> AsRef<VerifyingKey<C>> for SigningKey<C>where
C: PrimeCurve + CurveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> AsRef<VerifyingKey<C>> for SigningKey<C>where
C: PrimeCurve + CurveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
Source§fn as_ref(&self) -> &VerifyingKey<C>
fn as_ref(&self) -> &VerifyingKey<C>
Source§impl<C> Clone for VerifyingKey<C>
impl<C> Clone for VerifyingKey<C>
Source§fn clone(&self) -> VerifyingKey<C>
fn clone(&self) -> VerifyingKey<C>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more