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
impl Signature
Sourcepub fn v(&self) -> u8
pub fn v(&self) -> u8
Returns the v component of this signature, which is a u8 representing the recovery id.
Sourcepub fn verify(&self, message: Word, pub_key: &PublicKey) -> bool
pub fn verify(&self, message: Word, pub_key: &PublicKey) -> bool
Verifies this signature against a message and public key.
Sourcepub fn to_sec1_bytes(&self) -> [u8; 64]
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.
Sourcepub fn from_sec1_bytes_and_recovery_id(
bytes: [u8; 64],
v: u8,
) -> Result<Signature, DeserializationError>
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 componentsrecovery_id- recovery ID (0-3)
Trait Implementations§
Source§impl Deserializable for Signature
impl Deserializable for Signature
Source§fn read_from<R>(source: &mut R) -> Result<Signature, DeserializationError>where
R: ByteReader,
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 moreSource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
Source§impl Serializable for Signature
impl Serializable for Signature
Source§fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
Serializes
self into bytes and writes these bytes into the target.Source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
Returns an estimate of how many bytes are needed to represent self. Read more
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
Mutably borrows from an owned value. Read more