INNER CODE UNIT · TypeScript

encrypt

dfinity/examples · motoko/vetkeys/basic_ibe/frontend/src/main.ts:55

async function encrypt(
    cleartext: Uint8Array,
    receiver: Principal,
): Promise<Uint8Array> {
    const publicKey = await getIbePublicKey();
    const ciphertext = IbeCiphertext.encrypt(
        publicKey,
        IbeIdentity.fromPrincipal(receiver),
        cleartext,
        IbeSeed.random(),
    );
    return ciphertext.serialize();
}

async function getMyIbePrivateKey(): Promise<VetKey> {
    if (ibePrivateKey) return ibePrivateKey;

    if (!myPrincipal) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…