Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hpke/dhkem-x448

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hpke/dhkem-x448 - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

3

esm/src/errors.d.ts
/**
* The base error class of hpke-js.
*/
declare class HpkeError extends Error {
export declare class HpkeError extends Error {
constructor(e: unknown);

@@ -67,2 +67,1 @@ }

}
export {};
/**
* The base error class of hpke-js.
*/
class HpkeError extends Error {
export class HpkeError extends Error {
constructor(e) {

@@ -18,8 +18,2 @@ let message;

this.name = this.constructor.name;
if (this.message === "") {
this.message = this.name;
}
else {
this.message = this.name + ": " + this.message;
}
}

@@ -26,0 +20,0 @@ }

@@ -10,5 +10,8 @@ /**

};
/**
* The type of the Supported HPKE modes.
*/
export type Mode = typeof Mode[keyof typeof Mode];
/**
* Supported Key Encapsulation Mechanisms (KEMs).
* Supported Key Encapsulation Mechanism (KEM) identifiers.
*

@@ -25,2 +28,7 @@ * @deprecated Use {@link KdfId} instead.

};
/**
* The type of the supported KEM identifiers.
*
* @deprecated Use {@link KdfId} instead.
*/
export type Kem = typeof Kem[keyof typeof Kem];

@@ -38,5 +46,8 @@ /**

};
/**
* The type of the supported KEM identifiers.
*/
export type KemId = typeof KemId[keyof typeof KemId];
/**
* Supported Key Derivation Functions (KDFs).
* Supported Key Derivation Function (KDF) identifiers.
*

@@ -50,2 +61,7 @@ * @deprecated Use {@link KdfId} instead.

};
/**
* The type of the supported KDF identifiers.
*
* @deprecated Use {@link KdfId} instead.
*/
export type Kdf = typeof Kdf[keyof typeof Kdf];

@@ -60,5 +76,8 @@ /**

};
/**
* The type of the supported KDF identifiers.
*/
export type KdfId = typeof KdfId[keyof typeof KdfId];
/**
* Supported Authenticated Encryption with Associated Data (AEAD) Functions.
* Supported Authenticated Encryption with Associated Data (AEAD) identifiers.
*

@@ -74,4 +93,10 @@ * @deprecated Use {@link AeadId} instead.

/**
* Supported Authenticated Encryption with Associated Data (AEAD) function identifiers.
* The type of the supported AEAD identifiers.
*
* @deprecated Use {@link AeadId} instead.
*/
export type Aead = typeof Aead[keyof typeof Aead];
/**
* Supported Authenticated Encryption with Associated Data (AEAD) identifiers.
*/
export declare const AeadId: {

@@ -83,2 +108,5 @@ readonly Aes128Gcm: 1;

};
/**
* The type of the supported AEAD identifiers.
*/
export type AeadId = typeof AeadId[keyof typeof AeadId];

@@ -11,3 +11,3 @@ /**

/**
* Supported Key Encapsulation Mechanisms (KEMs).
* Supported Key Encapsulation Mechanism (KEM) identifiers.
*

@@ -29,3 +29,3 @@ * @deprecated Use {@link KdfId} instead.

/**
* Supported Key Derivation Functions (KDFs).
* Supported Key Derivation Function (KDF) identifiers.
*

@@ -44,3 +44,3 @@ * @deprecated Use {@link KdfId} instead.

/**
* Supported Authenticated Encryption with Associated Data (AEAD) Functions.
* Supported Authenticated Encryption with Associated Data (AEAD) identifiers.
*

@@ -56,4 +56,4 @@ * @deprecated Use {@link AeadId} instead.

/**
* Supported Authenticated Encryption with Associated Data (AEAD) function identifiers.
* Supported Authenticated Encryption with Associated Data (AEAD) identifiers.
*/
export const AeadId = Aead;

@@ -51,3 +51,3 @@ import { KdfId } from "../identifiers.js";

/**
* -
* Extracts a pseudorandom key and expand it to a specified length keying material.
*

@@ -54,0 +54,0 @@ * @param salt An additional random byte string.

@@ -21,2 +21,7 @@ import type { RecipientContextParams } from "./recipientContextParams.js";

*
* @remarks
*
* Basically, you don't need to call this function directly.
* This function is called by{@link CipherSuite} internally.
*
* @param api A SubtleCrypto API.

@@ -28,3 +33,8 @@ */

*
* @returns A key pair.
* @remarks
*
* If the error occurred, throws {@link NotSupportedError}.
*
* @returns A key pair generated.
* @throws {@link NotSupportedError}
*/

@@ -35,4 +45,9 @@ generateKeyPair(): Promise<CryptoKeyPair>;

*
* @remarks
*
* If the error occurred, throws {@link DeriveKeyPairError}.
*
* @param ikm An input keying material.
* @returns A key pair.
* @returns A key pair derived.
* @throws {@link DeriveKeyPairError}
*/

@@ -43,4 +58,9 @@ deriveKeyPair(ikm: ArrayBuffer): Promise<CryptoKeyPair>;

*
* @remarks
*
* If the error occurred, throws {@link SerializeError}.
*
* @param key A CryptoKey.
* @returns A key as bytes.
* @throws {@link SerializeError}
*/

@@ -51,13 +71,30 @@ serializePublicKey(key: CryptoKey): Promise<ArrayBuffer>;

*
* @remarks
*
* If the error occurred, throws {@link DeserializeError}.
*
* @param key A key as bytes.
* @returns A CryptoKey.
* @throws {@link DeserializeError}
*/
deserializePublicKey(key: ArrayBuffer): Promise<CryptoKey>;
/**
* Imports a key for the KEM.
* Imports a public or private key and converts to a {@link CryptoKey}.
*
* @param format An imput KEM key format.
* @param key A KEM key.
* @param isPublic The indicator whether the KEM key is public or not.
* @returns A CryptoKey.
* @remarks
*
* Since key parameters for {@link createSenderContext} or {@link createRecipientContext}
* are {@link CryptoKey} format, you have to use this function to convert provided keys
* to {@link CryptoKey}.
*
* Basically, this is a thin wrapper function of
* [SubtleCrypto.importKey](https://www.w3.org/TR/WebCryptoAPI/#dfn-SubtleCrypto-method-importKey).
*
* If the error occurred, throws {@link DeserializeError}.
*
* @param format For now, `'raw'` and `'jwk'` are supported.
* @param key A byte string of a raw key or A {@link JsonWebKey} object.
* @param isPublic The indicator whether the provided key is a public key or not, which is used only for `'raw'` format.
* @returns A public or private CryptoKey.
* @throws {@link DeserializeError}
*/

@@ -70,4 +107,9 @@ importKey(format: "raw" | "jwk", key: ArrayBuffer | JsonWebKey, isPublic: boolean): Promise<CryptoKey>;

*
* @remarks
*
* If the error occurred, throws {@link EncapError}.
*
* @param params A set of parameters for the sender context.
* @returns A shared secret and an encapsulated key as the output of the encapsulation step.
* @throws {@link EncapError}
*/

@@ -81,6 +123,11 @@ encap(params: SenderContextParams): Promise<{

*
* @remarks
*
* If the error occurred, throws {@link DecapError}.
*
* @param params A set of parameters for the recipient context.
* @returns A shared secret as the output of the decapsulation step.
* @throws {@link DecapError}
*/
decap(params: RecipientContextParams): Promise<ArrayBuffer>;
}
import { KemId } from "../identifiers.js";
import { Dhkem } from "./dhkem.js";
/**
* The DHKEM(X448, HKDF-SHA512).
*
* @remarks
*
* 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://deno.land/x/hpke/core/mod.ts?s=CipherSuiteParams | CipherSuiteParams} as follows:
*
* @example
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import { DhkemX448HkdfSha512 } from "https://deno.land/x/hpke/x/dhkem-x448/mod.ts";
* const suite = new CipherSuite({
* kem: new DhkemX448HkdfSha512(),
* kdf: KdfId.HkdfSha512,
* aead: AeadId.Aes128Gcm,
* });
* ```
*/
export declare class DhkemX448HkdfSha512 extends Dhkem {

@@ -4,0 +26,0 @@ readonly id: KemId;

@@ -5,2 +5,24 @@ import { KemId } from "../identifiers.js";

import { X448 } from "./dhkemPrimitives/x448.js";
/**
* The DHKEM(X448, HKDF-SHA512).
*
* @remarks
*
* 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://deno.land/x/hpke/core/mod.ts?s=CipherSuiteParams | CipherSuiteParams} as follows:
*
* @example
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import { DhkemX448HkdfSha512 } from "https://deno.land/x/hpke/x/dhkem-x448/mod.ts";
* const suite = new CipherSuite({
* kem: new DhkemX448HkdfSha512(),
* kdf: KdfId.HkdfSha512,
* aead: AeadId.Aes128Gcm,
* });
* ```
*/
export class DhkemX448HkdfSha512 extends Dhkem {

@@ -7,0 +29,0 @@ constructor() {

@@ -6,3 +6,3 @@ {

"name": "@hpke/dhkem-x448",
"version": "1.0.1",
"version": "1.0.2",
"description": "A Hybrid Public Key Encryption (HPKE) module extension for X448",

@@ -9,0 +9,0 @@ "repository": {

@@ -9,3 +9,3 @@ <h1 align="center">@hpke/dhkem-x448</h1>

[Doc(deno.land)](https://doc.deno.land/https://deno.land/x/hpke/x/dhkem-x448/mod.ts)/[Doc(pages, only for the latest version)](https://dajiaji.github.io/hpke-js/dhkem-x448/docs/)
Documentation: [deno.land](https://doc.deno.land/https://deno.land/x/hpke/x/dhkem-x448/mod.ts) | [pages(only for the latest ver.)](https://dajiaji.github.io/hpke-js/dhkem-x448/docs/)

@@ -35,4 +35,4 @@ </div>

<script type="module">
import * as hpke from "https://esm.sh/@hpke/core@1.0.1";
import * as x448 from "https://esm.sh/@hpke/dhkem-x448@1.0.1";
import * as hpke from "https://esm.sh/@hpke/core@1.0.2";
import * as x448 from "https://esm.sh/@hpke/dhkem-x448@1.0.2";
// ...

@@ -54,4 +54,4 @@ </script>

<script type="module">
import * as hpke from "https://unpkg.com/@hpke/core@1.0.1/esm/mod.js";
import * as x448 from "https://unpkg.com/@hpke/dhkem-x448@1.0.1/esm/mod.js";
import * as hpke from "https://unpkg.com/@hpke/core@1.0.2/esm/mod.js";
import * as x448 from "https://unpkg.com/@hpke/dhkem-x448@1.0.2/esm/mod.js";
// ...

@@ -81,4 +81,4 @@ </script>

// use a specific version
import * as hpke from "https://deno.land/x/hpke@1.0.1/core/mod.ts";
import * as x448 from "https://deno.land/x/hpke@1.0.1/x/dhkem-x448/mod.ts";
import * as hpke from "https://deno.land/x/hpke@1.0.2/core/mod.ts";
import * as x448 from "https://deno.land/x/hpke@1.0.2/x/dhkem-x448/mod.ts";

@@ -111,4 +111,4 @@ // use the latest stable version

<script type="module">
import { KdfId, AeadId, CipherSuite } from "https://esm.sh/@hpke/core@1.0.1";
import { DhkemX448HkdfSha512 } from "https://esm.sh/@hpke/dhkem-x448@1.0.1";
import { KdfId, AeadId, CipherSuite } from "https://esm.sh/@hpke/core@1.0.2";
import { DhkemX448HkdfSha512 } from "https://esm.sh/@hpke/dhkem-x448@1.0.2";

@@ -200,4 +200,4 @@ globalThis.doHpke = async () => {

```js
import { KdfId, AeadId, CipherSuite } from "https://deno.land/x/hpke@1.0.1/core/mod.ts";
import { DhkemX448HkdfSha512 } from "https://deno.land/x/hpke@1.0.1/x/dhkem-x448/mod.ts";
import { KdfId, AeadId, CipherSuite } from "https://deno.land/x/hpke@1.0.2/core/mod.ts";
import { DhkemX448HkdfSha512 } from "https://deno.land/x/hpke@1.0.2/x/dhkem-x448/mod.ts";

@@ -204,0 +204,0 @@ async function doHpke() {

/**
* The base error class of hpke-js.
*/
declare class HpkeError extends Error {
export declare class HpkeError extends Error {
constructor(e: unknown);

@@ -67,2 +67,1 @@ }

}
export {};

@@ -12,3 +12,3 @@ (function (factory) {

Object.defineProperty(exports, "__esModule", { value: true });
exports.NotSupportedError = exports.DeriveKeyPairError = exports.MessageLimitReachedError = exports.OpenError = exports.SealError = exports.ExportError = exports.DecapError = exports.EncapError = exports.DeserializeError = exports.SerializeError = exports.ValidationError = exports.InvalidParamError = void 0;
exports.NotSupportedError = exports.DeriveKeyPairError = exports.MessageLimitReachedError = exports.OpenError = exports.SealError = exports.ExportError = exports.DecapError = exports.EncapError = exports.DeserializeError = exports.SerializeError = exports.ValidationError = exports.InvalidParamError = exports.HpkeError = void 0;
/**

@@ -31,10 +31,5 @@ * The base error class of hpke-js.

this.name = this.constructor.name;
if (this.message === "") {
this.message = this.name;
}
else {
this.message = this.name + ": " + this.message;
}
}
}
exports.HpkeError = HpkeError;
/**

@@ -41,0 +36,0 @@ * Invalid parameter.

@@ -10,5 +10,8 @@ /**

};
/**
* The type of the Supported HPKE modes.
*/
export type Mode = typeof Mode[keyof typeof Mode];
/**
* Supported Key Encapsulation Mechanisms (KEMs).
* Supported Key Encapsulation Mechanism (KEM) identifiers.
*

@@ -25,2 +28,7 @@ * @deprecated Use {@link KdfId} instead.

};
/**
* The type of the supported KEM identifiers.
*
* @deprecated Use {@link KdfId} instead.
*/
export type Kem = typeof Kem[keyof typeof Kem];

@@ -38,5 +46,8 @@ /**

};
/**
* The type of the supported KEM identifiers.
*/
export type KemId = typeof KemId[keyof typeof KemId];
/**
* Supported Key Derivation Functions (KDFs).
* Supported Key Derivation Function (KDF) identifiers.
*

@@ -50,2 +61,7 @@ * @deprecated Use {@link KdfId} instead.

};
/**
* The type of the supported KDF identifiers.
*
* @deprecated Use {@link KdfId} instead.
*/
export type Kdf = typeof Kdf[keyof typeof Kdf];

@@ -60,5 +76,8 @@ /**

};
/**
* The type of the supported KDF identifiers.
*/
export type KdfId = typeof KdfId[keyof typeof KdfId];
/**
* Supported Authenticated Encryption with Associated Data (AEAD) Functions.
* Supported Authenticated Encryption with Associated Data (AEAD) identifiers.
*

@@ -74,4 +93,10 @@ * @deprecated Use {@link AeadId} instead.

/**
* Supported Authenticated Encryption with Associated Data (AEAD) function identifiers.
* The type of the supported AEAD identifiers.
*
* @deprecated Use {@link AeadId} instead.
*/
export type Aead = typeof Aead[keyof typeof Aead];
/**
* Supported Authenticated Encryption with Associated Data (AEAD) identifiers.
*/
export declare const AeadId: {

@@ -83,2 +108,5 @@ readonly Aes128Gcm: 1;

};
/**
* The type of the supported AEAD identifiers.
*/
export type AeadId = typeof AeadId[keyof typeof AeadId];

@@ -23,3 +23,3 @@ (function (factory) {

/**
* Supported Key Encapsulation Mechanisms (KEMs).
* Supported Key Encapsulation Mechanism (KEM) identifiers.
*

@@ -41,3 +41,3 @@ * @deprecated Use {@link KdfId} instead.

/**
* Supported Key Derivation Functions (KDFs).
* Supported Key Derivation Function (KDF) identifiers.
*

@@ -56,3 +56,3 @@ * @deprecated Use {@link KdfId} instead.

/**
* Supported Authenticated Encryption with Associated Data (AEAD) Functions.
* Supported Authenticated Encryption with Associated Data (AEAD) identifiers.
*

@@ -68,5 +68,5 @@ * @deprecated Use {@link AeadId} instead.

/**
* Supported Authenticated Encryption with Associated Data (AEAD) function identifiers.
* Supported Authenticated Encryption with Associated Data (AEAD) identifiers.
*/
exports.AeadId = exports.Aead;
});

@@ -51,3 +51,3 @@ import { KdfId } from "../identifiers.js";

/**
* -
* Extracts a pseudorandom key and expand it to a specified length keying material.
*

@@ -54,0 +54,0 @@ * @param salt An additional random byte string.

@@ -21,2 +21,7 @@ import type { RecipientContextParams } from "./recipientContextParams.js";

*
* @remarks
*
* Basically, you don't need to call this function directly.
* This function is called by{@link CipherSuite} internally.
*
* @param api A SubtleCrypto API.

@@ -28,3 +33,8 @@ */

*
* @returns A key pair.
* @remarks
*
* If the error occurred, throws {@link NotSupportedError}.
*
* @returns A key pair generated.
* @throws {@link NotSupportedError}
*/

@@ -35,4 +45,9 @@ generateKeyPair(): Promise<CryptoKeyPair>;

*
* @remarks
*
* If the error occurred, throws {@link DeriveKeyPairError}.
*
* @param ikm An input keying material.
* @returns A key pair.
* @returns A key pair derived.
* @throws {@link DeriveKeyPairError}
*/

@@ -43,4 +58,9 @@ deriveKeyPair(ikm: ArrayBuffer): Promise<CryptoKeyPair>;

*
* @remarks
*
* If the error occurred, throws {@link SerializeError}.
*
* @param key A CryptoKey.
* @returns A key as bytes.
* @throws {@link SerializeError}
*/

@@ -51,13 +71,30 @@ serializePublicKey(key: CryptoKey): Promise<ArrayBuffer>;

*
* @remarks
*
* If the error occurred, throws {@link DeserializeError}.
*
* @param key A key as bytes.
* @returns A CryptoKey.
* @throws {@link DeserializeError}
*/
deserializePublicKey(key: ArrayBuffer): Promise<CryptoKey>;
/**
* Imports a key for the KEM.
* Imports a public or private key and converts to a {@link CryptoKey}.
*
* @param format An imput KEM key format.
* @param key A KEM key.
* @param isPublic The indicator whether the KEM key is public or not.
* @returns A CryptoKey.
* @remarks
*
* Since key parameters for {@link createSenderContext} or {@link createRecipientContext}
* are {@link CryptoKey} format, you have to use this function to convert provided keys
* to {@link CryptoKey}.
*
* Basically, this is a thin wrapper function of
* [SubtleCrypto.importKey](https://www.w3.org/TR/WebCryptoAPI/#dfn-SubtleCrypto-method-importKey).
*
* If the error occurred, throws {@link DeserializeError}.
*
* @param format For now, `'raw'` and `'jwk'` are supported.
* @param key A byte string of a raw key or A {@link JsonWebKey} object.
* @param isPublic The indicator whether the provided key is a public key or not, which is used only for `'raw'` format.
* @returns A public or private CryptoKey.
* @throws {@link DeserializeError}
*/

@@ -70,4 +107,9 @@ importKey(format: "raw" | "jwk", key: ArrayBuffer | JsonWebKey, isPublic: boolean): Promise<CryptoKey>;

*
* @remarks
*
* If the error occurred, throws {@link EncapError}.
*
* @param params A set of parameters for the sender context.
* @returns A shared secret and an encapsulated key as the output of the encapsulation step.
* @throws {@link EncapError}
*/

@@ -81,6 +123,11 @@ encap(params: SenderContextParams): Promise<{

*
* @remarks
*
* If the error occurred, throws {@link DecapError}.
*
* @param params A set of parameters for the recipient context.
* @returns A shared secret as the output of the decapsulation step.
* @throws {@link DecapError}
*/
decap(params: RecipientContextParams): Promise<ArrayBuffer>;
}
import { KemId } from "../identifiers.js";
import { Dhkem } from "./dhkem.js";
/**
* The DHKEM(X448, HKDF-SHA512).
*
* @remarks
*
* 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://deno.land/x/hpke/core/mod.ts?s=CipherSuiteParams | CipherSuiteParams} as follows:
*
* @example
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import { DhkemX448HkdfSha512 } from "https://deno.land/x/hpke/x/dhkem-x448/mod.ts";
* const suite = new CipherSuite({
* kem: new DhkemX448HkdfSha512(),
* kdf: KdfId.HkdfSha512,
* aead: AeadId.Aes128Gcm,
* });
* ```
*/
export declare class DhkemX448HkdfSha512 extends Dhkem {

@@ -4,0 +26,0 @@ readonly id: KemId;

@@ -17,2 +17,24 @@ (function (factory) {

const x448_js_1 = require("./dhkemPrimitives/x448.js");
/**
* The DHKEM(X448, HKDF-SHA512).
*
* @remarks
*
* 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://deno.land/x/hpke/core/mod.ts?s=CipherSuiteParams | CipherSuiteParams} as follows:
*
* @example
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import { DhkemX448HkdfSha512 } from "https://deno.land/x/hpke/x/dhkem-x448/mod.ts";
* const suite = new CipherSuite({
* kem: new DhkemX448HkdfSha512(),
* kdf: KdfId.HkdfSha512,
* aead: AeadId.Aes128Gcm,
* });
* ```
*/
class DhkemX448HkdfSha512 extends dhkem_js_1.Dhkem {

@@ -19,0 +41,0 @@ constructor() {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc