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.
This
Bip39PrivateKey
class extendsPrivateKey
.It takes a BIP-39 mnemonic as its input (or randomly generates a new one for you) and then derives the Nostr PK using the NIP-06 derivation path.
Examples
Notes
embit
Adds Stepan Snigirev's
embit
library as a dependency. This is the library that powers the higher-level bitcoin operations for the Specter-DIY hardware wallet, Specter Desktop, SeedSigner, and Krux.Note that
embit
includes its own copy of Pieter Wiulle's bec32.py script, but it is an older version that has since had breaking changes.embit
's copy is isolated within its package name so there shouldn't be any conflicts.Bip39PrivateKey.with_mnemonic_length
I wanted to provide an option to specify a 12-word mnemonic. At first glance it seems like it would have been simpler to just offer an optional
mnemonic_length
attr when creating a new instance. Except there's no clear way to communicate the intention of that field when I'm providing my own mnemonic.If I had implemented it that way:
So instead, I just pulled it out into its own classmethod:
Debatable decision but seemed like the least confusing option.
Misc
Bumps required python version in the pyproject.toml to ">=3.9.0". The type hints that use the
typing
module work fine in earlier versions of python3, but elsewhere in the code there are newer type hints that were introduced in python3.9 and are not backwards-compatible. I'll probably look to make a future PR that would enable support down to python3.7 which is not yet at EOL. I'm not aware of any advantages of the new type hints from python3.9 (other than avoiding eventual future deprecation of thetyping
module).