pub struct Signature { /* private fields */ }
Expand description

Ethereum-style “recoverable signatures” which allow for the recovery of the signer’s VerifyingKey from the signature itself.

This format consists of Signature followed by a 1-byte recovery Id (65-bytes total):

  • r: 32-byte integer, big endian
  • s: 32-byte integer, big endian
  • v: 1-byte recovery Id

Implementations§

source§

impl Signature

source

pub fn new(signature: &Signature, recovery_id: Id) -> Result<Self>

Create a new recoverable ECDSA/secp256k1 signature from a regular fixed-size signature and an associated recovery Id.

This is an “unchecked” conversion and assumes the provided Id is valid for this signature.

source

pub fn recovery_id(self) -> Id

Get the recovery Id for this signature

source

pub fn from_digest_trial_recovery<D>( public_key: &VerifyingKey, digest: D, signature: &Signature ) -> Result<Self>where D: Clone + Digest + FixedOutput<OutputSize = U32>,

Given a public key, message digest, and signature, use trial recovery to determine if a suitable recovery ID exists, or return an error otherwise.

source

pub fn from_digest_bytes_trial_recovery( public_key: &VerifyingKey, digest_bytes: &FieldBytes, signature: &Signature ) -> Result<Self>

Given a public key, message digest, and signature, use trial recovery to determine if a suitable recovery ID exists, or return an error otherwise.

source

pub fn recover_verifying_key_from_digest<D>( &self, msg_digest: D ) -> Result<VerifyingKey>where D: Digest<OutputSize = U32>,

Recover the public key used to create the given signature as a VerifyingKey from the provided precomputed Digest.

source

pub fn recover_verifying_key_from_digest_bytes( &self, digest_bytes: &FieldBytes ) -> Result<VerifyingKey>

Recover the public key used to create the given signature as a VerifyingKey from the raw bytes of a message digest.

source

pub fn r(&self) -> NonZeroScalar

Parse the r component of this signature to a NonZeroScalar

source

pub fn s(&self) -> NonZeroScalar

Parse the s component of this signature to a NonZeroScalar

Trait Implementations§

source§

impl AsRef<[u8]> for Signature

source§

fn as_ref(&self) -> &[u8]

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

impl Clone for Signature

source§

fn clone(&self) -> Signature

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 Signature

source§

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

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

impl<D> DigestSigner<D, Signature> for SigningKeywhere D: Digest + FixedOutput<OutputSize = U32>,

source§

fn try_sign_digest(&self, msg_digest: D) -> Result<Signature>

Attempt to sign the given prehashed message Digest, returning a digital signature on success, or an error if something went wrong.
source§

fn sign_digest(&self, digest: D) -> S

Sign the given prehashed message Digest, returning a signature. Read more
source§

impl<D> DigestVerifier<D, Signature> for VerifyingKeywhere D: Digest + FixedOutput<OutputSize = U32>,

source§

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

Verify the signature against the given Digest output.
source§

impl From<Signature> for Signature

source§

fn from(sig: Signature) -> Self

Converts to this type from the input type.
source§

impl PartialEq<Signature> for Signature

source§

fn eq(&self, other: &Signature) -> 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 PrehashSigner<Signature> for SigningKey

source§

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

Attempt to sign the given message digest, returning a digital signature on success, or an error if something went wrong. Read more
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<D> RandomizedDigestSigner<D, Signature> for SigningKeywhere D: Digest + FixedOutput<OutputSize = U32>,

source§

fn try_sign_digest_with_rng( &self, rng: impl CryptoRng + RngCore, msg_digest: D ) -> Result<Signature, Error>

Attempt to sign the given prehashed message Digest, returning a digital signature on success, or an error if something went wrong.
source§

fn sign_digest_with_rng(&self, rng: impl CryptoRng + RngCore, digest: D) -> S

Sign the given prehashed message Digest, returning a signature. Read more
source§

impl Signature for Signature

source§

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

Parse a signature from its byte representation
source§

fn as_bytes(&self) -> &[u8]

Borrow a byte slice representing the serialized form of this signature
source§

impl TryFrom<&[u8]> for Signature

§

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 Copy for Signature

source§

impl Eq for Signature

source§

impl StructuralEq for Signature

source§

impl StructuralPartialEq for Signature

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.