Repository navigation
Fix Invalid Private Key Generation - #12
Merged
Merged
Conversation
Owner
|
Hi @witoff! Thank you for the detailed explanation and PR. Looks good and happy to merge it. I like your suggestion of adding a |
Contributor
Author
|
@miguelmota updated so that current functionality doesn't break. Since this is used by many upstream libraries, users will want a way to enable correct behavior without requiring everyone else to update so i also added envar support w/ tests. // This works as it did before.
account, err := wallet.Derive(path, false)
// This derives correctly
os.Setenv(issue179FixEnvar, "1")
account, err = wallet.Derive(path, false)
// This also derives correctly
wallet.SetFixIssue172(true)
account, err = wallet.Derive(path, false)Can you merge or advise on any other changes you think are needed? |
Owner
|
@witoff This is perfect! Awesome work. Merging. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #10 by upgrading btcutil dependencies.
This issue was tracked in the upstream btcsuite/btcutil dependency at btcsuite/btcutil#172
When a child key has less than 32 bytes, it is incorrectly padded leading to incorrect key derivation. This effects 1/256 hardened key derivations and twice is many (1/128) accounts with two hardened component. Upgrading dependencies replaces
key.Childwithkey.Derivewhich correctly pads addresses.Note that merging this will fix derivation, but break existing implementations for ~1/128 keys. btcsuite addressed this by adding a
IsAffectedByIssue172() boolfunction and changingChild()toDerive()to break the default interface and force implementers to address as needed and I suggest taking a similar approach.