pub struct Signature(/* private fields */);
Expand description
An ECDSA signature
Implementations§
source§impl Signature
impl Signature
sourcepub fn cmp_fast_unstable(&self, other: &Self) -> Ordering
pub fn cmp_fast_unstable(&self, other: &Self) -> Ordering
Like cmp::Cmp
but faster and with no guarantees across library versions.
The Cmp
implementation for FFI types is stable but slow because it first
serializes self
and other
before comparing them. This function provides a faster
comparison if you know that your types come from the same library version.
sourcepub fn eq_fast_unstable(&self, other: &Self) -> bool
pub fn eq_fast_unstable(&self, other: &Self) -> bool
Like cmp::Eq
but faster and with no guarantees across library versions.
The Eq
implementation for FFI types is stable but slow because it first serializes
self
and other
before comparing them. This function provides a faster equality
check if you know that your types come from the same library version.
source§impl Signature
impl Signature
sourcepub fn from_der(data: &[u8]) -> Result<Signature, Error>
pub fn from_der(data: &[u8]) -> Result<Signature, Error>
Converts a DER-encoded byte slice to a signature
sourcepub fn from_compact(data: &[u8]) -> Result<Signature, Error>
pub fn from_compact(data: &[u8]) -> Result<Signature, Error>
Converts a 64-byte compact-encoded byte slice to a signature
sourcepub fn from_der_lax(data: &[u8]) -> Result<Signature, Error>
pub fn from_der_lax(data: &[u8]) -> Result<Signature, Error>
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”
sourcepub fn normalize_s(&mut self)
pub fn normalize_s(&mut self)
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 considers signatures for which s is in the upper half of the field range invalid. 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.
sourcepub fn as_ptr(&self) -> *const Signature
👎Deprecated since 0.25.0: Use Self::as_c_ptr if you need to access the FFI layer
pub fn as_ptr(&self) -> *const Signature
Obtains a raw pointer suitable for use with FFI functions
sourcepub fn as_mut_ptr(&mut self) -> *mut Signature
👎Deprecated since 0.25.0: Use Self::as_mut_c_ptr if you need to access the FFI layer
pub fn as_mut_ptr(&mut self) -> *mut Signature
Obtains a raw mutable pointer suitable for use with FFI functions
sourcepub fn serialize_der(&self) -> SerializedSignature
pub fn serialize_der(&self) -> SerializedSignature
Serializes the signature in DER format
sourcepub fn serialize_compact(&self) -> [u8; 64]
pub fn serialize_compact(&self) -> [u8; 64]
Serializes the signature in compact format
Trait Implementations§
source§impl<'a> From<&'a Signature> for SerializedSignature
impl<'a> From<&'a Signature> for SerializedSignature
source§impl From<Signature> for SerializedSignature
impl From<Signature> for SerializedSignature
source§impl Ord for Signature
impl Ord for Signature
source§impl PartialEq for Signature
impl PartialEq for Signature
source§impl PartialOrd for Signature
impl PartialOrd for Signature
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a> TryFrom<&'a SerializedSignature> for Signature
impl<'a> TryFrom<&'a SerializedSignature> for Signature
source§impl TryFrom<SerializedSignature> for Signature
impl TryFrom<SerializedSignature> for Signature
impl Copy for Signature
impl Eq for Signature
impl StructuralPartialEq for Signature
Auto Trait Implementations§
impl Freeze for Signature
impl RefUnwindSafe for Signature
impl Send for Signature
impl Sync for Signature
impl Unpin for Signature
impl UnwindSafe for Signature
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)