hpke 0.3.0 → 0.4.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/package.json +8 -6
- package/pkg/node/hpke_dispatch.d.ts +18 -18
- package/pkg/node/hpke_dispatch.js +56 -47
- package/pkg/node/hpke_dispatch_bg.wasm +0 -0
- package/pkg/node/index.spec.mjs +4625 -0
- package/pkg/node/index.spec.mjs.map +7 -0
- package/pkg/node/module.mjs +582 -0
- package/pkg/node/module.mjs.map +7 -0
- package/pkg/node/package.json +1 -1
- package/pkg/web/hpke_dispatch.d.ts +29 -18
- package/pkg/web/hpke_dispatch.js +97 -57
- package/pkg/web/hpke_dispatch_bg.wasm +0 -0
- package/pkg/web/index.mjs +1 -1
- package/pkg/web/index.mjs.map +2 -2
- package/pkg/web/package.json +1 -1
- package/pkg/node/index.ts +0 -6
- package/pkg/node/node.ts +0 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hpke",
|
|
3
3
|
"description": "hybrid public key encryption",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -11,17 +11,17 @@
|
|
|
11
11
|
"build:browser:wasm": "wasm-pack build -t web --release --out-dir pkg/web",
|
|
12
12
|
"build:node:wasm": "wasm-pack build -t nodejs --release --out-dir pkg/node",
|
|
13
13
|
"build:browser:ts": "esbuild pkg/web/index.ts --bundle --outdir=pkg/web --loader:.wasm=binary --minify --sourcemap --format=esm --out-extension:.js=.mjs",
|
|
14
|
-
"build:node:ts": "esbuild pkg/node/index.ts pkg/node/index.spec.ts --outdir=pkg/node --sourcemap --loader:.wasm=binary --format=cjs",
|
|
15
14
|
"build:browser": "run-s build:browser:wasm build:browser:ts",
|
|
16
|
-
"build:node": "run-s build:node:wasm
|
|
15
|
+
"build:node": "run-s build:node:wasm",
|
|
17
16
|
"build": "run-s build:node build:browser",
|
|
18
|
-
"test": "mocha pkg/node/index.spec.
|
|
17
|
+
"test": "ts-mocha pkg/node/index.spec.ts"
|
|
19
18
|
},
|
|
20
19
|
"browser": "./pkg/web/index.mjs",
|
|
21
|
-
"main": "./pkg/node/
|
|
20
|
+
"main": "./pkg/node/hpke_dispatch.js",
|
|
22
21
|
"types": "./pkg/node/hpke_dispatch.d.ts",
|
|
23
22
|
"files": [
|
|
24
|
-
"pkg/node/*",
|
|
23
|
+
"pkg/node/*",
|
|
24
|
+
"pkg/web/*"
|
|
25
25
|
],
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"keywords": [
|
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
"@types/chai": "^4.3.1",
|
|
34
34
|
"@types/mocha": "^9.1.1",
|
|
35
35
|
"@types/node": "^18.0.4",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
|
36
37
|
"chai": "^4.3.6",
|
|
37
38
|
"esbuild": "^0.14.49",
|
|
38
39
|
"mocha": "^10.0.0",
|
|
39
40
|
"npm-run-all": "^4.1.5",
|
|
40
41
|
"prettier": "^2.7.1",
|
|
42
|
+
"ts-mocha": "^10.0.0",
|
|
41
43
|
"typescript": "^4.7.4",
|
|
42
44
|
"wasm-pack": "^0.10.3"
|
|
43
45
|
}
|
|
@@ -54,41 +54,41 @@ export function base_mode_open(config: Config, private_key: Uint8Array, encapped
|
|
|
54
54
|
export function base_mode_seal(config: Config, recipient_public_key: Uint8Array, info: Uint8Array, plaintext: Uint8Array, aad: Uint8Array): EncappedKeyAndCiphertext;
|
|
55
55
|
/**
|
|
56
56
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
57
|
+
*Kdf represents an key derivation function, as per
|
|
58
|
+
*[RFC9180§7.2](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.2)
|
|
59
59
|
*/
|
|
60
|
-
export enum
|
|
60
|
+
export enum Kdf {
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* Sha256 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
|
|
63
63
|
*/
|
|
64
|
-
|
|
64
|
+
Sha256,
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* Sha384 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
|
|
67
67
|
*/
|
|
68
|
-
|
|
68
|
+
Sha384,
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
70
|
+
* Sha512 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
|
|
71
71
|
*/
|
|
72
|
-
|
|
72
|
+
Sha512,
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
*
|
|
76
|
-
*
|
|
77
|
-
*[RFC9180§7.
|
|
76
|
+
*Aead represents an authenticated encryption with additional data
|
|
77
|
+
*encryption function, as per [RFC9180§7.3](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.3)
|
|
78
78
|
*/
|
|
79
|
-
export enum
|
|
79
|
+
export enum Aead {
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
81
|
+
* AES-128-GCM [GCM](https://doi.org/10.6028/nist.sp.800-38d)
|
|
82
82
|
*/
|
|
83
|
-
|
|
83
|
+
AesGcm128,
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
85
|
+
* AES-256-GCM [GCM](https://doi.org/10.6028/nist.sp.800-38d)
|
|
86
86
|
*/
|
|
87
|
-
|
|
87
|
+
AesGcm256,
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
89
|
+
* ChaCha20Poly1305 [RFC8439](https://www.rfc-editor.org/info/rfc8439)
|
|
90
90
|
*/
|
|
91
|
-
|
|
91
|
+
ChaCha20Poly1305,
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
*
|
|
@@ -36,12 +36,13 @@ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true
|
|
|
36
36
|
|
|
37
37
|
cachedTextDecoder.decode();
|
|
38
38
|
|
|
39
|
-
let
|
|
39
|
+
let cachedUint8Memory0 = new Uint8Array();
|
|
40
|
+
|
|
40
41
|
function getUint8Memory0() {
|
|
41
|
-
if (
|
|
42
|
-
|
|
42
|
+
if (cachedUint8Memory0.byteLength === 0) {
|
|
43
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
43
44
|
}
|
|
44
|
-
return
|
|
45
|
+
return cachedUint8Memory0;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
function getStringFromWasm0(ptr, len) {
|
|
@@ -64,12 +65,13 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
64
65
|
return ptr;
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
let
|
|
68
|
+
let cachedInt32Memory0 = new Int32Array();
|
|
69
|
+
|
|
68
70
|
function getInt32Memory0() {
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
+
if (cachedInt32Memory0.byteLength === 0) {
|
|
72
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
71
73
|
}
|
|
72
|
-
return
|
|
74
|
+
return cachedInt32Memory0;
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
function getArrayU8FromWasm0(ptr, len) {
|
|
@@ -189,24 +191,6 @@ function handleError(f, args) {
|
|
|
189
191
|
}
|
|
190
192
|
/**
|
|
191
193
|
*
|
|
192
|
-
*Aead represents an authenticated encryption with additional data
|
|
193
|
-
*encryption function, as per [RFC9180§7.3](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.3)
|
|
194
|
-
*/
|
|
195
|
-
module.exports.Aead = Object.freeze({
|
|
196
|
-
/**
|
|
197
|
-
* AES-128-GCM [GCM](https://doi.org/10.6028/nist.sp.800-38d)
|
|
198
|
-
*/
|
|
199
|
-
AesGcm128:1,"1":"AesGcm128",
|
|
200
|
-
/**
|
|
201
|
-
* AES-256-GCM [GCM](https://doi.org/10.6028/nist.sp.800-38d)
|
|
202
|
-
*/
|
|
203
|
-
AesGcm256:2,"2":"AesGcm256",
|
|
204
|
-
/**
|
|
205
|
-
* ChaCha20Poly1305 [RFC8439](https://www.rfc-editor.org/info/rfc8439)
|
|
206
|
-
*/
|
|
207
|
-
ChaCha20Poly1305:3,"3":"ChaCha20Poly1305", });
|
|
208
|
-
/**
|
|
209
|
-
*
|
|
210
194
|
*Kdf represents an key derivation function, as per
|
|
211
195
|
*[RFC9180§7.2](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.2)
|
|
212
196
|
*/
|
|
@@ -225,6 +209,24 @@ Sha384:2,"2":"Sha384",
|
|
|
225
209
|
Sha512:3,"3":"Sha512", });
|
|
226
210
|
/**
|
|
227
211
|
*
|
|
212
|
+
*Aead represents an authenticated encryption with additional data
|
|
213
|
+
*encryption function, as per [RFC9180§7.3](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.3)
|
|
214
|
+
*/
|
|
215
|
+
module.exports.Aead = Object.freeze({
|
|
216
|
+
/**
|
|
217
|
+
* AES-128-GCM [GCM](https://doi.org/10.6028/nist.sp.800-38d)
|
|
218
|
+
*/
|
|
219
|
+
AesGcm128:1,"1":"AesGcm128",
|
|
220
|
+
/**
|
|
221
|
+
* AES-256-GCM [GCM](https://doi.org/10.6028/nist.sp.800-38d)
|
|
222
|
+
*/
|
|
223
|
+
AesGcm256:2,"2":"AesGcm256",
|
|
224
|
+
/**
|
|
225
|
+
* ChaCha20Poly1305 [RFC8439](https://www.rfc-editor.org/info/rfc8439)
|
|
226
|
+
*/
|
|
227
|
+
ChaCha20Poly1305:3,"3":"ChaCha20Poly1305", });
|
|
228
|
+
/**
|
|
229
|
+
*
|
|
228
230
|
*Kem represents an asymmetric key encapsulation mechanism, as per
|
|
229
231
|
*[RFC9180§7.1][section-7.1]. Currently only two of options listed in
|
|
230
232
|
*the hpke draft are available.
|
|
@@ -268,6 +270,7 @@ class Config {
|
|
|
268
270
|
}
|
|
269
271
|
/**
|
|
270
272
|
* the [authenticated encryption with additional data encryption function](crate::Aead) to be used
|
|
273
|
+
* @returns {number}
|
|
271
274
|
*/
|
|
272
275
|
get aead() {
|
|
273
276
|
const ret = wasm.__wbg_get_config_aead(this.ptr);
|
|
@@ -282,6 +285,7 @@ class Config {
|
|
|
282
285
|
}
|
|
283
286
|
/**
|
|
284
287
|
* the [key derivation function](crate::Kdf) to be used
|
|
288
|
+
* @returns {number}
|
|
285
289
|
*/
|
|
286
290
|
get kdf() {
|
|
287
291
|
const ret = wasm.__wbg_get_config_kdf(this.ptr);
|
|
@@ -296,6 +300,7 @@ class Config {
|
|
|
296
300
|
}
|
|
297
301
|
/**
|
|
298
302
|
* the [asymmetric key encapsulation mechanism](crate::Kem) to be used
|
|
303
|
+
* @returns {number}
|
|
299
304
|
*/
|
|
300
305
|
get kem() {
|
|
301
306
|
const ret = wasm.__wbg_get_config_kem(this.ptr);
|
|
@@ -459,6 +464,7 @@ class EncappedKeyAndCiphertext {
|
|
|
459
464
|
}
|
|
460
465
|
/**
|
|
461
466
|
* the encapsulated encryption key
|
|
467
|
+
* @returns {Uint8Array}
|
|
462
468
|
*/
|
|
463
469
|
get encapped_key() {
|
|
464
470
|
try {
|
|
@@ -484,6 +490,7 @@ class EncappedKeyAndCiphertext {
|
|
|
484
490
|
}
|
|
485
491
|
/**
|
|
486
492
|
* the ciphertext, encrypted with the key
|
|
493
|
+
* @returns {Uint8Array}
|
|
487
494
|
*/
|
|
488
495
|
get ciphertext() {
|
|
489
496
|
try {
|
|
@@ -588,6 +595,7 @@ class Keypair {
|
|
|
588
595
|
}
|
|
589
596
|
/**
|
|
590
597
|
* the public key for this keypair
|
|
598
|
+
* @returns {Uint8Array}
|
|
591
599
|
*/
|
|
592
600
|
get public_key() {
|
|
593
601
|
try {
|
|
@@ -613,6 +621,7 @@ class Keypair {
|
|
|
613
621
|
}
|
|
614
622
|
/**
|
|
615
623
|
* the private key for this keypair,
|
|
624
|
+
* @returns {Uint8Array}
|
|
616
625
|
*/
|
|
617
626
|
get private_key() {
|
|
618
627
|
try {
|
|
@@ -657,7 +666,7 @@ module.exports.__wbg_idlookuperror_new = function(arg0) {
|
|
|
657
666
|
return addHeapObject(ret);
|
|
658
667
|
};
|
|
659
668
|
|
|
660
|
-
module.exports.
|
|
669
|
+
module.exports.__wbg_randomFillSync_065afffde01daa66 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
661
670
|
getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
|
|
662
671
|
}, arguments) };
|
|
663
672
|
|
|
@@ -665,11 +674,11 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
|
665
674
|
takeObject(arg0);
|
|
666
675
|
};
|
|
667
676
|
|
|
668
|
-
module.exports.
|
|
677
|
+
module.exports.__wbg_getRandomValues_b99eec4244a475bb = function() { return handleError(function (arg0, arg1) {
|
|
669
678
|
getObject(arg0).getRandomValues(getObject(arg1));
|
|
670
679
|
}, arguments) };
|
|
671
680
|
|
|
672
|
-
module.exports.
|
|
681
|
+
module.exports.__wbg_process_0cc2ada8524d6f83 = function(arg0) {
|
|
673
682
|
const ret = getObject(arg0).process;
|
|
674
683
|
return addHeapObject(ret);
|
|
675
684
|
};
|
|
@@ -680,12 +689,12 @@ module.exports.__wbindgen_is_object = function(arg0) {
|
|
|
680
689
|
return ret;
|
|
681
690
|
};
|
|
682
691
|
|
|
683
|
-
module.exports.
|
|
692
|
+
module.exports.__wbg_versions_c11acceab27a6c87 = function(arg0) {
|
|
684
693
|
const ret = getObject(arg0).versions;
|
|
685
694
|
return addHeapObject(ret);
|
|
686
695
|
};
|
|
687
696
|
|
|
688
|
-
module.exports.
|
|
697
|
+
module.exports.__wbg_node_7ff1ce49caf23815 = function(arg0) {
|
|
689
698
|
const ret = getObject(arg0).node;
|
|
690
699
|
return addHeapObject(ret);
|
|
691
700
|
};
|
|
@@ -695,32 +704,32 @@ module.exports.__wbindgen_is_string = function(arg0) {
|
|
|
695
704
|
return ret;
|
|
696
705
|
};
|
|
697
706
|
|
|
698
|
-
module.exports.
|
|
707
|
+
module.exports.__wbg_crypto_2036bed7c44c25e7 = function(arg0) {
|
|
699
708
|
const ret = getObject(arg0).crypto;
|
|
700
709
|
return addHeapObject(ret);
|
|
701
710
|
};
|
|
702
711
|
|
|
703
|
-
module.exports.
|
|
712
|
+
module.exports.__wbg_msCrypto_a21fc88caf1ecdc8 = function(arg0) {
|
|
704
713
|
const ret = getObject(arg0).msCrypto;
|
|
705
714
|
return addHeapObject(ret);
|
|
706
715
|
};
|
|
707
716
|
|
|
708
|
-
module.exports.
|
|
717
|
+
module.exports.__wbg_static_accessor_NODE_MODULE_cf6401cc1091279e = function() {
|
|
709
718
|
const ret = module;
|
|
710
719
|
return addHeapObject(ret);
|
|
711
720
|
};
|
|
712
721
|
|
|
713
|
-
module.exports.
|
|
722
|
+
module.exports.__wbg_require_a746e79b322b9336 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
714
723
|
const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
|
|
715
724
|
return addHeapObject(ret);
|
|
716
725
|
}, arguments) };
|
|
717
726
|
|
|
718
|
-
module.exports.
|
|
727
|
+
module.exports.__wbg_newnoargs_b5b063fc6c2f0376 = function(arg0, arg1) {
|
|
719
728
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
720
729
|
return addHeapObject(ret);
|
|
721
730
|
};
|
|
722
731
|
|
|
723
|
-
module.exports.
|
|
732
|
+
module.exports.__wbg_call_97ae9d8645dc388b = function() { return handleError(function (arg0, arg1) {
|
|
724
733
|
const ret = getObject(arg0).call(getObject(arg1));
|
|
725
734
|
return addHeapObject(ret);
|
|
726
735
|
}, arguments) };
|
|
@@ -730,22 +739,22 @@ module.exports.__wbindgen_object_clone_ref = function(arg0) {
|
|
|
730
739
|
return addHeapObject(ret);
|
|
731
740
|
};
|
|
732
741
|
|
|
733
|
-
module.exports.
|
|
742
|
+
module.exports.__wbg_self_6d479506f72c6a71 = function() { return handleError(function () {
|
|
734
743
|
const ret = self.self;
|
|
735
744
|
return addHeapObject(ret);
|
|
736
745
|
}, arguments) };
|
|
737
746
|
|
|
738
|
-
module.exports.
|
|
747
|
+
module.exports.__wbg_window_f2557cc78490aceb = function() { return handleError(function () {
|
|
739
748
|
const ret = window.window;
|
|
740
749
|
return addHeapObject(ret);
|
|
741
750
|
}, arguments) };
|
|
742
751
|
|
|
743
|
-
module.exports.
|
|
752
|
+
module.exports.__wbg_globalThis_7f206bda628d5286 = function() { return handleError(function () {
|
|
744
753
|
const ret = globalThis.globalThis;
|
|
745
754
|
return addHeapObject(ret);
|
|
746
755
|
}, arguments) };
|
|
747
756
|
|
|
748
|
-
module.exports.
|
|
757
|
+
module.exports.__wbg_global_ba75c50d1cf384f4 = function() { return handleError(function () {
|
|
749
758
|
const ret = global.global;
|
|
750
759
|
return addHeapObject(ret);
|
|
751
760
|
}, arguments) };
|
|
@@ -755,31 +764,31 @@ module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
|
755
764
|
return ret;
|
|
756
765
|
};
|
|
757
766
|
|
|
758
|
-
module.exports.
|
|
767
|
+
module.exports.__wbg_buffer_3f3d764d4747d564 = function(arg0) {
|
|
759
768
|
const ret = getObject(arg0).buffer;
|
|
760
769
|
return addHeapObject(ret);
|
|
761
770
|
};
|
|
762
771
|
|
|
763
|
-
module.exports.
|
|
772
|
+
module.exports.__wbg_new_8c3f0052272a457a = function(arg0) {
|
|
764
773
|
const ret = new Uint8Array(getObject(arg0));
|
|
765
774
|
return addHeapObject(ret);
|
|
766
775
|
};
|
|
767
776
|
|
|
768
|
-
module.exports.
|
|
777
|
+
module.exports.__wbg_set_83db9690f9353e79 = function(arg0, arg1, arg2) {
|
|
769
778
|
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
770
779
|
};
|
|
771
780
|
|
|
772
|
-
module.exports.
|
|
781
|
+
module.exports.__wbg_length_9e1ae1900cb0fbd5 = function(arg0) {
|
|
773
782
|
const ret = getObject(arg0).length;
|
|
774
783
|
return ret;
|
|
775
784
|
};
|
|
776
785
|
|
|
777
|
-
module.exports.
|
|
786
|
+
module.exports.__wbg_newwithlength_f5933855e4f48a19 = function(arg0) {
|
|
778
787
|
const ret = new Uint8Array(arg0 >>> 0);
|
|
779
788
|
return addHeapObject(ret);
|
|
780
789
|
};
|
|
781
790
|
|
|
782
|
-
module.exports.
|
|
791
|
+
module.exports.__wbg_subarray_58ad4efbb5bcb886 = function(arg0, arg1, arg2) {
|
|
783
792
|
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
784
793
|
return addHeapObject(ret);
|
|
785
794
|
};
|
|
Binary file
|