This page uses machine translation from English, which may contain errors or unclear language. For the most accurate information, please see the original English version. Some content may be in the original English due to frequent updates. Help us improve this page's translation by joining our effort on Crowdin. (Crowdin translation page, Contributing guide)
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()