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:
parent
21f3481c61
commit
27070e84a9
@ -374,20 +374,24 @@ class ProtocolMixin(object):
|
|||||||
def sign_message(self, coin_name, n, message):
|
def sign_message(self, coin_name, n, message):
|
||||||
n = self._convert_prime(n)
|
n = self._convert_prime(n)
|
||||||
|
|
||||||
|
try:
|
||||||
# Convert message to UTF8 NFC (seems to be a bitcoin-qt standard)
|
# Convert message to UTF8 NFC (seems to be a bitcoin-qt standard)
|
||||||
message = normalize_nfc(message)
|
message = normalize_nfc(message)
|
||||||
|
|
||||||
# Convert message to ASCII stream
|
# Convert message to ASCII stream
|
||||||
message = str(bytearray(message, 'utf-8'))
|
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))
|
return self.call(proto.SignMessage(coin_name=coin_name, address_n=n, message=message))
|
||||||
|
|
||||||
def verify_message(self, address, signature, message):
|
def verify_message(self, address, signature, message):
|
||||||
|
try:
|
||||||
# Convert message to UTF8 NFC (seems to be a bitcoin-qt standard)
|
# Convert message to UTF8 NFC (seems to be a bitcoin-qt standard)
|
||||||
message = normalize_nfc(message)
|
message = normalize_nfc(message)
|
||||||
|
|
||||||
# Convert message to ASCII stream
|
# Convert message to ASCII stream
|
||||||
message = str(bytearray(message, 'utf-8'))
|
message = str(bytearray(message, 'utf-8'))
|
||||||
|
except:
|
||||||
|
pass # it was not UTF8 string
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp = self.call(proto.VerifyMessage(address=address, signature=signature, message=message))
|
resp = self.call(proto.VerifyMessage(address=address, signature=signature, message=message))
|
||||||
|
Loading…
Reference in New Issue
Block a user