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
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.
issuer
(DIDString): The DID of the entity that issued 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. This would be the private key to the wallet address registered in Register DID.
options
(VerificationOptions): Configuration options necessary for the revocation process.
Examples
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);
// Ethereum wallet private key
const walletPrivateKey = "private_key_here";
// 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, walletPrivateKey, options);