Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Use did:peer:4 by default for DID Exchange #2166

Merged

Conversation

genaris
Copy link
Contributor

@genaris genaris commented Jan 30, 2025

Up to now, we were using did:peer:1 by default when creating DID Exchange requests. This PR changes this to use the newer did:peer:4, unless the peerNumAlgoForDidExchangeRequests in DIDComm connection module config is explicitly set to another one.

Note that this PR also applies some fixes found during this update:

  • In DID Exchange Response creation, ensure that invitation key is used to sign DID rotation attachment, since in some cases, such as using public DIDs or implicit invitations, we were using the keys present in the services from rotated DID (or the ones from routing parameter). I applied this to did_doc~attach as well, although in the RFC it does not explicitly mention that it should use the invitation keys. @TimoGlastra please let me know what's your interpretation for this.
  • When receiving an implicit invitation, we were setting theirLabel for the new connection with the value coming from label, which is supposed to be the opposite (our label instead). So now we put alias as theirLabel , as it usually happens to connections created with explicit invitations

@genaris genaris added this to the 0.6 milestone Jan 30, 2025
@genaris genaris requested a review from a team as a code owner January 30, 2025 18:53
Copy link

changeset-bot bot commented Jan 30, 2025

🦋 Changeset detected

Latest commit: b623c54

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 15 packages
Name Type
@credo-ts/didcomm Minor
@credo-ts/action-menu Minor
@credo-ts/anoncreds Minor
@credo-ts/drpc Minor
@credo-ts/node Minor
@credo-ts/question-answer Minor
@credo-ts/tenants Minor
@credo-ts/cheqd Minor
@credo-ts/indy-sdk-to-askar-migration Minor
@credo-ts/indy-vdr Minor
@credo-ts/bbs-signatures Minor
@credo-ts/openid4vc Minor
@credo-ts/askar Minor
@credo-ts/core Minor
@credo-ts/react-native Minor

Not sure what this means? Click here to learn what changesets are.

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

Copy link
Contributor

@TimoGlastra TimoGlastra left a comment

Choose a reason for hiding this comment

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

Can you add a changeset for each of the changes in this pr?

@@ -767,7 +767,7 @@ describe('out of band', () => {

// Use the invitation did from the first connection to create the second connection
const outOfBandRecord2 = await faberAgent.modules.oob.createInvitation({
invitationDid: outOfBandRecord1.outOfBandInvitation.invitationDids[0],
invitationDid: faberAliceConnection.did,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is different right? InvitationDid is usually not the final did

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case it should be the same, since we are not setting it as an multiUse invitation. I did this trick because OutOfBandInvitation.invitationdDids is dynamically generating peer:2 DIDs and this does not work directly when querying peer:4 DIDs.

But I'll take a second look to it to see if everything is in place.

// In case the DID Exchange started with an implicit invitation, take all recipient keys from the corresponding DID
for (const did of outOfBandRecord.outOfBandInvitation.getDidServices()) {
invitationRecipientKeys.push(
...(await getDidDocumentForCreatedDid(agentContext, parseDid(did).did)).recipientKeys.map(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we always need to do this, or only for implicit? Because now we run this always?

Copy link
Contributor Author

@genaris genaris Jan 31, 2025

Choose a reason for hiding this comment

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

I think the comment is misleading. It is useful for resolvable DIDs in general. However I'll review the DID Exchange Response creation more in details just to make sure it works properly in all cases.

return didRecord.didDocument

const didsApi = agentContext.dependencyManager.resolve(DidsApi)
return await didsApi.resolveDidDocument(did)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm 🤔

Are there cases where we don't store our own did?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, but I wanted to take all the advantages of DidsApi.resolveDidDocument() (such as dynamically generating the did:peer:4 DID Document) making sure that it would only resolve DIDs created by us (I can propagate a filtering parameter but it would modify a good number of methods).

Copy link
Contributor

Choose a reason for hiding this comment

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

This is okay! Just curious :)

Copy link
Contributor

Choose a reason for hiding this comment

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

It also has the benefit of caching, and even DIDs created by us, but not managed by us (e.g. think a did web for which we have one key, but it's stored outside of credo as it's regularly updated)

Signed-off-by: Ariel Gentile <[email protected]>
…change Requests as response to an Out of Band invitation.

It is possible to return to previous behaviour by manually setting `peerNumAlgoForDidExchangeRequests` option in DIDComm Connections module config.

Signed-off-by: Ariel Gentile <[email protected]>
@genaris genaris enabled auto-merge (squash) January 31, 2025 22:36
@genaris genaris merged commit 0d877f5 into openwallet-foundation:main Jan 31, 2025
16 checks passed
sairanjit pushed a commit to sairanjit/credo-ts that referenced this pull request Feb 7, 2025
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