From 3067339b41486ffa5aef3eda43c8d67ff9ab5371 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Thu, 19 Jul 2018 18:05:26 +0200 Subject: [PATCH] src: fix ethereum sign for chain_id >= 0x100 --- src/apps/ethereum/sign_tx.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/apps/ethereum/sign_tx.py b/src/apps/ethereum/sign_tx.py index 283baaa7b1..6a5b59c0eb 100644 --- a/src/apps/ethereum/sign_tx.py +++ b/src/apps/ethereum/sign_tx.py @@ -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)