From 9a5c38dad4d71648aad12e2278dc04f6c7593e1e Mon Sep 17 00:00:00 2001 From: hackyminer Date: Tue, 14 Aug 2018 23:35:02 +0900 Subject: [PATCH] src/apps/ethereum: support full 32bit chain_id * remove chain_id restriction to support full 32bit chain_id. * for chain_id > MAX_CHAIN_ID(2147483630) case, simply return v signature parity. * see also https://github.com/trezor/trezor-mcu/pull/399 --- src/apps/ethereum/sign_tx.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/apps/ethereum/sign_tx.py b/src/apps/ethereum/sign_tx.py index 9f1cf15c7b..251fc8ad39 100644 --- a/src/apps/ethereum/sign_tx.py +++ b/src/apps/ethereum/sign_tx.py @@ -138,7 +138,9 @@ async def send_signature(ctx, msg: EthereumSignTx, digest): req = EthereumTxRequest() req.signature_v = signature[0] - if msg.chain_id: + if msg.chain_id > MAX_CHAIN_ID: + req.signature_v -= 27 + elif msg.chain_id: req.signature_v += 2 * msg.chain_id + 8 req.signature_r = signature[1:33] @@ -151,7 +153,7 @@ def check(msg: EthereumSignTx): if msg.tx_type not in [1, 6, None]: raise wire.DataError("tx_type out of bounds") - if msg.chain_id < 0 or msg.chain_id > MAX_CHAIN_ID: + if msg.chain_id < 0: raise wire.DataError("chain_id out of bounds") if msg.data_length > 0: