diff --git a/client/src/ledger_app_clients/ethereum/client.py b/client/src/ledger_app_clients/ethereum/client.py index 3f95c82c24..9b6a4de89e 100644 --- a/client/src/ledger_app_clients/ethereum/client.py +++ b/client/src/ledger_app_clients/ethereum/client.py @@ -189,6 +189,18 @@ def eip712_filtering_amount_join_value(self, token_idx: int, name: str, sig: byt def eip712_filtering_datetime(self, name: str, sig: bytes, discarded: bool): return self._exchange_async(self._cmd_builder.eip712_filtering_datetime(name, sig, discarded)) + def eip712_filtering_trusted_name(self, + name: str, + name_type: list[int], + name_source: list[int], + sig: bytes, + discarded: bool): + return self._exchange_async(self._cmd_builder.eip712_filtering_trusted_name(name, + name_type, + name_source, + sig, + discarded)) + def eip712_filtering_raw(self, name: str, sig: bytes, discarded: bool): return self._exchange_async(self._cmd_builder.eip712_filtering_raw(name, sig, discarded)) diff --git a/client/src/ledger_app_clients/ethereum/command_builder.py b/client/src/ledger_app_clients/ethereum/command_builder.py index 67399448ab..d5fbe3124d 100644 --- a/client/src/ledger_app_clients/ethereum/command_builder.py +++ b/client/src/ledger_app_clients/ethereum/command_builder.py @@ -43,6 +43,7 @@ class P2Type(IntEnum): FILTERING_ACTIVATE = 0x00 FILTERING_DISCARDED_PATH = 0x01 FILTERING_MESSAGE_INFO = 0x0f + FILTERING_TRUSTED_NAME = 0xfb FILTERING_DATETIME = 0xfc FILTERING_TOKEN_ADDR_CHECK = 0xfd FILTERING_AMOUNT_FIELD = 0xfe @@ -214,6 +215,28 @@ def eip712_filtering_datetime(self, name: str, sig: bytes, discarded: bool) -> b P2Type.FILTERING_DATETIME, self._eip712_filtering_send_name(name, sig)) + def eip712_filtering_trusted_name(self, + name: str, + name_type: int, + name_source: int, + sig: bytes, + discarded: bool) -> bytes: + data = bytearray() + data.append(len(name)) + data += name.encode() + data.append(len(name_type)) + for t in name_type: + data.append(t) + data.append(len(name_source)) + for s in name_source: + data.append(s) + data.append(len(sig)) + data += sig + return self._serialize(InsType.EIP712_SEND_FILTERING, + int(discarded), + P2Type.FILTERING_TRUSTED_NAME, + data) + def eip712_filtering_raw(self, name: str, sig: bytes, discarded: bool) -> bytes: return self._serialize(InsType.EIP712_SEND_FILTERING, int(discarded), diff --git a/client/src/ledger_app_clients/ethereum/eip712/InputData.py b/client/src/ledger_app_clients/ethereum/eip712/InputData.py index 43f88f3af4..45f8b6fb3c 100644 --- a/client/src/ledger_app_clients/ethereum/eip712/InputData.py +++ b/client/src/ledger_app_clients/ethereum/eip712/InputData.py @@ -227,6 +227,12 @@ def send_filter(path: str, discarded: bool): discarded) elif filtering_paths[path]["type"] == "datetime": send_filtering_datetime(path, filtering_paths[path]["name"], discarded) + elif filtering_paths[path]["type"] == "trusted_name": + send_filtering_trusted_name(path, + filtering_paths[path]["name"], + filtering_paths[path]["tn_type"], + filtering_paths[path]["tn_source"], + discarded) elif filtering_paths[path]["type"] == "raw": send_filtering_raw(path, filtering_paths[path]["name"], discarded) else: @@ -358,6 +364,21 @@ def send_filtering_datetime(path: str, display_name: str, discarded: bool): pass +def send_filtering_trusted_name(path: str, display_name: str, name_type: list[int], name_source: list[int], discarded: bool): + global sig_ctx + + to_sign = start_signature_payload(sig_ctx, 44) + to_sign += path.encode() + to_sign += display_name.encode() + for t in name_type: + to_sign.append(t) + for s in name_source: + to_sign.append(s) + sig = keychain.sign_data(keychain.Key.CAL, to_sign) + with app_client.eip712_filtering_trusted_name(display_name, name_type, name_source, sig, discarded): + pass + + # ledgerjs doesn't actually sign anything, and instead uses already pre-computed signatures def send_filtering_raw(path: str, display_name: str, discarded: bool): global sig_ctx