2

I've got a signature, as a python bytes object, and want to split it into the components v, r, and s.

I understand the details of what needs to be done, by reading: What's the best way to transform bytes of a signature into v, r, s in solidity? but I don't want to re-write the code if someone else has already written it in python.

I don't want to use pyethereum because I hear that it's deprecated in favor of py-evm.

What is a concise way to perform this operation?

3

The eth-keys library has a number of convenient signature methods. This one in particular splits the signature into v, r, and s:

from eth_keys import keys
(v, r, s) = keys.Signature(signature_bytes=signature).vrs

Note that at the time of this answer writeup, the library has not undergone external security review, and is still in alpha. But there is low risk to use the library to split a signature into parts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.