UNPKG

@hpke/core

Version:

A Hybrid Public Key Encryption (HPKE) core module for various JavaScript runtimes

26 lines (25 loc) 751 B
import { EMPTY, SealError } from "@hpke/common"; import { EncryptionContextImpl } from "./encryptionContext.js"; export class SenderContextImpl extends EncryptionContextImpl { constructor(api, kdf, params, enc) { super(api, kdf, params); Object.defineProperty(this, "enc", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.enc = enc; } async seal(data, aad = EMPTY.buffer) { let ct; try { ct = await this._ctx.key.seal(this.computeNonce(this._ctx), data, aad); } catch (e) { throw new SealError(e); } this.incrementSeq(this._ctx); return ct; } }