The bbsDidFromPublicKey function is a synchronous method that generates a DID from a public key which can be either provided by the client or randomly generated.

Function Signature

TypeScript
export async function bbsDidFromPublicKey(
  publicKey: string;
): DID

Parameters

  • publicKey (string): A public key randomly generated by VC SDK or provided by the client.

Returns

  • DID: An object representing the DID with a method and identifier.

Examples

TypeScript
import {
  bbsDidFromPublicKey,
  blsG2PublicKeyFromPrivateKey,
} from "@terminal3/bbs_vc";
import { randomKeyBls } from "@terminal3/vc_core";

const privateKey = randomKeyBls();
const blsPublicKey = blsG2PublicKeyFromPrivateKey(privateKey);
const did = bbsDidFromPublicKey(blsPublicKey);