This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 162
docs: Presentation Exchange - adds samples #2437
Merged
+709
−275
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# Presentation Exchange | ||
|
||
This document shows how to use [Presentation Exchange](https://identity.foundation/presentation-exchange) by examples. | ||
Code examples can be found [here](example_test.go). | ||
|
||
1. This example demonstrates `predicate` and `limit_disclosure` usage. | ||
The `presentation definition` below requires field `age` to be greater or equal to 18. | ||
Also, we have `limit_disclosure=true` which requires that output data is limited to the entries specified in the `fields` property. | ||
The `predicate` means that the result should be expressed as a boolean value. | ||
```json | ||
{ | ||
"id": "31e2f0f1-6b70-411d-b239-56aed5321884", | ||
"purpose": "To sell you a drink we need to know that you are an adult.", | ||
"input_descriptors": [ | ||
{ | ||
"id": "867bfe7a-5b91-46b2-9ba4-70028b8d9cc8", | ||
"purpose": "Your age should be greater or equal to 18.", | ||
"schema": [ | ||
{ | ||
"uri": "https://www.w3.org/TR/vc-data-model/#types" | ||
} | ||
], | ||
"constraints": { | ||
"limit_disclosure": true, | ||
"fields": [ | ||
{ | ||
"path": [ | ||
"$.age" | ||
], | ||
"filter": { | ||
"type": "integer", | ||
"minimum": 18 | ||
}, | ||
"predicate": "required" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
Let's say we have such a credential in our database. | ||
```json | ||
{ | ||
"@context": [ | ||
"https://www.w3.org/2018/credentials/v1" | ||
], | ||
"age": 21, | ||
"credentialSchema": [ | ||
{ | ||
"id": "https://www.w3.org/TR/vc-data-model/#types" | ||
} | ||
], | ||
"first_name": "Jesse", | ||
"id": "2dc74354-e965-4883-be5e-bfec48bf60c7", | ||
"issuer": "", | ||
"last_name": "Pinkman", | ||
"type": "VerifiableCredential" | ||
} | ||
``` | ||
As a result, we will have the following `verifiable presentation`: | ||
```json | ||
{ | ||
"@context": [ | ||
"https://www.w3.org/2018/credentials/v1", | ||
"https://identity.foundation/presentation-exchange/submission/v1" | ||
], | ||
"presentation_submission": { | ||
"id": "accd5adf-1dbf-4ed9-9ba2-d687476126cb", | ||
"definition_id": "31e2f0f1-6b70-411d-b239-56aed5321884", | ||
"descriptor_map": [ | ||
{ | ||
"id": "867bfe7a-5b91-46b2-9ba4-70028b8d9cc8", | ||
"format": "ldp_vp", | ||
"path": "$.verifiableCredential[0]" | ||
} | ||
] | ||
}, | ||
"type": [ | ||
"VerifiablePresentation", | ||
"PresentationSubmission" | ||
], | ||
"verifiableCredential": [ | ||
{ | ||
"@context": [ | ||
"https://www.w3.org/2018/credentials/v1" | ||
], | ||
"age": true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a different claim than the one originally issued (by the Issuer). This new claim is not covered by cryptographic proof from the Issuer; it is unverifiable. How will this work in practice? |
||
"credentialSchema": [ | ||
{ | ||
"id": "https://www.w3.org/TR/vc-data-model/#types" | ||
} | ||
], | ||
"credentialSubject": null, | ||
"id": "2dc74354-e965-4883-be5e-bfec48bf60c7", | ||
"issuer": "", | ||
"type": "VerifiableCredential" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
As you can see the VP has a credential without `first_name` and `last_name` (because of `limit_disclosure`). | ||
Also, instead of `age`, we have a boolean value (because of `predicate`). | ||
soluchok marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@soluchok
This is a misunderstanding of the spec. The predicate is just criteria that the credential submitted in the presentation must satisfy. It is not a transformation function.