logo
pub struct Signature<C: PrimeCurve> where
    SignatureSize<C>: ArrayLength<u8>, 
{ /* private fields */ }
Expand description

ECDSA signature (fixed-size). Generic over elliptic curve types.

Serialized as fixed-sized big endian scalar values with no added 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 DER-encoded signatures also supported via the Signature::from_der and Signature::to_der methods.

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 uses a 64-byte fixed encoding when used with binary formats, and a hexadecimal encoding when used with text formats.

Implementations

Available on crate feature der only.

Parse a signature from ASN.1 DER

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

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

Available on crate feature der only.

Serialize this signature as ASN.1 DER

Available on crate feature alloc only.

Convert this signature into a byte vector.

Available on crate feature arithmetic only.

Get the r component of this signature

Available on crate feature arithmetic only.

Get the s component of this signature

Available on crate feature arithmetic only.

Split the signature into its r and s scalars.

Available on crate feature arithmetic only.

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

Trait Implementations

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Sign message digest using a deterministic ephemeral scalar (k) computed using the algorithm described in RFC6979 § 3.2.

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

Verify the signature against the given Digest output.

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

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

Formats the value using the given formatter.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Preferred Digest algorithm to use when computing this signature type.

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.

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

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more

Sign the given message and return a digital signature

Serialize this value into the given Serde serializer. Read more

Parse a signature from its byte representation

Borrow a byte slice representing the serialized form of this signature

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more

Sign the given message and return a digital signature

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Formats the value using the given formatter.

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.