Struct sm2::dsa::VerifyingKey

source ·
pub struct VerifyingKey { /* private fields */ }
Available on crate features arithmetic and dsa only.
Expand description

SM2DSA public key used for verifying signatures are valid for a given message.

Usage

The signature crate defines the following traits which are the primary API for verifying:

  • Verifier: verify a message against a provided key and signature
  • PrehashVerifier: verify the low-level raw output bytes of a message digest

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 VerifyingKey

source

pub fn new(distid: &str, public_key: PublicKey) -> Result<Self>

Initialize VerifyingKey from a signer’s distinguishing identifier and public key.

source

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

Initialize VerifyingKey from a SEC1-encoded public key.

source

pub fn from_affine(distid: &str, affine: AffinePoint) -> 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 as_affine(&self) -> &AffinePoint

Borrow the inner AffinePoint for this public key.

source

pub fn distid(&self) -> &str

Available on crate feature alloc only.

Get the distinguishing identifier for this key.

source

pub fn to_sec1_bytes(&self) -> Box<[u8]>

Available on crate feature alloc only.

Convert this VerifyingKey into the Elliptic-Curve-Point-to-Octet-String encoding described in SEC 1: Elliptic Curve Cryptography (Version 2.0) section 2.3.3 (page 10).

http://www.secg.org/sec1-v2.pdf

Trait Implementations§

source§

impl AsRef<AffinePoint<Sm2>> for VerifyingKey

source§

fn as_ref(&self) -> &AffinePoint

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

impl AsRef<VerifyingKey> for SigningKey

source§

fn as_ref(&self) -> &VerifyingKey

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 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 Debug for VerifyingKey

source§

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

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

impl From<&VerifyingKey> for PublicKey

source§

fn from(verifying_key: &VerifyingKey) -> PublicKey

Converts to this type from the input type.
source§

impl From<VerifyingKey> for PublicKey

source§

fn from(verifying_key: VerifyingKey) -> PublicKey

Converts to this type from the input type.
source§

impl PrehashVerifier<Signature> for VerifyingKey

source§

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

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

impl ToEncodedPoint<Sm2> for VerifyingKey

source§

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

Serialize this value as a SEC1 EncodedPoint, optionally applying point compression.
source§

impl Verifier<Signature> for VerifyingKey

source§

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

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

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