# Credential Exchange
> Stephen Curran - based on the Indy Agent WG call from 2019.03.20, I propose that we use the following messages for the 0.1 Version of the Credential Exchange Protocol. This is to make some things work for IIW. The in-process HIPE will be the ongoing HIPE that will be (eventually accepted).
>
> Update - 2019.03.28 - We are not going to be using the `proposal` messages for our IIW demo, and so have indicated they are off the table in this document. We look forward to adding them post-IIW.
>
## Issue Credential Protocol
The process can begin with either a `credential-offer` or a `credential-proposal` message. In some cases - and specifically, the case of Indy Catalyst Credential Registry (aka OrgBook), many credentials can be issued (via `credential-issue` messages) based on the same `credential-request`.
The thread decorator is implied for all messages except the first.
The <libindy json string> element is used in most messages and is the string returned from libindy for the given purpose - an escaped JSON string. The agent must process the string if there is a need to extract a data element from the JSON - for example to get the `cred-def-id` from the `credential-offer`.
Acknowledgments and Errors should be signalled via adopting the standard `ack` and `problem-report` message types, respectively.
---
### Credential Offer
The `credential_preview` attribute is optional.
```jsonld
{
"@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/credential-issuance/0.1/credential-offer",
"@id": "<uuid-offer>",
"comment": "some comment",
"credential_preview": <json-ld object>,
"offer_json": <libindy json string>
}
```
The `credential_preview` JSON-LD object will be:
``` jsonld
{
"@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/credential-issuance/0.1/credential-preview",
"@context": string,
"@id": string,
"attributes": [
{
"name": "attribute name",
"mime-type": "type",
"value": "value"
},
...
]
}
```
### ~~Credential Proposal~~
~~This is a message from the Prover to the Issuer indicating the credential data wanted. This message can be sent in response to a credit offer or to initiate a request.~~
~~**IDEA**: If the message is sent to initiate a request, the data in the comment or credential preview (*which one makes sense? either?*) could be used as input parameters for a search to get the data for a credential.~~
> ~~Use Case: When requesting a "verified email address" credential, the proposal is used to send to the issuer the email address to be verified.~~
~~The `credential_preview` attribute is optional~~
```jsonld
{
"@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/credential-issuance/0.1/credential-proposal",
"@id": "<uuid-offer>",
"comment": "some comment",
"credential_preview": "<json-ld object>",
"proposal" : {
"cred_def_id": string,
"schema_id": string
}
}
```
~~Either a cred_def_id or a schema_id can be included, but there should not be both.~~
### Credential Request
```jsonld
{
"@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/credential-issuance/0.1/credential-request",
"@id": "<uuid-request>",
"comment": "some comment",
"request": <libindy json string>
}
```
### Credential Issue
``` jsonld
{
"@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/credential-issuance/0.1/credential-issue",
"@id": "<uuid-credential>",
"issue": <libindy json string>
}
```
---
## Presentation Protocol
> Switch terminology now to use "Presentation" instead of "Proof" to align with W3C.
The message family to initiate a presentation. Either party (prover or verifier) can initiate the process.
The thread decorator is implied on every message other than the first message.
The `ack` and `problem-report` messages are to be adopted by this message family.
### Presentation Request
```jsonld
{
"@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/credential-presentation/0.1/presentation-request",
"@id": "<uuid-request>",
"comment": "some comment",
"request": <libindy json string>
}
```
### ~~Presentation Proposal~~
~~Negotiation message from the Prover to the Verifier. This could be used to initiate a presentation or to provide a counter offer to a presentation request.~~
```jsonld
{
"@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/credential-presentation/0.1/presentation-proposal",
"@id": "<uuid-request>",
"comment": "some comment",
"proposalemail ": <libindy json string>
}
```
### Credential-Presentation
```jsonld
{
"@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/credential-presentation/0.1/credential-presentation",
"@id": "<uuid-presentation>",
"comment": "some comment",
"presentation": <libindy json string>
}
```