Skip to content

feat(didcomm-v2): support P-256 keyAgreement#2811

Merged
genaris merged 13 commits into
openwallet-foundation:feat/didcomm-v2from
tarunvadde:feat/didcomm-v2-p256-keyagreement
Jun 8, 2026
Merged

feat(didcomm-v2): support P-256 keyAgreement#2811
genaris merged 13 commits into
openwallet-foundation:feat/didcomm-v2from
tarunvadde:feat/didcomm-v2-p256-keyagreement

Conversation

@tarunvadde

Copy link
Copy Markdown
Contributor

Adds P-256 keyAgreement support for DIDComm v2. Opt in via DidCommModuleConfig.v2KeyAgreementCurve: 'X25519' | 'P-256' (default X25519, throws at construction if 'P-256' is set without 'v2' in didcommVersions).

KMS layer accepts P-256 in ECDH-1PU+A256KW with a same-curve sender/recipient invariant. Envelope service generates P-256 ephemerals, emits EC/P-256 EPK with x and y, dispatches KDF per curve. OOB peer-DID builder emits the keyAgreement VM as JsonWebKey2020 for P-256, preserving the existing X25519KeyAgreementKey2019 path for X25519.

resolveV2Keys and the v2 connection equality checks widen to X25519 | P-256. New keyAgreementsEqual(a, b) helper replaces toX25519(a).equals(toX25519(b)) and only bridges Ed25519 to X25519 birationally as per RFC 7748 (P-256 is direct-compare only). Core's DidDocument.recipientKeys widens to include P-256 (additive; v1 paths skip P-256 via existing curve guards).

tarunvadde added 11 commits May 27, 2026 10:21
…ture

Signed-off-by: Tarun Vadde <vaddeofficial@gmail.com>
Signed-off-by: Tarun Vadde <vaddeofficial@gmail.com>
Signed-off-by: Tarun Vadde <vaddeofficial@gmail.com>
Signed-off-by: Tarun Vadde <vaddeofficial@gmail.com>
Signed-off-by: Tarun Vadde <vaddeofficial@gmail.com>
Signed-off-by: Tarun Vadde <vaddeofficial@gmail.com>
Signed-off-by: Tarun Vadde <vaddeofficial@gmail.com>
Signed-off-by: Tarun Vadde <vaddeofficial@gmail.com>
Signed-off-by: Tarun Vadde <vaddeofficial@gmail.com>
Signed-off-by: Tarun Vadde <vaddeofficial@gmail.com>
Signed-off-by: Tarun Vadde <vaddeofficial@gmail.com>
@changeset-bot

changeset-bot Bot commented May 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 206bedb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment on lines +248 to +250
publicJwk: PublicJwk<
MapX25519ToEd25519 extends true ? Ed25519PublicJwk : Ed25519PublicJwk | X25519PublicJwk | P256PublicJwk
>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this correctly taking into account all variants? Can MapX25519ToEd25519 be true and also have P256PublicJwk as return type?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No. When MapX25519ToEd25519 is true the conditional resolves to Ed25519PublicJwk only, and the runtime at line 343 drops P-256 entries (no Ed25519 birational sibling), so the returned array is Ed25519-only.

if (publicJwk.is(P256PublicJwk)) return []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why though? It is not clear to me why MapX25519ToEd25519 means "drop P-256 keys"? A did document can have multiple services, which mix ed25519/p-256 right?

@tarunvadde tarunvadde May 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was thinking of :true as "v1-compatible output" so figured P-256 had no place. Agree the flag name doesn't say that. P-256 passes through both branches now.

@tarunvadde tarunvadde marked this pull request as ready for review May 27, 2026 14:07
@tarunvadde tarunvadde requested a review from a team as a code owner May 27, 2026 14:07
Signed-off-by: Tarun Vadde <vaddeofficial@gmail.com>
@tarunvadde tarunvadde requested a review from TimoGlastra May 28, 2026 14:00
Signed-off-by: Tarun Vadde <vaddeofficial@gmail.com>
@tarunvadde

Copy link
Copy Markdown
Contributor Author

Hey @TimoGlastra, could you please review and add comments if any?

@genaris genaris left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's merge to move forward with #2815 and move any outstanding comment on #2704

@genaris genaris merged commit 9a7a499 into openwallet-foundation:feat/didcomm-v2 Jun 8, 2026
8 checks passed
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.

3 participants