pub struct EthereumSignature {
pub r: [u8; 32],
pub s: [u8; 32],
pub v: u64,
}Expand description
An Ethereum ECDSA signature with recovery ID.
Fields§
§r: [u8; 32]The R component (32 bytes).
s: [u8; 32]The S component (32 bytes), guaranteed to be low-S (EIP-2).
v: u64Recovery ID: 27 or 28 (legacy), or chain_id * 2 + 35 + rec_id (EIP-155).
Stored as u64 to support high chain IDs (Polygon=137, Arbitrum=42161, etc.).
Implementations§
Source§impl EthereumSignature
impl EthereumSignature
Sourcepub fn to_bytes(&self) -> [u8; 65]
pub fn to_bytes(&self) -> [u8; 65]
Encode as 65-byte r || s || v (legacy, v truncated to u8).
For EIP-155 signatures with high chain IDs, use to_bytes_eip155() instead.
Sourcepub fn to_bytes_eip155(&self) -> Vec<u8> ⓘ
pub fn to_bytes_eip155(&self) -> Vec<u8> ⓘ
Encode as r (32) || s (32) || v (8 bytes BE) for EIP-155 with large chain IDs.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, SignerError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, SignerError>
Decode from 65-byte r || s || v (v as single byte).
Sourcepub fn recovery_bit(&self) -> u8
pub fn recovery_bit(&self) -> u8
Extract the recovery bit (0 or 1) from v, handling both
legacy (v=27/28) and EIP-155 (v = chain_id*2 + 35 + {0,1}).
Trait Implementations§
Source§impl Clone for EthereumSignature
impl Clone for EthereumSignature
Source§fn clone(&self) -> EthereumSignature
fn clone(&self) -> EthereumSignature
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EthereumSignature
impl Debug for EthereumSignature
Source§impl Display for EthereumSignature
impl Display for EthereumSignature
Source§impl PartialEq for EthereumSignature
impl PartialEq for EthereumSignature
impl Eq for EthereumSignature
impl StructuralPartialEq for EthereumSignature
Auto Trait Implementations§
impl Freeze for EthereumSignature
impl RefUnwindSafe for EthereumSignature
impl Send for EthereumSignature
impl Sync for EthereumSignature
impl Unpin for EthereumSignature
impl UnsafeUnpin for EthereumSignature
impl UnwindSafe for EthereumSignature
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