Signature

Struct Signature 

Source
pub struct Signature { /* private fields */ }
Expand description

ECDSA signature over secp256k1 curve using Keccak to hash the messages when signing.

§Serialization Formats

This implementation supports 2 serialization formats:

§Custom Format (66 bytes):

  • Bytes 0-31: r component (32 bytes, big-endian)
  • Bytes 32-63: s component (32 bytes, big-endian)
  • Byte 64: recovery ID (v) - values 0-3

§SEC1 Format (64 bytes):

  • Bytes 0-31: r component (32 bytes, big-endian)
  • Bytes 32-63: s component (32 bytes, big-endian)
  • Note: Recovery ID

Implementations§

Source§

impl Signature

Source

pub fn r(&self) -> &[u8; 32]

Returns the r scalar of this signature.

Source

pub fn s(&self) -> &[u8; 32]

Returns the s scalar of this signature.

Source

pub fn v(&self) -> u8

Returns the v component of this signature, which is a u8 representing the recovery id.

Source

pub fn verify(&self, message: Word, pub_key: &PublicKey) -> bool

Verifies this signature against a message and public key.

Source

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

Converts signature to SEC1 format (standard 64-byte r||s format).

This format is the standard one used by most ECDSA libraries but loses the recovery ID.

Source

pub fn from_sec1_bytes_and_recovery_id( bytes: [u8; 64], v: u8, ) -> Result<Signature, DeserializationError>

Creates a signature from SEC1 format bytes with a given recovery id.

§Arguments
  • bytes - 64-byte array containing r and s components
  • recovery_id - recovery ID (0-3)

Trait Implementations§

Source§

impl Clone for Signature

Source§

fn clone(&self) -> Signature

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Signature

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Deserializable for Signature

Source§

fn read_from<R>(source: &mut R) -> Result<Signature, DeserializationError>
where R: ByteReader,

Reads a sequence of bytes from the provided source, attempts to deserialize these bytes into Self, and returns the result. Read more
Source§

fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>

Attempts to deserialize the provided bytes into Self and returns the result. Read more
Source§

impl PartialEq for Signature

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serializable for Signature

Source§

fn write_into<W>(&self, target: &mut W)
where W: ByteWriter,

Serializes self into bytes and writes these bytes into the target.
Source§

fn to_bytes(&self) -> Vec<u8>

Serializes self into a vector of bytes.
Source§

fn get_size_hint(&self) -> usize

Returns an estimate of how many bytes are needed to represent self. Read more
Source§

impl Eq for Signature

Source§

impl StructuralPartialEq for Signature

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V