Commit graph

85 commits

Author SHA1 Message Date
Daniel Liu
2a96ecf87e
feat(accounts): add support for Ledger Nano Gen5 #33297 (#2042)
adds support for the 0x0008 / 0x8000 product ID (Ledger Apex | Nano
Gen5).

Co-authored-by: mmsqe <tqd0800210105@gmail.com>
2026-02-28 17:00:13 +04:00
wit liu
62272ed4e6
accounts/usbwallet: fix double hashing in SignTextWithPassphrase #33138 (#1852) 2025-12-09 11:27:13 +05:30
wit liu
0fe8742241
accounts/usbwallet: fix version check in SignTypedMessage #33113 (#1767) 2025-11-14 20:06:46 +05:30
wit liu
077c4e6a45
accounts/usbwallet/trezor: fix gengerate files (#1577) 2025-10-08 12:27:34 +08:00
wit liu
d9ae317a38
all: format golang files (#1548)
Co-authored-by: wit <wit765765346@gmail>
2025-09-21 19:41:54 +08:00
Daniel Liu
b0996a2829
accounts/usbwallet: correct version comparison logic #32417 (#1430)
This PR fixes a bug in the Ledger hardware wallet version validation
logic for EIP-155 transaction signing. The original condition
incorrectly allowed older versions that don't support EIP-155 such as
0.9.9 and 0.1.5 to proceed.

Co-authored-by: Rizky Ikwan <rizzikwann@gmail.com>
2025-09-06 17:03:55 +08:00
Daniel Liu
4e3bd78545
accounts/usbwallet: full 32bit chainId support for Trezor #17439 (#1419)
This fix allows Trezor to support full 32bit chainId in geth, with the
next version of firmware.

For `chainId > 2147483630` case, Trezor returns signature bit only.
- Trezor returns only signature parity for `chainId > 2147483630` case.
- for `chainId == 2147483630` case, Trezor returns `MAX_UINT32` or `0`,
but it doesn't matter.
  (`2147483630 * 2 + 35` = `4294967295`(`MAX_UINT32`))

chainId | returned signature_v | compatible issue
---------|------------------------|--------------------
0 < chainId <= 255 | chainId * 2 + 35 + v | no issue (firmware `1.6.2`
for Trezor one)
255 < chainId <= 2147483630 | chainId * 2 + 35 + v | ***fixed.***
*firmware `1.6.3`*
chainId > 2147483630 | v | *firmware `1.6.3`*

Please see also: full 32bit chainId support for Trezor
- Trezor one: https://github.com/trezor/trezor-mcu/pull/399 ***merged***
- Trezor model T: https://github.com/trezor/trezor-core/pull/311
***merged***

---------

Signed-off-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
Co-authored-by: HackyMiner <hackyminer@gmail.com>
Co-authored-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
2025-09-03 15:48:01 +08:00
Daniel Liu
47d17e1b97
accounts/usbwallet: fix ledger access for latest firmware and add Ledger Flex #31004 (#1414)
The latest firmware for Ledger Nano S Plus now returns `0x5000` for it's
product ID, which doesn't match any of the product IDs enumerated in
`hub.go`.

This PR removes the assumption about the interfaces exposed, and simply
checks the upper byte for a match.

Also adds support for the `0x0007` / `0x7000` product ID (Ledger Flex).

Co-authored-by: Michael de Hoog <michael.dehoog@coinbase.com>
2025-09-03 15:45:34 +08:00
Daniel Liu
db3dc1932c accounts/usbwallet: support dynamic tx (#30180)
Adds support non-legacy transaction-signing using ledger

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-01-24 16:54:12 +08:00
Daniel Liu
5beff83a6d all: remove deprecated protobuf dependencies (#30232)
The package `github.com/golang/protobuf/proto` is deprecated in favor
`google.golang.org/protobuf/proto`. We should update the codes to
recommended package.

Signed-off-by: Icarus Wu <icaruswu66@qq.com>
2025-01-24 16:54:12 +08:00
Daniel Liu
1fcc36a2dc build: add check for stale generated files (#30037)
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-01-24 16:54:12 +08:00
Daniel Liu
a0a1322d84 accounts/usbwallet/trezor: upgrade to generate with protoc 27.1 (#30058) 2025-01-24 16:54:12 +08:00
Daniel Liu
13d39173b3 accounts/usbwallet: update hid library (#29176) 2025-01-24 16:54:12 +08:00
Daniel Liu
745c276ed3 fix: update outdated link to trezor docs (#28966)
fix: update link to trezor
2025-01-24 16:54:12 +08:00
Daniel Liu
0a0784d324 acounts/usbwallet: fix typo (#28815)
acounts:fix typo
2025-01-24 16:54:12 +08:00
Daniel Liu
36bf7311cd accounts: properly close managed wallets when closing manager (#28710) 2025-01-24 16:54:12 +08:00
Daniel Liu
3bce105c95 accounts: use atomic type (#27857) 2025-01-24 16:54:12 +08:00
Daniel Liu
ba053a5468 accounts/usbwallet: mitigate ledger app chunking issue (#26773)
This PR mitigates an issue with Ledger's on-device RLP deserialization, see
https://github.com/LedgerHQ/app-ethereum/issues/409

Ledger's RLP deserialization code does not validate the length of the RLP list received,
and it may prematurely enter the signing flow when a APDU chunk boundary falls immediately
before the EIP-155 chain_id when deserializing a transaction. Since the chain_id is
uninitialized, it is 0 during this signing flow. This may cause the user to accidentally
sign the transaction with chain_id = 0. That signature would be returned from the device 1
packet earlier than expected by the communication loop. The device blocks the
second-to-last packet waiting for the signer flow, and then errors on the successive
packet (which contains the chain_id, zeroed r, and zeroed s)

Since the signature's early arrival causes successive errors during the communication
process, geth does not parse the improper signature produced by the device, and therefore
no improperly-signed transaction can be created. User funds are not at risk.

We mitigate by selecting the highest chunk size that leaves at least 4 bytes in the
final chunk.
2025-01-24 16:54:11 +08:00
Daniel Liu
80f3eaac01 accounts/usbwallet: support Ledger Nano S Plus and FTS (#25933)
* usbwallet support Ledger Nano S Plus

* accounts/usbwallet: add definitions + ref to ledger docs

Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-01-24 16:54:11 +08:00
Daniel Liu
e2b5a03ce8 accounts: lint comments (#25726) 2025-01-24 16:54:11 +08:00
Daniel Liu
c046f36afd accounts: fix some typos (#25551) 2025-01-24 16:54:11 +08:00
Daniel Liu
9e82b201c7 accouts/scwallet: typo fix (#24207) 2025-01-24 16:18:30 +08:00
Daniel Liu
345ed3dc36 accounts: eip-712 signing for ledger (#22378)
* accounts: eip-712 signing for ledger

* address review comments
2025-01-24 16:18:30 +08:00
Daniel Liu
3946405983 accounts/usbwallet: fix ledger version check (#21733)
The version check logic did not take into account the second digit (i.e. the '4' in v1.4.0) - this one line patch corrects this.
2025-01-24 16:18:30 +08:00
Daniel Liu
5b48621c36 accouts, core: fix some comments (#21617) 2025-01-24 16:18:30 +08:00
Daniel Liu
321bcff620 accounts/usbwallet, signer/core: show accounts from ledger legacy derivation paths (#21517)
* accounts/usbwallet, signer/core: un-hide accounts from ledger legacy derivation paths

* Update accounts/usbwallet/wallet.go

* Update signer/core/api.go

* Update signer/core/api.go
2025-01-24 16:18:29 +08:00
Daniel Liu
193ee6d606 accounts/usbwallet: fix staticcheck warnings (#20372) 2025-01-24 16:18:29 +08:00
Daniel Liu
f571689bab signer/core: fix reference issue in key derivation (#19827)
* signer/core: fix reference issue in key derivation

* Review feedback
2025-01-24 16:18:29 +08:00
Daniel Liu
e6df5f8798 account/usbwallet: abort usb enumeration after failures (#19671) 2025-01-24 16:18:29 +08:00
Daniel Liu
2e21b96101 accounts/usbwallet: add webusb trezor support (#19588) 2025-01-24 16:18:29 +08:00
Daniel Liu
b2a9e1cb67 accounts/usbwallet: enable the Nano X and upcoming Ledger IDs (#19623) 2025-01-24 16:18:29 +08:00
Daniel Liu
b5ace99624 accounts/usbwallet: fix a comment typo in trezor driver (#19535) 2025-01-24 16:18:29 +08:00
Daniel Liu
194a77505f accounts: switch Ledger derivation path to canonical one (#19438) 2025-01-24 16:18:29 +08:00
Daniel Liu
e7d8247fda usbwallet: check error returned by driver close (#18057)
Although current two implementations(ledgerDriver, trezorDriver) of interface driver.Close do not actually return any error. Instead, they only return nil.
But since the declaration of Close function returns error, it is better to check the returned error in case in future some new implementation of Close function returns error and we may forget to modify the function which invokes Close function at that time.
2025-01-24 16:18:29 +08:00
Daniel Liu
4955476db4 accounts: prefer nil slices over zero-length slices (#19079) 2025-01-24 16:18:29 +08:00
Daniel Liu
43e6c8ecdc accounts: implemented EIP191/712 (#17789) 2025-01-24 16:18:29 +08:00
Daniel Liu
07935ce124 accounts: support for external signer API (#18079) 2025-01-24 16:18:29 +08:00
Daniel Liu
fe14069bd7 accounts: support for external signer API (#18079) 2025-01-24 16:18:29 +08:00
Daniel Liu
f0ed12486a accounts/usbwallet/trezor: expose protobuf package (#17980)
When some of the same messages are redefined anywhere in a Go project,
the protobuf package panics (see
https://github.com/golang/protobuf/issues/178).

Since this package is internal, there is no way to work around it, as
one cannot use it directly, but also cannot define the same messages.

There is no downside in making the package accessible.
2025-01-24 16:18:29 +08:00
Daniel Liu
e3c75c01c7 accounts/usbwallet: support trezor passphrases (#16503)
When opening the wallet, ask for passphrase as well as for the PIN
and return the relevant error (PIN/passphrase required). Open must then
be called again with either PIN or passphrase to advance the process.

This also updates the console bridge to support passphrase authentication.
2025-01-24 16:18:29 +08:00
Daniel Liu
5e6fa602c9 usbwallet: check returned error when decoding hexstr (#18056)
* usbwallet: check returned error when decoding hexstr

* Update accounts/usbwallet/ledger.go

Co-Authored-By: CoreyLin <514971757@qq.com>

* usbwallet: check hex decode error
2025-01-24 16:18:28 +08:00
Daniel Liu
b469d70433 accounts/usbwallet: simplify code using -= operator (#17904) 2025-01-24 16:18:28 +08:00
Daniel Liu
e5b484b63b accounts/usbwallet: correct comment typo (#16998) 2025-01-24 16:18:28 +08:00
Daniel Liu
8d2fb8c280 accounts/usbwallet: correct comment typo (#17008) 2025-01-24 16:18:28 +08:00
Daniel Liu
fbe415c975 accounts/usbwallet: remove unused variables in ledger.go (#16446) 2025-01-24 16:18:28 +08:00
Daniel Liu
18a5493575 accounts: add function UnmarshalJSON to parse URL (#16154) 2025-01-24 16:18:28 +08:00
Justin Dhillon
009542a92e accounts/usbwallet, common/bitutil: fix broken links in docs (#29078)
fixes some links in documentation
2024-12-28 09:06:31 +08:00
Daniel Liu
ad5e7d6db3 crypto: add SignatureLength constant and use it everywhere (#19996) 2024-12-09 17:48:59 +08:00
Daniel Liu
a79411fa06 all: fix staticcheck warning ST1005: incorrectly formatted error string 2024-10-24 09:48:20 +08:00
Daniel Liu
01e1728a94 all: add support for EIP-2718, EIP-2930 transactions (#21502) 2024-05-14 23:15:35 +08:00