1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-16 03:18:09 +00:00

src: fix ethereum sign for chain_id >= 0x100

This commit is contained in:
Pavol Rusnak 2018-07-19 18:05:26 +02:00
parent 20237ace5c
commit 3067339b41
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -98,7 +98,15 @@ def get_total_length(msg: EthereumSignTx, data_total: int) -> int:
length += rlp.field_length(len(field), field[:1])
if msg.chain_id: # forks replay protection
length += rlp.field_length(1, [msg.chain_id])
if msg.chain_id < 0x100:
l = 1
elif msg.chain_id < 0x10000:
l = 2
elif msg.chain_id < 0x1000000:
l = 3
else:
l = 4
length += rlp.field_length(l, [msg.chain_id])
length += rlp.field_length(0, 0)
length += rlp.field_length(0, 0)