mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 04:18:10 +00:00
parent
c3112fd83d
commit
8213fee15b
@ -1,5 +1,6 @@
|
|||||||
from ubinascii import hexlify
|
from ubinascii import hexlify
|
||||||
|
|
||||||
|
from trezor import wire
|
||||||
from trezor.crypto.curve import secp256k1
|
from trezor.crypto.curve import secp256k1
|
||||||
from trezor.crypto.hashlib import sha3_256
|
from trezor.crypto.hashlib import sha3_256
|
||||||
from trezor.messages.Success import Success
|
from trezor.messages.Success import Success
|
||||||
@ -22,12 +23,12 @@ async def verify_message(ctx, msg):
|
|||||||
pubkey = secp256k1.verify_recover(sig, digest)
|
pubkey = secp256k1.verify_recover(sig, digest)
|
||||||
|
|
||||||
if not pubkey:
|
if not pubkey:
|
||||||
raise ValueError("Invalid signature")
|
raise wire.DataError("Invalid signature")
|
||||||
|
|
||||||
pkh = sha3_256(pubkey[1:], keccak=True).digest()[-20:]
|
pkh = sha3_256(pubkey[1:], keccak=True).digest()[-20:]
|
||||||
|
|
||||||
if msg.address != pkh:
|
if msg.address != pkh:
|
||||||
raise ValueError("Invalid signature")
|
raise wire.DataError("Invalid signature")
|
||||||
|
|
||||||
address = "0x" + hexlify(msg.address).decode()
|
address = "0x" + hexlify(msg.address).decode()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user