[][src]Struct ecdsa::Signature

pub struct Signature<C: Curve> where
    SignatureSize<C>: ArrayLength<u8>, 
{ /* fields omitted */ }

ECDSA signatures (fixed-size).

Generic over elliptic curve types.

These signatures are serialized as fixed-sized big endian scalar values with no additional framing:

  • r: field element size for the given curve, big-endian
  • s: field element size for the given curve, big-endian

For example, in a curve with a 256-bit modulus like NIST P-256 or secp256k1, r and s will both be 32-bytes, resulting in a signature with a total of 64-bytes.

ASN.1 is also supported via the Signature::from_asn1 and Signature::to_asn1 methods.

Implementations

impl<C: Curve> Signature<C> where
    SignatureSize<C>: ArrayLength<u8>, 
[src]

pub fn from_scalars(r: &ElementBytes<C>, s: &ElementBytes<C>) -> Self[src]

Create a Signature from the serialized r and s components

pub fn from_asn1(bytes: &[u8]) -> Result<Self, Error> where
    C::ElementSize: Add + ArrayLength<u8>,
    MaxSize<C>: ArrayLength<u8>,
    <C::ElementSize as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>, 
[src]

Parse a signature from ASN.1 DER

pub fn to_asn1(&self) -> Signature<C> where
    C::ElementSize: Add + ArrayLength<u8>,
    MaxSize<C>: ArrayLength<u8>,
    <C::ElementSize as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>, 
[src]

Serialize this signature as ASN.1 DER

pub fn r(&self) -> &ElementBytes<C>[src]

Get the r component of this signature

pub fn s(&self) -> &ElementBytes<C>[src]

Get the s component of this signature

impl<C> Signature<C> where
    C: Curve + Arithmetic,
    C::Scalar: NormalizeLow,
    SignatureSize<C>: ArrayLength<u8>, 
[src]

pub fn normalize_s(&mut self) -> Result<bool, Error>[src]

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

Trait Implementations

impl<C: Curve> AsRef<[u8]> for Signature<C> where
    SignatureSize<C>: ArrayLength<u8>, 
[src]

impl<C: Clone + Curve> Clone for Signature<C> where
    SignatureSize<C>: ArrayLength<u8>, 
[src]

impl<C: Curve> Copy for Signature<C> where
    SignatureSize<C>: ArrayLength<u8>,
    <SignatureSize<C> as ArrayLength<u8>>::ArrayType: Copy
[src]

impl<C: Curve> Debug for Signature<C> where
    SignatureSize<C>: ArrayLength<u8>, 
[src]

impl<C, D> DigestVerifier<D, Signature<C>> for Verifier<C> where
    C: Curve + Arithmetic,
    D: Digest<OutputSize = C::ElementSize>,
    C::AffinePoint: VerifyPrimitive<C>,
    SignatureSize<C>: ArrayLength<u8>, 
[src]

impl<C: Eq + Curve> Eq for Signature<C> where
    SignatureSize<C>: ArrayLength<u8>, 
[src]

impl<C> From<Signature<C>> for Signature<C> where
    C: Curve,
    C::ElementSize: Add + ArrayLength<u8>,
    MaxSize<C>: ArrayLength<u8>,
    <C::ElementSize as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>, 
[src]

impl<C: PartialEq + Curve> PartialEq<Signature<C>> for Signature<C> where
    SignatureSize<C>: ArrayLength<u8>, 
[src]

impl<C: DigestPrimitive> PrehashSignature for Signature<C> where
    <C::ElementSize as Add>::Output: ArrayLength<u8>, 
[src]

type Digest = C::Digest

Preferred Digest algorithm to use when computing this signature type.

impl<C, D> RandomizedDigestSigner<D, Signature<C>> for Signer<C> where
    C: Curve + Arithmetic,
    D: Digest<OutputSize = C::ElementSize>,
    C::Scalar: Invert<Output = C::Scalar> + Generate + SignPrimitive<C> + Zeroize,
    SignatureSize<C>: ArrayLength<u8>, 
[src]

impl<C> RandomizedSigner<Signature<C>> for Signer<C> where
    C: Curve + Arithmetic + DigestPrimitive,
    C::Digest: Digest<OutputSize = C::ElementSize>,
    C::Scalar: Invert<Output = C::Scalar> + Generate + SignPrimitive<C> + Zeroize,
    SignatureSize<C>: ArrayLength<u8>, 
[src]

impl<C: Curve> Signature for Signature<C> where
    SignatureSize<C>: ArrayLength<u8>, 
[src]

impl<C: Curve> StructuralEq for Signature<C> where
    SignatureSize<C>: ArrayLength<u8>, 
[src]

impl<C: Curve> StructuralPartialEq for Signature<C> where
    SignatureSize<C>: ArrayLength<u8>, 
[src]

impl<C: Curve, '_> TryFrom<&'_ [u8]> for Signature<C> where
    SignatureSize<C>: ArrayLength<u8>, 
[src]

type Error = Error

The type returned in the event of a conversion error.

impl<C> Verifier<Signature<C>> for Verifier<C> where
    C: Curve + Arithmetic + DigestPrimitive,
    C::AffinePoint: VerifyPrimitive<C>,
    C::Digest: Digest<OutputSize = C::ElementSize>,
    SignatureSize<C>: ArrayLength<u8>, 
[src]

Auto Trait Implementations

impl<C> RefUnwindSafe for Signature<C> where
    <<<C as Curve>::ElementSize as Add<<C as Curve>::ElementSize>>::Output as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
    <C as Curve>::ElementSize: Add<<C as Curve>::ElementSize>, 

impl<C> Send for Signature<C> where
    <C as Curve>::ElementSize: Add<<C as Curve>::ElementSize>, 

impl<C> Sync for Signature<C> where
    <C as Curve>::ElementSize: Add<<C as Curve>::ElementSize>, 

impl<C> Unpin for Signature<C> where
    <<<C as Curve>::ElementSize as Add<<C as Curve>::ElementSize>>::Output as ArrayLength<u8>>::ArrayType: Unpin,
    <C as Curve>::ElementSize: Add<<C as Curve>::ElementSize>, 

impl<C> UnwindSafe for Signature<C> where
    <<<C as Curve>::ElementSize as Add<<C as Curve>::ElementSize>>::Output as ArrayLength<u8>>::ArrayType: UnwindSafe,
    <C as Curve>::ElementSize: Add<<C as Curve>::ElementSize>, 

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.