The revokeVC function is an asynchronous method designed to revoke a Verifiable Credential (VC) using blockchain technology. It interacts with a smart contract on a blockchain to mark a credential as revoked.

Function Signature

TypeScript
async function revokeVC(
  vcId: string,
  issuer: DIDString,
  privateKey: string,
  options: VerificationOptions
): Promise<void>;

Parameters

  • vcId (string): The identifier of the Verifiable Credential to be revoked. This is typically a hash of the credential.
  • privateKey (string): The private key of the entity that is authorized to revoke the credential. This key must correspond to a wallet that has permission to interact with the revocation registry contract.
  • options (VerificationOptions): Configuration options necessary for the revocation process,

Examples

TypeScript
import { BbsDID, createBbsCredential } from "@terminal3/bbs_vc";
import { revokeVC } from "@terminal3/revoke_vc";
import { DID, type VerificationOptions } from "@terminal3/vc_core";
import { verifyVc } from "@terminal3/verify_vc";
import { ethers } from "ethers";

// Issuer's private key and setup
const issuerPrivateKey = "private_key_here";
const issuer = new BbsDID(issuerPrivateKey);

// Holder's DID
const holderDid = new DID("ethr", "Ox....");

// Creating a credential with BBS+ signature
const claims = { kyc: "passed" };
const revocationRegistryAddress = "0x77Fb69B24e4C659CE03fB129c19Ad591374C349e";
const didRegistryAddress = "0x312C15922c22B60f5557bAa1A85F2CdA4891C39a";
const provider = new ethers.JsonRpcProvider(process.env.TEST_BLOCKCHAIN_URL);
const options = {
  revocationRegistryAddress,
  provider,
  didRegistryAddress,
} as unknown as VerificationOptions;

const credential = await createBbsCredential(
  issuer,
  holderDid,
  claims,
  ["KYCCredential"],
  undefined,
  undefined,
  options
);
console.log("Credential Issued:", credential);

// Verifying the credential
const verificationResult = await verifyVc(credential);
console.log("Verification Result:", verificationResult);

// Optionally revoke the credential
await revokeVC(credential.id, issuer.did, issuerPrivateKey, options);