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(proofs): proof negotiation #1131

Merged

Conversation

Przytua
Copy link
Contributor

@Przytua Przytua commented Nov 29, 2022

Signed-off-by: Łukasz Przytuła lprzytula@gmail.com

Allow proof negotiation by responding to presentation proposal with new presentation request, and responding to presentation request with new presentation proposal

@Przytua Przytua requested a review from a team as a code owner November 29, 2022 23:05
@codecov-commenter
Copy link

codecov-commenter commented Nov 29, 2022

Codecov Report

Merging #1131 (0613f82) into main (1af57fd) will increase coverage by 0.21%.
The diff coverage is 92.59%.

@@            Coverage Diff             @@
##             main    #1131      +/-   ##
==========================================
+ Coverage   88.55%   88.77%   +0.21%     
==========================================
  Files         706      706              
  Lines       16468    16495      +27     
  Branches     2670     2672       +2     
==========================================
+ Hits        14584    14643      +59     
+ Misses       1877     1845      -32     
  Partials        7        7              
Impacted Files Coverage Δ
packages/core/src/modules/proofs/ProofsApi.ts 86.11% <92.30%> (+0.84%) ⬆️
...e/src/modules/proofs/protocol/v2/V2ProofService.ts 93.25% <100.00%> (+4.94%) ⬆️
...e/src/modules/proofs/protocol/v1/V1ProofService.ts 85.05% <0.00%> (+4.63%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@genaris genaris left a comment

Choose a reason for hiding this comment

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

This is very interesting. But I'm curious about the usage of this negotiation in a loop that involves more than a single message of each type. I mean: is it possible for a proof exchange to follow the path: propose-presentation -> request-presentation -> propose-presentation -> request-presentation -> presentation? If so, what happens when we do agent.proofs.findRequestMessage or agent.proofs.findProposalMessage? As it is supposed to be a single message, would it be updated to the latest one?


if (!proofRecord.connectionId) {
throw new AriesFrameworkError(
`No connectionId found for credential record '${proofRecord.id}'. Connection-less issuance does not support presentation proposal or negotiation.`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think part of this message was a copy-paste from CredentialsApi. It should say 'proof exchange' instead of 'credential' and maybe Connection-less presentation (not issuance).

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. I copied it from the acceptProposal from the same file, so fixed it there as well.


if (!proofRecord.connectionId) {
throw new AriesFrameworkError(
`No connectionId found for credential record '${proofRecord.id}'. Connection-less issuance does not support negotiation.`
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

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

}
const { message } = await service.createRequestAsResponse(this.agentContext, requestOptions)

const outbound = createOutboundMessage(connection, message)
Copy link
Contributor

Choose a reason for hiding this comment

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

createOutboundMessage has been replaced by the class OutboundMessageContext

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

@Przytua
Copy link
Contributor Author

Przytua commented Nov 30, 2022

is it possible for a proof exchange to follow the path: propose-presentation -> request-presentation -> propose-presentation -> request-presentation -> presentation?

I assume (according to this diagram: https://github.com/hyperledger/aries-rfcs/blob/main/features/0037-present-proof/README.md#choreography-diagram) that it should be possible. With a small patch of AFJ and current implementation of acapy we were able to achieve request-presentation -> propose-presentation -> request-presentation -> presentation and it was properly updating former proof request message with the new one updated according to presentation proposal.

As it is supposed to be a single message, would it be updated to the latest one?

Yes. I added some more tests to make sure it returns latest message.

@Przytua Przytua force-pushed the feature/proof-negotiation branch 2 times, most recently from 90527f8 to 7b6a221 Compare November 30, 2022 22:01
@@ -56,10 +59,12 @@ import { ProofRepository } from './repository/ProofRepository'
export interface ProofsApi<PFs extends ProofFormat[], PSs extends ProofService<PFs>[]> {
// Proposal methods
proposeProof(options: ProposeProofOptions<PFs, PSs>): Promise<ProofExchangeRecord>
proposeProofAsResponse(options: ProposeProofAsResponseOptions<PFs>): Promise<ProofExchangeRecord>
Copy link
Contributor

Choose a reason for hiding this comment

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

For the credentials module we use negotiateRequest and negotiateProposal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to negotiateRequest and negotiateProposal accordingly in the ProofsApi. Functions in services were already implemented, and I just used them in the api. They're named createProposalAsResponse and createRequestAsResponse. Do you want me to rename them as well or is that fine?

Copy link
Contributor

Choose a reason for hiding this comment

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

We probably want to rename them, but it's more for a different pr I think.

@Przytua Przytua force-pushed the feature/proof-negotiation branch 2 times, most recently from 1188d03 to 930702d Compare December 1, 2022 09:09
@@ -0,0 +1,444 @@
import type { Agent } from '../../../../../agent/Agent'
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems there's thests both in the top level tests and also in the protocol specific directories. What's the difference between them?

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 added tests in the core/tests first (as it seemed to me more of a e2e test), and later I noticed, that there are test cases in the __tests__ folder of the protocol, that are covering similar scenarios, so added there as well. But true, they're almost no different

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove one of them in that case to keep this tidy? I think my preference would go to keep them in the credentials module folder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume you mean proofs module folder. Anyway removed those in core/tests.

Copy link
Contributor

@genaris genaris Dec 13, 2022

Choose a reason for hiding this comment

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

Yeah I think this comes from the proofs module, where its root tests directory has some unit tests but protocol/vx includes e2e tests.

I agree on merge these tests and leaving one of each in modules/proofs/__tests__. They can be named 'xxx.e2e.test.ts' like it happens in other modules E2E tests. Later we should open a new PR to harmonize this structure.

Copy link
Contributor

Choose a reason for hiding this comment

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

I assume you mean proofs module folder

yes 😬

@TimoGlastra
Copy link
Contributor

sorry forgot about this one. Code LGTM, just one qeustion about the tests

@TimoGlastra TimoGlastra changed the title feat: Proof Negotiation feat(proofs): proof negotiation Dec 12, 2022
@Przytua Przytua force-pushed the feature/proof-negotiation branch 2 times, most recently from 37dddd5 to 0613f82 Compare December 13, 2022 15:36
@TimoGlastra
Copy link
Contributor

@Przytua if you can update the branch with main I can merge

Signed-off-by: Łukasz Przytuła <lprzytula@gmail.com>
@Przytua
Copy link
Contributor Author

Przytua commented Dec 14, 2022

@Przytua if you can update the branch with main I can merge

@TimoGlastra updated

@TimoGlastra TimoGlastra merged commit c752461 into openwallet-foundation:main Dec 14, 2022
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