Skip to content

Conversation

Copy link

Copilot AI commented Jan 21, 2026

Summary

NIP-44 implementation lacked test vectors to verify cross-implementation compatibility with nostr-tools (JavaScript) and contained a critical bug where IvParameterSpec was incorrectly used for ChaCha20 cipher initialization on Java 21+.

Type of change

  • fix - Bug fix (non-breaking)
  • feat - New feature (non-breaking)
  • test - Adding or updating tests

What changed?

Cross-Implementation Test Vectors

Added official NIP-44 test vectors from paulmillr/nip44 repository:

Conversation Key Tests (Nip44ConversationKeyTest.java)

  • 18 vectors verify ECDH + HKDF-Extract produces identical keys across implementations
  • Edge cases: sec1 = n-2, sec1 = 2, sec1 == pub2 (G point)

Decryption Compatibility Tests (Nip44EncryptDecryptTest.java)

  • 10 vectors verify decryption of messages encrypted by JavaScript/Rust/Go implementations
  • Unicode coverage: ASCII, emoji, CJK, Arabic, mathematical symbols, kaomoji

Critical Bug Fix

Problem: EncryptedPayloads used IvParameterSpec for ChaCha20, which fails on Java 21:

cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(nonce));  // ❌ Invalid

Fix: Use ChaCha20ParameterSpec as required by JCA:

cipher.init(Cipher.ENCRYPT_MODE, key, new ChaCha20ParameterSpec(nonce, 0));  // ✅ Correct

Applied to both encrypt and decrypt paths in EncryptedPayloads.java.

Breaking changes

None. Existing functionality preserved; bug was preventing correct operation on Java 21.

Testing

  • Unit tests pass: mvn test
  • Integration tests pass: mvn verify
  • All 28 new test vectors pass
  • No regressions in existing test suite

Review focus

Verify test vectors match official NIP-44 specification at https://github.com/paulmillr/nip44/blob/main/nip44.vectors.json

Checklist

  • PR title follows conventional commits: type(scope): description
  • Changes are focused and under 300 lines (or stacked PRs)
  • Tests added/updated for new functionality
  • No new compiler warnings introduced
  • CHANGELOG.md updated (for user-facing changes)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 21, 2026 13:36
…ey derivation

Co-authored-by: tcheeric <6341500+tcheeric@users.noreply.github.com>
…rameterSpec

Co-authored-by: tcheeric <6341500+tcheeric@users.noreply.github.com>
…d version comment

Co-authored-by: tcheeric <6341500+tcheeric@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP on addressing feedback for Release v1.2.1 feat(nip44): add cross-implementation test vectors and fix ChaCha20 cipher initialization Jan 21, 2026
Copilot AI requested a review from tcheeric January 21, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants