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

@hpke/dhkem-secp256k1

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hpke/dhkem-secp256k1 - 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>;
}

@@ -5,10 +5,16 @@ import type { KemInterface } from "../../../src/interfaces/kemInterface.js";

/**
* The class of the DH-KEM with secp256k1 curve.
* The DHKEM(secp256k1, HKDF-SHA256).
*
* @remarks
*
* This class is implemented using
* {@link https://github.com/paulmillr/noble-curves | @noble/curves}.
*
* The public keys are assumed to be compressed.
* Note that it is experimental and not standardized.
*
* The instance of this class can be specified to the CipherSuiteParams as follows:
* 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";

@@ -21,2 +27,5 @@ * import { DhkemSecp256k1HkdfSha256} from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";

* });
* ```
*
* @experimental Note that it is experimental and not standardized.
*/

@@ -23,0 +32,0 @@ export declare class DhkemSecp256k1HkdfSha256 extends Dhkem implements KemInterface {

@@ -112,10 +112,16 @@ // @ts-ignore: for "npm:"

/**
* The class of the DH-KEM with secp256k1 curve.
* The DHKEM(secp256k1, HKDF-SHA256).
*
* @remarks
*
* This class is implemented using
* {@link https://github.com/paulmillr/noble-curves | @noble/curves}.
*
* The public keys are assumed to be compressed.
* Note that it is experimental and not standardized.
*
* The instance of this class can be specified to the CipherSuiteParams as follows:
* 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";

@@ -128,2 +134,5 @@ * import { DhkemSecp256k1HkdfSha256} from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";

* });
* ```
*
* @experimental Note that it is experimental and not standardized.
*/

@@ -130,0 +139,0 @@ export class DhkemSecp256k1HkdfSha256 extends Dhkem {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@@ -204,0 +207,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>;
}

@@ -5,10 +5,16 @@ import type { KemInterface } from "../../../src/interfaces/kemInterface.js";

/**
* The class of the DH-KEM with secp256k1 curve.
* The DHKEM(secp256k1, HKDF-SHA256).
*
* @remarks
*
* This class is implemented using
* {@link https://github.com/paulmillr/noble-curves | @noble/curves}.
*
* The public keys are assumed to be compressed.
* Note that it is experimental and not standardized.
*
* The instance of this class can be specified to the CipherSuiteParams as follows:
* 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";

@@ -21,2 +27,5 @@ * import { DhkemSecp256k1HkdfSha256} from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";

* });
* ```
*
* @experimental Note that it is experimental and not standardized.
*/

@@ -23,0 +32,0 @@ export declare class DhkemSecp256k1HkdfSha256 extends Dhkem implements KemInterface {

@@ -147,10 +147,16 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {

/**
* The class of the DH-KEM with secp256k1 curve.
* The DHKEM(secp256k1, HKDF-SHA256).
*
* @remarks
*
* This class is implemented using
* {@link https://github.com/paulmillr/noble-curves | @noble/curves}.
*
* The public keys are assumed to be compressed.
* Note that it is experimental and not standardized.
*
* The instance of this class can be specified to the CipherSuiteParams as follows:
* 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";

@@ -163,2 +169,5 @@ * import { DhkemSecp256k1HkdfSha256} from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";

* });
* ```
*
* @experimental Note that it is experimental and not standardized.
*/

@@ -165,0 +174,0 @@ class DhkemSecp256k1HkdfSha256 extends dhkem_js_1.Dhkem {

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