Closed mayerwin closed 7 years ago
you mean the xprv?
Have you able to run from pybitcointools.deterministic
successfully?
Fyi the issue has been resolved, see the StackExchange answer.
I'm encoutering the same problem though when I tried the answer given by Andrew I got some error with the pybitcointools.deterministic
I didn't get any error, though you may want to check which Python version you are running.
I have tried it both to python2.7 and 3.5 and got the same error no module named pybitcointools.deterministic :(
Try bitcoin.deterministic.
wow bitcoin.deterministic works thanks. But print final_key have error missing parentheses. when I try to use print(final_key) it throws indention error. when I try to adjust the indention it throws 'final key' is not defined.
it's weird.
Please post your full code. You're probably not far off. Parentheses are necessary for Python 3.5+. final_key should be defined.
Please paste your code within "Insert code" markup so it preserves any indentation.
>from bitcoin.deterministic import raw_crack_bip32_privkey, bip32_deserialize, bip32_serialize, bip32_privtopub
>from bitcoin.main import decode_privkey, encode_privkey
>parent_pub = 'xpub661MyMwAqRbcEnKbXcCqD2GT1di5zQxVqoHPAgHNe8dv5JP8gWmDproS6kFHJnLZd23tWevhdn4urGJ6b264DfTGKr8zjmYDjyDTi9U7iyT'
>wif_key = encode_privkey(decode_privkey('KyqcQVzcp7cHEMEDHQaz5eaE5azsRHaE4ukkeqwM2vdiQwBYtxeb'), 'bin_compressed')
>for i in xrange(2**31 -1):
> priv = (b'\x04\x88\xAD\xE4', 1, 0, i, b'', wif_key)
> pkey = raw_crack_bip32_privkey(bip32_deserialize(parent_pub), priv)
> final_key = bip32_serialize(pkey)
> if bip32_privtopub(final_key) == parent_pub:
> print (final_key)
I have posted this question with a 50 reputation bounty here: https://bitcoin.stackexchange.com/questions/55383/recover-the-extended-bip32-master-private-key-from-its-extended-bip32-public-key I will also consider rewarding the accepted answer with BTC.
I am trying to recover the extended BIP32 master private key from its extended BIP32 public key (which I already know) and a WIF private key (which I obtained by decrypting a BIP38 seed with a passphrase).
I followed the steps described in this article from Vitalik Buterin, but to use the
crack_bip32_privkey
function inpybitcointools
, I need to have a private key in BIP32 format (not WIF). I can see how to obtain a BIP32 private master key from a BIP32 seed (withbip32_master_key
), but not how to do the same from a private key in WIF format.How can I achieve this (if I understood things correctly), with pybitcointools?