Verify a Verifiable Presentation for Issued Verifiable Presentation
Verify 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 verifying 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
- An issued verifiable presentation for one or more issued verifiable credentials
Verify a Verifiable Presentation for Issued Verifiable Presentation
Request Format
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 verify a Verifiable Presentation for issued Verifiable Credentials:
- NodeJS
- Java
- PHP
- Add dependencies and set tenant info
const BIDVerifiableCredential = require("blockid-nodejs-helpers/BIDVerifiableCredential.js");
const tenantInfo = {
dns: "<tenant dns>",
communityName: "<community name>",
licenseKey: "<user license key>",
};
- Add verifiable presentation credentials
let vp = {
<"VP request object">
}
- Verify VP
async function verifyPresentation(vp) {
let verifiedVP = await BIDVerifiableCredential.verifyPresentation(
tenantInfo,
vp
);
console.log("verifiedVP::::::", JSON.stringify(verifiedVP));
return verifiedVP;
}
verifyPresentation(vp);
- Set tenant info
BIDTenantInfo tenantInfo = new BIDTenantInfo("<tenant dns>", "<community name>", "<license key>");
- Verify VP
BIDVerifiedVPResponse verifiedVP = BIDVerifiableCredential.verifyPresentation(tenantInfo, vp);
System.out.println("::::: verifiedVP::" + verifiedVP);
- Add dependencies and set tenant info
<?php
require_once("./BIDTenant.php");
require_once("./BIDVerifiableCredential.php");
$bidTenant = BIDTenant::getInstance();
$tenantInfo = array("dns" => "<tenant dns>", "communityName" => "<community>", "licenseKey" => "<license key>");
- Add verifiable presentation credentials
$vp = array(
"<VP request object>"
);
- Verify VP
$verifiedVP = BIDVerifiableCredential::verifyPresentation($tenantInfo, $vp);
?>
Example Request
We've provided a complete example request below for reference:
The data shown here is from the Driver's License VC response Dummy information is provided in this example
- NodeJS
- Java
- PHP
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 vp = {
"@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-ee4306de0000",
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-f60380104crt",
publicKey:
"aRnlolY2VlKAgOsdB2zmry0YzfiXYDt5GkCYyZIX4ITkNpMMuoTR/rKHuzDr7hKBhwBnAm+6LGnyuPSY/WK9XQ==",
proofOfAge: {
ageToProve: 20,
proof: "9da4d87adf481204db95b499a341d375",
encryptedAge: "dcf12fd920a5d31dd5c1134a7a602156",
},
},
proof: {
type: "Ed25519Signature2020",
created: "2022-12-12T05:17:50Z",
verificationMethod:
"did:key:blockid:z6MkvFNv22WzDetLgdzYidhFQJosD5Z9pDr9cmX7RtREuoji",
proofPurpose: "assertionMethod",
proofValue:
"z3sMWYFHUZeo11jysZMX2f2dVpu47Li6uJHYBUYCWR8UjCp3wszbfy6ZBmy9YBj4HAw2kF6zDyagqsUh43zZrRh",
},
statusUrl:
"https://blockid-trial.1kosmos.net/vcs/tenant/63627082d0b7e36525e281aa/community/63627302d0b7e36525e2828d/vc/did:blockid:442ac157-4fb2-4dd3-99b3-ee4306deb5d1/status",
},
],
proof: {
type: "Ed25519Sinature2020",
created: "2022-12-12T05:40:57Z",
verificationMethod:
"did:key:blockid:z6MkvFNv22WzDetLgdzYidCFhQJosD5ZpDr9cmX7RtREuoji",
proofPurpose: "assertionMethod",
proofValue:
"z4g6wvkWFMaiuKtWC8sYc5jkoMbvGhDACEZyFHbfbzfwLqxMyN8xiRieTEonScN7Ehh4KeqAiktyAqjSgLa77Esndg",
},
};
async function verifyPresentation(vp) {
let verifiedVP = await BIDVerifiableCredential.verifyPresentation(
tenantInfo,
vp
);
console.log("verifiedVP::::::", JSON.stringify(verifiedVP));
return verifiedVP;
}
verifyPresentation(vp);
BIDTenantInfo tenantInfo = new BIDTenantInfo("blockid-trial.1kosmos.net", "devx", "9b074532-845b-4c75-ba3e-2b89598ad405");
BIDVerifiedVPResponse verifiedVP = BIDVerifiableCredential.verifyPresentation(tenantInfo, vp);
Map<String, Object> contextData = new HashMap<>();
contextData.put("DriversLicenseCredential", "https://schema.org#DriversLicenseCredential");
contextData.put("documentId", "https://schema.org#documentId");
contextData.put("documentType", "https://schema.org#documentType");
contextData.put("firstName", "https://schema.org#firstName");
contextData.put("lastName", "https://schema.org#lastName");
contextData.put("dob", "https://schema.org#dob");
contextData.put("doe", "https://schema.org#doe");
contextData.put("doi", "https://schema.org#doi");
contextData.put("gender", "https://schema.org#gender");
contextData.put("street", "https://schema.org#street");
contextData.put("city", "https://schema.org#city");
contextData.put("state", "https://schema.org#state");
contextData.put("country", "https://schema.org#country");
contextData.put("zipCode", "https://schema.org#zipCode");
contextData.put("publicKey", "https://schema.org#publicKey");
List<Object> vcContext = new ArrayList<Object>();
vcContext.add("https://www.w3.org/2018/credentials/v1");
vcContext.add(contextData);
vcContext.add("https://w3id.org/security/suites/ed25519-2020/v1");
Map<String, Object> issuer = new HashMap<>();
issuer.put("id", "did:blockid:dmv:USA:WA");
Map<String, Object> credentialSubject = new HashMap<>();
credentialSubject.put("documentId", "W599Z0673B");
credentialSubject.put("documentType", "DL");
credentialSubject.put("firstName", "CAMEMON");
credentialSubject.put("lastName", "ABBA");
credentialSubject.put("dob", "1963-06-20");
credentialSubject.put("doe", "2027-06-20");
credentialSubject.put("doi", "2021-06-05");
credentialSubject.put("gender", "1");
credentialSubject.put("street", "19821 NE 185TH ST");
credentialSubject.put("city", "WOODINVILLE");
credentialSubject.put("state", "WA");
credentialSubject.put("country", "USA");
credentialSubject.put("zipCode", "980779426");
credentialSubject.put("id", "did:2d76124b-f85a-469e-8abe-a37a18927c0d");
credentialSubject.put("publicKey", "zGNlDjMb6XV7xLRZR6XF2XRdUd8eUN3ggn21ejyP5qbn6/q3LnXTBQZA2/4Y63y9/JbSGEsMVkyVH2/hW4YAVQ==");
Map<String, Object> vcProof = new HashMap<>();
vcProof.put("type", "Ed25519Signature2020");
vcProof.put("created", "2023-03-10T09:16:29Z");
vcProof.put("verificationMethod", "did:key:blockid:z6MkuVzvSAYanQX3uttMQjq9atr6KtMExNQFg1NFcn3cNKty");
vcProof.put("proofPurpose", "assertionMethod");
vcProof.put("proofValue", "z3e3YQFuiyMgM2zFHtE4jevWeHNLMg8NEkYNTxC4CsZtgAajmNH2HA4j2kgsJgJEZPTMFEv7SVXhMjYmUa7eaVAYk");
List<Object> type = new ArrayList<Object>();
type.add("VerifiableCredential");
type.add("DriversLicenseCredential");
Map<String, Object> vc = new HashMap<>();
vc.put("@context", vcContext);
vc.put("id", "did:blockid:811d7d59-2f9a-4483-9cf0-745c35bca646");
vc.put("type", type);
vc.put("issuer", issuer);
vc.put("issuanceDate", "2023-03-10T09:16:29.129Z");
vc.put("expirationDate", "2027-06-20T00:00:00.000Z");
vc.put("credentialSubject", credentialSubject);
vc.put("proof", vcProof);
vc.put("statusUrl", "https://blockid-trial.1kosmos.net/vcs/tenant/63627082d0b7e36525e281aa/community/63627302d0b7e36525e2828d/vc/did:blockid:811d7d59-2f9a-4483-9cf0-745c35bca646/status");
List<String> attributes = new ArrayList<String>();
attributes.add("firstName");
attributes.add("lastName");
attributes.add("gender");
attributes.add("street");
attributes.add("city");
attributes.add("state");
attributes.add("country");
attributes.add("zipCode");
List<Object> verifiableCredential = new ArrayList<Object>();
verifiableCredential.add(vc);
Map<String, Object> vpProof = new HashMap<>();
vpProof.put("type", "Ed25519Signature2020");
vpProof.put("created", "2023-03-10T09:16:29Z");
vpProof.put("verificationMethod", "did:key:blockid:z6MkuVzvSAYanQX3uttMQjq9atr6KtMExNQFg1NFcn3cNKty");
vpProof.put("proofPurpose", "assertionMethod");
vpProof.put("proofValue", "z3e3YQFuiyMgM2zFHtE4jevWeHNLMg8NEkYNTxC4CsZtgAajmNH2HA4j2kgsJgJEZPTMFEv7SVXhMjYmUa7eaVAYk");
List<Object> vpContext = new ArrayList<Object>();
vpContext.add("https://www.w3.org/2018/credentials/v1");
vpContext.add("https://w3id.org/security/suites/ed25519-2020/v1");
List<Object> vpType = new ArrayList<Object>();
vpType.add("VerifiablePresentation");
Map<String, Object> vp = new HashMap<>();
vp.put("@context", vpContext);
vp.put("type", vpType);
vp.put("verifiableCredential", verifiableCredential);
vp.put("proof", vpProof);
BIDVerifiedVPResponse verifiedVP = BIDVerifiableCredential.verifyPresentation(tenantInfo, vp);
System.out.println("::::: verifiedVP::" + verifiedVP);
<?php
require_once("./BIDTenant.php");
require_once("./BIDVerifiableCredential.php");
$bidTenant = BIDTenant::getInstance();
$tenantInfo = array("dns" => "blockid-trial.1kosmos.net", "communityName" => "devx", "licenseKey" => "9b074532-845b-4c75-ba3e-2b8950000000");
$vp = array(
"@context" => array(
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
),
"type" => array(
"VerifiablePresentation"
),
"verifiableCredential" => array(
array(
"@context" => array(
"https://www.w3.org/2018/credentials/v1",
array(
"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",
"dob" => "https://schema.org#dob",
"country" => "https://schema.org#country",
"zipCode" => "https://schema.org#zipCode",
"proofOfAge" => "https://schema.org#proofOfAge"
)
),
"id" => "did:blockid:56a12d60-c83a-48c5-827b-73ffef20a1b6",
"type" => array(
"VerifiableCredential",
"DriversLicenseCredential"
),
"issuer" => array(
"id" => "did:blockid:dmv:USA:WA"
),
"issuanceDate" => "2023-02-03T06:56:42.427Z",
"expirationDate" => "2027-06-20T00:00:00.000Z",
"credentialSubject" => array(
"firstName" => "CAMEMON",
"lastName" => "ABBA",
"gender" => "1",
"street" => "19821 NE 185TH ST",
"city" => "WOODINVILLE",
"state" => "WA",
"dob" => "1963-06-20",
"country" => "USA",
"zipCode" => "980779426",
"id" => "did:63dcb02508a8e",
"publicKey" => "zGNlDjMb6XV7xLRZR6XF2XRdUd8eUN3ggn21ejyP5qbn6/q3LnXTBQZA2/4Y63y9/JbSGEsMVkyVH2/hW4YAVQ==",
"proofOfAge" => array(
"ageToProve" => 20,
"proof" => "6418790121ac49649f14a188df00daca",
"encryptedAge" => "1fc9689f17e1e7810687276795a75c06"
)
),
"proof" => array(
"type" => "Ed25519Signature2020",
"created" => "2023-02-03T06:56:42Z",
"verificationMethod" => "did:key:blockid:z6MkpsmsefXGKzeLR9JhpUzcoC6CuaNNnQKGLEniUiasus3b",
"proofPurpose" => "assertionMethod",
"proofValue" => "z4TKisLZubneqFLEQ7JSW5VbDxwhxjrkGZg3k5Ssav5NdKxj9feiEzE5X7rwepXzAmQyfnFKYJcUJp7B8nnyaY6S8"
),
"statusUrl" => "https://blockid-dev.1kosmos.net/vcs/tenant/63627082d0b7e36525e281aa/community/63627302d0b7e36525e2828d/vc/did:blockid:56a12d60-c83a-48c5-827b-73ffef20a1b6/status"
)
),
"proof" => array(
"type" => "Ed25519Signature2020",
"created" => "2023-02-03T07:02:54Z",
"verificationMethod" => "did:key:blockid:z6MkpsmsefXGKzeLR9JhpUzcoC6CuaNNnQKGLEniUiasus3b",
"proofPurpose" => "assertionMethod",
"proofValue" => "z5NWDJgpbFqzPyxLCL4YUGFpDZjX4yoCDVyPN1eViazG6WSqy5azvMJUsZq4PEwZM3pr5S25Eyom6qcfUixtVVACA"
)
);
$verifiedVP = BIDVerifiableCredential::verifyPresentation($tenantInfo, $vp);
?>
Server Responses
Please review the responses below for expected output after verifying a VP. Successful verifications will return a "verified:true" response along with the did
of the credentials that were verified, while failed verifications will return a "verified:false" response with the did
of the credentials that failed.
Responses include dummy data as an example of a typical response
- 200 Successful Verification
- 200 Failed Verification
- 400
- 401
- 417
{
"verified": true,
"vc_status": [
{
"subject": {
"did": "did:2a651b36-c582-46cb-995c-f60380104c70",
"publicKey": "aRnlolY2VlKAgOsdB2zmry0YzfiXYDt5GrCYyZIX4ITkNpMMuoTR/rKHuzDr7hKBhwBnAm+6LGnyuPSY/WK9XQ=="
},
"type": [
"VerifiableCredential",
"DriversLicenseCredential"
],
"_id": "6396b97e028c790013b4c144",
"vcID": "did:blockid:442ac157-4fb2-4dd3-99b3-ee4306deb5d1",
"tenantId": "63627082d0b7e36525e281aa",
"communityId": "63627302d0b7e36525e2828d",
"proof": {
"type": "Ed25519Signature2020",
"created": "2022-12-12T05:17:50Z",
"verificationMethod": "did:key:blockid:z6MkvFNv22WzDetLgdzYidCFQJosD5Z9pDr9cmX7RtREuoji",
"proofPurpose": "assertionMethod",
"proofValue": "z3sMWYFHUZeo11jysZMX2f2dVpubJ47Li6uJHYBUYCWR8UjCp3wszbfy6ZBmy9YBj4HAw2kF6zDyagqsUh43zZrRh"
},
"issueTS": 1670822270,
"expiryTS": 1813449600,
"status": "issued",
"issuer": {
"id": "did:blockid:dmv:USA:WA"
}
}
],
"ageVerified": true
}
}
{
"verified": false,
"vc_status": [
{
"subject": {
"did": "did:2a651b36-c582-46cb-995c-f60380104c70",
"publicKey": "aRnlolY2VlKAgOsdB2zmry0YzfiXYDt5GrCYyZIX4ITkNpMMuoTR/rKHuzDr7hKBhwBnAm+6LGnyuPSY/WK9XQ=="
},
"type": [
"VerifiableCredential",
"DriversLicenseCredential"
],
"_id": "6396b97e028c790013b4c144",
"vcID": "did:blockid:442ac157-4fb2-4dd3-99b3-ee4306deb5d1",
"tenantId": "63627082d0b7e36525e281aa",
"communityId": "63627302d0b7e36525e2828d",
"proof": {
"type": "Ed25519Signature2020",
"created": "2022-12-12T05:17:50Z",
"verificationMethod": "did:key:blockid:z6MkvFNv22WzDetLgdzYidCFQJosD5Z9pDr9cmX7RtREuoji",
"proofPurpose": "assertionMethod",
"proofValue": "z3sMWYFHUZeo11jysZMX2f2dVpubJ47Li6uJHYBUYCWR8UjCp3wszbfy6ZBmy9YBj4HAw2kF6zDyagqsUh43zZrRh"
},
"issueTS": 1670822270,
"expiryTS": 1813449600,
"status": "issued",
"issuer": {
"id": "did:blockid:dmv:USA:WA"
}
}
],
"ageVerified": true
}
{
"error_code": 400,
"message":"Invalid Request"
}
{
"error_code": 401,
"message":"Unauthorized"
}
{
"error_code": 417,
"message":"Expectation Failed"
}