feat(nwcp): add NIP-44 v2 encryption#51
Open
satwise wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds NIP-44 v2 support to NWCServiceProvider so the provider can advertise, decrypt requests, and encrypt responses using nip44_v2, while preserving nip04 as a fallback for compatibility with existing clients.
Changes:
- Add NIP-44 v2 encrypt/decrypt implementation (HKDF-SHA256 + ChaCha20 + HMAC-SHA256) and route request/response handling based on an
encryptiontag. - Advertise supported encryptions (
nip44_v2 nip04) in the kind-13194 info event. - Add unit tests for the published NIP-44 v2 vector and for end-to-end request/response handling using
nip44_v2.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
nwcp.py |
Implements NIP-44 v2 crypto, adds encryption negotiation via tags, and updates info event advertisement + response encryption behavior. |
tests/unit/test_nwcp.py |
Adds vector test and async handling tests to cover NIP-44 v2 request decryption and response encryption/tagging. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
nip44_v2 nip04in the NIP-47 kind-13194 info event["encryption", "nip44_v2"]Closes #41
Testing
uvx ruff check nwcp.py tests/unit/test_nwcp.pyuvx black --check nwcp.py tests/unit/test_nwcp.pypython -m py_compile nwcp.py tests/unit/test_nwcp.pypynostr,coincurve==20.0.0,cryptography,loguru, andwebsocketsplus lightweight LNbits stubsNote: full
uv run pytestis blocked in this Windows environment because LNbits pullsuvloop, which does not support Windows.