Type Alias k256::ecdsa::Signature

source ·
pub type Signature = Signature<Secp256k1>;
Expand description

ECDSA/secp256k1 signature (fixed-size)

Aliased Type§

struct Signature { /* private fields */ }

Implementations

source§

impl<C> Signature<C>

source

pub fn from_bytes( bytes: &GenericArray<u8, <<C as Curve>::FieldBytesSize as Add>::Output>, ) -> Result<Signature<C>, Error>

Parse a signature from fixed-width bytes, i.e. 2 * the size of FieldBytes for a particular curve.

§Returns
  • Ok(signature) if the r and s components are both in the valid range 1..n when serialized as concatenated big endian integers.
  • Err(err) if the r and/or s component of the signature is out-of-range when interpreted as a big endian integer.
source

pub fn from_slice(slice: &[u8]) -> Result<Signature<C>, Error>

Parse a signature from a byte slice.

source

pub fn from_der(bytes: &[u8]) -> Result<Signature<C>, Error>

Parse a signature from ASN.1 DER.

source

pub fn from_scalars( r: impl Into<GenericArray<u8, <C as Curve>::FieldBytesSize>>, s: impl Into<GenericArray<u8, <C as Curve>::FieldBytesSize>>, ) -> Result<Signature<C>, Error>

Create a Signature from the serialized r and s scalar values which comprise the signature.

§Returns
  • Ok(signature) if the r and s components are both in the valid range 1..n when serialized as concatenated big endian integers.
  • Err(err) if the r and/or s component of the signature is out-of-range when interpreted as a big endian integer.
source

pub fn split_bytes( &self, ) -> (GenericArray<u8, <C as Curve>::FieldBytesSize>, GenericArray<u8, <C as Curve>::FieldBytesSize>)

Split the signature into its r and s components, represented as bytes.

source

pub fn to_bytes( &self, ) -> GenericArray<u8, <<C as Curve>::FieldBytesSize as Add>::Output>

Serialize this signature as bytes.

source

pub fn to_der(&self) -> Signature<C>

Serialize this signature as ASN.1 DER.

source

pub fn to_vec(&self) -> Vec<u8>

Convert this signature into a byte vector.

source§

impl<C> Signature<C>

source

pub fn r(&self) -> NonZeroScalar<C>

Get the r component of this signature

source

pub fn s(&self) -> NonZeroScalar<C>

Get the s component of this signature

source

pub fn split_scalars(&self) -> (NonZeroScalar<C>, NonZeroScalar<C>)

Split the signature into its r and s scalars.

source

pub fn normalize_s(&self) -> Option<Signature<C>>

Normalize signature into “low S” form as described in BIP 0062: Dealing with Malleability.

Trait Implementations

source§

impl<C> AssociatedOid for Signature<C>

ECDSA ObjectIdentifier which identifies the digest used by default with the Signer and Verifier traits.

To support non-default digest algorithms, use the SignatureWithOid type instead.

source§

const OID: ObjectIdentifier = _

The OID associated with this type.
source§

impl<C> Clone for Signature<C>
where C: Clone + PrimeCurve,

source§

fn clone(&self) -> Signature<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 Signature<C>

source§

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

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

impl<'de, C> Deserialize<'de> for Signature<C>

source§

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

Deserialize this value from the given Serde deserializer. Read more
source§

impl<C> Display for Signature<C>

source§

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

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

impl<C> From<SignatureWithOid<C>> for Signature<C>
where C: PrimeCurve,

source§

fn from(sig: SignatureWithOid<C>) -> Signature<C>

Converts to this type from the input type.
source§

impl<C> FromStr for Signature<C>

§

type Err = Error

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

fn from_str(hex: &str) -> Result<Signature<C>, Error>

Parses a string s to return a value of this type. Read more
source§

impl<C> LowerHex for Signature<C>

source§

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

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

impl<C> PartialEq for Signature<C>
where C: PartialEq + PrimeCurve,

source§

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

§

type Digest = <C as DigestPrimitive>::Digest

Preferred Digest algorithm to use when computing this signature type.
source§

impl<C> Serialize for Signature<C>

source§

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

Serialize this value into the given Serde serializer. Read more
source§

impl<C> SignatureEncoding for Signature<C>

§

type Repr = GenericArray<u8, <<C as Curve>::FieldBytesSize as Add>::Output>

Byte representation of a signature.
source§

fn to_bytes(&self) -> Self::Repr

Encode signature as its byte representation.
source§

fn to_vec(&self) -> Vec<u8>

Encode signature as a byte vector.
source§

fn encoded_len(&self) -> usize

Get the length of this signature when encoded.
source§

impl<C> TryFrom<&[u8]> for Signature<C>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(slice: &[u8]) -> Result<Signature<C>, Error>

Performs the conversion.
source§

impl<C> TryFrom<Signature<C>> for Signature<C>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(sig: Signature<C>) -> Result<Signature<C>, Error>

Performs the conversion.
source§

impl<C> UpperHex for Signature<C>

source§

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

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

impl<C> Copy for Signature<C>

source§

impl<C> Eq for Signature<C>
where C: Eq + PrimeCurve,

source§

impl<C> StructuralPartialEq for Signature<C>
where C: PrimeCurve,