[New Feature] Derive Nostr privkey / pubkey via NIP-06 #744
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.
Background
I originally built a full nostr integration for the 2023 Nostrica conference. That branch was always meant to just be a fun demo and a conversation starter (primarily around NIP-26 delegated signing). It was not intended to ever be PRed into the main SeedSigner repo.
However, the NIP-06 key derivation portions are actually broadly useful.
What is nostr
see: https://nostr.org/
What is NIP-06
see: https://github.com/nostr-protocol/nips/blob/master/06.md
It's a very simple BIP-32 derivation of a new privkey / pubkey pair using the specified derivation path. From there you can generate your nsec/npub for use in nostr clients. The nostr hex key formats are also trivially generated.
Nostr client support
Nostr clients have varying support for NIP-06 (either presenting the user with a BIP-39 mnemonic backup for a newly created nostr key or importing from a BIP-39 mnemonic to restore your nostr key).
But for purposes, NIP-06 integration isn't even necessary. Every nostr client or remote signer will support keys entered as nsec or hex format. And at least one, Amber, can read keys in via QR. I haven't exhaustively researched which other clients and apps support QR. I would assume others exist and, given the pace of nostr development, I'm sure other clients could add QR support quickly if there was enough interest.
This PR
Rationale
SeedSigner and nostr have always been aligned in the FOSS and self-sovereignty ethos. We can encourage and facilitate using BIP-39 mnemonics as the backup format for nostr keys, which by itself is a big win. And leveraging SeedSigner's bring-your-own-entropy seed creation as part of a user's Nostr key creation flow is another big win.
Also, new developments such as Frostr (literally FROST + nostr) possibly lend themselves to more offline key creation features that could some day be built into SeedSigner.
Details
I've refactored some of that original Nostrica demo code and stripped out everything except the NIP-06 key derivation features.
Creates a new Settings option (disabled by default) to add Nostr key export as an option for a given Seed.
If you select one of the privkey formats:
After this screen the nostr privkey or pubkey is displayed as a static QR.
Related changes
I opted to isolate the nostr functionality in its own:
helpers.nostr
views.nostr_views
screens.nostr_screens
Minimal touchpoints to the rest of the code. Just the necessary integrations in
SeedOptionsView
, Settings, screenshot generator.Full unit tests and flow tests added.
Updated
messages.pot
master translation file for the new nostr-related display strings.Note the obvious color scheme violation with the nostr-themed purple in the final display screen. As always I defer to @easyuxd if this indulgence should be allowed. My argument: it's a fun, harmless one-off that's buried deep in a specific flow that's disabled by default. But I will accept Easy's decision either way without gripe.
This pull request is categorized as a:
Checklist
pytest
and made sure all unit tests pass before sumbitting the PRIf you modified or added functionality/workflow, did you add new unit tests?
I have tested this PR on the following platforms/os: