INNER CODE UNIT · TypeScript
getIbePublicKey
dfinity/examples · motoko/vetkeys/basic_ibe/frontend/src/main.ts:46
async function getIbePublicKey(): Promise<DerivedPublicKey> {
if (ibePublicKey) return ibePublicKey;
const actor = await getBasicIbeActor();
ibePublicKey = DerivedPublicKey.deserialize(
new Uint8Array(await actor.getIbePublicKey()),
);
return ibePublicKey;
}
async function encrypt(
cleartext: Uint8Array,
receiver: Principal,
): Promise<Uint8Array> {
const publicKey = await getIbePublicKey();
const ciphertext = IbeCiphertext.encrypt(
publicKey,
IbeIdentity.fromPrincipal(receiver),
cleartext,