UNPKG

@hpke/dhkem-x448

Version:

A Hybrid Public Key Encryption (HPKE) module extension for X448

85 lines (84 loc) 2.92 kB
(function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports", "@hpke/common", "./hkdfSha512.js", "./x448.js"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DhkemX448HkdfSha512 = void 0; const common_1 = require("@hpke/common"); const hkdfSha512_js_1 = require("./hkdfSha512.js"); const x448_js_1 = require("./x448.js"); /** * The DHKEM(X448, HKDF-SHA512) for HPKE KEM implementing {@link KemInterface}. * * This class is implemented using * {@link https://github.com/paulmillr/noble-curves | @noble/curves}. * * The instance of this class can be specified to the * {@link https://jsr.io/@hpke/core/doc/~/CipherSuiteParams | CipherSuiteParams} as follows: * * @example Use with `@hpke/core`: * * ```ts * import { * Aes256Gcm, * CipherSuite, * HkdfSha512, * } from "@hpke/core"; * import { DhkemX448HkdfSha512 } from "@hpke/dhkem-x448"; * * const suite = new CipherSuite({ * kem: new DhkemX448HkdfSha512(), * kdf: new HkdfSha512(), * aead: new Aes256Gcm(), * }); * ``` */ class DhkemX448HkdfSha512 extends common_1.Dhkem { constructor() { const kdf = new hkdfSha512_js_1.HkdfSha512(); super(common_1.KemId.DhkemX448HkdfSha512, new x448_js_1.X448(kdf), kdf); /** KemId.DhkemX448HkdfSha512 (0x0021) */ Object.defineProperty(this, "id", { enumerable: true, configurable: true, writable: true, value: common_1.KemId.DhkemX448HkdfSha512 }); /** 64 */ Object.defineProperty(this, "secretSize", { enumerable: true, configurable: true, writable: true, value: 64 }); /** 56 */ Object.defineProperty(this, "encSize", { enumerable: true, configurable: true, writable: true, value: 56 }); /** 56 */ Object.defineProperty(this, "publicKeySize", { enumerable: true, configurable: true, writable: true, value: 56 }); /** 56 */ Object.defineProperty(this, "privateKeySize", { enumerable: true, configurable: true, writable: true, value: 56 }); } } exports.DhkemX448HkdfSha512 = DhkemX448HkdfSha512; });