Handle string and binary in signer backend

This commit is contained in:
nolash 2020-12-25 12:34:05 +01:00
parent 4d064240f9
commit 07bdbe9999
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746

View File

@ -44,6 +44,12 @@ class ReferenceSigner(Signer):
#msg = b'\x19Ethereum Signed Message:\n{}{}'.format(len(message), message) #msg = b'\x19Ethereum Signed Message:\n{}{}'.format(len(message), message)
k = keys.PrivateKey(self.keyGetter.get(address, password)) k = keys.PrivateKey(self.keyGetter.get(address, password))
#z = keys.ecdsa_sign(message_hash=g, private_key=k) #z = keys.ecdsa_sign(message_hash=g, private_key=k)
z = None
if type(message).__name__ == 'str':
z = k.sign_msg(message.encode('utf-8')) z = k.sign_msg(message.encode('utf-8'))
elif type(message).__name__ == 'bytes':
z = k.sign_msg(message)
else:
raise ValueError('message must be type str or bytes, received {}'.format(type(message).__name__))
return z return z