@hpke/core
Version:
A Hybrid Public Key Encryption (HPKE) core module for various JavaScript runtimes
40 lines • 1.34 kB
TypeScript
import type { Exporter } from "./exporter.js";
/**
* The encryption context interface for a recipient and a sender.
*/
export interface EncryptionContext extends Exporter {
/**
* Encrypts data.
*
* If the error occurred, throws `SealError` | `MessageLimitReachedError`.
*
* @param data A plain text as bytes to be encrypted.
* @param aad Additional authenticated data as bytes fed by an application.
* @returns A cipher text as bytes.
* @throws {@link MessageLimitReachedError}, {@link SealError}
*/
seal(data: ArrayBuffer, aad?: ArrayBuffer): Promise<ArrayBuffer>;
/**
* Decrypts data.
*
* If the error occurred, throws `OpenError`.
*
* @param data An encrypted text as bytes to be decrypted.
* @param aad Additional authenticated data as bytes fed by an application.
* @returns A decrypted plain text as bytes.
* @throws {@link OpenError}
*/
open(data: ArrayBuffer, aad?: ArrayBuffer): Promise<ArrayBuffer>;
}
/**
* The recipient encryption context.
*/
export type RecipientContext = EncryptionContext;
/**
* The sender encryption context.
*/
export interface SenderContext extends EncryptionContext {
/** The encapsulated key generated by the sender. */
enc: ArrayBuffer;
}
//# sourceMappingURL=encryptionContext.d.ts.map