# README

Presentation Exchange

This document shows how to use Presentation Exchange by examples. Code examples can be found here.

  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.
{
  "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.

{
  "@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:

{
  "@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,
      "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).

# Functions

WithCredentialOptions used when parsing the embedded credentials.
WithDisableSchemaValidation used to disable schema validation.
WithMergedSubmission provides a presentation submission that's external to the Presentations being matched, which contains the descriptor mapping for each Presentation.
WithMergedSubmissionMap provides a presentation submission that's external to the Presentations being matched, which contains the descriptor mapping for each Presentation.
WithSDCredentialOptions used when applying selective disclosure.
WithSelectiveDisclosureApply enables selective disclosure apply on resulting VC.

# Constants

All rule`s value.
CredentialApplicationJSONLDContextIRI is the JSONLD context of credential application which also contains presentation submission details.
CredentialApplicationJSONLDType is the JSONLD type of credential application.
DefinitionJSONSchemaV1 is the JSONSchema definition for PresentationDefinition.
DefinitionJSONSchemaV2 is the JSONSchema definition for PresentationDefinition.
FormatJWT presentation exchange format.
FormatJWTVC presentation exchange format.
FormatJWTVP presentation exchange format.
FormatLDP presentation exchange format.
FormatLDPVC presentation exchange format.
FormatLDPVP presentation exchange format.
Pick rule`s value.
Preferred predicate`s value.
PresentationSubmissionJSONLDContextIRI is the JSONLD context of presentation submissions.
PresentationSubmissionJSONLDType is the JSONLD type of presentation submissions.
Required predicate`s value.

# Variables

ErrNoCredentials when any credentials do not satisfy requirements.

# Structs

Constraints describes InputDescriptor`s Constraints field.
Field describes Constraints`s Fields field.
Filter describes filter.
Format describes PresentationDefinition`s Format field.
Holder describes Constraints`s holder object.
InputDescriptor input descriptors.
InputDescriptorMapping maps an InputDescriptor to a verifiable credential pointed to by the JSONPath in `Path`.
JwtType contains alg.
LdpType contains proof_type.
MatchedInputDescriptor contains information about VCs that matched an input descriptor of presentation definition.
MatchedSubmissionRequirement contains information about VCs that matched a presentation definition.
MatchOptions is a holder of options that can set when matching a submission against definitions.
MatchValue holds a matched credential from PresentationDefinition.Match, along with the ID of the presentation that held the matched credential.
PresentationDefinition presentation definitions (https://identity.foundation/presentation-exchange/).
PresentationSubmission is the container for the descriptor_map: https://identity.foundation/presentation-exchange/#presentation-submission.
Schema input descriptor schema.
SubmissionRequirement describes input that must be submitted via a Presentation Submission to satisfy Verifier demands.

# Interfaces

No description provided by the author

# Type aliases

MatchOption is an option that sets an option for when matching.
MatchRequirementsOpt is the MatchSubmissionRequirement option.
No description provided by the author
No description provided by the author