Skip to content

Update credential

Important

Before you update proof and credential subject please ensure you have created proof(link).

Updating Proof and Credential Subject for SD

Update the VC with the new proof and credential subject, containing only the revealed messages requested by the verifier. This step finalises the selective disclosure by ensuring that the VC only includes specific information authorised for sharing.

const newVC = JSON.parse(JSON.stringify(vc));
newVC["proof"] = {
  type: "BbsBlsSignature2020",
  created: "2020-04-26T04:21:07Z",
  verificationMethod: vcProof?.verificationMethod,
  proofPurpose: "assertionMethod",
  proofValue: Buffer.from(proof).toString("base64"),
  nonce: nonce.toString("base64"),
};
const newCredentialSubject = {};
selectiveDisclosureKeys.forEach((key: string) => {
  newCredentialSubject[key] = vc.credentialSubject[key];
});

newVC["credentialSubject"] = newCredentialSubject;

The updated VC, now tailored for selective disclosure, is ready for verification by the verifier. This streamlined process ensures privacy and security in the disclosure of information.