1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-15 19:08:07 +00:00

support binary messages in sign/verify message

This commit is contained in:
Pavol Rusnak 2014-03-11 18:06:38 +01:00
parent 21f3481c61
commit 27070e84a9

View File

@ -374,20 +374,24 @@ class ProtocolMixin(object):
def sign_message(self, coin_name, n, message):
n = self._convert_prime(n)
try:
# Convert message to UTF8 NFC (seems to be a bitcoin-qt standard)
message = normalize_nfc(message)
# Convert message to ASCII stream
message = str(bytearray(message, 'utf-8'))
except:
pass # it was not UTF8 string
return self.call(proto.SignMessage(coin_name=coin_name, address_n=n, message=message))
def verify_message(self, address, signature, message):
try:
# Convert message to UTF8 NFC (seems to be a bitcoin-qt standard)
message = normalize_nfc(message)
# Convert message to ASCII stream
message = str(bytearray(message, 'utf-8'))
except:
pass # it was not UTF8 string
try:
resp = self.call(proto.VerifyMessage(address=address, signature=signature, message=message))