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

Support connection re-use for did:peer:2/4 #2823

Merged
merged 27 commits into from
Mar 19, 2024

Conversation

ianco
Copy link
Contributor

@ianco ianco commented Mar 5, 2024

See issue #2703

This PR is READY FOR REVIEW!, reuse working for public DID and did:peer:2/4.

  • adds additional meta-data to the wallet DID, to flag a did:peer for re-using in invitations
  • add the DID meta-data to the admin API GET /wallet/did response
  • add a flag to the OOB create invitation to request a unique did (default is to re-use the invitation DID in the wallet)
  • reuse works for did:peer:2 and did:peer:4, and also public DID
  • added separate flags to the demo for:
    • --public-did-connections - use the inviter's public DID in invitations, and allow use of implicit invitations
    • --reuse-connections - support connection re-use (invitee will reuse an existing connection if it uses the same DID as in the new invitation)
    • --multi-use-invitations - inviter will issue multi-use invitations
    • note that the --reuse-connections flag needs to be enabled in both Faber and Alice for the demo to enable connection reuse

Also added a few new integration tests with the --connection-reuse flag.

@ianco ianco requested review from swcurran, amanji and dbluhm March 5, 2024 18:38
@swcurran
Copy link
Contributor

swcurran commented Mar 5, 2024

My thoughts on the questions:

reuse works for did:peer:2 and did:peer:4, and also public DID
should this be generic? and how to determine if the DID can be used for connection reuse? should it work for ALL DID methods?

The requirement for reuse in the spec. is that the service item in the invitation be a DID -- not a JSON structure such as happens with an unqualified DID (what we've mostly used to now) or a did:peer:1. As we are dropping support for either of those, likely any DID is valid -- since the DID is resolved. did:peer:2/4 are magic in that by "resolving" them, the DIDDoc (the data that would be in the JSON structure) is decoded. Note that did:key is not permitted as it does not have an endpoint to which messages can be sent.

Does that help?

adds additional meta-data to the wallet DID, to flag a did:peer for re-using in invitations

Perhaps this should also allow flagging ledger-based (published/public) DIDs? E.g. any DID that supports "resuse"?

add the DID meta-data to the admin API GET /wallet/did response

Sounds necessary to me.

@amanji
Copy link
Contributor

amanji commented Mar 5, 2024

Is there any way we can pull out the create methods for did:peer:2/4 into a separate but mergeable PR?. It would be useful to have for integration testing, but I can also patch in the change from this PR.

@ianco
Copy link
Contributor Author

ianco commented Mar 6, 2024

adds additional meta-data to the wallet DID, to flag a did:peer for re-using in invitations

Perhaps this should also allow flagging ledger-based (published/public) DIDs? E.g. any DID that supports "resuse"?

It's already used for flagging public DID's, so I'm just piggybacking on an existing feature.

@ianco
Copy link
Contributor Author

ianco commented Mar 6, 2024

The requirement for reuse in the spec. is that the service item in the invitation be a DID -- not a JSON structure such as happens with an unqualified DID

OK this is clear, I'll update to check for a DID, and remove the specific did_peer checks that I added

@ianco
Copy link
Contributor Author

ianco commented Mar 7, 2024

For did:peer:4 should the connection use the long form or short form of the did?

      "my_did": "did:peer:4zQmbCiTt4dS2XZz9BMGYpZTKH92mYzq9Q1cavQPtfrFEfiV",
      "their_did": "did:peer:4zQmUpGK93RFrakSGmJbwL9QJXqs4uC2S8NQeSyzcomCqKzz",

vs ...

    "my_did": "did:peer:4zQmbCiTt4dS2XZz9BMGYpZTKH92mYzq9Q1cavQPtfrFEfiV:zCo9LoqasV3ZFnxnYNDU8yhBL9F6kGgrTrneiFJHM5Z8L7jw9Gj3H61gCqSKjiMxqWzztJykZfSAM5AXaeyD6wtFwjgyoPMZ6EYSoJ2HwFRd4oafTXtCvGmTC8E4FpjcFaQgnbe1uVbtRmZ1q96mPeMwsDszPiKuyH5D9rHULHkETFwd9hjPKSroX9XVoNxRaprNVr9JLWproTuDzCFwrRYou24dwVAUSsVtnM1ti2PJuZk3D5sdYqDeL8y4yw7WwVvzqd9jykuCt9nQyPBE2DE6saLSAyJRY3tYin2kcdeLCgWJfmaubDVqaEKQnFLZFJodbuts52PHhKGKcgoVXu4nKowE6zedeVtTmZEjn4USXg3oePgnQ47wDbFC5Z1nQgkZG3o7HtWWxmpYZQGqxxZxNDYckfLVxyAdNGZcXN2uHd6i788bc5B5tEEmBptAr9BeaggjobsZanaMDxNHkMLTHbVpn199pNwYXLwpZR8mdB4WMk99FQHyziWHbBLLUihEJqJzsdX88v8",
      "their_did": "did:peer:4zQmUwLj6dLCg2Sv9YirbFkzwFaMyRvmoqSn5Pge9fdP9ATi:zCo9LoqasV3ZFnxnYNDU8yhBL9F6kGgrTrneiFJHM5Z8L7jw9Gj3H61gCqSKjiMxqWzztJykZfSAM5AXaeyD6wtFwjgyoPMZ6EYSoJ2HwFRd4oafTXtCvGmTC8E4FpjcFaQgnbe1uVbtRmZ1q96mPeMwsDszPiKuyH5D9rHULHkETFwd9hjPKSroX9XVoNxRaprNVr9JLWproTuDzCFwrRYou24dwVAUSsVtnM1qintrVJ618X7sPxk13tCXhXHsMUHxK7PeL8sZG8dUFpc75k5waWuCTWK7gQhpvBGoijh4JCZMbqhFWGqUEwRZ3UbgC5f2DWM1MDJFbVtWmgkWtjtiEcJ1366gsLPRpuLYjPfAbMGRD6fXhFLaAmAxJjkEKpR4SvHUucdzv1LYeUZT6dMxf15dY5of2ca8YYSeGdpWYxrfpeMDkkfCSqXbTvXd8opaDEWjdmYMUnQVDBiWiW7C1cuPs73ewcCaeJP11yUbgD24qNtZZFLziaz3XoGRc5N1UfJ6HmCUKTi",

@swcurran
Copy link
Contributor

swcurran commented Mar 7, 2024

@dbluhm and @TelegramSam — can you please weigh in on this one to help Ian complete the implementation? Thanks!

Signed-off-by: Ian Costanzo <[email protected]>
@dbluhm
Copy link
Contributor

dbluhm commented Mar 8, 2024

For did:peer:4 should the connection use the long form or short form of the did?

I'd say short form unless there's a strong reason not to (there isn't an obvious reason that comes to mind for me).

@dbluhm
Copy link
Contributor

dbluhm commented Mar 8, 2024

10 minute scan didn't reveal any red flags for me. I'll have to set aside some time to look deeper.

@ianco ianco marked this pull request as ready for review March 14, 2024 17:20
Signed-off-by: Ian Costanzo <[email protected]>
@ianco
Copy link
Contributor Author

ianco commented Mar 14, 2024

Integration tests have failed twice in a row, so I ran them locally and everything passed.

Signed-off-by: Ian Costanzo <[email protected]>
other_did_info = other_did.value_json
if len(other_did_info["did"]) < len(ret_did_info["did"]):
ret_did = other_did
ret_did_info = ret_did.value_json
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be ret_did_info = other_did.value_json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could be either I guess, it's the same value

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just keep it the same to alleviate confusion? I know it's a bit nitpicky but from an outside perspective I would assume there's a reason they're not referencing the same object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure I'll fix it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed :-P

Copy link
Contributor

@amanji amanji left a comment

Choose a reason for hiding this comment

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

Looks good so far. Leaving comments as I see things.

@@ -279,6 +284,99 @@ async def create_invitation(
routing_keys=[],
).serialize()

elif did_peer_4 or did_peer_2:
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is getting quite long and is difficult to track logic. I would suggest at some point we refactor this out into smaller and more digestible blocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I agree, I think that's a task for the next time a DID method needs to be supported for connection reuse

I chatted with Stephen about this general topic and we agreed to put it off. The next DID(s) - that we know of - that need to support connection reuse are all public, so we should be good for now ...

Copy link
Contributor

@amanji amanji left a comment

Choose a reason for hiding this comment

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

Small comment. Otherwise it LGTM!

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@ianco ianco enabled auto-merge March 19, 2024 15:52
@ianco ianco merged commit 3066c40 into openwallet-foundation:main Mar 19, 2024
7 of 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.

4 participants