Skip to content
This repository has been archived by the owner on Sep 22, 2023. It is now read-only.

Add presentation request to the "get-matching-credentials" call #100

Merged

Conversation

TheTechmage
Copy link
Contributor

When requesting matching credentials to a presentation, the credentials are returned without any indication of what the verifier requested. This change adds the presentation request to the response which will reduce API requests and unneeded complexity for the prover.

presentation-matching-credentials returned the matching credentials with
no way to link them to the requested attributes. Now, the
presentation-request tag is also sent back

Signed-off-by: Colton Wolkins (Indicio work address) <colton@indicio.tech>
Signed-off-by: Colton Wolkins (Indicio work address) <colton@indicio.tech>
Copy link
Contributor

@dbluhm dbluhm left a comment

Choose a reason for hiding this comment

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

Would love to see this same addition made to the presentation-request-received notification message for feature parity between the two. The notification message is intended to include everything needed to respond to a presentation request but presentation-get-matching-credentials can be used to synchronously receive the same info if the notification is not immediately acted upon.

@TheTechmage
Copy link
Contributor Author

When taking a look at the response generated for the presentation-request-received, it appears as if the presentation-request is already available through the record. This is what it looked like from the prover side when I dumped the response to the logs:

Prepared Message: {
    '@type': 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/admin-holder/0.1/presentation-request-received',
    '@id': 'bbbafd3f-5e13-448a-9d34-a097ae7786d8',
    'record': {
        'presentation_request_dict': {
            '@type': 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/present-proof/1.0/request-presentation',
            '@id': 'ac2e4aab-4ceb-4613-8431-aa6c944dac2d',
            'request_presentations~attach': [{
                '@id': 'libindy-request-presentation-0',
                'mime-type': 'application/json',
                'data': {
                    'base64': 'eyJub25jZSI6ICI3ODk1Nzk1NDAwOTA2NDQwNzUzOTM1OTIiLCAibmFtZSI6ICJUIiwgInZlcnNpb24iOiAiMS4wIiwgInJlcXVlc3RlZF9hdHRyaWJ1dGVzIjogeyJhZ2UiOiB7Im5hbWUiOiAiYWdlIiwgInJlc3RyaWN0aW9ucyI6IFtdfX0sICJyZXF1ZXN0ZWRfcHJlZGljYXRlcyI6IHt9fQ=='
                }
            }],
            'comment': ''
        },
        'initiator': 'external',
        'state': 'request_received',
        'role': 'prover',
        'auto_present': True,
        'thread_id': 'ac2e4aab-4ceb-4613-8431-aa6c944dac2d',
        'updated_at': '2021-10-08 12:23:57.866341Z',
        'presentation_request': {
            'nonce': '789579540090644075393592',
            'name': 'TestVerification',
            'version': '1.0',
            'requested_attributes': {
                'age': {
                    'restrictions': [],
                    'name': 'age'
                }
            },
            'requested_predicates': {}
        },
        'created_at': '2021-10-08 12:23:57.866341Z',
        'connection_id': '101d8303-24a8-4674-bab3-3e7f94c511e1',
        'trace': False,
        'presentation_exchange_id': 'a87ccc1b-8b00-4f7c-b03e-b7bb6fa09c34'
    },
    'matching_credentials': []
}

Should I duplicate that data and return it outside of the record, should I attempt to move it completely out, or is it fine as-is?

@dbluhm
Copy link
Contributor

dbluhm commented Oct 8, 2021

Ah, good catch. Let's trim the data to match the presentation-matching-credentials message. So rather than record, let's include presentation_exchange_id and presentation_request. Following with conventions in other places in the toolbox plugin, we may include a raw_repr field that has the full record contents but this is an optional field whenever used and is only for debug purposes so we don't need to include it right away.

@TheTechmage
Copy link
Contributor Author

Alright, with the new changes that I've made, the response should look something like this. I will get this committed and pushed in a few.

{
    '@type': 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/admin-holder/0.1/presentation-request-received',
    '@id': '90f4911b-682a-4dc1-9394-1ec22090cb38',
    'matching_credentials': [],
    'presentation_request': {
        'nonce': '488366535119219319455940',
        'name': 'Test Verification',
        'version': '1.0',
        'requested_attributes': {
            'age': {
                'restrictions': [],
                'name': 'age'
            }
        },
        'requested_predicates': {}
    },
    'presentation_exchange_id': '9f2cfe3c-a22e-4df0-9b38-2add1593f94f',
    'raw_repr': {
        'presentation_request_dict': {
            '@type': 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/present-proof/1.0/request-presentation',
            '@id': '680bcf40-39d7-4ab0-8c69-3a4a36cc395f',
            'comment': '',
            'request_presentations~attach': [{
                '@id': 'libindy-request-presentation-0',
                'mime-type': 'application/json',
                'data': {
                    'base64': 'eyJub25jZSI6ICI0ODgzNjY1MzUxMTkyMTkzMTk0NTU5NDAiLCAibmFtZSI6ICJUZXN0IFZlcmlmaWNhdGlvbiIsICJ2ZXJzaW9uIjogIjEuMCIsICJyZXF1ZXN0ZWRfYXR0cmlidXRlcyI6IHsiYWdlIjogeyJyZXN0cmljdGlvbnMiOiBbXSwgIm5hbWUiOiAiYWdlIn19LCAicmVxdWVzdGVkX3ByZWRpY2F0ZXMiOiB7fX0='
                }
            }]
        },
        'initiator': 'external',
        'thread_id': '680bcf40-39d7-4ab0-8c69-3a4a36cc395f',
        'updated_at': '2021-10-08 14:18:03.916407Z',
        'created_at': '2021-10-08 14:18:03.916407Z',
        'auto_present': True,
        'presentation_request': {
            'nonce': '488366535119219319455940',
            'name': 'Test Verification',
            'version': '1.0',
            'requested_attributes': {
                'age': {
                    'restrictions': [],
                    'name': 'age'
                }
            },
            'requested_predicates': {}
        },
        'connection_id': '9b387df3-52c4-426f-ac11-d7ae87220723',
        'role': 'prover',
        'trace': False,
        'state': 'request_received',
        'presentation_exchange_id': '9f2cfe3c-a22e-4df0-9b38-2add1593f94f'
    }
}

`presentation-request-received` had all presentation information
included because the raw record information was included. The user of
the API should not rely on the raw record, instead,
`presentation_exchange_id` and `presentation_request` have been pulled
out and are now top-level elements. Similar to the
`presentation-get-matching-credentials` API response.

Signed-off-by: Colton Wolkins (Indicio work address) <colton@indicio.tech>
@TheTechmage TheTechmage force-pushed the feature/matching-creds-pres-req branch from abeb5c4 to a592142 Compare October 8, 2021 15:48
Copy link
Contributor

@dbluhm dbluhm left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@dbluhm dbluhm merged commit 21de362 into hyperledger-archives:main Oct 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants