Open jkugler opened 4 years ago
Unfortunately not supported as it requires BIP-32 to be implemented.
Would a PR be accepted? Or is the feature not desired?
A PR would be fantastic! I started working on implementing it but never found the time to finish it. I could share it with you if you are interested in some collaboration on it?
I am a cryptocurrency newbie, but I'd be happy to take a look!
I'd like to help if I can, and if this is still on the "roadmap"!
Please let me know!
Yes please 😄
@bjarnemagnussen Can you show what you had?
I only have some snippets for the BIP32 part of this issue.
I was working on a BIP32 library implementation. It was forked from bip32utils
(which now does not exist anymore) and adjusted to work with coincurve
directly. It was however never tested thoroughly enough.
I also have some code that uses it with the wallet in its own class. Just let me know if any more input is helpful!
Files:
Thanks @bjarnemagnussen!
Just out of curiosity, does it make sense to draw inspiration from electrum
as well?
More precisely:
Electrum follows a slightly different approach though with regards to BIP 39: https://electrum.readthedocs.io/en/latest/seedphrase.html?highlight=bip39 so this may not be what is wanted ...
So, just to be sure I understand clearly, the reference implementation mentioned above (https://github.com/trezor/python-mnemonic) would have to be followed right?
In an attempt to answer my own question, it seems to me that the best approach may be to treat electrum
-based mnemonic phrases as a separate case that may or may not be supported. https://bitcointalk.org/index.php?topic=4514745.0 provides useful information in addition to electrum
's seed version system docs (mentioned above).
So, perhaps, it is best to first support BIP 39 as is, and perhaps later add support for electrum's approach:
electrum
's seed version system.This spreadsheet may be useful to provide context ... https://onedrive.live.com/view.aspx?resid=584F122BA17116EE!313&app=Excel
Also, to be noted from https://bitcointalk.org/index.php?topic=4514745.msg40763254#msg40763254
Electrum wallet itself is also compatible with BIP39 seeds... so while you can't generate a BIP39 seed within Electrum, you can still use a BIP39 seed (generated elsewhere) with Electrum to restore a wallet.
So, if the above is correct:
into >>>
electrum does workinto >>>
BIP 39 supporting wallets does not workfrom the electrum code: https://github.com/spesmilo/electrum/blob/b891d3dc8580976887e3bb61be8b504257a949b6/electrum/mnemonic.py#L146-L148
In any case, this would need to be tested. The above just aims to survey possible implementations to look at.
That sounds logical indeed, thanks! WDYT @bjarnemagnussen?
I think initially supporting BIP39 is very beneficial as it allows for better interoperability.
Of course later the support for Electrum's own seed system could always be added.
Just make sure that whatever you do, it's native C, or calling in to C libraries. I believe bip32utils was what I used first, and it was very slow at generating keys because it uses pure python libs. I then switched to pycoin and it was at least 10 times faster, if not more. Also, look in to cython. Even without type hinting, it can provide a large speed up.
My cython experience: https://twitter.com/pedahzur_ak/status/1232071487349067776
I just took two #Python modules, applied #Cython to them (made NO other changes to the code, not even type annotations), and my 100 iteration benchmark just went from 11.8 seconds to .8 seconds. Math-heavy code, but still. Order of a magnitude FTW.
It would then be interesting to see how bip32utils
performs with the changes above that make use of coincurve
instead, which is using CFFI as binding to C.
yikes, Electrum's bip32 code is unreadable...
@bjarnemagnussen Certainly worth a try. I think pycoin uses ctypes, so that is one reasons it's so fast.
I would very much appreciate mnemonic -> key support. There are two libraries that already have something like that, maybe it's copy-pasteable? :D Unfortunately, I lack the skills... https://pypi.org/project/bitcoin/ https://pypi.org/project/bitcoinlib/
hi guys! still no way to use mnemonic seeds to generate keys?
what's the next fast cython library for bitcoin that supports bip39 please?
I've read over the documentation, so please feel free to point out if I've missed something. :)
I'm trying to import a key into bit using the 12-word mnemonic seed, as generated by https://github.com/trezor/python-mnemonic. I get the seed via:
But, I do not see a way to do that. Am I missing something? Or is that functionality missing?