eth.sign verify

iFAiFA Posts: 7Member
I have a lot searched the internet for the code what verify the eth sign in python, but i dont have any good code found. I have coded it:

import bitcoin as b
from ethereum import utils
def RecoverAddress(msg,signature,address):
msghash = utils.sha3(msg).encode('hex')
r = long(signature[0:66],16)
s = long('0x'+signature[66:130],16)
v = long('0x'+signature[130:132],16)
if not v == 27 and not v == 28:
v += 27
recovered_addr = b.ecdsa_raw_recover(msghash.decode('hex'),(v,r,s))
pub = b.encode_pubkey(recovered_addr, 'bin')
return ('0x'+utils.sha3(pub[1:]).encode('hex')[24:64] == address)

msg = 'szia'
signature = "0x2b5ffd5b238e0859e96ab2a1e794f4dd9e03a78d2bd54b92c7c5c8d9fd14da46416837c36a9bac08521abd0f27def326462132b7bcd9092ef10318a88ec13faa00"
addr= "0x3f2da093bb16eb064f8bfa9e30b929d15f8e1c4c"

>>> RecoverAddress(msg,signature,addr)

For donate: 0x3f2da093bb16eb064f8bfa9e30b929d15f8e1c4c
Thanks ;)
Sign In or Register to comment.