Signature
Convert signature between r, s, v
and compressed string
format.
Import necessary classes from the Web3j and kaia libraries(web3j-ext
)
For converting {r ,s ,v}
signature to string
, create a Sign.SignatureData
object from params r, s ,v. Use Numeric.hexStringToByteArray
to convert string to byte array
To compress Sign.SignatureData
to compressed signature string
, use KaiaSignatureData.getSignatureString
with the signature object as param
For converting string
signature to {r ,s ,v}
, First convert the string signature to byte array. Use Numeric.hexStringToByteArray
to convert string to byte array
Extract r, s, v components from the byte array. R
is the first 32 indices, S
is the next 32 indices and V
is the last indice
You can use Numeric.toHexString
to convert each components from byte array
to string