A Verifiable Presentation is a presentation of a VC. It allows the holder to present and share their entire or partial information from the VC in a secure manner.

Basic Construction

VerifiablePresentation contains the following 7 fields:

To generate a VerifiablePresentation, you need to go through 2 steps:

  1. First, you need to generate a VerifiablePresentationBuilder via a DID;
  2. Second, generate the VerifiablePresentation by addVC() and build() methods;
export class VerifiablePresentationBuilder {
  #did: Did;
....}

export interface VerifiablePresentation {
  '@context': string[];
  version: VerifiablePresentationVersion;
  type: VerifiablePresentationType[];
  verifiableCredential: VerifiableCredential[];
  id: HexString;
  proof: Proof; // holder's signature
  hasher: [HashType];
}

Note: the id field of VP is calculated via hashing the VC's Digest, the default hash method is Keccak256.

    // generate the proof
    const {
      id,
      signature,
      type: signType
    } = await this.#did.signWithKey(u8aConcat(hash, stringToU8a(challenge)), 'authentication');

Key Methods

A VP contains the following methods to construct a VP from a VC: