UNPKG

@hpke/dhkem-x448

Version:

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

76 lines (75 loc) 2.17 kB
import { Dhkem, KemId, XCurveDhkemPrimitives } from "@hpke/common"; import { x448 } from "./primitives/x448.js"; import { HkdfSha512 } from "./hkdfSha512.js"; export class X448 extends XCurveDhkemPrimitives { constructor(hkdf) { super("X448", 56, x448, hkdf); } } /** * 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(), * }); * ``` */ export class DhkemX448HkdfSha512 extends Dhkem { constructor() { const kdf = new HkdfSha512(); super(KemId.DhkemX448HkdfSha512, new X448(kdf), kdf); /** KemId.DhkemX448HkdfSha512 (0x0021) */ Object.defineProperty(this, "id", { enumerable: true, configurable: true, writable: true, value: 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 }); } }