hpke 0.1.1 → 0.3.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.
@@ -1,4 +1,7 @@
1
- import * as wasm from './hpke_dispatch_bg.wasm';
1
+ let imports = {};
2
+ imports['__wbindgen_placeholder__'] = module.exports;
3
+ let wasm;
4
+ const { TextDecoder } = require(`util`);
2
5
 
3
6
  const heap = new Array(32).fill(undefined);
4
7
 
@@ -29,9 +32,7 @@ function addHeapObject(obj) {
29
32
  return idx;
30
33
  }
31
34
 
32
- const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
33
-
34
- let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
35
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
35
36
 
36
37
  cachedTextDecoder.decode();
37
38
 
@@ -47,6 +48,13 @@ function getStringFromWasm0(ptr, len) {
47
48
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
48
49
  }
49
50
 
51
+ function _assertClass(instance, klass) {
52
+ if (!(instance instanceof klass)) {
53
+ throw new Error(`expected instance of ${klass.name}`);
54
+ }
55
+ return instance.ptr;
56
+ }
57
+
50
58
  let WASM_VECTOR_LEN = 0;
51
59
 
52
60
  function passArray8ToWasm0(arg, malloc) {
@@ -67,121 +75,110 @@ function getInt32Memory0() {
67
75
  function getArrayU8FromWasm0(ptr, len) {
68
76
  return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
69
77
  }
70
-
71
- function _assertClass(instance, klass) {
72
- if (!(instance instanceof klass)) {
73
- throw new Error(`expected instance of ${klass.name}`);
74
- }
75
- return instance.ptr;
76
- }
77
78
  /**
78
79
  *
79
- *`base_mode_seal` provides an interface to [`hpke::single_shot_seal`]
80
- *that does not require compile time selection of an
81
- *algorithm. Instead, the selected algorithm is provided through the
82
- *[`Config`] passed as the first argument.
80
+ *`base_mode_open` provides an interface to [`hpke::single_shot_open`]
81
+ *that does not require compile time selection of an algorithm. Instead,
82
+ *the selected algorithm is provided through the [`Config`] passed as
83
+ *the first argument.
83
84
  *
84
- *Requires the `base-mode-seal` crate feature to be enabled.
85
+ *Requires the `base-mode-open` crate feature to be enabled.
85
86
  *
86
87
  *# Errors
87
88
  *
88
89
  *This will return an `Result::Err` variant if:
89
90
  *
90
- ** we are unable to deserialize the recipient public key
91
- ** there is an error in key encapsultion
92
- ** there is an error in encryption
93
- *
91
+ ** we are unable to deserialize the private key or encapsulated key
92
+ ** there is an error in key decapsulation
93
+ ** there is an error in decryption
94
94
  *
95
95
  * @param {Config} config
96
- * @param {Uint8Array} pk_recip
96
+ * @param {Uint8Array} private_key
97
+ * @param {Uint8Array} encapped_key
97
98
  * @param {Uint8Array} info
98
- * @param {Uint8Array} plaintext
99
+ * @param {Uint8Array} ciphertext
99
100
  * @param {Uint8Array} aad
100
- * @returns {EncappedKeyAndCiphertext}
101
+ * @returns {Uint8Array}
101
102
  */
102
- export function base_mode_seal(config, pk_recip, info, plaintext, aad) {
103
+ module.exports.base_mode_open = function(config, private_key, encapped_key, info, ciphertext, aad) {
103
104
  try {
104
105
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
105
106
  _assertClass(config, Config);
106
- var ptr0 = config.ptr;
107
- config.ptr = 0;
108
- const ptr1 = passArray8ToWasm0(pk_recip, wasm.__wbindgen_malloc);
107
+ const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
108
+ const len0 = WASM_VECTOR_LEN;
109
+ const ptr1 = passArray8ToWasm0(encapped_key, wasm.__wbindgen_malloc);
109
110
  const len1 = WASM_VECTOR_LEN;
110
111
  const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
111
112
  const len2 = WASM_VECTOR_LEN;
112
- const ptr3 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
113
+ const ptr3 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
113
114
  const len3 = WASM_VECTOR_LEN;
114
115
  const ptr4 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
115
116
  const len4 = WASM_VECTOR_LEN;
116
- wasm.base_mode_seal(retptr, ptr0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
117
+ wasm.base_mode_open(retptr, config.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
117
118
  var r0 = getInt32Memory0()[retptr / 4 + 0];
118
119
  var r1 = getInt32Memory0()[retptr / 4 + 1];
119
120
  var r2 = getInt32Memory0()[retptr / 4 + 2];
120
- if (r2) {
121
- throw takeObject(r1);
121
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
122
+ if (r3) {
123
+ throw takeObject(r2);
122
124
  }
123
- return EncappedKeyAndCiphertext.__wrap(r0);
125
+ var v5 = getArrayU8FromWasm0(r0, r1).slice();
126
+ wasm.__wbindgen_free(r0, r1 * 1);
127
+ return v5;
124
128
  } finally {
125
129
  wasm.__wbindgen_add_to_stack_pointer(16);
126
130
  }
127
- }
131
+ };
128
132
 
129
133
  /**
130
134
  *
131
- *`base_mode_open` provides an interface to [`hpke::single_shot_open`]
132
- *that does not require compile time selection of an algorithm. Instead,
133
- *the selected algorithm is provided through the [`Config`] passed as
134
- *the first argument.
135
+ *`base_mode_seal` provides an interface to [`hpke::single_shot_seal`]
136
+ *that does not require compile time selection of an
137
+ *algorithm. Instead, the selected algorithm is provided through the
138
+ *[`Config`] passed as the first argument.
135
139
  *
136
- *Requires the `base-mode-open` crate feature to be enabled.
140
+ *Requires the `base-mode-seal` crate feature to be enabled.
137
141
  *
138
142
  *# Errors
139
143
  *
140
144
  *This will return an `Result::Err` variant if:
141
145
  *
142
- ** we are unable to deserialize the private key or encapsulated key
143
- ** there is an error in key decapsulation
144
- ** there is an error in decryption
146
+ ** we are unable to deserialize the recipient public key
147
+ ** there is an error in key encapsultion
148
+ ** there is an error in encryption
149
+ *
145
150
  *
146
151
  * @param {Config} config
147
- * @param {Uint8Array} private_key
148
- * @param {Uint8Array} encapped_key
149
- * @param {Uint8Array} ciphertext
152
+ * @param {Uint8Array} recipient_public_key
150
153
  * @param {Uint8Array} info
154
+ * @param {Uint8Array} plaintext
151
155
  * @param {Uint8Array} aad
152
- * @returns {Uint8Array}
156
+ * @returns {EncappedKeyAndCiphertext}
153
157
  */
154
- export function base_mode_open(config, private_key, encapped_key, ciphertext, info, aad) {
158
+ module.exports.base_mode_seal = function(config, recipient_public_key, info, plaintext, aad) {
155
159
  try {
156
160
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
157
161
  _assertClass(config, Config);
158
- var ptr0 = config.ptr;
159
- config.ptr = 0;
160
- const ptr1 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
162
+ const ptr0 = passArray8ToWasm0(recipient_public_key, wasm.__wbindgen_malloc);
163
+ const len0 = WASM_VECTOR_LEN;
164
+ const ptr1 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
161
165
  const len1 = WASM_VECTOR_LEN;
162
- const ptr2 = passArray8ToWasm0(encapped_key, wasm.__wbindgen_malloc);
166
+ const ptr2 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
163
167
  const len2 = WASM_VECTOR_LEN;
164
- const ptr3 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
168
+ const ptr3 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
165
169
  const len3 = WASM_VECTOR_LEN;
166
- const ptr4 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
167
- const len4 = WASM_VECTOR_LEN;
168
- const ptr5 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
169
- const len5 = WASM_VECTOR_LEN;
170
- wasm.base_mode_open(retptr, ptr0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5);
170
+ wasm.base_mode_seal(retptr, config.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
171
171
  var r0 = getInt32Memory0()[retptr / 4 + 0];
172
172
  var r1 = getInt32Memory0()[retptr / 4 + 1];
173
173
  var r2 = getInt32Memory0()[retptr / 4 + 2];
174
- var r3 = getInt32Memory0()[retptr / 4 + 3];
175
- if (r3) {
176
- throw takeObject(r2);
174
+ if (r2) {
175
+ throw takeObject(r1);
177
176
  }
178
- var v6 = getArrayU8FromWasm0(r0, r1).slice();
179
- wasm.__wbindgen_free(r0, r1 * 1);
180
- return v6;
177
+ return EncappedKeyAndCiphertext.__wrap(r0);
181
178
  } finally {
182
179
  wasm.__wbindgen_add_to_stack_pointer(16);
183
180
  }
184
- }
181
+ };
185
182
 
186
183
  function handleError(f, args) {
187
184
  try {
@@ -195,7 +192,7 @@ function handleError(f, args) {
195
192
  *Aead represents an authenticated encryption with additional data
196
193
  *encryption function, as per [RFC9180§7.3](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.3)
197
194
  */
198
- export const Aead = Object.freeze({
195
+ module.exports.Aead = Object.freeze({
199
196
  /**
200
197
  * AES-128-GCM [GCM](https://doi.org/10.6028/nist.sp.800-38d)
201
198
  */
@@ -213,7 +210,7 @@ ChaCha20Poly1305:3,"3":"ChaCha20Poly1305", });
213
210
  *Kdf represents an key derivation function, as per
214
211
  *[RFC9180§7.2](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.2)
215
212
  */
216
- export const Kdf = Object.freeze({
213
+ module.exports.Kdf = Object.freeze({
217
214
  /**
218
215
  * Sha256 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
219
216
  */
@@ -229,10 +226,12 @@ Sha512:3,"3":"Sha512", });
229
226
  /**
230
227
  *
231
228
  *Kem represents an asymmetric key encapsulation mechanism, as per
232
- *[RFC9180§7.1](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.1). Currently
233
- *only two of options listed in the hpke draft are available.
229
+ *[RFC9180§7.1][section-7.1]. Currently only two of options listed in
230
+ *the hpke draft are available.
231
+ *
232
+ *[section-7.1]: https://www.rfc-editor.org/rfc/rfc9180.html#section-7.1
234
233
  */
235
- export const Kem = Object.freeze({
234
+ module.exports.Kem = Object.freeze({
236
235
  /**
237
236
  * DHKEM(P-256, HKDF-SHA256) [NISTCurves](https://doi.org/10.6028/nist.fips.186-4)
238
237
  */
@@ -247,7 +246,7 @@ X25519HkdfSha256:32,"32":"X25519HkdfSha256", });
247
246
  *algorithmic triple. This can be used with [`Config::base_mode_seal`],
248
247
  *[`Config::base_mode_open`], [`base_mode_seal`], or [`base_mode_open`].
249
248
  */
250
- export class Config {
249
+ class Config {
251
250
 
252
251
  static __wrap(ptr) {
253
252
  const obj = Object.create(Config.prototype);
@@ -327,17 +326,16 @@ export class Config {
327
326
  * * there is an error in encryption
328
327
  *
329
328
  *
330
- * @param {Uint8Array} pk_recip
329
+ * @param {Uint8Array} recipient_public_key
331
330
  * @param {Uint8Array} info
332
331
  * @param {Uint8Array} plaintext
333
332
  * @param {Uint8Array} aad
334
333
  * @returns {EncappedKeyAndCiphertext}
335
334
  */
336
- base_mode_seal(pk_recip, info, plaintext, aad) {
335
+ base_mode_seal(recipient_public_key, info, plaintext, aad) {
337
336
  try {
338
- const ptr = this.__destroy_into_raw();
339
337
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
340
- const ptr0 = passArray8ToWasm0(pk_recip, wasm.__wbindgen_malloc);
338
+ const ptr0 = passArray8ToWasm0(recipient_public_key, wasm.__wbindgen_malloc);
341
339
  const len0 = WASM_VECTOR_LEN;
342
340
  const ptr1 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
343
341
  const len1 = WASM_VECTOR_LEN;
@@ -345,7 +343,7 @@ export class Config {
345
343
  const len2 = WASM_VECTOR_LEN;
346
344
  const ptr3 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
347
345
  const len3 = WASM_VECTOR_LEN;
348
- wasm.base_mode_seal(retptr, ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
346
+ wasm.config_base_mode_seal(retptr, this.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
349
347
  var r0 = getInt32Memory0()[retptr / 4 + 0];
350
348
  var r1 = getInt32Memory0()[retptr / 4 + 1];
351
349
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -376,27 +374,26 @@ export class Config {
376
374
  *
377
375
  *
378
376
  * @param {Uint8Array} private_key
379
- * @param {Uint8Array} ciphertext
380
377
  * @param {Uint8Array} encapped_key
381
378
  * @param {Uint8Array} info
379
+ * @param {Uint8Array} ciphertext
382
380
  * @param {Uint8Array} aad
383
381
  * @returns {Uint8Array}
384
382
  */
385
- base_mode_open(private_key, ciphertext, encapped_key, info, aad) {
383
+ base_mode_open(private_key, encapped_key, info, ciphertext, aad) {
386
384
  try {
387
- const ptr = this.__destroy_into_raw();
388
385
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
389
386
  const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
390
387
  const len0 = WASM_VECTOR_LEN;
391
- const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
388
+ const ptr1 = passArray8ToWasm0(encapped_key, wasm.__wbindgen_malloc);
392
389
  const len1 = WASM_VECTOR_LEN;
393
- const ptr2 = passArray8ToWasm0(encapped_key, wasm.__wbindgen_malloc);
390
+ const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
394
391
  const len2 = WASM_VECTOR_LEN;
395
- const ptr3 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
392
+ const ptr3 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
396
393
  const len3 = WASM_VECTOR_LEN;
397
394
  const ptr4 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
398
395
  const len4 = WASM_VECTOR_LEN;
399
- wasm.base_mode_open(retptr, ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
396
+ wasm.config_base_mode_open(retptr, this.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
400
397
  var r0 = getInt32Memory0()[retptr / 4 + 0];
401
398
  var r1 = getInt32Memory0()[retptr / 4 + 1];
402
399
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -434,13 +431,13 @@ export class Config {
434
431
  }
435
432
  }
436
433
  }
434
+ module.exports.Config = Config;
437
435
  /**
438
- *r"
439
- * a simple struct to return the combined encapsulated key
440
- * and ciphertext from seal
441
436
  *
437
+ *a simple struct to return the combined encapsulated key
438
+ *and ciphertext from seal
442
439
  */
443
- export class EncappedKeyAndCiphertext {
440
+ class EncappedKeyAndCiphertext {
444
441
 
445
442
  static __wrap(ptr) {
446
443
  const obj = Object.create(EncappedKeyAndCiphertext.prototype);
@@ -461,13 +458,12 @@ export class EncappedKeyAndCiphertext {
461
458
  wasm.__wbg_encappedkeyandciphertext_free(ptr);
462
459
  }
463
460
  /**
464
- * getter for encapped_key
465
- * @returns {Uint8Array}
461
+ * the encapsulated encryption key
466
462
  */
467
463
  get encapped_key() {
468
464
  try {
469
465
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
470
- wasm.encappedkeyandciphertext_encapped_key(retptr, this.ptr);
466
+ wasm.__wbg_get_encappedkeyandciphertext_encapped_key(retptr, this.ptr);
471
467
  var r0 = getInt32Memory0()[retptr / 4 + 0];
472
468
  var r1 = getInt32Memory0()[retptr / 4 + 1];
473
469
  var v0 = getArrayU8FromWasm0(r0, r1).slice();
@@ -478,13 +474,21 @@ export class EncappedKeyAndCiphertext {
478
474
  }
479
475
  }
480
476
  /**
481
- * getter for ciphertext
482
- * @returns {Uint8Array}
477
+ * the encapsulated encryption key
478
+ * @param {Uint8Array} arg0
479
+ */
480
+ set encapped_key(arg0) {
481
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
482
+ const len0 = WASM_VECTOR_LEN;
483
+ wasm.__wbg_set_encappedkeyandciphertext_encapped_key(this.ptr, ptr0, len0);
484
+ }
485
+ /**
486
+ * the ciphertext, encrypted with the key
483
487
  */
484
488
  get ciphertext() {
485
489
  try {
486
490
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
487
- wasm.encappedkeyandciphertext_ciphertext(retptr, this.ptr);
491
+ wasm.__wbg_get_encappedkeyandciphertext_ciphertext(retptr, this.ptr);
488
492
  var r0 = getInt32Memory0()[retptr / 4 + 0];
489
493
  var r1 = getInt32Memory0()[retptr / 4 + 1];
490
494
  var v0 = getArrayU8FromWasm0(r0, r1).slice();
@@ -494,13 +498,23 @@ export class EncappedKeyAndCiphertext {
494
498
  wasm.__wbindgen_add_to_stack_pointer(16);
495
499
  }
496
500
  }
501
+ /**
502
+ * the ciphertext, encrypted with the key
503
+ * @param {Uint8Array} arg0
504
+ */
505
+ set ciphertext(arg0) {
506
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
507
+ const len0 = WASM_VECTOR_LEN;
508
+ wasm.__wbg_set_encappedkeyandciphertext_ciphertext(this.ptr, ptr0, len0);
509
+ }
497
510
  }
511
+ module.exports.EncappedKeyAndCiphertext = EncappedKeyAndCiphertext;
498
512
  /**
499
513
  *r"
500
514
  * a newtype wrapper for HpkeError so we can use it in wasm_bindgen
501
515
  *
502
516
  */
503
- export class HpkeError {
517
+ class HpkeError {
504
518
 
505
519
  static __wrap(ptr) {
506
520
  const obj = Object.create(HpkeError.prototype);
@@ -521,11 +535,13 @@ export class HpkeError {
521
535
  wasm.__wbg_hpkeerror_free(ptr);
522
536
  }
523
537
  }
538
+ module.exports.HpkeError = HpkeError;
524
539
  /**
525
540
  *
526
541
  *A simple error type for failed id lookups
542
+ *
527
543
  */
528
- export class IdLookupError {
544
+ class IdLookupError {
529
545
 
530
546
  static __wrap(ptr) {
531
547
  const obj = Object.create(IdLookupError.prototype);
@@ -546,150 +562,242 @@ export class IdLookupError {
546
562
  wasm.__wbg_idlookuperror_free(ptr);
547
563
  }
548
564
  }
565
+ module.exports.IdLookupError = IdLookupError;
566
+ /**
567
+ * An encoded keypair
568
+ */
569
+ class Keypair {
549
570
 
550
- export function __wbg_idlookuperror_new(arg0) {
551
- const ret = IdLookupError.__wrap(arg0);
571
+ static __wrap(ptr) {
572
+ const obj = Object.create(Keypair.prototype);
573
+ obj.ptr = ptr;
574
+
575
+ return obj;
576
+ }
577
+
578
+ __destroy_into_raw() {
579
+ const ptr = this.ptr;
580
+ this.ptr = 0;
581
+
582
+ return ptr;
583
+ }
584
+
585
+ free() {
586
+ const ptr = this.__destroy_into_raw();
587
+ wasm.__wbg_keypair_free(ptr);
588
+ }
589
+ /**
590
+ * the public key for this keypair
591
+ */
592
+ get public_key() {
593
+ try {
594
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
595
+ wasm.__wbg_get_keypair_public_key(retptr, this.ptr);
596
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
597
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
598
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
599
+ wasm.__wbindgen_free(r0, r1 * 1);
600
+ return v0;
601
+ } finally {
602
+ wasm.__wbindgen_add_to_stack_pointer(16);
603
+ }
604
+ }
605
+ /**
606
+ * the public key for this keypair
607
+ * @param {Uint8Array} arg0
608
+ */
609
+ set public_key(arg0) {
610
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
611
+ const len0 = WASM_VECTOR_LEN;
612
+ wasm.__wbg_set_keypair_public_key(this.ptr, ptr0, len0);
613
+ }
614
+ /**
615
+ * the private key for this keypair,
616
+ */
617
+ get private_key() {
618
+ try {
619
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
620
+ wasm.__wbg_get_keypair_private_key(retptr, this.ptr);
621
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
622
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
623
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
624
+ wasm.__wbindgen_free(r0, r1 * 1);
625
+ return v0;
626
+ } finally {
627
+ wasm.__wbindgen_add_to_stack_pointer(16);
628
+ }
629
+ }
630
+ /**
631
+ * the private key for this keypair,
632
+ * @param {Uint8Array} arg0
633
+ */
634
+ set private_key(arg0) {
635
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
636
+ const len0 = WASM_VECTOR_LEN;
637
+ wasm.__wbg_set_keypair_private_key(this.ptr, ptr0, len0);
638
+ }
639
+ /**
640
+ * generate a keypair from a [`Kem`]
641
+ * @param {number} kem
642
+ */
643
+ constructor(kem) {
644
+ const ret = wasm.keypair_new(kem);
645
+ return Keypair.__wrap(ret);
646
+ }
647
+ }
648
+ module.exports.Keypair = Keypair;
649
+
650
+ module.exports.__wbg_hpkeerror_new = function(arg0) {
651
+ const ret = HpkeError.__wrap(arg0);
552
652
  return addHeapObject(ret);
553
653
  };
554
654
 
555
- export function __wbg_hpkeerror_new(arg0) {
556
- const ret = HpkeError.__wrap(arg0);
655
+ module.exports.__wbg_idlookuperror_new = function(arg0) {
656
+ const ret = IdLookupError.__wrap(arg0);
557
657
  return addHeapObject(ret);
558
658
  };
559
659
 
560
- export function __wbg_randomFillSync_654a7797990fb8db() { return handleError(function (arg0, arg1, arg2) {
660
+ module.exports.__wbg_randomFillSync_654a7797990fb8db = function() { return handleError(function (arg0, arg1, arg2) {
561
661
  getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
562
662
  }, arguments) };
563
663
 
564
- export function __wbindgen_object_drop_ref(arg0) {
664
+ module.exports.__wbindgen_object_drop_ref = function(arg0) {
565
665
  takeObject(arg0);
566
666
  };
567
667
 
568
- export function __wbg_getRandomValues_fb6b088efb6bead2() { return handleError(function (arg0, arg1) {
668
+ module.exports.__wbg_getRandomValues_fb6b088efb6bead2 = function() { return handleError(function (arg0, arg1) {
569
669
  getObject(arg0).getRandomValues(getObject(arg1));
570
670
  }, arguments) };
571
671
 
572
- export function __wbg_process_70251ed1291754d5(arg0) {
672
+ module.exports.__wbg_process_70251ed1291754d5 = function(arg0) {
573
673
  const ret = getObject(arg0).process;
574
674
  return addHeapObject(ret);
575
675
  };
576
676
 
577
- export function __wbindgen_is_object(arg0) {
677
+ module.exports.__wbindgen_is_object = function(arg0) {
578
678
  const val = getObject(arg0);
579
679
  const ret = typeof(val) === 'object' && val !== null;
580
680
  return ret;
581
681
  };
582
682
 
583
- export function __wbg_versions_b23f2588cdb2ddbb(arg0) {
683
+ module.exports.__wbg_versions_b23f2588cdb2ddbb = function(arg0) {
584
684
  const ret = getObject(arg0).versions;
585
685
  return addHeapObject(ret);
586
686
  };
587
687
 
588
- export function __wbg_node_61b8c9a82499895d(arg0) {
688
+ module.exports.__wbg_node_61b8c9a82499895d = function(arg0) {
589
689
  const ret = getObject(arg0).node;
590
690
  return addHeapObject(ret);
591
691
  };
592
692
 
593
- export function __wbindgen_is_string(arg0) {
693
+ module.exports.__wbindgen_is_string = function(arg0) {
594
694
  const ret = typeof(getObject(arg0)) === 'string';
595
695
  return ret;
596
696
  };
597
697
 
598
- export function __wbg_static_accessor_NODE_MODULE_33b45247c55045b0() {
599
- const ret = module;
698
+ module.exports.__wbg_crypto_2f56257a38275dbd = function(arg0) {
699
+ const ret = getObject(arg0).crypto;
600
700
  return addHeapObject(ret);
601
701
  };
602
702
 
603
- export function __wbg_require_2a93bc09fee45aca() { return handleError(function (arg0, arg1, arg2) {
604
- const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
703
+ module.exports.__wbg_msCrypto_d07655bf62361f21 = function(arg0) {
704
+ const ret = getObject(arg0).msCrypto;
605
705
  return addHeapObject(ret);
606
- }, arguments) };
706
+ };
607
707
 
608
- export function __wbg_crypto_2f56257a38275dbd(arg0) {
609
- const ret = getObject(arg0).crypto;
708
+ module.exports.__wbg_static_accessor_NODE_MODULE_33b45247c55045b0 = function() {
709
+ const ret = module;
610
710
  return addHeapObject(ret);
611
711
  };
612
712
 
613
- export function __wbg_msCrypto_d07655bf62361f21(arg0) {
614
- const ret = getObject(arg0).msCrypto;
713
+ module.exports.__wbg_require_2a93bc09fee45aca = function() { return handleError(function (arg0, arg1, arg2) {
714
+ const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
615
715
  return addHeapObject(ret);
616
- };
716
+ }, arguments) };
617
717
 
618
- export function __wbg_newnoargs_e23b458e372830de(arg0, arg1) {
718
+ module.exports.__wbg_newnoargs_e23b458e372830de = function(arg0, arg1) {
619
719
  const ret = new Function(getStringFromWasm0(arg0, arg1));
620
720
  return addHeapObject(ret);
621
721
  };
622
722
 
623
- export function __wbg_call_ae78342adc33730a() { return handleError(function (arg0, arg1) {
723
+ module.exports.__wbg_call_ae78342adc33730a = function() { return handleError(function (arg0, arg1) {
624
724
  const ret = getObject(arg0).call(getObject(arg1));
625
725
  return addHeapObject(ret);
626
726
  }, arguments) };
627
727
 
628
- export function __wbindgen_object_clone_ref(arg0) {
728
+ module.exports.__wbindgen_object_clone_ref = function(arg0) {
629
729
  const ret = getObject(arg0);
630
730
  return addHeapObject(ret);
631
731
  };
632
732
 
633
- export function __wbg_self_99737b4dcdf6f0d8() { return handleError(function () {
733
+ module.exports.__wbg_self_99737b4dcdf6f0d8 = function() { return handleError(function () {
634
734
  const ret = self.self;
635
735
  return addHeapObject(ret);
636
736
  }, arguments) };
637
737
 
638
- export function __wbg_window_9b61fbbf3564c4fb() { return handleError(function () {
738
+ module.exports.__wbg_window_9b61fbbf3564c4fb = function() { return handleError(function () {
639
739
  const ret = window.window;
640
740
  return addHeapObject(ret);
641
741
  }, arguments) };
642
742
 
643
- export function __wbg_globalThis_8e275ef40caea3a3() { return handleError(function () {
743
+ module.exports.__wbg_globalThis_8e275ef40caea3a3 = function() { return handleError(function () {
644
744
  const ret = globalThis.globalThis;
645
745
  return addHeapObject(ret);
646
746
  }, arguments) };
647
747
 
648
- export function __wbg_global_5de1e0f82bddcd27() { return handleError(function () {
748
+ module.exports.__wbg_global_5de1e0f82bddcd27 = function() { return handleError(function () {
649
749
  const ret = global.global;
650
750
  return addHeapObject(ret);
651
751
  }, arguments) };
652
752
 
653
- export function __wbindgen_is_undefined(arg0) {
753
+ module.exports.__wbindgen_is_undefined = function(arg0) {
654
754
  const ret = getObject(arg0) === undefined;
655
755
  return ret;
656
756
  };
657
757
 
658
- export function __wbg_buffer_7af23f65f6c64548(arg0) {
758
+ module.exports.__wbg_buffer_7af23f65f6c64548 = function(arg0) {
659
759
  const ret = getObject(arg0).buffer;
660
760
  return addHeapObject(ret);
661
761
  };
662
762
 
663
- export function __wbg_new_cc9018bd6f283b6f(arg0) {
763
+ module.exports.__wbg_new_cc9018bd6f283b6f = function(arg0) {
664
764
  const ret = new Uint8Array(getObject(arg0));
665
765
  return addHeapObject(ret);
666
766
  };
667
767
 
668
- export function __wbg_set_f25e869e4565d2a2(arg0, arg1, arg2) {
768
+ module.exports.__wbg_set_f25e869e4565d2a2 = function(arg0, arg1, arg2) {
669
769
  getObject(arg0).set(getObject(arg1), arg2 >>> 0);
670
770
  };
671
771
 
672
- export function __wbg_length_0acb1cf9bbaf8519(arg0) {
772
+ module.exports.__wbg_length_0acb1cf9bbaf8519 = function(arg0) {
673
773
  const ret = getObject(arg0).length;
674
774
  return ret;
675
775
  };
676
776
 
677
- export function __wbg_newwithlength_8f0657faca9f1422(arg0) {
777
+ module.exports.__wbg_newwithlength_8f0657faca9f1422 = function(arg0) {
678
778
  const ret = new Uint8Array(arg0 >>> 0);
679
779
  return addHeapObject(ret);
680
780
  };
681
781
 
682
- export function __wbg_subarray_da527dbd24eafb6b(arg0, arg1, arg2) {
782
+ module.exports.__wbg_subarray_da527dbd24eafb6b = function(arg0, arg1, arg2) {
683
783
  const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
684
784
  return addHeapObject(ret);
685
785
  };
686
786
 
687
- export function __wbindgen_throw(arg0, arg1) {
787
+ module.exports.__wbindgen_throw = function(arg0, arg1) {
688
788
  throw new Error(getStringFromWasm0(arg0, arg1));
689
789
  };
690
790
 
691
- export function __wbindgen_memory() {
791
+ module.exports.__wbindgen_memory = function() {
692
792
  const ret = wasm.memory;
693
793
  return addHeapObject(ret);
694
794
  };
695
795
 
796
+ const path = require('path').join(__dirname, 'hpke_dispatch_bg.wasm');
797
+ const bytes = require('fs').readFileSync(path);
798
+
799
+ const wasmModule = new WebAssembly.Module(bytes);
800
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
801
+ wasm = wasmInstance.exports;
802
+ module.exports.__wasm = wasm;
803
+