@hpke/dhkem-x448
Version:
A Hybrid Public Key Encryption (HPKE) module extension for X448
71 lines (70 loc) • 2.01 kB
JavaScript
import { Dhkem, KemId } from "@hpke/common";
import { HkdfSha512 } from "./hkdfSha512.js";
import { X448 } from "./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(),
* });
* ```
*/
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
});
}
}