From b938c52e85348d9ee9f078ef194bf92b2de697eb Mon Sep 17 00:00:00 2001 From: HackyMiner Date: Wed, 15 Aug 2018 18:31:30 +0900 Subject: [PATCH] add more eip155 test cases (#297) --- trezorlib/client.py | 5 +++ .../test_msg_ethereum_signtx_eip155.py | 40 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/trezorlib/client.py b/trezorlib/client.py index e8cc4d67a0..d7fdaae064 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -523,6 +523,11 @@ class ProtocolMixin(object): data, chunk = data[data_length:], data[:data_length] response = self.call(proto.EthereumTxAck(data_chunk=chunk)) + # https://github.com/trezor/trezor-mcu/pull/399 + # only signature bit returned. recalculate signature_v + if response.signature_v <= 1: + response.signature_v += 2 * chain_id + 35 + return response.signature_v, response.signature_r, response.signature_s @expect(proto.EthereumMessageSignature) diff --git a/trezorlib/tests/device_tests/test_msg_ethereum_signtx_eip155.py b/trezorlib/tests/device_tests/test_msg_ethereum_signtx_eip155.py index d34bd82ad3..9e156a4be5 100644 --- a/trezorlib/tests/device_tests/test_msg_ethereum_signtx_eip155.py +++ b/trezorlib/tests/device_tests/test_msg_ethereum_signtx_eip155.py @@ -157,6 +157,46 @@ class TestMsgEthereumSigntxChainId(TrezorTest): 21004, b"\0", ), + ( + 2147483630, + 1, + 4294967295, + b"fd0377ff429a51ae284c4b09b7d7c26c78944c86bb311b5988d70be4fc59eeba", + b"2ad183858ac6b1efa820b9ee2c2dbf6659a73cc5b714d32c380b263d024f2ee9", + 0, + 21004, + None, + ), + ( + 2147483631, + 1, + 4294967298, + b"a4e89720285b179f679ecec1c79e4948b18ee4cf08f76b11d701cbead5e81a70", + b"094b32d3e53833c8085dadfe169782db4d32856d7b556f832f64dfdcfa1dd3b8", + 100000000000000000, + 21000, + None, + ), + ( + 3125659152, + 1, + 6251318340, + b"a39e51d16cb10c81a9c1d9b071b714c4ecf112702407f1cc7aae35c85eced3d3", + b"0b0654665e4677c77510fc2a43026ee66c13261d3d893895bc49e6f4eaa5c8bd", + 1, + 21005, + None, + ), + ( + 4294967295, + 1, + 8589934625, + b"3367230b5f506426f075f3137f4fd6a5fc4198326dd4936bbc38bf0c5ff43a5e", + b"6e48c3c95b3a534f7853a3b5dd72cdeffe9b7e93503eb7a793c9d5fdc14c4e99", + 100000000000000000, + 21000, + None, + ), ] self.setup_mnemonic_allallall()