pub enum Signature {
LegacySignature {
v: Uint256,
r: Uint256,
s: Uint256,
},
ModernSignature {
v: bool,
r: Uint256,
s: Uint256,
},
}
Variants§
Implementations§
source§impl Signature
impl Signature
pub fn new(v: bool, r: Uint256, s: Uint256) -> Signature
pub fn new_legacy(v: Uint256, r: Uint256, s: Uint256) -> Signature
pub fn get_r(&self) -> Uint256
pub fn get_s(&self) -> Uint256
sourcepub fn error_check(&self) -> Result<(), Error>
pub fn error_check(&self) -> Result<(), Error>
Like is_valid() but returns a reason
pub fn is_valid(&self) -> bool
sourcepub fn legacy_network_id(&self) -> Option<Uint256>
pub fn legacy_network_id(&self) -> Option<Uint256>
Extracts the chain id from the legacy signature v value will return none if the signature is either a legacy signature not protected from replay or if the signature is a modern signature at which point the chain_id value is contained in the tx
sourcepub fn get_signature_v(&self) -> Result<u8, Error>
pub fn get_signature_v(&self) -> Result<u8, Error>
Get the actual signature component V value, only two possibilities 27 or 28 this is different from V encoded with a chain id for which you should use get_v()
sourcepub fn into_bytes(self) -> [u8; 65]
pub fn into_bytes(self) -> [u8; 65]
Converts a signature into a bytes string.
A signature in binary form consists of 65 bytes where first 32 bytes are “r” in big endian form, next 32 bytes are “s” in big endian form, and at the end there is one byte made of “v”.
This also consumes the signature.
sourcepub fn to_bytes(&self) -> [u8; 65]
pub fn to_bytes(&self) -> [u8; 65]
Extracts signature as bytes.
This supersedes into_bytes
as it does not consume the object itself.
sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
Constructs a signature from a bytes string
This is opposite to into_bytes()
where a signature is created based
on a slice of bytes.