UNPKG

@hpke/core

Version:

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

16 lines (15 loc) 477 B
import { EMPTY, OpenError } from "@hpke/common"; import { EncryptionContextImpl } from "./encryptionContext.js"; export class RecipientContextImpl extends EncryptionContextImpl { async open(data, aad = EMPTY.buffer) { let pt; try { pt = await this._ctx.key.open(this.computeNonce(this._ctx), data, aad); } catch (e) { throw new OpenError(e); } this.incrementSeq(this._ctx); return pt; } }