hpke 0.5.0 → 1.0.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,812 +0,0 @@
1
- let imports = {};
2
- imports['__wbindgen_placeholder__'] = module.exports;
3
- let wasm;
4
- const { TextDecoder } = require(`util`);
5
-
6
- const heap = new Array(32).fill(undefined);
7
-
8
- heap.push(undefined, null, true, false);
9
-
10
- function getObject(idx) { return heap[idx]; }
11
-
12
- let heap_next = heap.length;
13
-
14
- function dropObject(idx) {
15
- if (idx < 36) return;
16
- heap[idx] = heap_next;
17
- heap_next = idx;
18
- }
19
-
20
- function takeObject(idx) {
21
- const ret = getObject(idx);
22
- dropObject(idx);
23
- return ret;
24
- }
25
-
26
- function addHeapObject(obj) {
27
- if (heap_next === heap.length) heap.push(heap.length + 1);
28
- const idx = heap_next;
29
- heap_next = heap[idx];
30
-
31
- heap[idx] = obj;
32
- return idx;
33
- }
34
-
35
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
36
-
37
- cachedTextDecoder.decode();
38
-
39
- let cachedUint8Memory0 = new Uint8Array();
40
-
41
- function getUint8Memory0() {
42
- if (cachedUint8Memory0.byteLength === 0) {
43
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
44
- }
45
- return cachedUint8Memory0;
46
- }
47
-
48
- function getStringFromWasm0(ptr, len) {
49
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
50
- }
51
-
52
- let cachedInt32Memory0 = new Int32Array();
53
-
54
- function getInt32Memory0() {
55
- if (cachedInt32Memory0.byteLength === 0) {
56
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
57
- }
58
- return cachedInt32Memory0;
59
- }
60
-
61
- function getArrayU8FromWasm0(ptr, len) {
62
- return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
63
- }
64
-
65
- let WASM_VECTOR_LEN = 0;
66
-
67
- function passArray8ToWasm0(arg, malloc) {
68
- const ptr = malloc(arg.length * 1);
69
- getUint8Memory0().set(arg, ptr / 1);
70
- WASM_VECTOR_LEN = arg.length;
71
- return ptr;
72
- }
73
-
74
- function _assertClass(instance, klass) {
75
- if (!(instance instanceof klass)) {
76
- throw new Error(`expected instance of ${klass.name}`);
77
- }
78
- return instance.ptr;
79
- }
80
- /**
81
- *
82
- *`base_mode_seal` provides an interface to [`hpke::single_shot_seal`]
83
- *that does not require compile time selection of an
84
- *algorithm. Instead, the selected algorithm is provided through the
85
- *[`Config`] passed as the first argument.
86
- *
87
- *Requires the `base-mode-seal` crate feature to be enabled.
88
- *
89
- *# Errors
90
- *
91
- *This will return an `Result::Err` variant if:
92
- *
93
- ** we are unable to deserialize the recipient public key
94
- ** there is an error in key encapsultion
95
- ** there is an error in encryption
96
- *
97
- *
98
- * @param {Config} config
99
- * @param {Uint8Array} recipient_public_key
100
- * @param {Uint8Array} info
101
- * @param {Uint8Array} plaintext
102
- * @param {Uint8Array} aad
103
- * @returns {EncappedKeyAndCiphertext}
104
- */
105
- module.exports.base_mode_seal = function(config, recipient_public_key, info, plaintext, aad) {
106
- try {
107
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
108
- _assertClass(config, Config);
109
- const ptr0 = passArray8ToWasm0(recipient_public_key, wasm.__wbindgen_malloc);
110
- const len0 = WASM_VECTOR_LEN;
111
- const ptr1 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
112
- const len1 = WASM_VECTOR_LEN;
113
- const ptr2 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
114
- const len2 = WASM_VECTOR_LEN;
115
- const ptr3 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
116
- const len3 = WASM_VECTOR_LEN;
117
- wasm.base_mode_seal(retptr, config.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
118
- var r0 = getInt32Memory0()[retptr / 4 + 0];
119
- var r1 = getInt32Memory0()[retptr / 4 + 1];
120
- var r2 = getInt32Memory0()[retptr / 4 + 2];
121
- if (r2) {
122
- throw takeObject(r1);
123
- }
124
- return EncappedKeyAndCiphertext.__wrap(r0);
125
- } finally {
126
- wasm.__wbindgen_add_to_stack_pointer(16);
127
- }
128
- };
129
-
130
- /**
131
- *
132
- *`base_mode_open` provides an interface to [`hpke::single_shot_open`]
133
- *that does not require compile time selection of an algorithm. Instead,
134
- *the selected algorithm is provided through the [`Config`] passed as
135
- *the first argument.
136
- *
137
- *Requires the `base-mode-open` crate feature to be enabled.
138
- *
139
- *# Errors
140
- *
141
- *This will return an `Result::Err` variant if:
142
- *
143
- ** we are unable to deserialize the private key or encapsulated key
144
- ** there is an error in key decapsulation
145
- ** there is an error in decryption
146
- *
147
- * @param {Config} config
148
- * @param {Uint8Array} private_key
149
- * @param {Uint8Array} encapped_key
150
- * @param {Uint8Array} info
151
- * @param {Uint8Array} ciphertext
152
- * @param {Uint8Array} aad
153
- * @returns {Uint8Array}
154
- */
155
- module.exports.base_mode_open = function(config, private_key, encapped_key, info, ciphertext, aad) {
156
- try {
157
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
158
- _assertClass(config, Config);
159
- const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
160
- const len0 = WASM_VECTOR_LEN;
161
- const ptr1 = passArray8ToWasm0(encapped_key, wasm.__wbindgen_malloc);
162
- const len1 = WASM_VECTOR_LEN;
163
- const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
164
- const len2 = WASM_VECTOR_LEN;
165
- const ptr3 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
166
- const len3 = WASM_VECTOR_LEN;
167
- const ptr4 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
168
- const len4 = WASM_VECTOR_LEN;
169
- wasm.base_mode_open(retptr, config.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
170
- var r0 = getInt32Memory0()[retptr / 4 + 0];
171
- var r1 = getInt32Memory0()[retptr / 4 + 1];
172
- var r2 = getInt32Memory0()[retptr / 4 + 2];
173
- var r3 = getInt32Memory0()[retptr / 4 + 3];
174
- if (r3) {
175
- throw takeObject(r2);
176
- }
177
- var v5 = getArrayU8FromWasm0(r0, r1).slice();
178
- wasm.__wbindgen_free(r0, r1 * 1);
179
- return v5;
180
- } finally {
181
- wasm.__wbindgen_add_to_stack_pointer(16);
182
- }
183
- };
184
-
185
- function handleError(f, args) {
186
- try {
187
- return f.apply(this, args);
188
- } catch (e) {
189
- wasm.__wbindgen_exn_store(addHeapObject(e));
190
- }
191
- }
192
- /**
193
- *
194
- *Aead represents an authenticated encryption with additional data
195
- *encryption function, as per [RFC9180§7.3](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.3)
196
- */
197
- module.exports.Aead = Object.freeze({
198
- /**
199
- * AES-128-GCM [GCM](https://doi.org/10.6028/nist.sp.800-38d)
200
- */
201
- AesGcm128:1,"1":"AesGcm128",
202
- /**
203
- * AES-256-GCM [GCM](https://doi.org/10.6028/nist.sp.800-38d)
204
- */
205
- AesGcm256:2,"2":"AesGcm256",
206
- /**
207
- * ChaCha20Poly1305 [RFC8439](https://www.rfc-editor.org/info/rfc8439)
208
- */
209
- ChaCha20Poly1305:3,"3":"ChaCha20Poly1305", });
210
- /**
211
- *
212
- *Kdf represents an key derivation function, as per
213
- *[RFC9180§7.2](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.2)
214
- */
215
- module.exports.Kdf = Object.freeze({
216
- /**
217
- * Sha256 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
218
- */
219
- Sha256:1,"1":"Sha256",
220
- /**
221
- * Sha384 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
222
- */
223
- Sha384:2,"2":"Sha384",
224
- /**
225
- * Sha512 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
226
- */
227
- Sha512:3,"3":"Sha512", });
228
- /**
229
- *
230
- *Kem represents an asymmetric key encapsulation mechanism, as per
231
- *[RFC9180§7.1][section-7.1]. Currently only two of options listed in
232
- *the hpke draft are available.
233
- *
234
- *[section-7.1]: https://www.rfc-editor.org/rfc/rfc9180.html#section-7.1
235
- */
236
- module.exports.Kem = Object.freeze({
237
- /**
238
- * DHKEM(P-256, HKDF-SHA256) [NISTCurves](https://doi.org/10.6028/nist.fips.186-4)
239
- */
240
- DhP256HkdfSha256:16,"16":"DhP256HkdfSha256",
241
- /**
242
- * DHKEM(X25519, HKDF-SHA256) [RFC7748](https://www.rfc-editor.org/info/rfc7748)
243
- */
244
- X25519HkdfSha256:32,"32":"X25519HkdfSha256", });
245
- /**
246
- *
247
- *Config is an open struct that contains an ([`Aead`], [`Kdf`], [`Kem`])
248
- *algorithmic triple. This can be used with [`Config::base_mode_seal`],
249
- *[`Config::base_mode_open`], [`base_mode_seal`], or [`base_mode_open`].
250
- */
251
- class Config {
252
-
253
- static __wrap(ptr) {
254
- const obj = Object.create(Config.prototype);
255
- obj.ptr = ptr;
256
-
257
- return obj;
258
- }
259
-
260
- __destroy_into_raw() {
261
- const ptr = this.ptr;
262
- this.ptr = 0;
263
-
264
- return ptr;
265
- }
266
-
267
- free() {
268
- const ptr = this.__destroy_into_raw();
269
- wasm.__wbg_config_free(ptr);
270
- }
271
- /**
272
- * the [authenticated encryption with additional data encryption function](crate::Aead) to be used
273
- * @returns {number}
274
- */
275
- get aead() {
276
- const ret = wasm.__wbg_get_config_aead(this.ptr);
277
- return ret >>> 0;
278
- }
279
- /**
280
- * the [authenticated encryption with additional data encryption function](crate::Aead) to be used
281
- * @param {number} arg0
282
- */
283
- set aead(arg0) {
284
- wasm.__wbg_set_config_aead(this.ptr, arg0);
285
- }
286
- /**
287
- * the [key derivation function](crate::Kdf) to be used
288
- * @returns {number}
289
- */
290
- get kdf() {
291
- const ret = wasm.__wbg_get_config_kdf(this.ptr);
292
- return ret >>> 0;
293
- }
294
- /**
295
- * the [key derivation function](crate::Kdf) to be used
296
- * @param {number} arg0
297
- */
298
- set kdf(arg0) {
299
- wasm.__wbg_set_config_kdf(this.ptr, arg0);
300
- }
301
- /**
302
- * the [asymmetric key encapsulation mechanism](crate::Kem) to be used
303
- * @returns {number}
304
- */
305
- get kem() {
306
- const ret = wasm.__wbg_get_config_kem(this.ptr);
307
- return ret >>> 0;
308
- }
309
- /**
310
- * the [asymmetric key encapsulation mechanism](crate::Kem) to be used
311
- * @param {number} arg0
312
- */
313
- set kem(arg0) {
314
- wasm.__wbg_set_config_kem(this.ptr, arg0);
315
- }
316
- /**
317
- *
318
- * base_mode_seal provides an interface to [`hpke::single_shot_seal`] that does
319
- * not require compile time selection of an algorithm. Instead, the
320
- * selected algorithm is provided through the [`Config`] that this
321
- * method is called on.
322
- *
323
- * Requires the `base-mode-seal` crate feature to be enabled.
324
- *
325
- * # Errors
326
- *
327
- * This will return an `Result::Err` variant if:
328
- *
329
- * * we are unable to deserialize the recipient public key
330
- * * there is an error in key encapsultion
331
- * * there is an error in encryption
332
- *
333
- *
334
- * @param {Uint8Array} recipient_public_key
335
- * @param {Uint8Array} info
336
- * @param {Uint8Array} plaintext
337
- * @param {Uint8Array} aad
338
- * @returns {EncappedKeyAndCiphertext}
339
- */
340
- base_mode_seal(recipient_public_key, info, plaintext, aad) {
341
- try {
342
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
343
- const ptr0 = passArray8ToWasm0(recipient_public_key, wasm.__wbindgen_malloc);
344
- const len0 = WASM_VECTOR_LEN;
345
- const ptr1 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
346
- const len1 = WASM_VECTOR_LEN;
347
- const ptr2 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
348
- const len2 = WASM_VECTOR_LEN;
349
- const ptr3 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
350
- const len3 = WASM_VECTOR_LEN;
351
- wasm.config_base_mode_seal(retptr, this.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
352
- var r0 = getInt32Memory0()[retptr / 4 + 0];
353
- var r1 = getInt32Memory0()[retptr / 4 + 1];
354
- var r2 = getInt32Memory0()[retptr / 4 + 2];
355
- if (r2) {
356
- throw takeObject(r1);
357
- }
358
- return EncappedKeyAndCiphertext.__wrap(r0);
359
- } finally {
360
- wasm.__wbindgen_add_to_stack_pointer(16);
361
- }
362
- }
363
- /**
364
- *
365
- * base_mode_open provides an interface to [`hpke::single_shot_open`]
366
- * that does not require compile time selection of an
367
- * algorithm. Instead, the selected algorithm is provided through the
368
- * [`Config`] that this method is called on.
369
- *
370
- * Requires the `base-mode-open` crate feature to be enabled.
371
- *
372
- * # Errors
373
- *
374
- * This will return an `Result::Err` variant if:
375
- *
376
- * * we are unable to deserialize the private key or encapsulated key
377
- * * there is an error in key decapsulation
378
- * * there is an error in decryption
379
- *
380
- *
381
- * @param {Uint8Array} private_key
382
- * @param {Uint8Array} encapped_key
383
- * @param {Uint8Array} info
384
- * @param {Uint8Array} ciphertext
385
- * @param {Uint8Array} aad
386
- * @returns {Uint8Array}
387
- */
388
- base_mode_open(private_key, encapped_key, info, ciphertext, aad) {
389
- try {
390
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
391
- const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
392
- const len0 = WASM_VECTOR_LEN;
393
- const ptr1 = passArray8ToWasm0(encapped_key, wasm.__wbindgen_malloc);
394
- const len1 = WASM_VECTOR_LEN;
395
- const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
396
- const len2 = WASM_VECTOR_LEN;
397
- const ptr3 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
398
- const len3 = WASM_VECTOR_LEN;
399
- const ptr4 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
400
- const len4 = WASM_VECTOR_LEN;
401
- wasm.config_base_mode_open(retptr, this.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
402
- var r0 = getInt32Memory0()[retptr / 4 + 0];
403
- var r1 = getInt32Memory0()[retptr / 4 + 1];
404
- var r2 = getInt32Memory0()[retptr / 4 + 2];
405
- var r3 = getInt32Memory0()[retptr / 4 + 3];
406
- if (r3) {
407
- throw takeObject(r2);
408
- }
409
- var v5 = getArrayU8FromWasm0(r0, r1).slice();
410
- wasm.__wbindgen_free(r0, r1 * 1);
411
- return v5;
412
- } finally {
413
- wasm.__wbindgen_add_to_stack_pointer(16);
414
- }
415
- }
416
- /**
417
- * Attempt to convert three u16 ids into a valid config. The id mappings are defined in the draft.
418
- * @param {number} aead_id
419
- * @param {number} kdf_id
420
- * @param {number} kem_id
421
- * @returns {Config}
422
- */
423
- static try_from_ids(aead_id, kdf_id, kem_id) {
424
- try {
425
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
426
- wasm.config_try_from_ids(retptr, aead_id, kdf_id, kem_id);
427
- var r0 = getInt32Memory0()[retptr / 4 + 0];
428
- var r1 = getInt32Memory0()[retptr / 4 + 1];
429
- var r2 = getInt32Memory0()[retptr / 4 + 2];
430
- if (r2) {
431
- throw takeObject(r1);
432
- }
433
- return Config.__wrap(r0);
434
- } finally {
435
- wasm.__wbindgen_add_to_stack_pointer(16);
436
- }
437
- }
438
- }
439
- module.exports.Config = Config;
440
- /**
441
- *
442
- *a simple struct to return the combined encapsulated key
443
- *and ciphertext from seal
444
- */
445
- class EncappedKeyAndCiphertext {
446
-
447
- static __wrap(ptr) {
448
- const obj = Object.create(EncappedKeyAndCiphertext.prototype);
449
- obj.ptr = ptr;
450
-
451
- return obj;
452
- }
453
-
454
- __destroy_into_raw() {
455
- const ptr = this.ptr;
456
- this.ptr = 0;
457
-
458
- return ptr;
459
- }
460
-
461
- free() {
462
- const ptr = this.__destroy_into_raw();
463
- wasm.__wbg_encappedkeyandciphertext_free(ptr);
464
- }
465
- /**
466
- * the encapsulated encryption key
467
- * @returns {Uint8Array}
468
- */
469
- get encapped_key() {
470
- try {
471
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
472
- wasm.__wbg_get_encappedkeyandciphertext_encapped_key(retptr, this.ptr);
473
- var r0 = getInt32Memory0()[retptr / 4 + 0];
474
- var r1 = getInt32Memory0()[retptr / 4 + 1];
475
- var v0 = getArrayU8FromWasm0(r0, r1).slice();
476
- wasm.__wbindgen_free(r0, r1 * 1);
477
- return v0;
478
- } finally {
479
- wasm.__wbindgen_add_to_stack_pointer(16);
480
- }
481
- }
482
- /**
483
- * the encapsulated encryption key
484
- * @param {Uint8Array} arg0
485
- */
486
- set encapped_key(arg0) {
487
- const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
488
- const len0 = WASM_VECTOR_LEN;
489
- wasm.__wbg_set_encappedkeyandciphertext_encapped_key(this.ptr, ptr0, len0);
490
- }
491
- /**
492
- * the ciphertext, encrypted with the key
493
- * @returns {Uint8Array}
494
- */
495
- get ciphertext() {
496
- try {
497
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
498
- wasm.__wbg_get_encappedkeyandciphertext_ciphertext(retptr, this.ptr);
499
- var r0 = getInt32Memory0()[retptr / 4 + 0];
500
- var r1 = getInt32Memory0()[retptr / 4 + 1];
501
- var v0 = getArrayU8FromWasm0(r0, r1).slice();
502
- wasm.__wbindgen_free(r0, r1 * 1);
503
- return v0;
504
- } finally {
505
- wasm.__wbindgen_add_to_stack_pointer(16);
506
- }
507
- }
508
- /**
509
- * the ciphertext, encrypted with the key
510
- * @param {Uint8Array} arg0
511
- */
512
- set ciphertext(arg0) {
513
- const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
514
- const len0 = WASM_VECTOR_LEN;
515
- wasm.__wbg_set_encappedkeyandciphertext_ciphertext(this.ptr, ptr0, len0);
516
- }
517
- }
518
- module.exports.EncappedKeyAndCiphertext = EncappedKeyAndCiphertext;
519
- /**
520
- *r"
521
- * a newtype wrapper for HpkeError so we can use it in wasm_bindgen
522
- *
523
- */
524
- class HpkeError {
525
-
526
- static __wrap(ptr) {
527
- const obj = Object.create(HpkeError.prototype);
528
- obj.ptr = ptr;
529
-
530
- return obj;
531
- }
532
-
533
- __destroy_into_raw() {
534
- const ptr = this.ptr;
535
- this.ptr = 0;
536
-
537
- return ptr;
538
- }
539
-
540
- free() {
541
- const ptr = this.__destroy_into_raw();
542
- wasm.__wbg_hpkeerror_free(ptr);
543
- }
544
- }
545
- module.exports.HpkeError = HpkeError;
546
- /**
547
- *
548
- *A simple error type for failed id lookups
549
- *
550
- */
551
- class IdLookupError {
552
-
553
- static __wrap(ptr) {
554
- const obj = Object.create(IdLookupError.prototype);
555
- obj.ptr = ptr;
556
-
557
- return obj;
558
- }
559
-
560
- __destroy_into_raw() {
561
- const ptr = this.ptr;
562
- this.ptr = 0;
563
-
564
- return ptr;
565
- }
566
-
567
- free() {
568
- const ptr = this.__destroy_into_raw();
569
- wasm.__wbg_idlookuperror_free(ptr);
570
- }
571
- }
572
- module.exports.IdLookupError = IdLookupError;
573
- /**
574
- * An encoded keypair
575
- */
576
- class Keypair {
577
-
578
- static __wrap(ptr) {
579
- const obj = Object.create(Keypair.prototype);
580
- obj.ptr = ptr;
581
-
582
- return obj;
583
- }
584
-
585
- __destroy_into_raw() {
586
- const ptr = this.ptr;
587
- this.ptr = 0;
588
-
589
- return ptr;
590
- }
591
-
592
- free() {
593
- const ptr = this.__destroy_into_raw();
594
- wasm.__wbg_keypair_free(ptr);
595
- }
596
- /**
597
- * the public key for this keypair
598
- * @returns {Uint8Array}
599
- */
600
- get public_key() {
601
- try {
602
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
603
- wasm.__wbg_get_keypair_public_key(retptr, this.ptr);
604
- var r0 = getInt32Memory0()[retptr / 4 + 0];
605
- var r1 = getInt32Memory0()[retptr / 4 + 1];
606
- var v0 = getArrayU8FromWasm0(r0, r1).slice();
607
- wasm.__wbindgen_free(r0, r1 * 1);
608
- return v0;
609
- } finally {
610
- wasm.__wbindgen_add_to_stack_pointer(16);
611
- }
612
- }
613
- /**
614
- * the public key for this keypair
615
- * @param {Uint8Array} arg0
616
- */
617
- set public_key(arg0) {
618
- const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
619
- const len0 = WASM_VECTOR_LEN;
620
- wasm.__wbg_set_keypair_public_key(this.ptr, ptr0, len0);
621
- }
622
- /**
623
- * the private key for this keypair,
624
- * @returns {Uint8Array}
625
- */
626
- get private_key() {
627
- try {
628
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
629
- wasm.__wbg_get_keypair_private_key(retptr, this.ptr);
630
- var r0 = getInt32Memory0()[retptr / 4 + 0];
631
- var r1 = getInt32Memory0()[retptr / 4 + 1];
632
- var v0 = getArrayU8FromWasm0(r0, r1).slice();
633
- wasm.__wbindgen_free(r0, r1 * 1);
634
- return v0;
635
- } finally {
636
- wasm.__wbindgen_add_to_stack_pointer(16);
637
- }
638
- }
639
- /**
640
- * the private key for this keypair,
641
- * @param {Uint8Array} arg0
642
- */
643
- set private_key(arg0) {
644
- const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
645
- const len0 = WASM_VECTOR_LEN;
646
- wasm.__wbg_set_keypair_private_key(this.ptr, ptr0, len0);
647
- }
648
- /**
649
- * generate a keypair from a [`Kem`]
650
- * @param {number} kem
651
- */
652
- constructor(kem) {
653
- const ret = wasm.keypair_new(kem);
654
- return Keypair.__wrap(ret);
655
- }
656
- }
657
- module.exports.Keypair = Keypair;
658
-
659
- module.exports.__wbg_idlookuperror_new = function(arg0) {
660
- const ret = IdLookupError.__wrap(arg0);
661
- return addHeapObject(ret);
662
- };
663
-
664
- module.exports.__wbg_hpkeerror_new = function(arg0) {
665
- const ret = HpkeError.__wrap(arg0);
666
- return addHeapObject(ret);
667
- };
668
-
669
- module.exports.__wbg_process_0cc2ada8524d6f83 = function(arg0) {
670
- const ret = getObject(arg0).process;
671
- return addHeapObject(ret);
672
- };
673
-
674
- module.exports.__wbindgen_is_object = function(arg0) {
675
- const val = getObject(arg0);
676
- const ret = typeof(val) === 'object' && val !== null;
677
- return ret;
678
- };
679
-
680
- module.exports.__wbg_versions_c11acceab27a6c87 = function(arg0) {
681
- const ret = getObject(arg0).versions;
682
- return addHeapObject(ret);
683
- };
684
-
685
- module.exports.__wbg_node_7ff1ce49caf23815 = function(arg0) {
686
- const ret = getObject(arg0).node;
687
- return addHeapObject(ret);
688
- };
689
-
690
- module.exports.__wbindgen_is_string = function(arg0) {
691
- const ret = typeof(getObject(arg0)) === 'string';
692
- return ret;
693
- };
694
-
695
- module.exports.__wbindgen_object_drop_ref = function(arg0) {
696
- takeObject(arg0);
697
- };
698
-
699
- module.exports.__wbg_crypto_2036bed7c44c25e7 = function(arg0) {
700
- const ret = getObject(arg0).crypto;
701
- return addHeapObject(ret);
702
- };
703
-
704
- module.exports.__wbg_msCrypto_a21fc88caf1ecdc8 = function(arg0) {
705
- const ret = getObject(arg0).msCrypto;
706
- return addHeapObject(ret);
707
- };
708
-
709
- module.exports.__wbg_static_accessor_NODE_MODULE_cf6401cc1091279e = function() {
710
- const ret = module;
711
- return addHeapObject(ret);
712
- };
713
-
714
- module.exports.__wbg_require_a746e79b322b9336 = function() { return handleError(function (arg0, arg1, arg2) {
715
- const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
716
- return addHeapObject(ret);
717
- }, arguments) };
718
-
719
- module.exports.__wbg_getRandomValues_b99eec4244a475bb = function() { return handleError(function (arg0, arg1) {
720
- getObject(arg0).getRandomValues(getObject(arg1));
721
- }, arguments) };
722
-
723
- module.exports.__wbg_randomFillSync_065afffde01daa66 = function() { return handleError(function (arg0, arg1, arg2) {
724
- getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
725
- }, arguments) };
726
-
727
- module.exports.__wbg_newnoargs_b5b063fc6c2f0376 = function(arg0, arg1) {
728
- const ret = new Function(getStringFromWasm0(arg0, arg1));
729
- return addHeapObject(ret);
730
- };
731
-
732
- module.exports.__wbg_call_97ae9d8645dc388b = function() { return handleError(function (arg0, arg1) {
733
- const ret = getObject(arg0).call(getObject(arg1));
734
- return addHeapObject(ret);
735
- }, arguments) };
736
-
737
- module.exports.__wbindgen_object_clone_ref = function(arg0) {
738
- const ret = getObject(arg0);
739
- return addHeapObject(ret);
740
- };
741
-
742
- module.exports.__wbg_self_6d479506f72c6a71 = function() { return handleError(function () {
743
- const ret = self.self;
744
- return addHeapObject(ret);
745
- }, arguments) };
746
-
747
- module.exports.__wbg_window_f2557cc78490aceb = function() { return handleError(function () {
748
- const ret = window.window;
749
- return addHeapObject(ret);
750
- }, arguments) };
751
-
752
- module.exports.__wbg_globalThis_7f206bda628d5286 = function() { return handleError(function () {
753
- const ret = globalThis.globalThis;
754
- return addHeapObject(ret);
755
- }, arguments) };
756
-
757
- module.exports.__wbg_global_ba75c50d1cf384f4 = function() { return handleError(function () {
758
- const ret = global.global;
759
- return addHeapObject(ret);
760
- }, arguments) };
761
-
762
- module.exports.__wbindgen_is_undefined = function(arg0) {
763
- const ret = getObject(arg0) === undefined;
764
- return ret;
765
- };
766
-
767
- module.exports.__wbg_buffer_3f3d764d4747d564 = function(arg0) {
768
- const ret = getObject(arg0).buffer;
769
- return addHeapObject(ret);
770
- };
771
-
772
- module.exports.__wbg_new_8c3f0052272a457a = function(arg0) {
773
- const ret = new Uint8Array(getObject(arg0));
774
- return addHeapObject(ret);
775
- };
776
-
777
- module.exports.__wbg_set_83db9690f9353e79 = function(arg0, arg1, arg2) {
778
- getObject(arg0).set(getObject(arg1), arg2 >>> 0);
779
- };
780
-
781
- module.exports.__wbg_length_9e1ae1900cb0fbd5 = function(arg0) {
782
- const ret = getObject(arg0).length;
783
- return ret;
784
- };
785
-
786
- module.exports.__wbg_newwithlength_f5933855e4f48a19 = function(arg0) {
787
- const ret = new Uint8Array(arg0 >>> 0);
788
- return addHeapObject(ret);
789
- };
790
-
791
- module.exports.__wbg_subarray_58ad4efbb5bcb886 = function(arg0, arg1, arg2) {
792
- const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
793
- return addHeapObject(ret);
794
- };
795
-
796
- module.exports.__wbindgen_throw = function(arg0, arg1) {
797
- throw new Error(getStringFromWasm0(arg0, arg1));
798
- };
799
-
800
- module.exports.__wbindgen_memory = function() {
801
- const ret = wasm.memory;
802
- return addHeapObject(ret);
803
- };
804
-
805
- const path = require('path').join(__dirname, 'hpke_dispatch_bg.wasm');
806
- const bytes = require('fs').readFileSync(path);
807
-
808
- const wasmModule = new WebAssembly.Module(bytes);
809
- const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
810
- wasm = wasmInstance.exports;
811
- module.exports.__wasm = wasm;
812
-