Skip to main content

Request a Verifiable Presentation for Issued Verifiable Credentials

Request a Verifiable Presentation (VP) for one or more issued verifiable credentials using the BlockID SDK. As defined in the W3C Verifiable Credentials Data Model, a verifiable presentation expresses data from one or more Verifiable Credentials (VC) and is packaged in such a way that the authorship of the data is verifiable. If verifiable credentials are presented directly, they become verifiable presentations.

BlockID currently supports requesting VPs for one or more issued credentials. Please see Request a Verifiable Credential (VC) for a Driver's License and Request a Verifiable Credential (VC) for an Employment Card for information on how to request an issued VC.

Prerequisites

Users first need to request a Verifiable Credential. Once a credential has been issued users can verify the credential data.

Please see the pages below for more information on how to request a verifiable credential for a Driver's License or Employment Card:

Request a Verifiable Presentation for an Issued Credential

Parameters

  • dns: tenant domain as shown in the dashboard
  • communityName: tenant community as shown in the dashboard
  • licenseKey: tenant license key as shown in the dashboard
  • issuedVerifiableCredential: issued verifiable credential

Request Format

tip

All requests are plug-and-play, not copy-paste. Please ensure that you are replacing the parameters in the request format below with the actual values

Please use the following format outlined below to request a Verifiable Presentation for issued Verifiable Credentials:

  • Add dependencies and set tenant info
const BIDTenant = require("blockid-nodejs-helpers/BIDTenant.js");
const BIDVerifiableCredential = require("blockid-nodejs-helpers/BIDVerifiableCredential.js");

const tenantInfo = {
dns: "<tenant dns>",
communityName: "<community name>",
licenseKey: "<user license key>",
};
  • Add issued VC
let issuedVerifiableCredential = {
"<issued verified credential request object>"
}
  • Request VP for issued credentials
async function requestVPForCredentials(vcs) {
let issuedVerifiablePresentation =
await BIDVerifiableCredential.requestVPForCredentials(tenantInfo, vcs);

console.log(
"issuedVerifiablePresentation::::::",
JSON.stringify(issuedVerifiablePresentation)
);

return issuedVerifiablePresentation;
}
  • Define VC attributes
tip

Users can set which VC attributes they wish to verify. Only the attributes that are listed will be returned in the response.

let vcs = [
{
vc: issuedVerifiableCredential,
attributes: [
"firstName",
"lastName",
"gender",
"street",
"city",
"state",
"country",
"zipCode",
],
ageToProve: "20",
},
];
requestVPForCredentials(vcs);

Example Request

We've provided a complete example request below for reference:

tip

The data shown here is from the Driver's License VC response Dummy information is provided in this example

const BIDTenant = require("blockid-nodejs-helpers/BIDTenant.js");
const BIDVerifiableCredential = require("blockid-nodejs-helpers/BIDVerifiableCredential.js");

let tenantInfo = {
dns: "blockid-trial.1kosmos.net",
communityName: "devx",
licenseKey: "9b074532-845b-4c75-ba3e-2b8950000000",
};

let issuedVerifiableCredential = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
{
DriversLicenseCredential: "https://schema.org#DriversLicenseCredential",
documentId: "https://schema.org#documentId",
documentType: "https://schema.org#documentType",
firstName: "https://schema.org#firstName",
lastName: "https://schema.org#lastName",
dob: "https://schema.org#dob",
doe: "https://schema.org#doe",
doi: "https://schema.org#doi",
gender: "https://schema.org#gender",
street: "https://schema.org#street",
city: "https://schema.org#city",
state: "https://schema.org#state",
country: "https://schema.org#country",
zipCode: "https://schema.org#zipCode",
publicKey: "https://schema.org#publicKey",
},
"https://w3id.org/security/suites/ed25519-2020/v1",
],
id: "did:blockid:442ac157-4fb2-4dd3-99b3-ee4306deb5d1",
type: ["VerifiableCredential", "DriversLicenseCredential"],
issuer: { id: "did:blockid:dmv:USA:WA" },
issuanceDate: "2022-12-12T05:17:50.149Z",
expirationDate: "2027-06-20T00:00:00.000Z",
credentialSubject: {
documentId: "W599Z0673B",
documentType: "DL",
firstName: "CAMEMON",
lastName: "ABBA",
dob: "1963-06-20",
doe: "2027-06-20",
doi: "2021-06-05",
gender: "1",
street: "19821 NE 185TH ST",
city: "WOODINVILLE",
state: "WA",
country: "USA",
zipCode: "980779426",
id: "did:2a651b36-c582-46cb-995c-f60380104c70",
publicKey:
"aRnlolY2VlKAgOsdB2zmry0YzfiXYDt5GrCYyZIX4ITkNpMMuoTR/rKHuzDr7hKBhwBnAm+6LGnyuPSY/WK9XQ==",
},
proof: {
type: "Ed25519Signature2020",
created: "2022-12-12T05:17:50Z",
verificationMethod:
"did:key:blockid:z6MkvFNv22WzDetLgdzYidCFQJosD5Z9pDr9cmX7RtREuoji",
proofPurpose: "assertionMethod",
proofValue:
"z3sMWYFHUZeo11jysZMX2f2dVpubJ47Li6uJHYBUYCWR8UjCp3wszbfy6ZBmy9YBj4HAw2kF6zDyagqsUh43zZrRh",
},
statusUrl:
"https://blockid-trial.1kosmos.net/vcs/tenant/63627082d0b7e36525e281aa/community/63627302d0b7e36525e2828d/vc/did:blockid:442ac157-4fb2-4dd3-99b3-ee4306deb5d1/status",
};

async function requestVPForCredentials(vcs) {
let issuedVerifiablePresentation =
await BIDVerifiableCredential.requestVPForCredentials(tenantInfo, vcs);

console.log(
"issuedVerifiablePresentation::::::",
JSON.stringify(issuedVerifiablePresentation)
);

return issuedVerifiablePresentation;
}

let vcs = [
{
vc: issuedVerifiableCredential,
attributes: [
"firstName",
"lastName",
"gender",
"street",
"city",
"state",
"country",
"zipCode",
],
ageToProve: "20",
},
];
requestVPForCredentials(vcs);

Server Responses

Please review the responses below for expected output after requesting a VP. A successful request will include a "type:VerifiablePresentation" response object.

tip

Responses include dummy data as an example of a typical response

200 OK
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"type": [
"VerifiablePresentation"
],
"verifiableCredential": [
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
{
"DriversLicenseCredential": "https://schema.org#DriversLicenseCredential",
"publicKey": "https://schema.org#publicKey",
"firstName": "https://schema.org#firstName",
"lastName": "https://schema.org#lastName",
"gender": "https://schema.org#gender",
"street": "https://schema.org#street",
"city": "https://schema.org#city",
"state": "https://schema.org#state",
"country": "https://schema.org#country",
"zipCode": "https://schema.org#zipCode",
"proofOfAge": "https://schema.org#proofOfAge"
}
],
"id": "did:blockid:442ac157-4fb2-4dd3-99b3-ee4306deb5d1",
"type": [
"VerifiableCredential",
"DriversLicenseCredential"
],
"issuer": {
"id": "did:blockid:dmv:USA:WA"
},
"issuanceDate": "2022-12-12T05:17:50.149Z",
"expirationDate": "2027-06-20T00:00:00.000Z",
"credentialSubject": {
"firstName": "CAMEMON",
"lastName": "ABBA",
"gender": "1",
"street": "19821 NE 185TH ST",
"city": "WOODINVILLE",
"state": "WA",
"country": "USA",
"zipCode": "980779426",
"id": "did:2a651b36-c582-46cb-995c-f60380104c70",
"publicKey": "aRnlolY2VlKAgOsdB2zmry0YzfiXYDt5GrCYyZIX4ITkNpMMuoTR/rKHuzDr7hKBhwBnAm+6LGnyuPSY/WK9XQ==",
"proofOfAge": {
"ageToProve": 20,
"proof": "9da4d87adf481204db95b499a341d375",
"encryptedAge": "dcf12fd920a5d31dd5c1134a7a602156"
}
},
"proof": {
"type": "Ed25519Signature2020",
"created": "2022-12-12T05:17:50Z",
"verificationMethod": "did:key:blockid:z6MkvFNv22WzDetLgdzYidCFQJosD5Z9pDr9cmX7RtREuoji",
"proofPurpose": "assertionMethod",
"proofValue": "z3sMWYFHUZeo11jysZMX2f2dVpubJ47Li6uJHYBUYCWR8UjCp3wszbfy6ZBmy9YBj4HAw2kF6zDyagqsUh43zZrRh"
},
"statusUrl": "https://blockid-trial.1kosmos.net/vcs/tenant/63627082d0b7e36525e00000/community/63627302d0b7e36525e00000/vc/did:blockid:442ac157-4fb2-4dd3-99b3-ee4306deb5d1/status"
}
],
"proof": {
"type": "Ed25519Signature2020",
"created": "2022-12-12T05:40:57Z",
"verificationMethod": "did:key:blockid:z6MkvFNv22WzDetLgdzYidCFQJosD5Z9pDr9cmX7RtREuoji",
"proofPurpose": "assertionMethod",
"proofValue": "z4g6wvkWFMaiuKtWC8sYc5jkoMbvGhDACEZyFHbfbzfwLqxMyN8xiRieTEonScN7E4KeqAiktyAqjSgLaY77Esndg"
}
}