Signature
Convert signature between r, s, v
and compressed string
format.
Import the bytes_to_hex_str
, hex_str_to_bytes
from web3py_ext
For converting {r,s,v}
signature to string, define a signature in r,s,v
format, use hex_str_to_bytes
to convert each components to bytes
Concatenate the components in order of r + s + v
and convert the result bytes to string
.
For converting string
signature to {r,s,v}
, define a signature in string format
Convert the string signature to bytes
using hex_str_to_bytes
Extract R first 32 indices
, S next 32 indices
, V last indice
from the signature bytes
You can convert each components back to string using bytes_to_hex_str()
and hex()