mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-19 00:29:03 +00:00
feat(tests): test ethereum signing anti-exfil protocol
This commit is contained in:
parent
9ece9ae6c0
commit
7ff5c223a1
@ -517,3 +517,134 @@ def test_signtx_staking_eip1559(client: Client, parameters: dict, result: dict):
|
||||
assert sig_r.hex() == result["sig_r"]
|
||||
assert sig_s.hex() == result["sig_s"]
|
||||
assert sig_v == result["sig_v"]
|
||||
|
||||
|
||||
@pytest.mark.models("core", reason="Not implemented")
|
||||
def test_anti_exfil(client: Client):
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
[
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.SignTx),
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.SignTx),
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.SignTx),
|
||||
message_filters.EthereumTxRequest(
|
||||
data_length=1,
|
||||
signature_v=None,
|
||||
signature_r=None,
|
||||
signature_s=None,
|
||||
nonce_commitment=None,
|
||||
),
|
||||
message_filters.EthereumTxRequest(
|
||||
data_length=None,
|
||||
signature_v=None,
|
||||
signature_r=None,
|
||||
signature_s=None,
|
||||
nonce_commitment=bytes.fromhex(
|
||||
"03957e53baf3a5a3c0b0376b1b5a397abc3612f5509c5a1436d701cb1ef985555b"
|
||||
),
|
||||
),
|
||||
message_filters.EthereumTxRequest(
|
||||
data_length=None,
|
||||
signature_v=None,
|
||||
signature_r=bytes.fromhex(
|
||||
"7fd641fa851220322d82a26ad68f1409b26c336db60cd45e69a6c7ac5f504e47"
|
||||
),
|
||||
signature_s=bytes.fromhex(
|
||||
"3e53105405b8d984e4d76f300157441d87f9d553213859b0a11068c0d6a70430"
|
||||
),
|
||||
nonce_commitment=None,
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
anti_exfil_signature = ethereum.sign_tx_new(
|
||||
client,
|
||||
n=parse_path("m/44h/60h/0h/0/0"),
|
||||
nonce=0,
|
||||
gas_price=20_000,
|
||||
gas_limit=20_000,
|
||||
to=TO_ADDR,
|
||||
value=0,
|
||||
data=b"A" * 1025,
|
||||
chain_id=1,
|
||||
use_anti_exfil=True,
|
||||
entropy=bytes(32),
|
||||
)
|
||||
|
||||
assert anti_exfil_signature == ethereum.AntiExfilSignature(
|
||||
signature=bytes.fromhex(
|
||||
"7fd641fa851220322d82a26ad68f1409b26c336db60cd45e69a6c7ac5f504e473e53105405b8d984e4d76f300157441d87f9d553213859b0a11068c0d6a70430"
|
||||
),
|
||||
entropy=bytes.fromhex(
|
||||
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||
),
|
||||
nonce_commitment=bytes.fromhex(
|
||||
"03957e53baf3a5a3c0b0376b1b5a397abc3612f5509c5a1436d701cb1ef985555b"
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.models(skip="legacy", reason="Not implemented")
|
||||
def test_anti_exfil_eip1559(client: Client):
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
[
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.SignTx),
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.SignTx),
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.SignTx),
|
||||
message_filters.EthereumTxRequest(
|
||||
data_length=1,
|
||||
signature_v=None,
|
||||
signature_r=None,
|
||||
signature_s=None,
|
||||
nonce_commitment=None,
|
||||
),
|
||||
message_filters.EthereumTxRequest(
|
||||
data_length=None,
|
||||
signature_v=None,
|
||||
signature_r=None,
|
||||
signature_s=None,
|
||||
nonce_commitment=bytes.fromhex(
|
||||
"039802b7d2fa6d6490fd3300b1b48021f477905232f2378c6cf56bf1efa53792f8"
|
||||
),
|
||||
),
|
||||
message_filters.EthereumTxRequest(
|
||||
data_length=None,
|
||||
signature_v=None,
|
||||
signature_r=bytes.fromhex(
|
||||
"bd43e3e33f79fa6cdb5bc71dabe8fc8990b47e8559f8d86ee7fc8f7e9a3d1d3e"
|
||||
),
|
||||
signature_s=bytes.fromhex(
|
||||
"63c6155e9c2b65cee17d6337565a153aa29b1033519989cbe5584c73ea843be2"
|
||||
),
|
||||
nonce_commitment=None,
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
anti_exfil_signature = ethereum.sign_tx_eip1559_new(
|
||||
client,
|
||||
n=parse_path("m/44h/60h/0h/0/0"),
|
||||
nonce=0,
|
||||
gas_limit=20_000,
|
||||
to=TO_ADDR,
|
||||
value=0,
|
||||
data=b"A" * 1025,
|
||||
chain_id=1,
|
||||
max_gas_fee=10,
|
||||
max_priority_fee=10,
|
||||
use_anti_exfil=True,
|
||||
entropy=bytes(32),
|
||||
)
|
||||
|
||||
assert anti_exfil_signature == ethereum.AntiExfilSignature(
|
||||
signature=bytes.fromhex(
|
||||
"bd43e3e33f79fa6cdb5bc71dabe8fc8990b47e8559f8d86ee7fc8f7e9a3d1d3e63c6155e9c2b65cee17d6337565a153aa29b1033519989cbe5584c73ea843be2"
|
||||
),
|
||||
entropy=bytes.fromhex(
|
||||
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||
),
|
||||
nonce_commitment=bytes.fromhex(
|
||||
"039802b7d2fa6d6490fd3300b1b48021f477905232f2378c6cf56bf1efa53792f8"
|
||||
),
|
||||
)
|
||||
|
@ -4917,6 +4917,8 @@
|
||||
"T2T1_en_ethereum-test_sign_verify_message.py::test_verify[parameters6-result6]": "bad4506e175916842703425d6b663c943a8c70cf53f217bb79556ae2a97a0641",
|
||||
"T2T1_en_ethereum-test_sign_verify_message.py::test_verify[parameters7-result7]": "970d4437c1680e0cc78eabd99ecb77a97de793ba62bba20aac03e0a064bb6695",
|
||||
"T2T1_en_ethereum-test_sign_verify_message.py::test_verify_invalid": "2669092fb946e0c562d103895f6023ec449f8e40c7dcd97933d5070544838ffc",
|
||||
"T2T1_en_ethereum-test_signtx.py::test_anti_exfil": "0dcd1fe0d7bf72bc2be632ec259e2148f2cc0b7fd5c90811970f77824ae7baf2",
|
||||
"T2T1_en_ethereum-test_signtx.py::test_anti_exfil_eip1559": "fbf0554abcea8effb612d069d8d45b9e3cd5fba8ac157e72bbc438f1e7352ac1",
|
||||
"T2T1_en_ethereum-test_signtx.py::test_data_streaming": "30c0ccd605a528d6362650089c9f7b81aaeb7160b320fb3dd7b1312bb701d0fd",
|
||||
"T2T1_en_ethereum-test_signtx.py::test_sanity_checks": "8b1ccc0dbd6e6e3d02a896650ab90dd332ba4edbbcc4095e0fbb6a96e5256f75",
|
||||
"T2T1_en_ethereum-test_signtx.py::test_sanity_checks_eip1559": "8b1ccc0dbd6e6e3d02a896650ab90dd332ba4edbbcc4095e0fbb6a96e5256f75",
|
||||
@ -13822,6 +13824,8 @@
|
||||
"T3B1_en_ethereum-test_sign_verify_message.py::test_verify[parameters6-result6]": "ee864676bee4fafa79cdb1b18df064964c6140596f904a65d84fa6674bddfb5b",
|
||||
"T3B1_en_ethereum-test_sign_verify_message.py::test_verify[parameters7-result7]": "be6a9c8dc43e8673b19e4196caf8ad97ec5b5592caeb67c63855869291604e7e",
|
||||
"T3B1_en_ethereum-test_sign_verify_message.py::test_verify_invalid": "234a241a3ed0b05920178c7849402d8c715a4e0bd4797b26cd316f9863014cc0",
|
||||
"T3B1_en_ethereum-test_signtx.py::test_anti_exfil": "e2821a03c1850a5736f1d274967c35044778c5bafb4a493ee5df8cc3ed9dc446",
|
||||
"T3B1_en_ethereum-test_signtx.py::test_anti_exfil_eip1559": "3cf50fb2726b4155f979158b05a9eaab68e2a17695715e63b401c1f59e7d0e9f",
|
||||
"T3B1_en_ethereum-test_signtx.py::test_data_streaming": "d592ad4dad4564dbf53287615b63896f862a4f8410bbdb6bd0f0f631b312c07d",
|
||||
"T3B1_en_ethereum-test_signtx.py::test_sanity_checks": "1477d62e338f4d7c1bfac2fc5d2fc231218da5768666c11482dc1f83229506f3",
|
||||
"T3B1_en_ethereum-test_signtx.py::test_sanity_checks_eip1559": "1477d62e338f4d7c1bfac2fc5d2fc231218da5768666c11482dc1f83229506f3",
|
||||
@ -22545,6 +22549,8 @@
|
||||
"T3T1_en_ethereum-test_sign_verify_message.py::test_verify[parameters6-result6]": "38a9b40398843c674a7c4f9131e200f950cff4e8a0756faf2c7a628691c5fa6c",
|
||||
"T3T1_en_ethereum-test_sign_verify_message.py::test_verify[parameters7-result7]": "3e3cd1ae3b01c7a9404a08a3ce8bd1116156f2f5ba47e755027550a3836d8257",
|
||||
"T3T1_en_ethereum-test_sign_verify_message.py::test_verify_invalid": "84b110371fc8aaec493afc3b373fda8ab744a2808f04db80518d268ba1c86e61",
|
||||
"T3T1_en_ethereum-test_signtx.py::test_anti_exfil": "a8afb75c7efa59b63336a125c30795270e280145756968b892310e08cb64709f",
|
||||
"T3T1_en_ethereum-test_signtx.py::test_anti_exfil_eip1559": "d6cb1dcc247e6aa2378f14acf2e89cc774c81823757ec49558cec544a7fb84cf",
|
||||
"T3T1_en_ethereum-test_signtx.py::test_data_streaming": "4c1a6364e9738777942aeb4b4b2e50966d69462f02bf8d1e5d9afc72a4a9a589",
|
||||
"T3T1_en_ethereum-test_signtx.py::test_sanity_checks": "92b7fb03fbf28636b3c06ee5018fe44f92285e50c379b9671b1d4efddf232f85",
|
||||
"T3T1_en_ethereum-test_signtx.py::test_sanity_checks_eip1559": "92b7fb03fbf28636b3c06ee5018fe44f92285e50c379b9671b1d4efddf232f85",
|
||||
|
Loading…
Reference in New Issue
Block a user