Skip to content

Commit 1990f9f

Browse files
Now supports shrunk TLV data for EIP-7702
1 parent 2bd7d59 commit 1990f9f

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

client/src/ledger_app_clients/ethereum/tx_auth_7702.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ def __init__(self,
2929
def serialize(self) -> bytes:
3030
payload: bytes = self.serialize_field(FieldTag.STRUCT_VERSION, 1)
3131
payload += self.serialize_field(FieldTag.DELEGATE_ADDR, self.delegate)
32-
payload += self.serialize_field(FieldTag.NONCE, self.nonce.to_bytes(8, 'big'))
33-
payload += self.serialize_field(FieldTag.CHAIN_ID, self.chain_id.to_bytes(8, 'big'))
32+
payload += self.serialize_field(FieldTag.CHAIN_ID, self.chain_id)
33+
payload += self.serialize_field(FieldTag.NONCE, self.nonce)
3434
return payload

src_features/signAuthorizationEIP7702/auth_7702.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,37 @@ static bool handle_version(const s_tlv_data *data, s_auth_7702_ctx *context) {
3131
}
3232

3333
static bool handle_delegate_addr(const s_tlv_data *data, s_auth_7702_ctx *context) {
34-
if (data->length != sizeof(context->auth_7702.delegate)) {
34+
uint8_t buf[sizeof(context->auth_7702.delegate)];
35+
36+
if (data->length > sizeof(buf)) {
3537
return false;
3638
}
37-
memmove(context->auth_7702.delegate, data->value, sizeof(context->auth_7702.delegate));
39+
buf_shrink_expand(data->value, data->length, buf, sizeof(buf));
40+
memmove(context->auth_7702.delegate, buf, sizeof(buf));
3841
context->mask_parsed |= SET_BIT(BIT_DELEGATE_ADDR);
3942
return true;
4043
}
4144

4245
static bool handle_chain_id(const s_tlv_data *data, s_auth_7702_ctx *context) {
43-
if (data->length != sizeof(uint64_t)) {
46+
uint8_t buf[sizeof(context->auth_7702.chainId)];
47+
48+
if (data->length > sizeof(buf)) {
4449
return false;
4550
}
46-
context->auth_7702.chainId = read_u64_be(data->value, 0);
51+
buf_shrink_expand(data->value, data->length, buf, sizeof(buf));
52+
context->auth_7702.chainId = read_u64_be(buf, 0);
4753
context->mask_parsed |= SET_BIT(BIT_CHAIN_ID);
4854
return true;
4955
}
5056

5157
static bool handle_nonce(const s_tlv_data *data, s_auth_7702_ctx *context) {
52-
if (data->length != sizeof(uint64_t)) {
58+
uint8_t buf[sizeof(context->auth_7702.nonce)];
59+
60+
if (data->length > sizeof(buf)) {
5361
return false;
5462
}
55-
context->auth_7702.nonce = read_u64_be(data->value, 0);
63+
buf_shrink_expand(data->value, data->length, buf, sizeof(buf));
64+
context->auth_7702.nonce = read_u64_be(buf, 0);
5665
context->mask_parsed |= SET_BIT(BIT_NONCE);
5766
return true;
5867
}

0 commit comments

Comments
 (0)