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.2.1 to 1.2.2

11

esm/src/algorithm.js

@@ -0,10 +1,9 @@

import * as dntShim from "../_dnt.shims.js";
import { NotSupportedError } from "./errors.js";
import { isBrowser, isCloudflareWorkers } from "./utils/misc.js";
async function loadSubtleCrypto() {
if (isBrowser() || isCloudflareWorkers()) {
if (globalThis.crypto !== undefined) {
return globalThis.crypto.subtle;
}
// jsdom
if (dntShim.dntGlobalThis !== undefined && globalThis.crypto !== undefined) {
// Browsers, Node.js >= v19, Cloudflare Workers, Bun, etc.
return globalThis.crypto.subtle;
}
// Node.js <= v18
try {

@@ -11,0 +10,0 @@ // @ts-ignore: to ignore "crypto"

@@ -21,15 +21,24 @@ import type { KdfInterface } from "../interfaces/kdfInterface.js";

export declare class HkdfSha256Native extends HkdfNative {
/** KdfId.HkdfSha256 (0x0001) */
readonly id: KdfId;
/** 32 */
readonly hashSize: number;
/** The parameters for Web Cryptography API */
protected readonly algHash: HmacKeyGenParams;
}
export declare class HkdfSha384Native extends HkdfNative {
/** KdfId.HkdfSha384 (0x0002) */
readonly id: KdfId;
/** 48 */
readonly hashSize: number;
/** The parameters for Web Cryptography API */
protected readonly algHash: HmacKeyGenParams;
}
export declare class HkdfSha512Native extends HkdfNative {
/** KdfId.HkdfSha512 (0x0003) */
readonly id: KdfId;
/** 64 */
readonly hashSize: number;
/** The parameters for Web Cryptography API */
protected readonly algHash: HmacKeyGenParams;
}

@@ -130,2 +130,3 @@ import { NativeAlgorithm } from "../algorithm.js";

super(...arguments);
/** KdfId.HkdfSha256 (0x0001) */
Object.defineProperty(this, "id", {

@@ -137,2 +138,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "hashSize", {

@@ -144,2 +146,3 @@ enumerable: true,

});
/** The parameters for Web Cryptography API */
Object.defineProperty(this, "algHash", {

@@ -160,2 +163,3 @@ enumerable: true,

super(...arguments);
/** KdfId.HkdfSha384 (0x0002) */
Object.defineProperty(this, "id", {

@@ -167,2 +171,3 @@ enumerable: true,

});
/** 48 */
Object.defineProperty(this, "hashSize", {

@@ -174,2 +179,3 @@ enumerable: true,

});
/** The parameters for Web Cryptography API */
Object.defineProperty(this, "algHash", {

@@ -190,2 +196,3 @@ enumerable: true,

super(...arguments);
/** KdfId.HkdfSha512 (0x0003) */
Object.defineProperty(this, "id", {

@@ -197,2 +204,3 @@ enumerable: true,

});
/** 64 */
Object.defineProperty(this, "hashSize", {

@@ -204,2 +212,3 @@ enumerable: true,

});
/** The parameters for Web Cryptography API */
Object.defineProperty(this, "algHash", {

@@ -206,0 +215,0 @@ enumerable: true,

import { KemId } from "../identifiers.js";
import { Dhkem } from "./dhkem.js";
/**
* The DHKEM(secp256k1, HKDF-SHA256).
* The DHKEM(secp256k1, HKDF-SHA256) for HPKE KEM implementing {@link KemInterface}.
*

@@ -14,7 +14,8 @@ * This class is implemented using

*
* @example
* @example Use with `hpke-js` (`https://deno.land/x/hpke/mod.ts`).
*
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import { DhkemSecp256k1HkdfSha256} from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";
* import { AeadId, CipherSuite, KdfId } from "https://deno.land/x/hpke/mod.ts";
* import { DhkemSecp256k1HkdfSha256 } from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";
*
* const suite = new CipherSuite({

@@ -27,11 +28,36 @@ * kem: new DhkemSecp256k1HkdfSha256(),

*
* When using `hpke-js` (`https://deno.land/x/hpke/mod.ts`), `KemId.DhkemSecp256k1HkdfSha256`
* cannot be used as well. So you need to specify the instance of this class as follows:
*
* @example Use with `@hpke/core` (`https://deno.land/x/hpke/core/mod.ts`).
*
* ```ts
* import {
* Aes128Gcm,
* CipherSuite,
* HkdfSha256,
* } from "https://deno.land/x/hpke/core/mod.ts";
* import { DhkemSecp256k1HkdfSha256 } from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemSecp256k1HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes128Gcm(),
* });
* ```
*
* @experimental Note that it is experimental and not standardized.
*/
export declare class DhkemSecp256k1HkdfSha256 extends Dhkem {
/** KemId.DhkemSecp256k1HkdfSha256 (0x0013) EXPERIMENTAL */
readonly id: KemId;
/** 32 */
readonly secretSize: number;
/** 33 */
readonly encSize: number;
/** 33 */
readonly publicKeySize: number;
/** 32 */
readonly privateKeySize: number;
constructor();
}

@@ -6,3 +6,3 @@ import { KemId } from "../identifiers.js";

/**
* The DHKEM(secp256k1, HKDF-SHA256).
* The DHKEM(secp256k1, HKDF-SHA256) for HPKE KEM implementing {@link KemInterface}.
*

@@ -17,7 +17,8 @@ * This class is implemented using

*
* @example
* @example Use with `hpke-js` (`https://deno.land/x/hpke/mod.ts`).
*
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import { DhkemSecp256k1HkdfSha256} from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";
* import { AeadId, CipherSuite, KdfId } from "https://deno.land/x/hpke/mod.ts";
* import { DhkemSecp256k1HkdfSha256 } from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";
*
* const suite = new CipherSuite({

@@ -30,2 +31,22 @@ * kem: new DhkemSecp256k1HkdfSha256(),

*
* When using `hpke-js` (`https://deno.land/x/hpke/mod.ts`), `KemId.DhkemSecp256k1HkdfSha256`
* cannot be used as well. So you need to specify the instance of this class as follows:
*
* @example Use with `@hpke/core` (`https://deno.land/x/hpke/core/mod.ts`).
*
* ```ts
* import {
* Aes128Gcm,
* CipherSuite,
* HkdfSha256,
* } from "https://deno.land/x/hpke/core/mod.ts";
* import { DhkemSecp256k1HkdfSha256 } from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemSecp256k1HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes128Gcm(),
* });
* ```
*
* @experimental Note that it is experimental and not standardized.

@@ -37,2 +58,3 @@ */

super(KemId.DhkemSecp256k1HkdfSha256, new Secp256k1(kdf), kdf);
/** KemId.DhkemSecp256k1HkdfSha256 (0x0013) EXPERIMENTAL */
Object.defineProperty(this, "id", {

@@ -44,2 +66,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "secretSize", {

@@ -51,2 +74,3 @@ enumerable: true,

});
/** 33 */
Object.defineProperty(this, "encSize", {

@@ -58,2 +82,3 @@ enumerable: true,

});
/** 33 */
Object.defineProperty(this, "publicKeySize", {

@@ -65,2 +90,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "privateKeySize", {

@@ -67,0 +93,0 @@ enumerable: true,

/**
* Checks whether the execution env is browser or not.
*/
export declare const isBrowser: () => boolean;
/**
* Checks whether the execution env is Cloudflare Workers or not.
*/
export declare const isCloudflareWorkers: () => boolean;
/**
* Checks whether the execution env is Deno or not.

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

@@ -1,11 +0,2 @@

import * as dntShim from "../../_dnt.shims.js";
/**
* Checks whether the execution env is browser or not.
*/
export const isBrowser = () => typeof dntShim.dntGlobalThis !== "undefined";
/**
* Checks whether the execution env is Cloudflare Workers or not.
*/
export const isCloudflareWorkers = () => typeof caches !== "undefined";
/**
* Checks whether the execution env is Deno or not.

@@ -12,0 +3,0 @@ */

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

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

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

@@ -48,4 +48,4 @@ <h1 align="center">@hpke/dhkem-secp256k1</h1>

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

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

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

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

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

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

```js
import { Aes256Gcm, CipherSuite, HkdfSha512 } from "https://deno.land/x/hpke@1.2.1/core/mod.ts";
import { DhkemSecp256k1HkdfSha256 } from "https://deno.land/x/hpke@1.2.1/x/dhkem-secp256k1/mod.ts";
import { Aes256Gcm, CipherSuite, HkdfSha512 } from "https://deno.land/x/hpke@1.2.2/core/mod.ts";
import { DhkemSecp256k1HkdfSha256 } from "https://deno.land/x/hpke@1.2.2/x/dhkem-secp256k1/mod.ts";

@@ -200,4 +200,4 @@ async function doHpke() {

<script type="module">
import { Aes128Gcm, CipherSuite, HkdfSha256 } from "https://esm.sh/@hpke/core@1.2.1";
import { DhkemSecp256k1HkdfSha256 } from "https://esm.sh/@hpke/dhkem-secp256k1@1.2.1";
import { Aes128Gcm, CipherSuite, HkdfSha256 } from "https://esm.sh/@hpke/core@1.2.2";
import { DhkemSecp256k1HkdfSha256 } from "https://esm.sh/@hpke/dhkem-secp256k1@1.2.2";

@@ -204,0 +204,0 @@ globalThis.doHpke = async () => {

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

else if (typeof define === "function" && define.amd) {
define(["require", "exports", "./errors.js", "./utils/misc.js"], factory);
define(["require", "exports", "../_dnt.shims.js", "./errors.js"], factory);
}

@@ -38,11 +38,10 @@ })(function (require, exports) {

exports.NativeAlgorithm = void 0;
const dntShim = __importStar(require("../_dnt.shims.js"));
const errors_js_1 = require("./errors.js");
const misc_js_1 = require("./utils/misc.js");
async function loadSubtleCrypto() {
if ((0, misc_js_1.isBrowser)() || (0, misc_js_1.isCloudflareWorkers)()) {
if (globalThis.crypto !== undefined) {
return globalThis.crypto.subtle;
}
// jsdom
if (dntShim.dntGlobalThis !== undefined && globalThis.crypto !== undefined) {
// Browsers, Node.js >= v19, Cloudflare Workers, Bun, etc.
return globalThis.crypto.subtle;
}
// Node.js <= v18
try {

@@ -49,0 +48,0 @@ // @ts-ignore: to ignore "crypto"

@@ -21,15 +21,24 @@ import type { KdfInterface } from "../interfaces/kdfInterface.js";

export declare class HkdfSha256Native extends HkdfNative {
/** KdfId.HkdfSha256 (0x0001) */
readonly id: KdfId;
/** 32 */
readonly hashSize: number;
/** The parameters for Web Cryptography API */
protected readonly algHash: HmacKeyGenParams;
}
export declare class HkdfSha384Native extends HkdfNative {
/** KdfId.HkdfSha384 (0x0002) */
readonly id: KdfId;
/** 48 */
readonly hashSize: number;
/** The parameters for Web Cryptography API */
protected readonly algHash: HmacKeyGenParams;
}
export declare class HkdfSha512Native extends HkdfNative {
/** KdfId.HkdfSha512 (0x0003) */
readonly id: KdfId;
/** 64 */
readonly hashSize: number;
/** The parameters for Web Cryptography API */
protected readonly algHash: HmacKeyGenParams;
}

@@ -143,2 +143,3 @@ (function (factory) {

super(...arguments);
/** KdfId.HkdfSha256 (0x0001) */
Object.defineProperty(this, "id", {

@@ -150,2 +151,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "hashSize", {

@@ -157,2 +159,3 @@ enumerable: true,

});
/** The parameters for Web Cryptography API */
Object.defineProperty(this, "algHash", {

@@ -174,2 +177,3 @@ enumerable: true,

super(...arguments);
/** KdfId.HkdfSha384 (0x0002) */
Object.defineProperty(this, "id", {

@@ -181,2 +185,3 @@ enumerable: true,

});
/** 48 */
Object.defineProperty(this, "hashSize", {

@@ -188,2 +193,3 @@ enumerable: true,

});
/** The parameters for Web Cryptography API */
Object.defineProperty(this, "algHash", {

@@ -205,2 +211,3 @@ enumerable: true,

super(...arguments);
/** KdfId.HkdfSha512 (0x0003) */
Object.defineProperty(this, "id", {

@@ -212,2 +219,3 @@ enumerable: true,

});
/** 64 */
Object.defineProperty(this, "hashSize", {

@@ -219,2 +227,3 @@ enumerable: true,

});
/** The parameters for Web Cryptography API */
Object.defineProperty(this, "algHash", {

@@ -221,0 +230,0 @@ enumerable: true,

import { KemId } from "../identifiers.js";
import { Dhkem } from "./dhkem.js";
/**
* The DHKEM(secp256k1, HKDF-SHA256).
* The DHKEM(secp256k1, HKDF-SHA256) for HPKE KEM implementing {@link KemInterface}.
*

@@ -14,7 +14,8 @@ * This class is implemented using

*
* @example
* @example Use with `hpke-js` (`https://deno.land/x/hpke/mod.ts`).
*
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import { DhkemSecp256k1HkdfSha256} from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";
* import { AeadId, CipherSuite, KdfId } from "https://deno.land/x/hpke/mod.ts";
* import { DhkemSecp256k1HkdfSha256 } from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";
*
* const suite = new CipherSuite({

@@ -27,11 +28,36 @@ * kem: new DhkemSecp256k1HkdfSha256(),

*
* When using `hpke-js` (`https://deno.land/x/hpke/mod.ts`), `KemId.DhkemSecp256k1HkdfSha256`
* cannot be used as well. So you need to specify the instance of this class as follows:
*
* @example Use with `@hpke/core` (`https://deno.land/x/hpke/core/mod.ts`).
*
* ```ts
* import {
* Aes128Gcm,
* CipherSuite,
* HkdfSha256,
* } from "https://deno.land/x/hpke/core/mod.ts";
* import { DhkemSecp256k1HkdfSha256 } from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemSecp256k1HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes128Gcm(),
* });
* ```
*
* @experimental Note that it is experimental and not standardized.
*/
export declare class DhkemSecp256k1HkdfSha256 extends Dhkem {
/** KemId.DhkemSecp256k1HkdfSha256 (0x0013) EXPERIMENTAL */
readonly id: KemId;
/** 32 */
readonly secretSize: number;
/** 33 */
readonly encSize: number;
/** 33 */
readonly publicKeySize: number;
/** 32 */
readonly privateKeySize: number;
constructor();
}

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

/**
* The DHKEM(secp256k1, HKDF-SHA256).
* The DHKEM(secp256k1, HKDF-SHA256) for HPKE KEM implementing {@link KemInterface}.
*

@@ -29,7 +29,8 @@ * This class is implemented using

*
* @example
* @example Use with `hpke-js` (`https://deno.land/x/hpke/mod.ts`).
*
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import { DhkemSecp256k1HkdfSha256} from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";
* import { AeadId, CipherSuite, KdfId } from "https://deno.land/x/hpke/mod.ts";
* import { DhkemSecp256k1HkdfSha256 } from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";
*
* const suite = new CipherSuite({

@@ -42,2 +43,22 @@ * kem: new DhkemSecp256k1HkdfSha256(),

*
* When using `hpke-js` (`https://deno.land/x/hpke/mod.ts`), `KemId.DhkemSecp256k1HkdfSha256`
* cannot be used as well. So you need to specify the instance of this class as follows:
*
* @example Use with `@hpke/core` (`https://deno.land/x/hpke/core/mod.ts`).
*
* ```ts
* import {
* Aes128Gcm,
* CipherSuite,
* HkdfSha256,
* } from "https://deno.land/x/hpke/core/mod.ts";
* import { DhkemSecp256k1HkdfSha256 } from "https://deno.land/x/hpke/x/dhkem-secp256k1/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemSecp256k1HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes128Gcm(),
* });
* ```
*
* @experimental Note that it is experimental and not standardized.

@@ -49,2 +70,3 @@ */

super(identifiers_js_1.KemId.DhkemSecp256k1HkdfSha256, new secp256k1_js_1.Secp256k1(kdf), kdf);
/** KemId.DhkemSecp256k1HkdfSha256 (0x0013) EXPERIMENTAL */
Object.defineProperty(this, "id", {

@@ -56,2 +78,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "secretSize", {

@@ -63,2 +86,3 @@ enumerable: true,

});
/** 33 */
Object.defineProperty(this, "encSize", {

@@ -70,2 +94,3 @@ enumerable: true,

});
/** 33 */
Object.defineProperty(this, "publicKeySize", {

@@ -77,2 +102,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "privateKeySize", {

@@ -79,0 +105,0 @@ enumerable: true,

/**
* Checks whether the execution env is browser or not.
*/
export declare const isBrowser: () => boolean;
/**
* Checks whether the execution env is Cloudflare Workers or not.
*/
export declare const isCloudflareWorkers: () => boolean;
/**
* Checks whether the execution env is Deno or not.

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

@@ -1,24 +0,1 @@

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
(function (factory) {

@@ -30,3 +7,3 @@ if (typeof module === "object" && typeof module.exports === "object") {

else if (typeof define === "function" && define.amd) {
define(["require", "exports", "../../_dnt.shims.js"], factory);
define(["require", "exports"], factory);
}

@@ -36,15 +13,4 @@ })(function (require, exports) {

Object.defineProperty(exports, "__esModule", { value: true });
exports.base64UrlToBytes = exports.concat = exports.i2Osp = exports.isCryptoKeyPair = exports.isDeno = exports.isCloudflareWorkers = exports.isBrowser = void 0;
const dntShim = __importStar(require("../../_dnt.shims.js"));
exports.base64UrlToBytes = exports.concat = exports.i2Osp = exports.isCryptoKeyPair = exports.isDeno = void 0;
/**
* Checks whether the execution env is browser or not.
*/
const isBrowser = () => typeof dntShim.dntGlobalThis !== "undefined";
exports.isBrowser = isBrowser;
/**
* Checks whether the execution env is Cloudflare Workers or not.
*/
const isCloudflareWorkers = () => typeof caches !== "undefined";
exports.isCloudflareWorkers = isCloudflareWorkers;
/**
* Checks whether the execution env is Deno or not.

@@ -51,0 +17,0 @@ */

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