@hpke/hybridkem-x-wing 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/esm/src/xWing.d.ts +3 -3
- package/esm/src/xWing.d.ts.map +1 -1
- package/esm/src/xWing.js +11 -9
- package/package.json +6 -4
- package/script/src/xWing.d.ts +3 -3
- package/script/src/xWing.d.ts.map +1 -1
- package/script/src/xWing.js +10 -8
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<h1 align="center">@hpke/hybridkem-x-wing</h1>
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
|
+
<a href="https://www.npmjs.com/package/@hpke/hybridkem-x-wing"><img src="https://img.shields.io/npm/v/@hpke/hybridkem-x-wing" alt="npm"/></a>
|
|
4
5
|
<a href="https://jsr.io/@hpke/hybridkem-x-wing"><img src="https://jsr.io/badges/@hpke/hybridkem-x-wing" alt="JSR"/></a>
|
|
5
6
|
</div>
|
|
6
7
|
|
|
@@ -100,8 +101,8 @@ yarn add @hpke/hybridkem-x-wing
|
|
|
100
101
|
pnpm install @hpke/hybridkem-x-wing
|
|
101
102
|
# Using jsr:
|
|
102
103
|
npx jsr add @hpke/hybridkem-x-wing
|
|
103
|
-
yarn
|
|
104
|
-
pnpm
|
|
104
|
+
yarn add jsr:@hpke/hybridkem-x-wing
|
|
105
|
+
pnpm add jsr:@hpke/hybridkem-x-wing
|
|
105
106
|
```
|
|
106
107
|
|
|
107
108
|
The above manner can be used with other JavaScript runtimes that support npm,
|
package/esm/src/xWing.d.ts
CHANGED
|
@@ -36,9 +36,9 @@ export declare class XWing implements KemInterface {
|
|
|
36
36
|
private _api;
|
|
37
37
|
constructor();
|
|
38
38
|
serializePublicKey(key: CryptoKey): Promise<ArrayBuffer>;
|
|
39
|
-
deserializePublicKey(key:
|
|
39
|
+
deserializePublicKey(key: ArrayBufferLike | ArrayBufferView): Promise<CryptoKey>;
|
|
40
40
|
serializePrivateKey(key: CryptoKey): Promise<ArrayBuffer>;
|
|
41
|
-
deserializePrivateKey(key:
|
|
41
|
+
deserializePrivateKey(key: ArrayBufferLike | ArrayBufferView): Promise<CryptoKey>;
|
|
42
42
|
/**
|
|
43
43
|
* Generates a new key pair.
|
|
44
44
|
*
|
|
@@ -61,7 +61,7 @@ export declare class XWing implements KemInterface {
|
|
|
61
61
|
* @throws {DeriveKeyPairError} Thrown if the key pair cannot be derived.
|
|
62
62
|
* @throws {InvalidParamError} Thrown if the length of the IKM is not 32 bytes.
|
|
63
63
|
*/
|
|
64
|
-
deriveKeyPair(ikm:
|
|
64
|
+
deriveKeyPair(ikm: ArrayBufferLike | ArrayBufferView): Promise<CryptoKeyPair>;
|
|
65
65
|
/**
|
|
66
66
|
* Imports a key from the input.
|
|
67
67
|
* @param format The format of the key. "raw" or "jwk" can be specified.
|
package/esm/src/xWing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xWing.d.ts","sourceRoot":"","sources":["../../src/src/xWing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAsB,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAUL,KAAK,
|
|
1
|
+
{"version":3,"file":"xWing.d.ts","sourceRoot":"","sources":["../../src/src/xWing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAsB,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAUL,KAAK,EAMN,MAAM,cAAc,CAAC;AAItB,OAAO,EAAc,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAkCxD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,KA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A;KAAE,CAAC;IA4C3D;;;;;;;;OAQG;IACU,KAAK,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC;IA0BxE;;;;OAIG;YACW,MAAM;IAOpB;;;;OAIG;YACW,sBAAsB;IAOpC;;;;OAIG;YACW,uBAAuB;IAUrC,OAAO,CAAC,mBAAmB;IAe3B,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,oBAAoB;IAe5B,OAAO,CAAC,sBAAsB;IAW9B,OAAO,CAAC,UAAU;CAmCnB"}
|
package/esm/src/xWing.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-ignore: Unreachable code error
|
|
2
2
|
import { MlKem768, sha3_256, shake256 } from "mlkem";
|
|
3
|
-
import { base64UrlToBytes, concat, DecapError, DeriveKeyPairError, DeserializeError, EncapError, InvalidParamError, isCryptoKeyPair, KEM_USAGES, KemId, loadCrypto, NotSupportedError, SerializeError, XCryptoKey, } from "@hpke/common";
|
|
3
|
+
import { base64UrlToBytes, concat, DecapError, DeriveKeyPairError, DeserializeError, EncapError, InvalidParamError, isCryptoKeyPair, KEM_USAGES, KemId, loadCrypto, NotSupportedError, SerializeError, toArrayBuffer, XCryptoKey, } from "@hpke/common";
|
|
4
4
|
const ALG_NAME = "X-Wing";
|
|
5
5
|
import { HkdfSha256, X25519 } from "@hpke/dhkem-x25519";
|
|
6
6
|
// deno-fmt-ignore
|
|
@@ -123,7 +123,7 @@ export class XWing {
|
|
|
123
123
|
async deserializePublicKey(key) {
|
|
124
124
|
await this._setup();
|
|
125
125
|
try {
|
|
126
|
-
return await this._deserializePublicKey(key);
|
|
126
|
+
return await this._deserializePublicKey(toArrayBuffer(key));
|
|
127
127
|
}
|
|
128
128
|
catch (e) {
|
|
129
129
|
throw new DeserializeError(e);
|
|
@@ -141,7 +141,7 @@ export class XWing {
|
|
|
141
141
|
async deserializePrivateKey(key) {
|
|
142
142
|
await this._setup();
|
|
143
143
|
try {
|
|
144
|
-
return await this._deserializePrivateKey(key);
|
|
144
|
+
return await this._deserializePrivateKey(toArrayBuffer(key));
|
|
145
145
|
}
|
|
146
146
|
catch (e) {
|
|
147
147
|
throw new DeserializeError(e);
|
|
@@ -203,8 +203,9 @@ export class XWing {
|
|
|
203
203
|
async deriveKeyPair(ikm) {
|
|
204
204
|
await this._setup();
|
|
205
205
|
try {
|
|
206
|
+
const rawIkm = toArrayBuffer(ikm);
|
|
206
207
|
const sk = shake256.create({ dkLen: 32 })
|
|
207
|
-
.update(new Uint8Array(
|
|
208
|
+
.update(new Uint8Array(rawIkm))
|
|
208
209
|
.digest();
|
|
209
210
|
const [_sk, pk] = await this._generateKeyPairDerand(sk);
|
|
210
211
|
const dSk = await this.deserializePrivateKey(sk.buffer);
|
|
@@ -266,11 +267,12 @@ export class XWing {
|
|
|
266
267
|
async encap(params) {
|
|
267
268
|
let ekm = undefined;
|
|
268
269
|
if (params.ekm !== undefined && !isCryptoKeyPair(params.ekm)) {
|
|
269
|
-
|
|
270
|
+
ekm = toArrayBuffer(params.ekm);
|
|
271
|
+
if (ekm.byteLength !== 64) {
|
|
270
272
|
throw new InvalidParamError("ekm must be 64 bytes in length");
|
|
271
273
|
}
|
|
272
|
-
ekm = params.ekm;
|
|
273
274
|
}
|
|
275
|
+
await this._setup();
|
|
274
276
|
let ekM = undefined;
|
|
275
277
|
let ekX;
|
|
276
278
|
if (ekm !== undefined) {
|
|
@@ -291,7 +293,6 @@ export class XWing {
|
|
|
291
293
|
if (pk.byteLength !== 1216) {
|
|
292
294
|
throw new InvalidParamError("Invalid length of recipientPublicKey");
|
|
293
295
|
}
|
|
294
|
-
await this._setup();
|
|
295
296
|
try {
|
|
296
297
|
const pkM = pk.subarray(0, 1184);
|
|
297
298
|
const pkX = pk.subarray(1184, 1216);
|
|
@@ -317,10 +318,11 @@ export class XWing {
|
|
|
317
318
|
* @throws {DecapError} Thrown if the shared secret cannot be decapsulated.
|
|
318
319
|
*/
|
|
319
320
|
async decap(params) {
|
|
321
|
+
const enc = toArrayBuffer(params.enc);
|
|
320
322
|
const rSk = isCryptoKeyPair(params.recipientKey)
|
|
321
323
|
? params.recipientKey.privateKey
|
|
322
324
|
: params.recipientKey;
|
|
323
|
-
if (
|
|
325
|
+
if (enc.byteLength !== 1120) {
|
|
324
326
|
throw new InvalidParamError("Invalid length of enc");
|
|
325
327
|
}
|
|
326
328
|
const sk = new Uint8Array(await this.serializePrivateKey(rSk));
|
|
@@ -330,7 +332,7 @@ export class XWing {
|
|
|
330
332
|
await this._setup();
|
|
331
333
|
try {
|
|
332
334
|
const [skM, skX, _pkM, pkX] = await this._expandDecapsulationKey(sk);
|
|
333
|
-
const ct = new Uint8Array(
|
|
335
|
+
const ct = new Uint8Array(enc);
|
|
334
336
|
const ctM = ct.subarray(0, 1088);
|
|
335
337
|
const ctX = ct.subarray(1088);
|
|
336
338
|
const ssM = await this._m.decap(ctM, skM);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpke/hybridkem-x-wing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "A Hybrid Public Key Encryption (HPKE) module extension for X-Wing: general-purpose hybrid post-quantum KEM.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hpke",
|
|
@@ -38,12 +38,14 @@
|
|
|
38
38
|
"node": ">=16.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@hpke/common": "^1.
|
|
42
|
-
"@hpke/dhkem-x25519": "^1.
|
|
41
|
+
"@hpke/common": "^1.10.0",
|
|
42
|
+
"@hpke/dhkem-x25519": "^1.8.0",
|
|
43
43
|
"mlkem": "^2.5.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@types/node": "^20.9.0"
|
|
46
|
+
"@types/node": "^20.9.0",
|
|
47
|
+
"@deno/shim-deno": "~0.18.0",
|
|
48
|
+
"picocolors": "^1.0.0"
|
|
47
49
|
},
|
|
48
50
|
"_generatedBy": "dnt@dev"
|
|
49
51
|
}
|
package/script/src/xWing.d.ts
CHANGED
|
@@ -36,9 +36,9 @@ export declare class XWing implements KemInterface {
|
|
|
36
36
|
private _api;
|
|
37
37
|
constructor();
|
|
38
38
|
serializePublicKey(key: CryptoKey): Promise<ArrayBuffer>;
|
|
39
|
-
deserializePublicKey(key:
|
|
39
|
+
deserializePublicKey(key: ArrayBufferLike | ArrayBufferView): Promise<CryptoKey>;
|
|
40
40
|
serializePrivateKey(key: CryptoKey): Promise<ArrayBuffer>;
|
|
41
|
-
deserializePrivateKey(key:
|
|
41
|
+
deserializePrivateKey(key: ArrayBufferLike | ArrayBufferView): Promise<CryptoKey>;
|
|
42
42
|
/**
|
|
43
43
|
* Generates a new key pair.
|
|
44
44
|
*
|
|
@@ -61,7 +61,7 @@ export declare class XWing implements KemInterface {
|
|
|
61
61
|
* @throws {DeriveKeyPairError} Thrown if the key pair cannot be derived.
|
|
62
62
|
* @throws {InvalidParamError} Thrown if the length of the IKM is not 32 bytes.
|
|
63
63
|
*/
|
|
64
|
-
deriveKeyPair(ikm:
|
|
64
|
+
deriveKeyPair(ikm: ArrayBufferLike | ArrayBufferView): Promise<CryptoKeyPair>;
|
|
65
65
|
/**
|
|
66
66
|
* Imports a key from the input.
|
|
67
67
|
* @param format The format of the key. "raw" or "jwk" can be specified.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xWing.d.ts","sourceRoot":"","sources":["../../src/src/xWing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAsB,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAUL,KAAK,
|
|
1
|
+
{"version":3,"file":"xWing.d.ts","sourceRoot":"","sources":["../../src/src/xWing.ts"],"names":[],"mappings":"AACA,OA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;IAgBzB;;;;;;;OAOG;IACU,SAAS,CACpB,MAAM,EAAE,KAAK,GAAG,KAAK,EACrB,GAAG,EAAE,WAAW,GAAG,kBAAkB,EACrC,QAAQ,UAAO,GACd,OAAO,CAAC,SAAS,CAAC;IAmCrB;;;;;;OAMG;IACU,KAAK,CAChB,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC;QAAE,YAAY,EAAE,WAAW,CAAC;QAAC,GAAG,EAAE,WAAW,CAAA;KAAE,CAAC;IA4C3D;;;;;;;;OAQG;IACU,KAAK,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC;IA0BxE;;;;OAIG;YACW,MAAM;IAOpB;;;;OAIG;YACW,sBAAsB;IAOpC;;;;OAIG;YACW,uBAAuB;IAUrC,OAAO,CAAC,mBAAmB;IAe3B,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,oBAAoB;IAe5B,OAAO,CAAC,sBAAsB;IAW9B,OAAO,CAAC,UAAU;CAmCnB"}
|
package/script/src/xWing.js
CHANGED
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
async deserializePublicKey(key) {
|
|
136
136
|
await this._setup();
|
|
137
137
|
try {
|
|
138
|
-
return await this._deserializePublicKey(key);
|
|
138
|
+
return await this._deserializePublicKey((0, common_1.toArrayBuffer)(key));
|
|
139
139
|
}
|
|
140
140
|
catch (e) {
|
|
141
141
|
throw new common_1.DeserializeError(e);
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
async deserializePrivateKey(key) {
|
|
154
154
|
await this._setup();
|
|
155
155
|
try {
|
|
156
|
-
return await this._deserializePrivateKey(key);
|
|
156
|
+
return await this._deserializePrivateKey((0, common_1.toArrayBuffer)(key));
|
|
157
157
|
}
|
|
158
158
|
catch (e) {
|
|
159
159
|
throw new common_1.DeserializeError(e);
|
|
@@ -215,8 +215,9 @@
|
|
|
215
215
|
async deriveKeyPair(ikm) {
|
|
216
216
|
await this._setup();
|
|
217
217
|
try {
|
|
218
|
+
const rawIkm = (0, common_1.toArrayBuffer)(ikm);
|
|
218
219
|
const sk = mlkem_1.shake256.create({ dkLen: 32 })
|
|
219
|
-
.update(new Uint8Array(
|
|
220
|
+
.update(new Uint8Array(rawIkm))
|
|
220
221
|
.digest();
|
|
221
222
|
const [_sk, pk] = await this._generateKeyPairDerand(sk);
|
|
222
223
|
const dSk = await this.deserializePrivateKey(sk.buffer);
|
|
@@ -278,11 +279,12 @@
|
|
|
278
279
|
async encap(params) {
|
|
279
280
|
let ekm = undefined;
|
|
280
281
|
if (params.ekm !== undefined && !(0, common_1.isCryptoKeyPair)(params.ekm)) {
|
|
281
|
-
|
|
282
|
+
ekm = (0, common_1.toArrayBuffer)(params.ekm);
|
|
283
|
+
if (ekm.byteLength !== 64) {
|
|
282
284
|
throw new common_1.InvalidParamError("ekm must be 64 bytes in length");
|
|
283
285
|
}
|
|
284
|
-
ekm = params.ekm;
|
|
285
286
|
}
|
|
287
|
+
await this._setup();
|
|
286
288
|
let ekM = undefined;
|
|
287
289
|
let ekX;
|
|
288
290
|
if (ekm !== undefined) {
|
|
@@ -303,7 +305,6 @@
|
|
|
303
305
|
if (pk.byteLength !== 1216) {
|
|
304
306
|
throw new common_1.InvalidParamError("Invalid length of recipientPublicKey");
|
|
305
307
|
}
|
|
306
|
-
await this._setup();
|
|
307
308
|
try {
|
|
308
309
|
const pkM = pk.subarray(0, 1184);
|
|
309
310
|
const pkX = pk.subarray(1184, 1216);
|
|
@@ -329,10 +330,11 @@
|
|
|
329
330
|
* @throws {DecapError} Thrown if the shared secret cannot be decapsulated.
|
|
330
331
|
*/
|
|
331
332
|
async decap(params) {
|
|
333
|
+
const enc = (0, common_1.toArrayBuffer)(params.enc);
|
|
332
334
|
const rSk = (0, common_1.isCryptoKeyPair)(params.recipientKey)
|
|
333
335
|
? params.recipientKey.privateKey
|
|
334
336
|
: params.recipientKey;
|
|
335
|
-
if (
|
|
337
|
+
if (enc.byteLength !== 1120) {
|
|
336
338
|
throw new common_1.InvalidParamError("Invalid length of enc");
|
|
337
339
|
}
|
|
338
340
|
const sk = new Uint8Array(await this.serializePrivateKey(rSk));
|
|
@@ -342,7 +344,7 @@
|
|
|
342
344
|
await this._setup();
|
|
343
345
|
try {
|
|
344
346
|
const [skM, skX, _pkM, pkX] = await this._expandDecapsulationKey(sk);
|
|
345
|
-
const ct = new Uint8Array(
|
|
347
|
+
const ct = new Uint8Array(enc);
|
|
346
348
|
const ctM = ct.subarray(0, 1088);
|
|
347
349
|
const ctX = ct.subarray(1088);
|
|
348
350
|
const ssM = await this._m.decap(ctM, skM);
|