Struct libsecp256k1::Signature[][src]

pub struct Signature {
    pub r: Scalar,
    pub s: Scalar,
}
Expand description

An ECDSA signature.

Fields

r: Scalars: Scalar

Implementations

impl Signature[src]

pub fn parse_overflowing(p: &[u8; 64]) -> Signature[src]

Parse an possibly overflowing signature.

A SECP256K1 signature is usually required to be within 0 and curve order. This function, however, allows signatures larger than curve order by taking the signature and minus curve order.

Note that while this function is technically safe, it is non-standard, meaning you will have compatibility issues if you also use other SECP256K1 libraries. It’s not recommended to use this function. Please use parse_standard instead.

pub fn parse_standard(p: &[u8; 64]) -> Result<Signature, Error>[src]

Parse a standard SECP256K1 signature. The signature is required to be within 0 and curve order. Returns error if it overflows.

pub fn parse_overflowing_slice(p: &[u8]) -> Result<Signature, Error>[src]

Parse a possibly overflowing signature slice. See also parse_overflowing.

It’s not recommended to use this function. Please use parse_standard_slice instead.

pub fn parse_standard_slice(p: &[u8]) -> Result<Signature, Error>[src]

Parse a standard signature slice. See also parse_standard.

pub fn parse_der(p: &[u8]) -> Result<Signature, Error>[src]

Parse a DER-encoded byte slice to a signature.

pub fn parse_der_lax(p: &[u8]) -> Result<Signature, Error>[src]

Converts a “lax DER”-encoded byte slice to a signature. This is basically only useful for validating signatures in the Bitcoin blockchain from before 2016. It should never be used in new applications. This library does not support serializing to this “format”

pub fn normalize_s(&mut self)[src]

Normalizes a signature to a “low S” form. In ECDSA, signatures are of the form (r, s) where r and s are numbers lying in some finite field. The verification equation will pass for (r, s) iff it passes for (r, -s), so it is possible to ``modify’’ signatures in transit by flipping the sign of s. This does not constitute a forgery since the signed message still cannot be changed, but for some applications, changing even the signature itself can be a problem. Such applications require a “strong signature”. It is believed that ECDSA is a strong signature except for this ambiguity in the sign of s, so to accommodate these applications libsecp256k1 will only accept signatures for which s is in the lower half of the field range. This eliminates the ambiguity.

However, for some systems, signatures with high s-values are considered valid. (For example, parsing the historic Bitcoin blockchain requires this.) For these applications we provide this normalization function, which ensures that the s value lies in the lower half of its range.

pub fn serialize(&self) -> [u8; 64][src]

Serialize a signature to a standard byte representation. This is the reverse of parse_standard.

pub fn serialize_der(&self) -> SignatureArray[src]

Serialize a signature to a DER encoding. This is the reverse of parse_der.

Trait Implementations

impl Clone for Signature[src]

fn clone(&self) -> Signature[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Signature[src]

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

Formats the value using the given formatter. Read more

impl PartialEq<Signature> for Signature[src]

fn eq(&self, other: &Signature) -> bool[src]

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

fn ne(&self, other: &Signature) -> bool[src]

This method tests for !=.

impl Copy for Signature[src]

impl Eq for Signature[src]

impl StructuralEq for Signature[src]

impl StructuralPartialEq for Signature[src]

Auto Trait Implementations

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

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.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

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

recently added

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

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V