Title: Conversions: mnemo => seed => WIF Post by: pbies on December 14, 2023, 07:56:29 PM Hi guys,
can you tell me how in Python (>=3.0) to convert mnemonic (12 english words) to hex seed (128 hex digits or 64 bytes) and then to Bitcoin WIF (first one for that seed = /0/0)? I have scripts already but doubt they are working properly... Title: Re: Conversions: mnemo => seed => WIF Post by: BTCapsule on December 14, 2023, 10:52:00 PM Are you trying to import it into Bitcoin Core?
If so, you can try the Python code at the bottom of this post: https://www.reddit.com/r/Bitcoin/comments/r5g0ws/howto_ways_to_use_12_word_seeds_bip39_in_bitcoin/ I’ll warn you that Bitcoin Core WIF uses 128 bits and mnemonics are 512 bits. The best I’ve been able to do is create individual addresses from the mnemonic and importing the private key into Core. https://github.com/BTCapsule/soverynode Title: Re: Conversions: mnemo => seed => WIF Post by: pbies on December 15, 2023, 04:14:10 AM I got two scripts:
First: Code: #!/usr/bin/env python3 Second: Code: #!/usr/bin/env python3 Title: Re: Conversions: mnemo => seed => WIF Post by: pooya87 on December 15, 2023, 04:32:00 AM The proposal itself has a reference implementation and two of them are in python that you can use[1].
You can also always check out popular wallets that support BIP-39 algorithm and use their code or just use the wallet itself (ie. import mnemonic and just extract the single child key you are looking for). Electrum is a good option that does support BIP-39[2] and is written in python. [1] https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#reference-implementation [2] https://github.com/spesmilo/electrum/blob/2d954bb55439ff7d0d84b2c45b43b2c47c0d73b7/electrum/keystore.py#L975-L1018 Title: Re: Conversions: mnemo => seed => WIF Post by: pbies on December 15, 2023, 05:08:04 AM The proposal itself has a reference implementation and two of them are in python that you can use[1]. You can also always check out popular wallets that support BIP-39 algorithm and use their code or just use the wallet itself (ie. import mnemonic and just extract the single child key you are looking for). Electrum is a good option that does support BIP-39[2] and is written in python. [1] https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#reference-implementation [2] https://github.com/spesmilo/electrum/blob/2d954bb55439ff7d0d84b2c45b43b2c47c0d73b7/electrum/keystore.py#L975-L1018 These are mnemo to seed, need more about seed to WIF... Does not help... Title: Re: Conversions: mnemo => seed => WIF Post by: pooya87 on December 15, 2023, 03:23:30 PM These are mnemo to seed, need more about seed to WIF... To derive child keys (seed to WIF) you need to use the BIP-32 algorithm [1]. Electrum also has the implementation for that[2]. Method names like CKD_priv are according to the documentation so it's a good idea to read that first.Does not help... [1] https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki [2] https://github.com/spesmilo/electrum/blob/2d954bb55439ff7d0d84b2c45b43b2c47c0d73b7/electrum/bip32.py Title: Re: Conversions: mnemo => seed => WIF Post by: Greg Tonoski on December 18, 2023, 03:06:05 PM (...) and then to Bitcoin WIF? For the conversion from HEX to WIF you could use: "https://gist.github.com/GregTonoski/438992249df6e4bd613f9758421ff38a (https://gist.github.com/GregTonoski/438992249df6e4bd613f9758421ff38a)". It works in bash (which can be called from Python or used without Python).Title: Re: Conversions: mnemo => seed => WIF Post by: pbies on December 18, 2023, 06:11:07 PM (...) and then to Bitcoin WIF? For the conversion from HEX to WIF you could use: "https://gist.github.com/GregTonoski/438992249df6e4bd613f9758421ff38a (https://gist.github.com/GregTonoski/438992249df6e4bd613f9758421ff38a)". It works in bash (which can be called from Python or used without Python).O, witam kolegę! Pisałem do ciebie maile ale trafiłem na beton. Greg, you didn't understood the process, it is not private key to WIF but seed to WIF. Your script is useless in this case. I already have at least dozen of scripts that convert priv key to WIF. Another thing is that I've made python script for verifying mnemonics: Code: #!/usr/bin/env python3 It is based on pooya87's links. Title: Re: Conversions: mnemo => seed => WIF Post by: Greg Tonoski on December 28, 2023, 08:22:44 AM Hi guys, can you tell me how in Python (>=3.0) to convert mnemonic (12 english words) to hex seed (128 hex digits or 64 bytes) and then to Bitcoin WIF (first one for that seed = /0/0)? I have scripts already but doubt they are working properly... There is the implemetation in Python: https://github.com/mcdallas/cryptotools (https://github.com/mcdallas/cryptotools) |