Skip to content
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

get_child() has nothing to do with BIP32_PATH #14

Open
icodeface opened this issue Apr 19, 2018 · 4 comments
Open

get_child() has nothing to do with BIP32_PATH #14

icodeface opened this issue Apr 19, 2018 · 4 comments

Comments

@icodeface
Copy link
Contributor

icodeface commented Apr 19, 2018

Hi,
I read your code, and found that the function get_child() has nothing to do with BIP32_PATH, this might be an issue.
https://github.com/ranaroussi/pywallet/blob/master/pywallet/wallet.py#L158
https://github.com/ranaroussi/pywallet/blob/master/pywallet/utils/bip32.py#L190

wechatimg378
wechatimg380

the address generated doesn't match the bip32_path

@ghost
Copy link

ghost commented May 10, 2018

Not sure if you ever figured this out, but I'm also seeing inconsistencies. Trying all kinds of things but can't ever seem to get it to match addresses from https://iancoleman.io/bip39/ or the pycoin library I thought about swapping this out with.

Tried some things like

    print('btc child 1')
    print(w.get_child(0).get_child(0).get_child(0).to_address())
    print('btc child 1v2')
    print(w.get_child_for_path("m/44'/0'/0'/0").to_address())

but not matching up at all.

@jonashaag
Copy link

Same here

@Abd0s
Copy link

Abd0s commented Feb 26, 2020

Could this be releated too:

Bug Notice

Versions of bitmerchant prior to 0.1.8 contained a caching bug that may have resulted in calls to bip32.Wallet.get_child to return incorrect results. All affected versions were removed from pypi, and no users are known to have been affected by this bug.

The steps to reproduce the bug are unlikely and do not match the typical usage patterns of bitmerchant.

At this time, no users are known to have been affected by this bug.

If you have been affected by this bug and need help recovering any lost or misplaced coins, please contact me directly at steven.buss+bitmerchant@gmail.com.

The affected versions of bitmerchant have been removed from pypi. They have not been untagged in git.

The two possible failure scenarios are: misplaced coins and stolen coins

https://github.com/sbuss/bitmerchant/blob/master/BUG_NOTICE.rst

@ZenulAbidin
Copy link

ZenulAbidin commented May 14, 2023

It seems that the chain codes used for calculating the child keys are completely wrong - it does HMAC on the mnemonic words themselves instead of the 128-bit seed entropy of the mnemonic.

See Wallet.from_master_key for reference. By contrast, HDPrivateKey.from_master_mnemonic method derives correct child keys.

Just put this code at the beginning of from_master_key to fix the bug:

# bip32.py, at the beginning of the file
from mnemonic.mnemonic import mnemonic
from .utils import ensure_bytes

# ...
# in Wallet.from_master_key
    m = Mnemonic(language='english')
    seed = ensure_bytes(m.to_seed(seed))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@jonashaag @icodeface @ZenulAbidin @Abd0s and others