mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-11 16:00:57 +00:00
feat(core/bitcoin): SignMessage: whitelist T1 firmware signing address_n
[no changelog]
This commit is contained in:
parent
b12de5d861
commit
fc3ee87c25
@ -1,7 +1,7 @@
|
||||
from micropython import const
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.messages import AuthorizeCoinJoin
|
||||
from trezor.messages import AuthorizeCoinJoin, SignMessage
|
||||
|
||||
from apps.common.paths import PATTERN_BIP44, PathSchema
|
||||
|
||||
@ -20,7 +20,6 @@ if TYPE_CHECKING:
|
||||
GetAddress,
|
||||
GetOwnershipId,
|
||||
GetPublicKey,
|
||||
SignMessage,
|
||||
VerifyMessage,
|
||||
GetOwnershipProof,
|
||||
SignTx,
|
||||
@ -85,6 +84,9 @@ PATTERN_UNCHAINED_UNHARDENED = (
|
||||
)
|
||||
PATTERN_UNCHAINED_DEPRECATED = "m/45'/coin_type'/account'/[0-1000000]/address_index"
|
||||
|
||||
# Model 1 firmware signing.
|
||||
PATTERN_SLIP26_T1_FW = "m/10026'/49'/2'/0'"
|
||||
|
||||
# SLIP-44 coin type for Bitcoin
|
||||
_SLIP44_BITCOIN = const(0)
|
||||
|
||||
@ -159,6 +161,9 @@ def validate_path_against_script_type(
|
||||
append(PATTERN_BIP86)
|
||||
append(PATTERN_SLIP25_TAPROOT)
|
||||
|
||||
elif SignMessage.is_type_of(msg):
|
||||
append(PATTERN_SLIP26_T1_FW)
|
||||
|
||||
return any(
|
||||
PathSchema.parse(pattern, coin.slip44).match(address_n) for pattern in patterns
|
||||
)
|
||||
@ -188,6 +193,7 @@ def _get_schemas_for_coin(
|
||||
PATTERN_GREENADDRESS_B,
|
||||
PATTERN_GREENADDRESS_SIGN_A,
|
||||
PATTERN_GREENADDRESS_SIGN_B,
|
||||
PATTERN_SLIP26_T1_FW,
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -29,11 +29,12 @@ from trezorlib.tools import parse_path
|
||||
S = messages.InputScriptType
|
||||
|
||||
|
||||
def case(id, *args, altcoin=False):
|
||||
def case(id, *args, altcoin=False, skip_t1=False):
|
||||
marks = []
|
||||
if altcoin:
|
||||
marks = pytest.mark.altcoin
|
||||
else:
|
||||
marks = ()
|
||||
marks.append(pytest.mark.altcoin)
|
||||
if skip_t1:
|
||||
marks.append(pytest.mark.skip_t1)
|
||||
return pytest.param(*args, id=id, marks=marks)
|
||||
|
||||
|
||||
@ -155,6 +156,18 @@ VECTORS = ( # case name, coin_name, path, script_type, address, message, signat
|
||||
MESSAGE_NFC,
|
||||
NFKD_NFC_SIGNATURE,
|
||||
),
|
||||
# ==== T1 FW signing ====
|
||||
case(
|
||||
"t1 firmware path",
|
||||
"Bitcoin",
|
||||
"m/10026'/49'/2'/0'",
|
||||
S.SPENDADDRESS,
|
||||
False,
|
||||
"1Cykx69qc6WPukP6V1BhBfRi4zt8PgzcP6",
|
||||
b"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
|
||||
"1fd240d06000fb0854446ca08dfa8f6ca51b2d3c194c7a655d940aab8b7c727c6459276fe44d70c88e5c56d60ff2fa1b8682ca01d203f4fcad37b58f9ed98ad0d2",
|
||||
skip_t1=True,
|
||||
),
|
||||
# ==== Testnet script types ====
|
||||
case(
|
||||
"p2pkh",
|
||||
|
@ -863,6 +863,7 @@
|
||||
"TT_bitcoin-test_signmessage.py::test_signmessage[segwit-p2sh0]": "ee002ce0851daf9d71a43bbea055b33779ad38403c716417c1b3ca1a13ac5e18",
|
||||
"TT_bitcoin-test_signmessage.py::test_signmessage[segwit-p2sh1]": "ee002ce0851daf9d71a43bbea055b33779ad38403c716417c1b3ca1a13ac5e18",
|
||||
"TT_bitcoin-test_signmessage.py::test_signmessage[segwit-p2sh2]": "5c7758b049bb4a2870a5f0486e0a7bbf07e590ef7a18214076025ceb1da648c0",
|
||||
"TT_bitcoin-test_signmessage.py::test_signmessage[t1 firmware path]": "a3fc21f9ea0d80d0b9b098f9db9a9c4b3169827e8291b28f2eae734598395c9c",
|
||||
"TT_bitcoin-test_signmessage.py::test_signmessage_pagination[long_words]": "ffdada0b56c548001cd31f3c7dcdc0d1f095b648cb085fdc6341b9f9843ad4d1",
|
||||
"TT_bitcoin-test_signmessage.py::test_signmessage_pagination[newlines]": "791ff7121d6f0e92754706ffc51319f6980ff615acde6ede7f12aa891771475a",
|
||||
"TT_bitcoin-test_signmessage.py::test_signmessage_pagination[no_spaces]": "6b1c656ec45a7725247c5c875373af0eb889a50f21979e95f6d8b7dbebad72e9",
|
||||
|
Loading…
Reference in New Issue
Block a user