-
Notifications
You must be signed in to change notification settings - Fork 21.5k
accounts, signer: fix Ledger Live account derivation path (clef) #21757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
holiman
merged 4 commits into
ethereum:master
from
svenski123:fix-ledger-live-account-derivation
Nov 29, 2020
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
213d80e
signer/core/api: fix derivation of ledger live accounts
svenski123 b719dbe
signer/core/api: derive ten default paths for all hardware wallets, p…
svenski123 d23a7d4
signer/core/api: as .../0'/0/0 already included by default paths, do …
svenski123 7b315a3
accounts, signer: implement path iterators for hd wallets
holiman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This modifies the default derivation path, afaict. Shouldn't you do
?
Also, let's maybe do a sanity check that
incrOffset < len(nextpath)so it doesn't just panic later onAlso,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a look.
The existing code makes a distinction between ledger and non-ledger hardware wallet by checking the url scheme for "ledger" and derives different accounts accordingly - I left this in place.
Changing it to derive 30 accounts - 10x at .../0'/0/N, 10x at .../N'/0/0 and 10x at .../0'/N irrespective of url scheme / hardware wallet type would also work in my opinion with the possible drawback of including many unused accounts to the account list and possibly confusing the user.
The array offsets are all hard coded as is the derivation path so a panic appropriate.
In fact it would be better if the locally defined derive() function could be a macro instead so bounds check errors could be caught at compile time but I don't know if golang offers this facility.
IMHO having the derivation path be defined in a separate file makes this code harder to read / maintain and would better if it were a locally defined constant (the prefix m/44'/60`/0' is very unlikely to change)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the default paths back for ledger, so you now get 10 default, 10 legacy, 10 live - so every address derived by the old code will be derived by the new code (plus more).
Also added logged warning on the level-to-increment index - should never occur with hard coded values but if something changes in future, should hopefully be helpful.