[][src]Struct ecdsa::Signature

pub struct Signature<C: Curve + CheckSignatureBytes> 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> Signature<C> where
    C: Curve + CheckSignatureBytes,
    SignatureSize<C>: ArrayLength<u8>, 
[src]

pub fn from_scalars(
    r: impl Into<FieldBytes<C>>,
    s: impl Into<FieldBytes<C>>
) -> Result<Self, Error>
[src]

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

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

Parse a signature from ASN.1 DER

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

Serialize this signature as ASN.1 DER

impl<C> Signature<C> where
    C: Curve + ProjectiveArithmetic,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>,
    <Scalar<C> as PrimeField>::Repr: From<Scalar<C>> + for<'a> From<&'a Scalar<C>>,
    SignatureSize<C>: ArrayLength<u8>, 
[src]

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

This is supported on crate feature arithmetic only.

Get the r component of this signature

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

This is supported on crate feature arithmetic only.

Get the s component of this signature

pub fn normalize_s(&mut self) -> Result<bool, Error> where
    Scalar<C>: NormalizeLow
[src]

This is supported on crate feature arithmetic only.

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

Trait Implementations

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

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

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

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

impl<C, D> DigestSigner<D, Signature<C>> for SigningKey<C> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
    D: FixedOutput<OutputSize = C::FieldSize> + BlockInput + Clone + Default + Reset + Update,
    SignatureSize<C>: ArrayLength<u8>, 
[src]

fn try_sign_digest(&self, digest: D) -> Result<Signature<C>, Error>[src]

Sign message prehash using a deterministic ephemeral scalar (k) computed using the algorithm described in RFC 6979 (Section 3.2): https://tools.ietf.org/html/rfc6979#section-3

impl<C, D> DigestVerifier<D, Signature<C>> for VerifyKey<C> where
    C: Curve + ProjectiveArithmetic,
    D: Digest<OutputSize = C::FieldSize>,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C>,
    AffinePoint<C>: Clone + Debug + VerifyPrimitive<C>,
    SignatureSize<C>: ArrayLength<u8>, 
[src]

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

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

impl<C> PrehashSignature for Signature<C> where
    C: DigestPrimitive + CheckSignatureBytes,
    <C::FieldSize 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 SigningKey<C> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
    D: FixedOutput<OutputSize = C::FieldSize> + BlockInput + Clone + Default + Reset + Update,
    SignatureSize<C>: ArrayLength<u8>, 
[src]

fn try_sign_digest_with_rng(
    &self,
    rng: impl CryptoRng + RngCore,
    digest: D
) -> Result<Signature<C>, Error>
[src]

Sign message prehash using an ephemeral scalar (k) derived according to a variant of RFC 6979 (Section 3.6) which supplies additional entropy from an RNG.

impl<C> RandomizedSigner<Signature<C>> for SigningKey<C> where
    C: Curve + ProjectiveArithmetic + DigestPrimitive,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
    SignatureSize<C>: ArrayLength<u8>,
    Self: RandomizedDigestSigner<C::Digest, Signature<C>>, 
[src]

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

impl<C> Signer<Signature<C>> for SigningKey<C> where
    C: Curve + ProjectiveArithmetic + DigestPrimitive,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
    SignatureSize<C>: ArrayLength<u8>,
    Self: DigestSigner<C::Digest, Signature<C>>, 
[src]

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

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

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

type Error = Error

The type returned in the event of a conversion error.

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

type Error = Error

The type returned in the event of a conversion error.

impl<C> Verifier<Signature<C>> for VerifyKey<C> where
    C: Curve + ProjectiveArithmetic + DigestPrimitive,
    C::Digest: Digest<OutputSize = C::FieldSize>,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C>,
    AffinePoint<C>: Clone + Debug + VerifyPrimitive<C>,
    SignatureSize<C>: ArrayLength<u8>, 
[src]

Auto Trait Implementations

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

impl<C> Send for Signature<C>

impl<C> Sync for Signature<C>

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

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

Blanket Implementations

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

impl<A, T> AsBits<T> for A where
    A: AsRef<[T]>,
    T: BitStore + BitMemory, 

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

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

impl<T> Conv for T

impl<T> FmtForward for T

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

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

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

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.