Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/src/ledger_app_clients/ethereum/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def send_raw(self, cla: int, ins: int, p1: int, p2: int, payload: bytes):
header.append(p1)
header.append(p2)
header.append(len(payload))
return self._exchange(header + payload)
return self._exchange(bytes(header + payload))

def send_raw_async(self, cla: int, ins: int, p1: int, p2: int, payload: bytes):
header = bytearray()
Expand All @@ -79,7 +79,7 @@ def send_raw_async(self, cla: int, ins: int, p1: int, p2: int, payload: bytes):
header.append(p1)
header.append(p2)
header.append(len(payload))
return self._exchange_async(header + payload)
return self._exchange_async(bytes(header + payload))

def get_app_configuration(self):
return self._exchange(self._cmd_builder.get_app_configuration())
Expand Down
10 changes: 5 additions & 5 deletions client/src/ledger_app_clients/ethereum/command_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import struct
import math
from enum import IntEnum
from typing import Optional
from typing import Optional, Union
from ragger.bip import pack_derivation_path

from .eip712.struct import EIP712FieldType, EIP712TypeDescOffset
Expand Down Expand Up @@ -89,15 +89,15 @@ def _serialize(self,
ins: InsType,
p1: int,
p2: int,
cdata: bytes = bytes()) -> bytes:
cdata: Union[bytes, bytearray] = bytes()) -> bytes:

header = bytearray()
header.append(self._CLA)
header.append(ins)
header.append(p1)
header.append(p2)
header.append(len(cdata))
return header + cdata
return bytes(header + cdata)

def eip712_send_struct_def_struct_name(self, name: str) -> bytes:
return self._serialize(InsType.EIP712_SEND_STRUCT_DEF,
Expand Down Expand Up @@ -200,7 +200,7 @@ def _eip712_filtering_send_name(self, name: str, sig: bytes) -> bytes:
data += name.encode()
data.append(len(sig))
data += sig
return data
return bytes(data)

def eip712_filtering_discarded_path(self, path: str) -> bytes:
data = bytearray()
Expand Down Expand Up @@ -401,7 +401,7 @@ def sign(self,
apdus: list[bytes] = []
payload = bytearray()
if bip32_path is not None:
payload = pack_derivation_path(bip32_path)
payload = bytearray(pack_derivation_path(bip32_path))
if rlp_data is not None:
payload += rlp_data
p1 = P1Type.SIGN_FIRST_CHUNK
Expand Down
26 changes: 13 additions & 13 deletions client/src/ledger_app_clients/ethereum/eip712/InputData.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def send_filtering_message_info(display_name: str, filters_count: int):
to_sign.append(filters_count)
to_sign += display_name.encode()

sig = CAL_COIN_META_PARTNER.sign(to_sign)
sig = CAL_COIN_META_PARTNER.sign(bytes(to_sign))
with app_client.eip712_filtering_message_info(display_name, filters_count, sig):
pass
response = app_client.response()
Expand All @@ -368,7 +368,7 @@ def send_filtering_amount_join_token(path: str, join_id: int, discarded: bool):
to_sign = start_signature_payload(sig_ctx, 11)
to_sign += path.encode()
to_sign.append(join_id)
sig = CAL_COIN_META_PARTNER.sign(to_sign)
sig = CAL_COIN_META_PARTNER.sign(bytes(to_sign))
with app_client.eip712_filtering_amount_join_token(join_id, sig, discarded):
pass
response = app_client.response()
Expand All @@ -382,7 +382,7 @@ def send_filtering_amount_join_value(path: str, join_id: int, display_name: str,
to_sign += path.encode()
to_sign += display_name.encode()
to_sign.append(join_id)
sig = CAL_COIN_META_PARTNER.sign(to_sign)
sig = CAL_COIN_META_PARTNER.sign(bytes(to_sign))
with app_client.eip712_filtering_amount_join_value(join_id, display_name, sig, discarded):
pass
response = app_client.response()
Expand All @@ -395,7 +395,7 @@ def send_filtering_datetime(path: str, display_name: str, discarded: bool):
to_sign = start_signature_payload(sig_ctx, 33)
to_sign += path.encode()
to_sign += display_name.encode()
sig = CAL_COIN_META_PARTNER.sign(to_sign)
sig = CAL_COIN_META_PARTNER.sign(bytes(to_sign))
with app_client.eip712_filtering_datetime(display_name, sig, discarded):
pass
response = app_client.response()
Expand All @@ -416,7 +416,7 @@ def send_filtering_trusted_name(path: str,
to_sign.append(t)
for s in name_source:
to_sign.append(s)
sig = CAL_COIN_META_PARTNER.sign(to_sign)
sig = CAL_COIN_META_PARTNER.sign(bytes(to_sign))
with app_client.eip712_filtering_trusted_name(display_name, name_type, name_source, sig, discarded):
pass
response = app_client.response()
Expand All @@ -440,7 +440,7 @@ def send_filtering_calldata_info(index: int,
to_sign.append(selector_filter_flag)
to_sign.append(amount_filter_flag)
to_sign.append(int(spender_filter_flag))
sig = CAL_COIN_META_PARTNER.sign(to_sign)
sig = CAL_COIN_META_PARTNER.sign(bytes(to_sign))
response = app_client.eip712_filtering_calldata_info(index,
value_filter_flag,
callee_filter_flag,
Expand All @@ -457,7 +457,7 @@ def send_filtering_calldata_value(path: str, index: int, discarded: bool):
to_sign = start_signature_payload(sig_ctx, 66)
to_sign += path.encode()
to_sign.append(index)
sig = CAL_COIN_META_PARTNER.sign(to_sign)
sig = CAL_COIN_META_PARTNER.sign(bytes(to_sign))
response = app_client.eip712_filtering_calldata_value(index, sig, discarded)
assert response.status == StatusWord.SWO_SUCCESS, \
f"Error sending filtering calldata value for {path}: {response.status}"
Expand All @@ -467,7 +467,7 @@ def send_filtering_calldata_callee(path: str, index: int, discarded: bool):
to_sign = start_signature_payload(sig_ctx, 77)
to_sign += path.encode()
to_sign.append(index)
sig = CAL_COIN_META_PARTNER.sign(to_sign)
sig = CAL_COIN_META_PARTNER.sign(bytes(to_sign))
response = app_client.eip712_filtering_calldata_callee(index, sig, discarded)
assert response.status == StatusWord.SWO_SUCCESS, \
f"Error sending filtering calldata callee for {path}: {response.status}"
Expand All @@ -477,7 +477,7 @@ def send_filtering_calldata_chain_id(path: str, index: int, discarded: bool):
to_sign = start_signature_payload(sig_ctx, 88)
to_sign += path.encode()
to_sign.append(index)
sig = CAL_COIN_META_PARTNER.sign(to_sign)
sig = CAL_COIN_META_PARTNER.sign(bytes(to_sign))
response = app_client.eip712_filtering_calldata_chain_id(index, sig, discarded)
assert response.status == StatusWord.SWO_SUCCESS, \
f"Error sending filtering calldata callee for {path}: {response.status}"
Expand All @@ -487,7 +487,7 @@ def send_filtering_calldata_selector(path: str, index: int, discarded: bool):
to_sign = start_signature_payload(sig_ctx, 99)
to_sign += path.encode()
to_sign.append(index)
sig = CAL_COIN_META_PARTNER.sign(to_sign)
sig = CAL_COIN_META_PARTNER.sign(bytes(to_sign))
response = app_client.eip712_filtering_calldata_selector(index, sig, discarded)
assert response.status == StatusWord.SWO_SUCCESS, \
f"Error sending filtering calldata callee for {path}: {response.status}"
Expand All @@ -497,7 +497,7 @@ def send_filtering_calldata_amount(path: str, index: int, discarded: bool):
to_sign = start_signature_payload(sig_ctx, 110)
to_sign += path.encode()
to_sign.append(index)
sig = CAL_COIN_META_PARTNER.sign(to_sign)
sig = CAL_COIN_META_PARTNER.sign(bytes(to_sign))
response = app_client.eip712_filtering_calldata_amount(index, sig, discarded)
assert response.status == StatusWord.SWO_SUCCESS, \
f"Error sending filtering calldata callee for {path}: {response.status}"
Expand All @@ -507,7 +507,7 @@ def send_filtering_calldata_spender(path: str, index: int, discarded: bool):
to_sign = start_signature_payload(sig_ctx, 121)
to_sign += path.encode()
to_sign.append(index)
sig = CAL_COIN_META_PARTNER.sign(to_sign)
sig = CAL_COIN_META_PARTNER.sign(bytes(to_sign))
response = app_client.eip712_filtering_calldata_spender(index, sig, discarded)
assert response.status == StatusWord.SWO_SUCCESS, \
f"Error sending filtering calldata callee for {path}: {response.status}"
Expand All @@ -518,7 +518,7 @@ def send_filtering_raw(path: str, display_name: str, discarded: bool):
to_sign = start_signature_payload(sig_ctx, 72)
to_sign += path.encode()
to_sign += display_name.encode()
sig = CAL_COIN_META_PARTNER.sign(to_sign)
sig = CAL_COIN_META_PARTNER.sign(bytes(to_sign))
with app_client.eip712_filtering_raw(display_name, sig, discarded):
pass
response = app_client.response()
Expand Down
4 changes: 2 additions & 2 deletions client/src/ledger_app_clients/ethereum/enum_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ def serialize(self) -> bytes:
payload += self.serialize_field(Tag.NAME, self.name)
sig = self.signature
if sig is None:
sig = CALLDATA_PARTNER.sign(payload)
sig = CALLDATA_PARTNER.sign(bytes(payload))
payload += self.serialize_field(Tag.SIGNATURE, sig)
return payload
return bytes(payload)
42 changes: 21 additions & 21 deletions client/src/ledger_app_clients/ethereum/gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ def serialize(self) -> bytes:
payload += self.serialize_field(TxInfoTag.DEPLOY_DATE, self.deploy_date)
signature = self.signature
if signature is None:
signature = CALLDATA_PARTNER.sign(payload)
signature = CALLDATA_PARTNER.sign(bytes(payload))
payload += self.serialize_field(TxInfoTag.SIGNATURE, signature)
return payload
return bytes(payload)


class ParamType(IntEnum):
Expand Down Expand Up @@ -144,7 +144,7 @@ def serialize(self) -> bytes:
payload += self.serialize_field(0x02, struct.pack(">h", self.start))
if self.end is not None:
payload += self.serialize_field(0x03, struct.pack(">h", self.end))
return payload
return bytes(payload)


class PathRef(TlvSerializable):
Expand Down Expand Up @@ -186,7 +186,7 @@ def serialize(self) -> bytes:
payload += self.serialize_field(0x01, struct.pack(">h", self.start))
if self.end is not None:
payload += self.serialize_field(0x02, struct.pack(">h", self.end))
return payload
return bytes(payload)


class DataPath(TlvSerializable):
Expand Down Expand Up @@ -214,7 +214,7 @@ def serialize(self) -> bytes:
else:
assert False, f"Unknown path node type : {type(node)}"
payload += self.serialize_field(tag, node.serialize())
return payload
return bytes(payload)


class ContainerPath(IntEnum):
Expand All @@ -239,7 +239,7 @@ def serialize(self) -> bytes:
payload += self.serialize_field(0x00, self.version)
payload += self.serialize_field(0x01, self.id)
payload += self.serialize_field(0x02, self.key.serialize())
return payload
return bytes(payload)


class Value(TlvSerializable):
Expand Down Expand Up @@ -281,7 +281,7 @@ def serialize(self) -> bytes:
payload += self.serialize_field(0x05, self.constant)
if self.map_ref is not None:
payload += self.serialize_field(0x06, self.map_ref.serialize())
return payload
return bytes(payload)


class FieldParam(TlvSerializable):
Expand All @@ -301,7 +301,7 @@ def serialize(self) -> bytes:
payload = bytearray()
payload += self.serialize_field(0x00, self.version)
payload += self.serialize_field(0x01, self.value.serialize())
return payload
return bytes(payload)


class ParamAmount(FieldParam):
Expand All @@ -317,7 +317,7 @@ def serialize(self) -> bytes:
payload = bytearray()
payload += self.serialize_field(0x00, self.version)
payload += self.serialize_field(0x01, self.value.serialize())
return payload
return bytes(payload)


class ParamTokenAmount(FieldParam):
Expand Down Expand Up @@ -356,7 +356,7 @@ def serialize(self) -> bytes:
payload += self.serialize_field(0x04, self.threshold)
if self.above_threshold_msg is not None:
payload += self.serialize_field(0x05, self.above_threshold_msg)
return payload
return bytes(payload)


class ParamNFT(FieldParam):
Expand All @@ -375,7 +375,7 @@ def serialize(self) -> bytes:
payload += self.serialize_field(0x00, self.version)
payload += self.serialize_field(0x01, self.id.serialize())
payload += self.serialize_field(0x02, self.collection.serialize())
return payload
return bytes(payload)


class DatetimeType(IntEnum):
Expand All @@ -399,7 +399,7 @@ def serialize(self) -> bytes:
payload += self.serialize_field(0x00, self.version)
payload += self.serialize_field(0x01, self.value.serialize())
payload += self.serialize_field(0x02, self.dt_type)
return payload
return bytes(payload)


class ParamDuration(FieldParam):
Expand All @@ -415,7 +415,7 @@ def serialize(self) -> bytes:
payload = bytearray()
payload += self.serialize_field(0x00, self.version)
payload += self.serialize_field(0x01, self.value.serialize())
return payload
return bytes(payload)


class ParamUnit(FieldParam):
Expand Down Expand Up @@ -447,7 +447,7 @@ def serialize(self) -> bytes:
payload += self.serialize_field(0x03, self.decimals)
if self.prefix is not None:
payload += self.serialize_field(0x04, self.prefix)
return payload
return bytes(payload)


class TrustedNameValueType(IntEnum):
Expand Down Expand Up @@ -495,7 +495,7 @@ def serialize(self) -> bytes:
payload += self.serialize_field(0x04, addr)
if self.value_type is not None:
payload += self.serialize_field(0x05, self.value_type)
return payload
return bytes(payload)


class ParamEnum(FieldParam):
Expand All @@ -514,7 +514,7 @@ def serialize(self) -> bytes:
payload += self.serialize_field(0x00, self.version)
payload += self.serialize_field(0x01, self.id)
payload += self.serialize_field(0x02, self.value.serialize())
return payload
return bytes(payload)


class ParamCalldata(FieldParam):
Expand Down Expand Up @@ -556,7 +556,7 @@ def serialize(self) -> bytes:
payload += self.serialize_field(0x05, self.amount.serialize())
if self.spender is not None:
payload += self.serialize_field(0x06, self.spender.serialize())
return payload
return bytes(payload)


class ParamToken(FieldParam):
Expand All @@ -577,7 +577,7 @@ def serialize(self) -> bytes:
if self.native_currency is not None:
for nat_cur in self.native_currency:
payload += self.serialize_field(0x02, nat_cur)
return payload
return bytes(payload)


class ParamNetwork(FieldParam):
Expand All @@ -593,7 +593,7 @@ def serialize(self) -> bytes:
payload = bytearray()
payload += self.serialize_field(0x00, self.version)
payload += self.serialize_field(0x01, self.value.serialize())
return payload
return bytes(payload)


class FieldTag(IntEnum):
Expand Down Expand Up @@ -652,7 +652,7 @@ def serialize(self) -> bytes:
payload += self.serialize_field(FieldTag.CONSTRAINT, constraint)
if self.separator is not None:
payload += self.serialize_field(FieldTag.SEPARATOR, self.separator)
return payload
return bytes(payload)


class ParamGroup(FieldParam):
Expand All @@ -676,4 +676,4 @@ def serialize(self) -> bytes:
payload += self.serialize_field(0x01, self.iteration_type)
for field in self.fields:
payload += self.serialize_field(0x02, field.serialize())
return payload
return bytes(payload)
4 changes: 2 additions & 2 deletions client/src/ledger_app_clients/ethereum/map_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ def serialize(self) -> bytes:
payload += self.serialize_field(Tag.VALUE, self.value)
sig = self.signature
if sig is None:
sig = CALLDATA_PARTNER.sign(payload)
sig = CALLDATA_PARTNER.sign(bytes(payload))
payload += self.serialize_field(Tag.SIGNATURE, sig)
return payload
return bytes(payload)
4 changes: 2 additions & 2 deletions client/src/ledger_app_clients/ethereum/proxy_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ def serialize(self) -> bytes:
payload += self.serialize_field(Tag.DELEGATION_TYPE, self.delegation_type)
sig = self.signature
if sig is None:
sig = TRUSTED_NAME_PARTNER.sign(payload)
sig = TRUSTED_NAME_PARTNER.sign(bytes(payload))
payload += self.serialize_field(Tag.SIGNATURE, sig)
return payload
return bytes(payload)
2 changes: 1 addition & 1 deletion client/src/ledger_app_clients/ethereum/tlv.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def serialize_field(tag: int, value: Union[int, str, bytes, bytearray]) -> bytes
tlv += TlvSerializable.der_encode(tag)
tlv += TlvSerializable.der_encode(len(value))
tlv += value
return tlv
return bytes(tlv)


def format_tlv(tag: int, value: Union[int, str, bytes, bytearray]) -> bytes:
Expand Down
Loading
Loading