Now uses Web3 to check EIP-712 signatures in Ragger tests
Fixed platformFeeRecipient address length in 14-rabby_bug-data.json since Web3 does not handle addresses with a length != 20B
@@ -1,4 +0,0 @@
|
||||
[signature]
|
||||
v = 1b
|
||||
r = 23599abd6c4b631e42770c112b5955907fe91339f1ea1e102f7682262ca178b9
|
||||
s = 29fc94518588165114b4c4acb4d73e6d028dfb051d90e517b3b4746e04eb0f5f
|
||||
@@ -1,4 +0,0 @@
|
||||
[signature]
|
||||
v = 1c
|
||||
r = 3f084a471e6158bce792287500d62d40061acc1864180ed2da7a704bf3aced0f
|
||||
s = 3b799ced9e48cda152b4b9a4b7f45e3119dc7acdf16710a73800b4e336fa1b40
|
||||
@@ -38,10 +38,6 @@
|
||||
{ "name": "chainId", "type": "uint256" },
|
||||
{ "name": "verifyingContract", "type": "address" }
|
||||
],
|
||||
"Group": [
|
||||
{ "name": "name", "type": "string" },
|
||||
{ "name": "members", "type": "Person[]" }
|
||||
],
|
||||
"Mail": [
|
||||
{ "name": "from", "type": "Person" },
|
||||
{ "name": "to", "type": "Person[]" },
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
[signature]
|
||||
v = 1b
|
||||
r = 49dd2aa96d7494e0cd9111f19f87ac50194e4bbc61ea9f4bb86d674da0ae7721
|
||||
s = 7a12ddd9083b4caaabd2fb80df6de1d5d926c0e8a73bf371a45e231d409d79d6
|
||||
@@ -33,10 +33,6 @@
|
||||
{ "name": "chainId", "type": "uint256" },
|
||||
{ "name": "verifyingContract", "type": "address" }
|
||||
],
|
||||
"Group": [
|
||||
{ "name": "name", "type": "string" },
|
||||
{ "name": "members", "type": "Person[]" }
|
||||
],
|
||||
"Mail": [
|
||||
{ "name": "from", "type": "Person" },
|
||||
{ "name": "to", "type": "Person[]" },
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
[signature]
|
||||
v = 1c
|
||||
r = b23ffac2cb350fd6e7d06ec4b981fe016d33426d753c870e7e753797cc43bb1f
|
||||
s = 37948a656fa3403e21956ef10c8d3152f7ce22cc252d958c9f9249435090f426
|
||||
@@ -33,10 +33,6 @@
|
||||
{ "name": "chainId", "type": "uint256" },
|
||||
{ "name": "verifyingContract", "type": "address" }
|
||||
],
|
||||
"Group": [
|
||||
{ "name": "name", "type": "string" },
|
||||
{ "name": "members", "type": "Person[]" }
|
||||
],
|
||||
"Mail": [
|
||||
{ "name": "from", "type": "Person" },
|
||||
{ "name": "to", "type": "Person[]" },
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
[signature]
|
||||
v = 1b
|
||||
r = db18ea1b9757773385138d0802fb2f8107c3e45882962b8e0c6789eccdbfab05
|
||||
s = 3d66d4dee47916fb7fec39a538ad8d5e94fbc92f99327410716180ab07591218
|
||||
@@ -1,4 +0,0 @@
|
||||
[signature]
|
||||
v = 1c
|
||||
r = 50fb2861367daf3b5b73cac277e698b27bf7627a462fade1acb5a2ef285ba8ae
|
||||
s = 131a62515a0a5c4b35c5cb672b46f562151c45508d8efcdf78c4608bc14c5f30
|
||||
@@ -1,4 +0,0 @@
|
||||
[signature]
|
||||
v = 1c
|
||||
r = 929681d77ed88cd1adef57185a0cd7b3a268aca5d4122b8c0acfd2ce4c0afb18
|
||||
s = 5afe8e3004c182b6b02fe7559c26f20f4133ad9b17223658ccd9061b33b021cf
|
||||
@@ -1,4 +0,0 @@
|
||||
[signature]
|
||||
v = 1b
|
||||
r = e021d88afc50079b0341b01193c4687c47b85bcd6749fe69e0b87521d65a1847
|
||||
s = 5b7670d2a67c781a11164920403db0f7707161e81d88226cdbf91298390dfeda
|
||||
@@ -1,4 +0,0 @@
|
||||
[signature]
|
||||
v = 1b
|
||||
r = 1539547ae7cf8ebcd3eabfb57cd2b1fb7775ce757c3f4a307c7425d35b7bfff7
|
||||
s = 47248cb61e554c1f90af6331d9c9e51cbb8655667514194f509abe097a032319
|
||||
@@ -1,4 +0,0 @@
|
||||
[signature]
|
||||
v = 1c
|
||||
r = 341bca1c0dfd805d4befc21500084424dbe559c7aafd78d8fb461c0c76dfea1d
|
||||
s = 33ebb7b6fe0691961cd8b263faac20ecbbdcaef3febb57eb76614cad629080ea
|
||||
@@ -1,4 +0,0 @@
|
||||
[signature]
|
||||
v = 1b
|
||||
r = d11a91bdf7836288818875d046452061d565cc6dc1bf3dd6216ab27ef9a2844f
|
||||
s = 4f6bda8ac4c39721aff7ae08989897ede9d573085a192d03ab0eb7735d2ef403
|
||||
@@ -1,4 +0,0 @@
|
||||
[signature]
|
||||
v = 1c
|
||||
r = cce2e63aaac6a5f9a74684d8fdddcbc7f3b27aa17235bfab89226821ead933b6
|
||||
s = 3f3c93977abcc3f8cc9a3dc1ecc02dbca14aca1a6ecb2fb6ca3d7c713ace1ec4
|
||||
@@ -1,4 +0,0 @@
|
||||
[signature]
|
||||
v = 1b
|
||||
r = 7be1671577753c13bfd1da8b234b6df8484daf47351c2366637fd291dd4aa4d9
|
||||
s = 1a7ffbb01dc8a64e9ee97d19b8f154e9eecbe0b1bfb9dcfa781a65e474573963
|
||||
@@ -1,4 +0,0 @@
|
||||
[signature]
|
||||
v = 1b
|
||||
r = 5d0635a868602e29366da6328f8fadf2d6a9b4e69ee7a65928e85ca56fb1b515
|
||||
s = 257364d6faaf5687edf90c3984f4240b0ce7b2dee55aa1f8f39c32d0d4d8c93d
|
||||
@@ -45,7 +45,7 @@
|
||||
"expiryTime": "1709280466",
|
||||
"startNonce": "7",
|
||||
"erc20Token": "0x09bc4e0d864854c6afb6eb9a9cdf58ac190d0df9",
|
||||
"platformFeeRecipient": "0x7538262ae993ca117a0e481f908209137a4626e",
|
||||
"platformFeeRecipient": "0x07538262ae993ca117a0e481f908209137a4626e",
|
||||
"basicCollections": [
|
||||
{
|
||||
"nftAddress": "0xaaaea1fb9f3de3f70e89f37b69ab11b47eb9ce6f",
|
||||
|
||||
|
Before Width: | Height: | Size: 472 B After Width: | Height: | Size: 472 B |
|
Before Width: | Height: | Size: 414 B After Width: | Height: | Size: 414 B |
|
Before Width: | Height: | Size: 338 B After Width: | Height: | Size: 338 B |
|
Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 336 B |
|
Before Width: | Height: | Size: 324 B After Width: | Height: | Size: 324 B |
|
Before Width: | Height: | Size: 364 B After Width: | Height: | Size: 364 B |
|
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 381 B |
|
Before Width: | Height: | Size: 472 B After Width: | Height: | Size: 472 B |
|
Before Width: | Height: | Size: 463 B After Width: | Height: | Size: 463 B |
|
Before Width: | Height: | Size: 371 B After Width: | Height: | Size: 371 B |
|
Before Width: | Height: | Size: 298 B After Width: | Height: | Size: 298 B |
|
Before Width: | Height: | Size: 285 B After Width: | Height: | Size: 285 B |
|
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
|
Before Width: | Height: | Size: 433 B After Width: | Height: | Size: 433 B |
|
Before Width: | Height: | Size: 555 B After Width: | Height: | Size: 555 B |
|
Before Width: | Height: | Size: 709 B After Width: | Height: | Size: 709 B |
|
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 321 B |
|
Before Width: | Height: | Size: 774 B After Width: | Height: | Size: 774 B |
|
Before Width: | Height: | Size: 364 B After Width: | Height: | Size: 364 B |
|
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 381 B |
|
Before Width: | Height: | Size: 472 B After Width: | Height: | Size: 472 B |
|
Before Width: | Height: | Size: 414 B After Width: | Height: | Size: 414 B |
|
Before Width: | Height: | Size: 338 B After Width: | Height: | Size: 338 B |
|
Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 336 B |
|
Before Width: | Height: | Size: 324 B After Width: | Height: | Size: 324 B |
|
Before Width: | Height: | Size: 364 B After Width: | Height: | Size: 364 B |
|
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 381 B |
|
Before Width: | Height: | Size: 472 B After Width: | Height: | Size: 472 B |
|
Before Width: | Height: | Size: 463 B After Width: | Height: | Size: 463 B |
|
Before Width: | Height: | Size: 371 B After Width: | Height: | Size: 371 B |
|
Before Width: | Height: | Size: 298 B After Width: | Height: | Size: 298 B |
|
Before Width: | Height: | Size: 285 B After Width: | Height: | Size: 285 B |
|
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
|
Before Width: | Height: | Size: 433 B After Width: | Height: | Size: 433 B |
|
Before Width: | Height: | Size: 555 B After Width: | Height: | Size: 555 B |
|
Before Width: | Height: | Size: 709 B After Width: | Height: | Size: 709 B |
|
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 321 B |
|
Before Width: | Height: | Size: 774 B After Width: | Height: | Size: 774 B |
|
Before Width: | Height: | Size: 364 B After Width: | Height: | Size: 364 B |
|
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 381 B |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
@@ -1,12 +1,12 @@
|
||||
import fnmatch
|
||||
import os
|
||||
import time
|
||||
from configparser import ConfigParser
|
||||
from functools import partial
|
||||
from pathlib import Path
|
||||
import json
|
||||
from typing import Optional
|
||||
import pytest
|
||||
from eth_account.messages import encode_typed_data
|
||||
|
||||
import client.response_parser as ResponseParser
|
||||
from client.utils import recover_message
|
||||
@@ -29,7 +29,8 @@ class SnapshotsConfig:
|
||||
|
||||
|
||||
BIP32_PATH = "m/44'/60'/0'/0/0"
|
||||
snaps_config: Optional[SnapshotsConfig] = None
|
||||
SNAPS_CONFIG: Optional[SnapshotsConfig] = None
|
||||
WALLET_ADDR: Optional[bytes] = None
|
||||
|
||||
|
||||
def eip712_json_path() -> str:
|
||||
@@ -59,33 +60,44 @@ def filtering_fixture(request) -> bool:
|
||||
return request.param
|
||||
|
||||
|
||||
def get_wallet_addr(client: EthAppClient) -> bytes:
|
||||
global WALLET_ADDR
|
||||
|
||||
# don't ask again if we already have it
|
||||
if WALLET_ADDR is None:
|
||||
with client.get_public_addr(display=False):
|
||||
pass
|
||||
_, WALLET_ADDR, _ = ResponseParser.pk_addr(client.response().data)
|
||||
return WALLET_ADDR
|
||||
|
||||
|
||||
def test_eip712_legacy(firmware: Firmware,
|
||||
backend: BackendInterface,
|
||||
navigator: Navigator):
|
||||
app_client = EthAppClient(backend)
|
||||
with app_client.eip712_sign_legacy(
|
||||
BIP32_PATH,
|
||||
bytes.fromhex('6137beb405d9ff777172aa879e33edb34a1460e701802746c5ef96e741710e59'),
|
||||
bytes.fromhex('eb4221181ff3f1a83ea7313993ca9218496e424604ba9492bb4052c03d5c3df8')):
|
||||
moves = []
|
||||
if firmware.device.startswith("nano"):
|
||||
moves += [NavInsID.RIGHT_CLICK]
|
||||
if firmware.device == "nanos":
|
||||
screens_per_hash = 4
|
||||
|
||||
with open(input_files()[0]) as file:
|
||||
data = json.load(file)
|
||||
smsg = encode_typed_data(full_message=data)
|
||||
with app_client.eip712_sign_legacy(BIP32_PATH, smsg.header, smsg.body):
|
||||
moves = []
|
||||
if firmware.device.startswith("nano"):
|
||||
moves += [NavInsID.RIGHT_CLICK]
|
||||
if firmware.device == "nanos":
|
||||
screens_per_hash = 4
|
||||
else:
|
||||
screens_per_hash = 2
|
||||
moves += [NavInsID.RIGHT_CLICK] * screens_per_hash * 2
|
||||
moves += [NavInsID.BOTH_CLICK]
|
||||
else:
|
||||
screens_per_hash = 2
|
||||
moves += [NavInsID.RIGHT_CLICK] * screens_per_hash * 2
|
||||
moves += [NavInsID.BOTH_CLICK]
|
||||
else:
|
||||
moves += [NavInsID.USE_CASE_REVIEW_TAP] * 2
|
||||
moves += [NavInsID.USE_CASE_REVIEW_CONFIRM]
|
||||
navigator.navigate(moves)
|
||||
moves += [NavInsID.USE_CASE_REVIEW_TAP] * 2
|
||||
moves += [NavInsID.USE_CASE_REVIEW_CONFIRM]
|
||||
navigator.navigate(moves)
|
||||
|
||||
v, r, s = ResponseParser.signature(app_client.response().data)
|
||||
vrs = ResponseParser.signature(app_client.response().data)
|
||||
recovered_addr = recover_message(data, vrs)
|
||||
|
||||
assert v == bytes.fromhex("1c")
|
||||
assert r == bytes.fromhex("ea66f747173762715751c889fea8722acac3fc35db2c226d37a2e58815398f64")
|
||||
assert s == bytes.fromhex("52d8ba9153de9255da220ffd36762c0b027701a3b5110f0a765f94b16a9dfb55")
|
||||
assert recovered_addr == get_wallet_addr(app_client)
|
||||
|
||||
|
||||
def autonext(firmware: Firmware, navigator: Navigator, default_screenshot_path: Path):
|
||||
@@ -94,18 +106,18 @@ def autonext(firmware: Firmware, navigator: Navigator, default_screenshot_path:
|
||||
moves = [NavInsID.RIGHT_CLICK]
|
||||
else:
|
||||
moves = [NavInsID.USE_CASE_REVIEW_TAP]
|
||||
if snaps_config is not None:
|
||||
if SNAPS_CONFIG is not None:
|
||||
navigator.navigate_and_compare(default_screenshot_path,
|
||||
snaps_config.test_name,
|
||||
SNAPS_CONFIG.test_name,
|
||||
moves,
|
||||
screen_change_before_first_instruction=False,
|
||||
screen_change_after_last_instruction=False,
|
||||
snap_start_idx=snaps_config.idx)
|
||||
snaps_config.idx += 1
|
||||
snap_start_idx=SNAPS_CONFIG.idx)
|
||||
SNAPS_CONFIG.idx += 1
|
||||
else:
|
||||
navigator.navigate(moves,
|
||||
screen_change_before_first_instruction=False,
|
||||
screen_change_after_last_instruction=False)
|
||||
screen_change_before_first_instruction=False,
|
||||
screen_change_after_last_instruction=False)
|
||||
|
||||
|
||||
def eip712_new_common(firmware: Firmware,
|
||||
@@ -132,12 +144,12 @@ def eip712_new_common(firmware: Firmware,
|
||||
if not verbose and filters is None:
|
||||
moves += [NavInsID.USE_CASE_REVIEW_TAP]
|
||||
moves += [NavInsID.USE_CASE_REVIEW_CONFIRM]
|
||||
if snaps_config is not None:
|
||||
if SNAPS_CONFIG is not None:
|
||||
navigator.navigate_and_compare(default_screenshot_path,
|
||||
snaps_config.test_name,
|
||||
moves,
|
||||
snap_start_idx=snaps_config.idx)
|
||||
snaps_config.idx += 1
|
||||
SNAPS_CONFIG.test_name,
|
||||
moves,
|
||||
snap_start_idx=SNAPS_CONFIG.idx)
|
||||
SNAPS_CONFIG.idx += 1
|
||||
else:
|
||||
navigator.navigate(moves)
|
||||
return ResponseParser.signature(app_client.response().data)
|
||||
@@ -155,7 +167,6 @@ def test_eip712_new(firmware: Firmware,
|
||||
pytest.skip("Not supported on LNS")
|
||||
|
||||
test_path = f"{input_file.parent}/{'-'.join(input_file.stem.split('-')[:-1])}"
|
||||
conf_file = f"{test_path}.ini"
|
||||
|
||||
filters = None
|
||||
if filtering:
|
||||
@@ -166,51 +177,39 @@ def test_eip712_new(firmware: Firmware,
|
||||
except (IOError, json.decoder.JSONDecodeError) as e:
|
||||
pytest.skip(f"{filterfile.name}: {e.strerror}")
|
||||
|
||||
config = ConfigParser()
|
||||
config.read(conf_file)
|
||||
|
||||
# sanity check
|
||||
assert "signature" in config.sections()
|
||||
assert "v" in config["signature"]
|
||||
assert "r" in config["signature"]
|
||||
assert "s" in config["signature"]
|
||||
|
||||
if verbose:
|
||||
settings_toggle(firmware, navigator, [SettingID.VERBOSE_EIP712])
|
||||
|
||||
with open(input_file, encoding="utf-8") as file:
|
||||
v, r, s = eip712_new_common(firmware,
|
||||
navigator,
|
||||
default_screenshot_path,
|
||||
app_client,
|
||||
json.load(file),
|
||||
filters,
|
||||
verbose)
|
||||
data = json.load(file)
|
||||
vrs = eip712_new_common(firmware,
|
||||
navigator,
|
||||
default_screenshot_path,
|
||||
app_client,
|
||||
data,
|
||||
filters,
|
||||
verbose)
|
||||
|
||||
assert v == bytes.fromhex(config["signature"]["v"])
|
||||
assert r == bytes.fromhex(config["signature"]["r"])
|
||||
assert s == bytes.fromhex(config["signature"]["s"])
|
||||
recovered_addr = recover_message(data, vrs)
|
||||
|
||||
assert recovered_addr == get_wallet_addr(app_client)
|
||||
|
||||
|
||||
def test_eip712_address_substitution(firmware: Firmware,
|
||||
backend: BackendInterface,
|
||||
navigator: Navigator,
|
||||
default_screenshot_path: Path,
|
||||
test_name: str,
|
||||
verbose: bool):
|
||||
global snaps_config
|
||||
global SNAPS_CONFIG
|
||||
|
||||
app_client = EthAppClient(backend)
|
||||
if firmware.device == "nanos":
|
||||
pytest.skip("Not supported on LNS")
|
||||
|
||||
with app_client.get_public_addr(display=False):
|
||||
pass
|
||||
_, DEVICE_ADDR, _ = ResponseParser.pk_addr(app_client.response().data)
|
||||
|
||||
test_name = "eip712_address_substitution"
|
||||
if verbose:
|
||||
test_name += "_verbose"
|
||||
snaps_config = SnapshotsConfig(test_name)
|
||||
SNAPS_CONFIG = SnapshotsConfig(test_name)
|
||||
with open(f"{eip712_json_path()}/address_substitution.json", encoding="utf-8") as file:
|
||||
data = json.load(file)
|
||||
|
||||
@@ -247,4 +246,4 @@ def test_eip712_address_substitution(firmware: Firmware,
|
||||
|
||||
# verify signature
|
||||
addr = recover_message(data, vrs)
|
||||
assert addr == DEVICE_ADDR
|
||||
assert addr == get_wallet_addr(app_client)
|
||||
|
||||