-
-
Notifications
You must be signed in to change notification settings - Fork 257
support full 32bit chain_id, cast (uint64_t)v #386
Conversation
(trezor testsuite, chainId support added, recalc |
Sorry, I am against this change. I think that 2 billions chain_ids are enough for everyone and using higher values than 2147483630 might break lots of other software. |
It is more resonable for Trezor to support full range 32-bit chainId rather than the etheruem EIP155 specific encoding. so it should be considered as a bug I think. |
That's unfortunate, but I am not fixing this. |
just to be clear, current status of official firmware.
how about to fix method 1diff --git a/firmware/ethereum.c b/firmware/ethereum.c
index a5cf7a3..a3c1689 100644
--- a/firmware/ethereum.c
+++ b/firmware/ethereum.c
@@ -203,7 +203,11 @@ static void send_signature(void)
msg_tx_request.has_signature_v = true;
if (chain_id) {
- msg_tx_request.signature_v = v + 2 * chain_id + 35;
+ if (chain_id > 255) {
+ msg_tx_request.signature_v = v;
+ } else {
+ msg_tx_request.signature_v = v + 2 * chain_id + 35;
+ }
} else {
msg_tx_request.signature_v = v + 27;
}
method 2or simply just return the signature bit --- a/firmware/ethereum.c
+++ b/firmware/ethereum.c
@@ -203,7 +203,7 @@ static void send_signature(void)
msg_tx_request.has_signature_v = true;
if (chain_id) {
- msg_tx_request.signature_v = v + 2 * chain_id + 35;
+ msg_tx_request.signature_v = v;
} else {
msg_tx_request.signature_v = v + 27;
}
or even shortly --- a/firmware/ethereum.c
+++ b/firmware/ethereum.c
@@ -203,7 +203,xx @@ static void send_signature(void)
msg_tx_request.has_signature_v = true;
- if (chain_id) {
- msg_tx_request.signature_v = v + 2 * chain_id + 35;
+ msg_tx_request.signature_v = v;
- } else {
- msg_tx_request.signature_v = v + 27;
- }
|
Or even shorter - no firmware change, use |
@prusnak // I guess you miss understood me. EthersocialNetwork#2 this is my new PR based on the 1st method. |
See also Ledger case LedgerHQ/ledgerjs#168 |
Another reason why not use chain_id wider than 32 bits, so this proves my point |
finally Ledger support full ranged 32bits chain_id. Ledger even returns only
for example, MyEtherWallet/etherwallet#1979 |
with the following PR trezor/trezor-common#174 (64bitsignature_v
)r,s
value can be calculated successfully.I'm not sure whyv
value is truncated to 32bit. but anyway,with this fix,
r
,s
values are correctly obtained for full ranged 32bits chain_id.for some larger chain_id, signature
v
value is truncated to 32bits, but anyway,simply recalculate
v
value at the client side javascript level, signing could be done successfully with full ranged 32bits chain_id.