INNER CODE UNIT · TypeScript
getMyIbePrivateKey
dfinity/examples · motoko/vetkeys/basic_ibe/frontend/src/main.ts:69
async function getMyIbePrivateKey(): Promise<VetKey> {
if (ibePrivateKey) return ibePrivateKey;
if (!myPrincipal) {
throw Error("My principal is not set");
} else {
const transportSecretKey = TransportSecretKey.random();
const actor = await getBasicIbeActor();
const encryptedKey = Uint8Array.from(
await actor.getMyEncryptedIbeKey(
transportSecretKey.publicKeyBytes(),
),
);
ibePrivateKey = EncryptedVetKey.deserialize(
encryptedKey,
).decryptAndVerify(
transportSecretKey,
await getIbePublicKey(),