1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 15:28:10 +00:00

core: display coin name when signing message

Also when verifying message.
This commit is contained in:
Martin Milata 2020-08-11 17:10:39 +02:00 committed by Tomas Susanka
parent 927ee0812b
commit 3f21e8f400
9 changed files with 49 additions and 47 deletions

View File

@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
- Print inverted question mark for non-printable characters.
- Remove pre-fill bar from text rendering functions. [#1173]
- Display coin name when signing or verifying messages. [#1159]
### Deprecated
@ -264,5 +265,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
[#1115]: https://github.com/trezor/trezor-firmware/issues/1115
[#1126]: https://github.com/trezor/trezor-firmware/issues/1126
[#1139]: https://github.com/trezor/trezor-firmware/issues/1139
[#1159]: https://github.com/trezor/trezor-firmware/issues/1159
[#1165]: https://github.com/trezor/trezor-firmware/pull/1165
[#1173]: https://github.com/trezor/trezor-firmware/pull/1173

View File

@ -16,7 +16,7 @@ async def sign_message(ctx, msg, keychain, coin):
address_n = msg.address_n
script_type = msg.script_type or 0
await require_confirm_sign_message(ctx, "Sign message", message)
await require_confirm_sign_message(ctx, coin.coin_shortcut, message)
await validate_path(
ctx,
validate_full_path,

View File

@ -57,7 +57,7 @@ async def verify_message(ctx, msg):
raise wire.ProcessError("Invalid signature")
await require_confirm_verify_message(
ctx, address_short(coin, address), "Verify message", message
ctx, address_short(coin, address), coin.coin_shortcut, message
)
return Success(message="Message verified")

View File

@ -41,8 +41,9 @@ def split_message(message: bytes) -> List[str]:
async def require_confirm_sign_message(
ctx: wire.Context, header: str, message: bytes
ctx: wire.Context, coin: str, message: bytes
) -> None:
header = "Sign {} message".format(coin)
message = split_message(message)
text = Text(header, new_lines=False)
text.normal(*message)
@ -50,9 +51,12 @@ async def require_confirm_sign_message(
async def require_confirm_verify_message(
ctx: wire.Context, address: str, header: str, message: bytes
ctx: wire.Context, address: str, coin: str, message: bytes
) -> None:
text = Text("Confirm address", new_lines=False)
header = "Verify {} message".format(coin)
text = Text(header, new_lines=False)
text.bold("Confirm address:")
text.br()
text.mono(*split_address(address))
await require_confirm(ctx, text)

View File

@ -23,7 +23,7 @@ async def sign_message(ctx, msg, keychain):
await paths.validate_path(
ctx, address.validate_full_path, keychain, msg.address_n, CURVE
)
await require_confirm_sign_message(ctx, "Sign ETH message", msg.message)
await require_confirm_sign_message(ctx, "ETH", msg.message)
node = keychain.derive(msg.address_n)
signature = secp256k1.sign(

View File

@ -27,8 +27,6 @@ async def verify_message(ctx, msg):
address = address_from_bytes(address_bytes)
await require_confirm_verify_message(
ctx, address, "Verify ETH message", msg.message
)
await require_confirm_verify_message(ctx, address, "ETH", msg.message)
return Success(message="Message verified")

View File

@ -24,7 +24,7 @@ def message_digest(message):
@with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True)
async def sign_message(ctx, msg, keychain):
await paths.validate_path(ctx, validate_full_path, keychain, msg.address_n, CURVE)
await require_confirm_sign_message(ctx, "Sign Lisk message", msg.message)
await require_confirm_sign_message(ctx, "Lisk", msg.message)
node = keychain.derive(msg.address_n)
seckey = node.private_key()

View File

@ -15,8 +15,6 @@ async def verify_message(ctx, msg):
raise wire.ProcessError("Invalid signature")
address = get_address_from_public_key(msg.public_key)
await require_confirm_verify_message(
ctx, address, "Verify Lisk message", msg.message
)
await require_confirm_verify_message(ctx, address, "Lisk", msg.message)
return Success(message="Message verified")

View File

@ -141,7 +141,7 @@
"test_msg_ethereum_signtx_eip155.py::test_chain_ids[4-1-sig2]": "aa53c8ba48faa3ac1227b0c187d73783d47063ce130c2a58fab1dcab841fa1dd",
"test_msg_ethereum_signtx_eip155.py::test_chain_ids[61-61-sig3]": "cd5f04cc7b055503e83f0538709a7ac577445c6089ead12f1fc3a3c45ad96419",
"test_msg_ethereum_signtx_eip155.py::test_with_data": "33e97436953f55bc61c5f54bd9702b1ba962c0e716d20ddbe9827be3d24ad98d",
"test_msg_ethereum_verifymessage.py-test_verify": "5d1c3f207e498c1b6e874156f2dcb6dd51f8efc27fc5f8474c35abc7c32e4cfb",
"test_msg_ethereum_verifymessage.py-test_verify": "2c360ce34c1063cab113c521f2d77d9f312f88a971dbbd71c8891e37d37a70c1",
"test_msg_ethereum_verifymessage.py-test_verify_invalid": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586",
"test_msg_getaddress.py::test_unknown_path": "70da33d9f9ccbc228a9418a725f7e9acdbe4d7537903387336a72fe0337ef5e7",
"test_msg_getaddress_segwit.py-test_show_multisig_3": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586",
@ -190,8 +190,8 @@
"test_msg_lisk_signtx.py-test_lisk_sign_tx_send": "07e5a905588b9e2518db7554c76c548c5a1267849b30cf911259477938705ff8",
"test_msg_lisk_signtx.py-test_lisk_sign_tx_send_with_data": "ea969f90b6e4b840bb8728a9a99e5d07f59f478dba6b144218148d9db83f7a49",
"test_msg_lisk_signtx.py-test_lisk_sign_tx_send_wrong_path": "94926de286243a18fb94d20adfd97613f02b8b1e84f4db71e36cb0089c048919",
"test_msg_lisk_verifymessage.py-test_verify": "1854e1c346d1db91c8e35b8081e3fcfe851340a367d1207c51dac156dddc93ea",
"test_msg_lisk_verifymessage.py-test_verify_long": "1798e15f373dc321e43094b13d07d6bbb8ad532c31f425351433f6571d61c289",
"test_msg_lisk_verifymessage.py-test_verify": "45df85077b20182803b5c4363386c555845e070f3a8a019add99e34dad510a07",
"test_msg_lisk_verifymessage.py-test_verify_long": "d7d0ae3402b9ca6c7b0e61164fa483c4ba9549d306780c98ae15edd2dde51285",
"test_msg_loaddevice.py-test_load_device_1": "1c6db0d592b1d22b3c9fce3ddab8a9fd138f11d83e5d4e64431a02bf4ffed605",
"test_msg_loaddevice.py-test_load_device_2": "06426c64d246068fe80fea79b0afd06d3eac4545fbd711279b816c0fdbf1b794",
"test_msg_loaddevice.py-test_load_device_slip39_advanced": "1c6db0d592b1d22b3c9fce3ddab8a9fd138f11d83e5d4e64431a02bf4ffed605",
@ -266,22 +266,22 @@
"test_msg_sd_protect.py::test_refresh": "1a12c939fbb625908d940928a3b1b72f4c6f79a82f187300663fa188ebfbd5ee",
"test_msg_sd_protect.py::test_wipe": "67a32e8b242bcb2a597d42ab373704a51a7a4e54de2dd335d5ec7a419471a437",
"test_msg_signidentity.py-test_sign": "32ce801c760dad2a01b605a2363847b24899ace78420f1d195c7167ce39da8c5",
"test_msg_signmessage.py::test_signmessage[NFC message]": "ebdd2b084e3178d08e911c24287c7e850111985254b4ea84e761f1962cb37ec2",
"test_msg_signmessage.py::test_signmessage[NFKD message]": "ebdd2b084e3178d08e911c24287c7e850111985254b4ea84e761f1962cb37ec2",
"test_msg_signmessage.py::test_signmessage[bcash]": "afced22a35654f96108611b53bde65e8a11cc8ab258a95012da722c818c0a2d2",
"test_msg_signmessage.py::test_signmessage[decred]": "afced22a35654f96108611b53bde65e8a11cc8ab258a95012da722c818c0a2d2",
"test_msg_signmessage.py::test_signmessage[grs-p2pkh]": "9a21b2633749b87174fb666144641f4563d58aaec5c5694e1d1eac3ac993831d",
"test_msg_signmessage.py::test_signmessage[grs-segwit-native]": "9a21b2633749b87174fb666144641f4563d58aaec5c5694e1d1eac3ac993831d",
"test_msg_signmessage.py::test_signmessage[grs-segwit-p2sh]": "9a21b2633749b87174fb666144641f4563d58aaec5c5694e1d1eac3ac993831d",
"test_msg_signmessage.py::test_signmessage[p2pkh long message]": "9360986c6e160d56fa4049903f04e2edcbda085eedb892e800d54c06422328c3",
"test_msg_signmessage.py::test_signmessage[p2pkh0]": "afced22a35654f96108611b53bde65e8a11cc8ab258a95012da722c818c0a2d2",
"test_msg_signmessage.py::test_signmessage[p2pkh1]": "afced22a35654f96108611b53bde65e8a11cc8ab258a95012da722c818c0a2d2",
"test_msg_signmessage.py::test_signmessage[segwit-native long message]": "9360986c6e160d56fa4049903f04e2edcbda085eedb892e800d54c06422328c3",
"test_msg_signmessage.py::test_signmessage[segwit-native0]": "afced22a35654f96108611b53bde65e8a11cc8ab258a95012da722c818c0a2d2",
"test_msg_signmessage.py::test_signmessage[segwit-native1]": "afced22a35654f96108611b53bde65e8a11cc8ab258a95012da722c818c0a2d2",
"test_msg_signmessage.py::test_signmessage[segwit-p2sh long message]": "9360986c6e160d56fa4049903f04e2edcbda085eedb892e800d54c06422328c3",
"test_msg_signmessage.py::test_signmessage[segwit-p2sh0]": "afced22a35654f96108611b53bde65e8a11cc8ab258a95012da722c818c0a2d2",
"test_msg_signmessage.py::test_signmessage[segwit-p2sh1]": "afced22a35654f96108611b53bde65e8a11cc8ab258a95012da722c818c0a2d2",
"test_msg_signmessage.py::test_signmessage[NFC message]": "69bd412ca0c2f980b7e0bfcc8329c7454b144d89bae40193ef8e61bdf24a6961",
"test_msg_signmessage.py::test_signmessage[NFKD message]": "69bd412ca0c2f980b7e0bfcc8329c7454b144d89bae40193ef8e61bdf24a6961",
"test_msg_signmessage.py::test_signmessage[bcash]": "d25510e01fb7599df0cd81fbc4b843fe08950435a0c706ced32682954fd66adc",
"test_msg_signmessage.py::test_signmessage[decred]": "8ba7d70f772524c74642fd13ddaf86e331cc8edea04ab550561cce58c89195ae",
"test_msg_signmessage.py::test_signmessage[grs-p2pkh]": "ec3e945d48671cb2636eb0894f2f9e098021f4f887ed5811038786ecbe888f32",
"test_msg_signmessage.py::test_signmessage[grs-segwit-native]": "ec3e945d48671cb2636eb0894f2f9e098021f4f887ed5811038786ecbe888f32",
"test_msg_signmessage.py::test_signmessage[grs-segwit-p2sh]": "ec3e945d48671cb2636eb0894f2f9e098021f4f887ed5811038786ecbe888f32",
"test_msg_signmessage.py::test_signmessage[p2pkh long message]": "e71fa88fc3ff09d0984bc10b935e89bdd042e8c7c94038594ad19707e026dd44",
"test_msg_signmessage.py::test_signmessage[p2pkh0]": "7a87ec7a17c6acb3522c496318a116b4adde87373d4408201a8e3de4dacfaa3d",
"test_msg_signmessage.py::test_signmessage[p2pkh1]": "0421042764ba76d4d7977c35778476bd46af57033a51b0fdab3374be815d3acf",
"test_msg_signmessage.py::test_signmessage[segwit-native long message]": "e71fa88fc3ff09d0984bc10b935e89bdd042e8c7c94038594ad19707e026dd44",
"test_msg_signmessage.py::test_signmessage[segwit-native0]": "7a87ec7a17c6acb3522c496318a116b4adde87373d4408201a8e3de4dacfaa3d",
"test_msg_signmessage.py::test_signmessage[segwit-native1]": "0421042764ba76d4d7977c35778476bd46af57033a51b0fdab3374be815d3acf",
"test_msg_signmessage.py::test_signmessage[segwit-p2sh long message]": "e71fa88fc3ff09d0984bc10b935e89bdd042e8c7c94038594ad19707e026dd44",
"test_msg_signmessage.py::test_signmessage[segwit-p2sh0]": "7a87ec7a17c6acb3522c496318a116b4adde87373d4408201a8e3de4dacfaa3d",
"test_msg_signmessage.py::test_signmessage[segwit-p2sh1]": "0421042764ba76d4d7977c35778476bd46af57033a51b0fdab3374be815d3acf",
"test_msg_signtx.py-test_attack_change_input_address": "6b4ab9704a9e02f5de20ed7bd0bd70c3c5c67f0f6c4cd453ea078fdb1796909e",
"test_msg_signtx.py-test_attack_change_outputs": "4872e0db49b2c66f2f033d055abc086520cdd667ffe48ead0ad5ed0f4452af1a",
"test_msg_signtx.py-test_attack_modify_change_address": "cfd5c83510c044c456622298138e222aee135a6df607bb6e5603228535f0762f",
@ -384,21 +384,21 @@
"test_msg_tezos_sign_tx.py-test_tezos_smart_contract_delegation": "e466bd6c5ab4238e6174f1c2df91543f50507e006db50cc084911eb295a5243d",
"test_msg_tezos_sign_tx.py-test_tezos_smart_contract_transfer": "2d6b7f18fb79676707e58804414553e95bf3aca8eb15bc513137e81de73441a0",
"test_msg_tezos_sign_tx.py-test_tezos_smart_contract_transfer_to_contract": "88eed16fe60952c069326b1a74b3ee3d65598f42381e51d9a17ed8618a567612",
"test_msg_verifymessage.py-test_message_grs": "507bd5412292355b4b0c1cb684eb2305ab4c0016f2ca297b8c1359120fbe2ae1",
"test_msg_verifymessage.py-test_message_long": "45e8597d27f354d8f7f18b96f563729b247f9454c3a9496ea0e5f985232e3ef7",
"test_msg_verifymessage.py-test_message_testnet": "7295f8f7ca84c069a0e000766fd685b1b2bafe3f2a60f8b102796d0af79ed67b",
"test_msg_verifymessage.py-test_message_verify": "a357a0874e3ae40c0e385aa5ef365a1d20a34d51feb7ea1691c0d86c6f9bf242",
"test_msg_verifymessage.py-test_message_verify_bcash": "e88b6bd86172f87662ed401b9847f7ec4a31ee67e87df584f449da89d0b7e646",
"test_msg_verifymessage.py-test_verify_bitcoind": "60172931e504d810918aa99a6b87f7fb3fbc8e8ebf14421fbfc8d3a9b1b6349a",
"test_msg_verifymessage.py-test_verify_utf": "0632bad652f414daebeb9cd5e684d5ac62d786cb88d2e03eecb3cd6ae652306f",
"test_msg_verifymessage_segwit.py-test_message_long": "84c3d161e694b656ea0472dbc77dd0d88d9772f4ffffa94c4304e3e3cb958770",
"test_msg_verifymessage_segwit.py-test_message_testnet": "2df34d0457f537023d513de468b4ccc7fbfcd70e9f980e4e1ec30d3c63157f36",
"test_msg_verifymessage_segwit.py-test_message_verify": "9af19581b27db5dfed6250f0a245be98428ac98149b3bbd93409756becee07e5",
"test_msg_verifymessage_segwit.py-test_verify_utf": "3812bdaf2610559ddabf265f7f571fc097fb6db163823c90c283361178c4df6d",
"test_msg_verifymessage_segwit_native.py-test_message_long": "09bdef88a5a43df4ff349101adc05e7b485bb437b029031406348e1a3f6d6866",
"test_msg_verifymessage_segwit_native.py-test_message_testnet": "113ad2d6389810b542e5ae5aba5d0de2aa52661e321c3f1d9f45cc91637b3c1d",
"test_msg_verifymessage_segwit_native.py-test_message_verify": "b206b7a79c40525efa765718376d5f369caf424e11e93dd0eab97861dc1f4f8d",
"test_msg_verifymessage_segwit_native.py-test_verify_utf": "118265328951cb575b2a044acabaec0d80597b730cd06b3dbcbc66193dab8315",
"test_msg_verifymessage.py-test_message_grs": "6cc8d8e5abffb5e956e6f5bb9ff7c973ec85209012deb27ee0d234301a1c9819",
"test_msg_verifymessage.py-test_message_long": "a462c3c68cbcba8b47436c6efe575a8b3ed244ae0a2487453c13028dd5d19472",
"test_msg_verifymessage.py-test_message_testnet": "740c525df373dac85ab1079e768737ad3ca6843d1eeffb44b78e389a2ce1ef82",
"test_msg_verifymessage.py-test_message_verify": "eda9ecd708e1bb0a2c3f4a032a96de656434f6285ffd386d5f36e070a946322f",
"test_msg_verifymessage.py-test_message_verify_bcash": "c1996b7a0506be782a0320a51c43fe522c323331ba682c1211d1eb961246a767",
"test_msg_verifymessage.py-test_verify_bitcoind": "329ccdcdd24f1bac10bcdb2d4c1f8b1bdf72134eda7cdd95c78d1d8f4c8a03e4",
"test_msg_verifymessage.py-test_verify_utf": "fd2d6ec07d3bd32e9243575f5a682bddc024d68688811d58dbaa34080d44d7e9",
"test_msg_verifymessage_segwit.py-test_message_long": "644446973443dcb398cdb4202374262adfe776ce7d05b2e5cf8dbcc5f22cf5b4",
"test_msg_verifymessage_segwit.py-test_message_testnet": "46fbbdcbd9b311071cca39eacd24797630f4fe5bc9617fbd20dd60f3dadedd4c",
"test_msg_verifymessage_segwit.py-test_message_verify": "3cf672e588be09f4e3e88f0e09b65b3a35f177aefe1d2fcb654fdd58dbeb1e8f",
"test_msg_verifymessage_segwit.py-test_verify_utf": "21315017e1e8cc1c0c709743d445e5f6f03f835c3989d37c6c910dc0758fbbff",
"test_msg_verifymessage_segwit_native.py-test_message_long": "24855f64d64f713c468625c580a37d3a9b4715a1064d8f7c489c1f6c79fa4a40",
"test_msg_verifymessage_segwit_native.py-test_message_testnet": "4bca71b5a5f0bd84a6f2e1f5f669f561b490b52741a4d3e1e4538072b2a0e5b4",
"test_msg_verifymessage_segwit_native.py-test_message_verify": "818b8c38b040ac45e1525ca2bc90507092b57380b220503ad11f7c1e03a5ee62",
"test_msg_verifymessage_segwit_native.py-test_verify_utf": "f89d64e7ca25daa7ad180294d45d01d40e4265679dd327c5a23579a261622d24",
"test_msg_webauthn.py::test_add_remove": "a9cdefeb089f197427257e097d07179b23de4fcad4ee91af0191ed767f80577c",
"test_msg_wipedevice.py::test_wipe_device": "bc6acd0386b9d009e6550519917d6e08632b3badde0b0cf04c95abe5f773038a",
"test_multisig.py-test_15_of_15": "9d1799a199b45785ac69ae6af715c251b10aebb60f981c9b73d78e53e1a91374",