Skip to content

Comments

feat: Adopt W3C JWE standard for encryption#90

Merged
macterra merged 8 commits intomainfrom
85-add-JOSE
Feb 18, 2026
Merged

feat: Adopt W3C JWE standard for encryption#90
macterra merged 8 commits intomainfrom
85-add-JOSE

Conversation

@macterra
Copy link
Collaborator

Replace custom ECIES (secp256k1 ECDH + XChaCha20-Poly1305) with standard JWE Compact Serialization (ECDH-ES + A256GCM) per the W3C VC-JOSE-COSE spec. Built using existing @noble primitives to maintain browser compatibility (Web Crypto doesn't support secp256k1).

Backward compatible: legacy ciphertext is auto-detected and decrypted via decryptMessageLegacy/decryptBytesLegacy methods.

Replace custom ECIES (secp256k1 ECDH + XChaCha20-Poly1305) with
standard JWE Compact Serialization (ECDH-ES + A256GCM) per the
W3C VC-JOSE-COSE spec. Built using existing @noble primitives to
maintain browser compatibility (Web Crypto doesn't support secp256k1).

Backward compatible: legacy ciphertext is auto-detected and decrypted
via decryptMessageLegacy/decryptBytesLegacy methods.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@macterra macterra linked an issue Feb 18, 2026 that may be closed by this pull request
@coveralls
Copy link

coveralls commented Feb 18, 2026

Pull Request Test Coverage Report for Build 22152092432

Details

  • 118 of 122 (96.72%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on 85-add-JOSE at 95.409%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/cipher/src/jwe.ts 50 51 98.04%
packages/keymaster/src/keymaster.ts 35 36 97.22%
packages/cipher/src/cipher-base.ts 9 11 81.82%
Totals Coverage Status
Change from base Build 22116124280: 95.4%
Covered Lines: 3395
Relevant Lines: 3493

💛 - Coveralls

macterra and others added 6 commits February 18, 2026 11:20
The decrypt methods now accept an optional legacyPubKey parameter,
centralizing format detection. Removes decryptMessageCompat and
decryptBytesCompat from keymaster.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request replaces the custom ECIES encryption scheme (secp256k1 ECDH + XChaCha20-Poly1305) with standard W3C JWE Compact Serialization (ECDH-ES + A256GCM) to align with the W3C VC-JOSE-COSE specification. The implementation maintains backward compatibility by auto-detecting legacy ciphertext format and providing explicit legacy decryption methods.

Changes:

  • Implements JWE Compact Serialization with ECDH-ES key agreement and A256GCM encryption using @noble primitives
  • Updates cipher API to use single recipient public key parameter (removing sender private key requirement)
  • Migrates message metadata (sender, created) from encrypted payload to DID document controller/metadata fields
  • Provides backward compatibility through legacy decryption methods and optional legacyPubKey parameter

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/cipher/src/jwe.ts New JWE implementation with buildJweCompact/parseJweCompact functions
packages/cipher/src/concat-kdf.ts Concat KDF implementation per NIST SP 800-56A and RFC 7518
packages/cipher/src/cipher-base.ts Updated cipher interface with new encryption API and backward compatibility
packages/cipher/src/types.ts Updated type signatures for encryption methods and added legacy methods
packages/keymaster/src/keymaster.ts Updated all encryption/decryption call sites to new API, changed message metadata storage
packages/keymaster/src/types.ts Made EncryptedMessage sender/created fields optional
tests/cipher/jwe.test.ts Comprehensive tests for JWE implementation and KDF
tests/keymaster/crypto.test.ts Updated tests to verify new metadata storage approach
services/gatekeeper/client/src/App.js Updated decryptMessage call with reordered parameters
apps/react-wallet/src/contexts/WalletProvider.tsx Updated decryptMessage call with reordered parameters
apps/chrome-extension/src/contexts/WalletProvider.tsx Updated decryptMessage call with reordered parameters
python/keymaster_sdk/tests/test_keymaster_sdk.py Updated test to check controller field instead of encrypted.sender
jest.config.js Added module mappings for new JWE and KDF files
package.json Version bump to 0.3.0 with updated description

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@macterra macterra merged commit 2321ca7 into main Feb 18, 2026
13 checks passed
@macterra macterra deleted the 85-add-JOSE branch February 18, 2026 18:28
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.

Add OKP/Ed25519 key support to cipher

2 participants