@enclave-e3/wasm 0.1.7 → 0.1.9

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,150 +1,5 @@
1
- let wasm;
1
+ /* @ts-self-types="./e3_wasm.d.ts" */
2
2
 
3
- let cachedUint8ArrayMemory0 = null;
4
-
5
- function getUint8ArrayMemory0() {
6
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
7
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
8
- }
9
- return cachedUint8ArrayMemory0;
10
- }
11
-
12
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
-
14
- cachedTextDecoder.decode();
15
-
16
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
17
- let numBytesDecoded = 0;
18
- function decodeText(ptr, len) {
19
- numBytesDecoded += len;
20
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
21
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
22
- cachedTextDecoder.decode();
23
- numBytesDecoded = len;
24
- }
25
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
26
- }
27
-
28
- function getStringFromWasm0(ptr, len) {
29
- ptr = ptr >>> 0;
30
- return decodeText(ptr, len);
31
- }
32
-
33
- let WASM_VECTOR_LEN = 0;
34
-
35
- const cachedTextEncoder = new TextEncoder();
36
-
37
- if (!('encodeInto' in cachedTextEncoder)) {
38
- cachedTextEncoder.encodeInto = function (arg, view) {
39
- const buf = cachedTextEncoder.encode(arg);
40
- view.set(buf);
41
- return {
42
- read: arg.length,
43
- written: buf.length
44
- };
45
- }
46
- }
47
-
48
- function passStringToWasm0(arg, malloc, realloc) {
49
-
50
- if (realloc === undefined) {
51
- const buf = cachedTextEncoder.encode(arg);
52
- const ptr = malloc(buf.length, 1) >>> 0;
53
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
54
- WASM_VECTOR_LEN = buf.length;
55
- return ptr;
56
- }
57
-
58
- let len = arg.length;
59
- let ptr = malloc(len, 1) >>> 0;
60
-
61
- const mem = getUint8ArrayMemory0();
62
-
63
- let offset = 0;
64
-
65
- for (; offset < len; offset++) {
66
- const code = arg.charCodeAt(offset);
67
- if (code > 0x7F) break;
68
- mem[ptr + offset] = code;
69
- }
70
-
71
- if (offset !== len) {
72
- if (offset !== 0) {
73
- arg = arg.slice(offset);
74
- }
75
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
76
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
77
- const ret = cachedTextEncoder.encodeInto(arg, view);
78
-
79
- offset += ret.written;
80
- ptr = realloc(ptr, len, offset, 1) >>> 0;
81
- }
82
-
83
- WASM_VECTOR_LEN = offset;
84
- return ptr;
85
- }
86
-
87
- let cachedDataViewMemory0 = null;
88
-
89
- function getDataViewMemory0() {
90
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
91
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
92
- }
93
- return cachedDataViewMemory0;
94
- }
95
-
96
- function addToExternrefTable0(obj) {
97
- const idx = wasm.__externref_table_alloc();
98
- wasm.__wbindgen_externrefs.set(idx, obj);
99
- return idx;
100
- }
101
-
102
- function handleError(f, args) {
103
- try {
104
- return f.apply(this, args);
105
- } catch (e) {
106
- const idx = addToExternrefTable0(e);
107
- wasm.__wbindgen_exn_store(idx);
108
- }
109
- }
110
-
111
- function getArrayU8FromWasm0(ptr, len) {
112
- ptr = ptr >>> 0;
113
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
114
- }
115
-
116
- function isLikeNone(x) {
117
- return x === undefined || x === null;
118
- }
119
-
120
- function passArray8ToWasm0(arg, malloc) {
121
- const ptr = malloc(arg.length * 1, 1) >>> 0;
122
- getUint8ArrayMemory0().set(arg, ptr / 1);
123
- WASM_VECTOR_LEN = arg.length;
124
- return ptr;
125
- }
126
-
127
- let cachedBigUint64ArrayMemory0 = null;
128
-
129
- function getBigUint64ArrayMemory0() {
130
- if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
131
- cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
132
- }
133
- return cachedBigUint64ArrayMemory0;
134
- }
135
-
136
- function passArray64ToWasm0(arg, malloc) {
137
- const ptr = malloc(arg.length * 8, 8) >>> 0;
138
- getBigUint64ArrayMemory0().set(arg, ptr / 8);
139
- WASM_VECTOR_LEN = arg.length;
140
- return ptr;
141
- }
142
-
143
- function takeFromExternrefTable0(idx) {
144
- const value = wasm.__wbindgen_externrefs.get(idx);
145
- wasm.__externref_table_dealloc(idx);
146
- return value;
147
- }
148
3
  /**
149
4
  * A function to encrypt a u64 value using BFV and default params.
150
5
  *
@@ -225,16 +80,6 @@ export function bfv_encrypt_vector(data, public_key, degree, plaintext_modulus,
225
80
  return v4;
226
81
  }
227
82
 
228
- function getArrayJsValueFromWasm0(ptr, len) {
229
- ptr = ptr >>> 0;
230
- const mem = getDataViewMemory0();
231
- const result = [];
232
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
233
- result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
234
- }
235
- wasm.__externref_drop_slice(ptr, len);
236
- return result;
237
- }
238
83
  /**
239
84
  * A function to encrypt a u64 value using BFV and default params and
240
85
  * generate circuit inputs for Greco
@@ -317,11 +162,63 @@ export function bfv_verifiable_encrypt_vector(data, public_key, degree, plaintex
317
162
  return v4;
318
163
  }
319
164
 
165
+ /**
166
+ * A function to compute the public key commitment for a given public key.
167
+ *
168
+ * # Arguments
169
+ *
170
+ * * `public_key` - The public key to compute the commitment for
171
+ *
172
+ * # Returns
173
+ * Returns a `Result<Vec<u8>, JsValue>` containing the commitment and any errors.
174
+ *
175
+ * # Panics
176
+ *
177
+ * Panics if the public key cannot be computed
178
+ * @param {Uint8Array} public_key
179
+ * @param {number} degree
180
+ * @param {bigint} plaintext_modulus
181
+ * @param {BigUint64Array} moduli
182
+ * @returns {Uint8Array}
183
+ */
184
+ export function compute_pk_commitment(public_key, degree, plaintext_modulus, moduli) {
185
+ const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
186
+ const len0 = WASM_VECTOR_LEN;
187
+ const ptr1 = passArray64ToWasm0(moduli, wasm.__wbindgen_malloc);
188
+ const len1 = WASM_VECTOR_LEN;
189
+ const ret = wasm.compute_pk_commitment(ptr0, len0, degree, plaintext_modulus, ptr1, len1);
190
+ if (ret[3]) {
191
+ throw takeFromExternrefTable0(ret[2]);
192
+ }
193
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
194
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
195
+ return v3;
196
+ }
197
+
198
+ /**
199
+ * Generate a public key from JavaScript.
200
+ * @param {number} degree
201
+ * @param {bigint} plaintext_modulus
202
+ * @param {BigUint64Array} moduli
203
+ * @returns {Uint8Array}
204
+ */
205
+ export function generate_public_key(degree, plaintext_modulus, moduli) {
206
+ const ptr0 = passArray64ToWasm0(moduli, wasm.__wbindgen_malloc);
207
+ const len0 = WASM_VECTOR_LEN;
208
+ const ret = wasm.generate_public_key(degree, plaintext_modulus, ptr0, len0);
209
+ if (ret[3]) {
210
+ throw takeFromExternrefTable0(ret[2]);
211
+ }
212
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
213
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
214
+ return v2;
215
+ }
216
+
320
217
  /**
321
218
  * Retrieves a BFV parameter set by name.
322
219
  *
323
220
  * # Parameters
324
- * * `name` - Parameter set identifier (e.g., "SET_8192_1000_4")
221
+ * * `name` - Parameter set identifier (e.g., "SECURE_THRESHOLD_8192")
325
222
  *
326
223
  * # Returns
327
224
  * A JavaScript object with the following structure:
@@ -354,7 +251,7 @@ export function get_bfv_params(name) {
354
251
  *
355
252
  * # Returns
356
253
  * Array of parameter set names that can be passed to `get_bfv_params()`.
357
- * Includes both production-ready sets (e.g., "SET_8192_1000_4") and
254
+ * Includes both production-ready sets (e.g., "SECURE_THRESHOLD_8192") and
358
255
  * insecure sets for testing (prefixed with "INSECURE_").
359
256
  * @returns {string[]}
360
257
  */
@@ -365,220 +262,371 @@ export function get_bfv_params_list() {
365
262
  return v1;
366
263
  }
367
264
 
368
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
265
+ function __wbg_get_imports() {
266
+ const import0 = {
267
+ __proto__: null,
268
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
269
+ const ret = Error(getStringFromWasm0(arg0, arg1));
270
+ return ret;
271
+ },
272
+ __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
273
+ const ret = String(arg1);
274
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
275
+ const len1 = WASM_VECTOR_LEN;
276
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
277
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
278
+ },
279
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
280
+ const ret = typeof(arg0) === 'function';
281
+ return ret;
282
+ },
283
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
284
+ const val = arg0;
285
+ const ret = typeof(val) === 'object' && val !== null;
286
+ return ret;
287
+ },
288
+ __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
289
+ const ret = typeof(arg0) === 'string';
290
+ return ret;
291
+ },
292
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
293
+ const ret = arg0 === undefined;
294
+ return ret;
295
+ },
296
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
297
+ throw new Error(getStringFromWasm0(arg0, arg1));
298
+ },
299
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
300
+ const ret = arg0.call(arg1);
301
+ return ret;
302
+ }, arguments); },
303
+ __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
304
+ const ret = arg0.call(arg1, arg2);
305
+ return ret;
306
+ }, arguments); },
307
+ __wbg_crypto_86f2631e91b51511: function(arg0) {
308
+ const ret = arg0.crypto;
309
+ return ret;
310
+ },
311
+ __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
312
+ arg0.getRandomValues(arg1);
313
+ }, arguments); },
314
+ __wbg_length_32ed9a279acd054c: function(arg0) {
315
+ const ret = arg0.length;
316
+ return ret;
317
+ },
318
+ __wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
319
+ const ret = arg0.msCrypto;
320
+ return ret;
321
+ },
322
+ __wbg_new_361308b2356cecd0: function() {
323
+ const ret = new Object();
324
+ return ret;
325
+ },
326
+ __wbg_new_3eb36ae241fe6f44: function() {
327
+ const ret = new Array();
328
+ return ret;
329
+ },
330
+ __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
331
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
332
+ return ret;
333
+ },
334
+ __wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
335
+ const ret = new Uint8Array(arg0 >>> 0);
336
+ return ret;
337
+ },
338
+ __wbg_node_e1f24f89a7336c2e: function(arg0) {
339
+ const ret = arg0.node;
340
+ return ret;
341
+ },
342
+ __wbg_process_3975fd6c72f520aa: function(arg0) {
343
+ const ret = arg0.process;
344
+ return ret;
345
+ },
346
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
347
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
348
+ },
349
+ __wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
350
+ arg0.randomFillSync(arg1);
351
+ }, arguments); },
352
+ __wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
353
+ const ret = module.require;
354
+ return ret;
355
+ }, arguments); },
356
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
357
+ arg0[arg1] = arg2;
358
+ },
359
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
360
+ arg0[arg1 >>> 0] = arg2;
361
+ },
362
+ __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
363
+ const ret = typeof global === 'undefined' ? null : global;
364
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
365
+ },
366
+ __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
367
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
368
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
369
+ },
370
+ __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
371
+ const ret = typeof self === 'undefined' ? null : self;
372
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
373
+ },
374
+ __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
375
+ const ret = typeof window === 'undefined' ? null : window;
376
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
377
+ },
378
+ __wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
379
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
380
+ return ret;
381
+ },
382
+ __wbg_versions_4e31226f5e8dc909: function(arg0) {
383
+ const ret = arg0.versions;
384
+ return ret;
385
+ },
386
+ __wbindgen_cast_0000000000000001: function(arg0) {
387
+ // Cast intrinsic for `F64 -> Externref`.
388
+ const ret = arg0;
389
+ return ret;
390
+ },
391
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
392
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
393
+ const ret = getArrayU8FromWasm0(arg0, arg1);
394
+ return ret;
395
+ },
396
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
397
+ // Cast intrinsic for `Ref(String) -> Externref`.
398
+ const ret = getStringFromWasm0(arg0, arg1);
399
+ return ret;
400
+ },
401
+ __wbindgen_cast_0000000000000004: function(arg0) {
402
+ // Cast intrinsic for `U64 -> Externref`.
403
+ const ret = BigInt.asUintN(64, arg0);
404
+ return ret;
405
+ },
406
+ __wbindgen_cast_0000000000000005: function(arg0, arg1) {
407
+ var v0 = getArrayU8FromWasm0(arg0, arg1).slice();
408
+ wasm.__wbindgen_free(arg0, arg1 * 1, 1);
409
+ // Cast intrinsic for `Vector(U8) -> Externref`.
410
+ const ret = v0;
411
+ return ret;
412
+ },
413
+ __wbindgen_init_externref_table: function() {
414
+ const table = wasm.__wbindgen_externrefs;
415
+ const offset = table.grow(4);
416
+ table.set(0, undefined);
417
+ table.set(offset + 0, undefined);
418
+ table.set(offset + 1, null);
419
+ table.set(offset + 2, true);
420
+ table.set(offset + 3, false);
421
+ },
422
+ };
423
+ return {
424
+ __proto__: null,
425
+ "./e3_wasm_bg.js": import0,
426
+ };
427
+ }
428
+
429
+ function addToExternrefTable0(obj) {
430
+ const idx = wasm.__externref_table_alloc();
431
+ wasm.__wbindgen_externrefs.set(idx, obj);
432
+ return idx;
433
+ }
434
+
435
+ function getArrayJsValueFromWasm0(ptr, len) {
436
+ ptr = ptr >>> 0;
437
+ const mem = getDataViewMemory0();
438
+ const result = [];
439
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
440
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
441
+ }
442
+ wasm.__externref_drop_slice(ptr, len);
443
+ return result;
444
+ }
445
+
446
+ function getArrayU8FromWasm0(ptr, len) {
447
+ ptr = ptr >>> 0;
448
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
449
+ }
450
+
451
+ let cachedBigUint64ArrayMemory0 = null;
452
+ function getBigUint64ArrayMemory0() {
453
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
454
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
455
+ }
456
+ return cachedBigUint64ArrayMemory0;
457
+ }
458
+
459
+ let cachedDataViewMemory0 = null;
460
+ function getDataViewMemory0() {
461
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
462
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
463
+ }
464
+ return cachedDataViewMemory0;
465
+ }
466
+
467
+ function getStringFromWasm0(ptr, len) {
468
+ ptr = ptr >>> 0;
469
+ return decodeText(ptr, len);
470
+ }
471
+
472
+ let cachedUint8ArrayMemory0 = null;
473
+ function getUint8ArrayMemory0() {
474
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
475
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
476
+ }
477
+ return cachedUint8ArrayMemory0;
478
+ }
479
+
480
+ function handleError(f, args) {
481
+ try {
482
+ return f.apply(this, args);
483
+ } catch (e) {
484
+ const idx = addToExternrefTable0(e);
485
+ wasm.__wbindgen_exn_store(idx);
486
+ }
487
+ }
488
+
489
+ function isLikeNone(x) {
490
+ return x === undefined || x === null;
491
+ }
492
+
493
+ function passArray64ToWasm0(arg, malloc) {
494
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
495
+ getBigUint64ArrayMemory0().set(arg, ptr / 8);
496
+ WASM_VECTOR_LEN = arg.length;
497
+ return ptr;
498
+ }
499
+
500
+ function passArray8ToWasm0(arg, malloc) {
501
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
502
+ getUint8ArrayMemory0().set(arg, ptr / 1);
503
+ WASM_VECTOR_LEN = arg.length;
504
+ return ptr;
505
+ }
506
+
507
+ function passStringToWasm0(arg, malloc, realloc) {
508
+ if (realloc === undefined) {
509
+ const buf = cachedTextEncoder.encode(arg);
510
+ const ptr = malloc(buf.length, 1) >>> 0;
511
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
512
+ WASM_VECTOR_LEN = buf.length;
513
+ return ptr;
514
+ }
515
+
516
+ let len = arg.length;
517
+ let ptr = malloc(len, 1) >>> 0;
518
+
519
+ const mem = getUint8ArrayMemory0();
520
+
521
+ let offset = 0;
522
+
523
+ for (; offset < len; offset++) {
524
+ const code = arg.charCodeAt(offset);
525
+ if (code > 0x7F) break;
526
+ mem[ptr + offset] = code;
527
+ }
528
+ if (offset !== len) {
529
+ if (offset !== 0) {
530
+ arg = arg.slice(offset);
531
+ }
532
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
533
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
534
+ const ret = cachedTextEncoder.encodeInto(arg, view);
535
+
536
+ offset += ret.written;
537
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
538
+ }
539
+
540
+ WASM_VECTOR_LEN = offset;
541
+ return ptr;
542
+ }
543
+
544
+ function takeFromExternrefTable0(idx) {
545
+ const value = wasm.__wbindgen_externrefs.get(idx);
546
+ wasm.__externref_table_dealloc(idx);
547
+ return value;
548
+ }
549
+
550
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
551
+ cachedTextDecoder.decode();
552
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
553
+ let numBytesDecoded = 0;
554
+ function decodeText(ptr, len) {
555
+ numBytesDecoded += len;
556
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
557
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
558
+ cachedTextDecoder.decode();
559
+ numBytesDecoded = len;
560
+ }
561
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
562
+ }
563
+
564
+ const cachedTextEncoder = new TextEncoder();
565
+
566
+ if (!('encodeInto' in cachedTextEncoder)) {
567
+ cachedTextEncoder.encodeInto = function (arg, view) {
568
+ const buf = cachedTextEncoder.encode(arg);
569
+ view.set(buf);
570
+ return {
571
+ read: arg.length,
572
+ written: buf.length
573
+ };
574
+ };
575
+ }
576
+
577
+ let WASM_VECTOR_LEN = 0;
578
+
579
+ let wasmModule, wasm;
580
+ function __wbg_finalize_init(instance, module) {
581
+ wasm = instance.exports;
582
+ wasmModule = module;
583
+ cachedBigUint64ArrayMemory0 = null;
584
+ cachedDataViewMemory0 = null;
585
+ cachedUint8ArrayMemory0 = null;
586
+ wasm.__wbindgen_start();
587
+ return wasm;
588
+ }
369
589
 
370
590
  async function __wbg_load(module, imports) {
371
591
  if (typeof Response === 'function' && module instanceof Response) {
372
592
  if (typeof WebAssembly.instantiateStreaming === 'function') {
373
593
  try {
374
594
  return await WebAssembly.instantiateStreaming(module, imports);
375
-
376
595
  } catch (e) {
377
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
596
+ const validResponse = module.ok && expectedResponseType(module.type);
378
597
 
379
598
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
380
599
  console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
381
600
 
382
- } else {
383
- throw e;
384
- }
601
+ } else { throw e; }
385
602
  }
386
603
  }
387
604
 
388
605
  const bytes = await module.arrayBuffer();
389
606
  return await WebAssembly.instantiate(bytes, imports);
390
-
391
607
  } else {
392
608
  const instance = await WebAssembly.instantiate(module, imports);
393
609
 
394
610
  if (instance instanceof WebAssembly.Instance) {
395
611
  return { instance, module };
396
-
397
612
  } else {
398
613
  return instance;
399
614
  }
400
615
  }
401
- }
402
616
 
403
- function __wbg_get_imports() {
404
- const imports = {};
405
- imports.wbg = {};
406
- imports.wbg.__wbg_Error_e83987f665cf5504 = function(arg0, arg1) {
407
- const ret = Error(getStringFromWasm0(arg0, arg1));
408
- return ret;
409
- };
410
- imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
411
- const ret = String(arg1);
412
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
413
- const len1 = WASM_VECTOR_LEN;
414
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
415
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
416
- };
417
- imports.wbg.__wbg___wbindgen_is_function_ee8a6c5833c90377 = function(arg0) {
418
- const ret = typeof(arg0) === 'function';
419
- return ret;
420
- };
421
- imports.wbg.__wbg___wbindgen_is_object_c818261d21f283a4 = function(arg0) {
422
- const val = arg0;
423
- const ret = typeof(val) === 'object' && val !== null;
424
- return ret;
425
- };
426
- imports.wbg.__wbg___wbindgen_is_string_fbb76cb2940daafd = function(arg0) {
427
- const ret = typeof(arg0) === 'string';
428
- return ret;
429
- };
430
- imports.wbg.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
431
- const ret = arg0 === undefined;
432
- return ret;
433
- };
434
- imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
435
- throw new Error(getStringFromWasm0(arg0, arg1));
436
- };
437
- imports.wbg.__wbg_call_525440f72fbfc0ea = function() { return handleError(function (arg0, arg1, arg2) {
438
- const ret = arg0.call(arg1, arg2);
439
- return ret;
440
- }, arguments) };
441
- imports.wbg.__wbg_call_e762c39fa8ea36bf = function() { return handleError(function (arg0, arg1) {
442
- const ret = arg0.call(arg1);
443
- return ret;
444
- }, arguments) };
445
- imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
446
- const ret = arg0.crypto;
447
- return ret;
448
- };
449
- imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
450
- arg0.getRandomValues(arg1);
451
- }, arguments) };
452
- imports.wbg.__wbg_length_69bca3cb64fc8748 = function(arg0) {
453
- const ret = arg0.length;
454
- return ret;
455
- };
456
- imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
457
- const ret = arg0.msCrypto;
458
- return ret;
459
- };
460
- imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
461
- const ret = new Object();
462
- return ret;
463
- };
464
- imports.wbg.__wbg_new_e17d9f43105b08be = function() {
465
- const ret = new Array();
466
- return ret;
467
- };
468
- imports.wbg.__wbg_new_no_args_ee98eee5275000a4 = function(arg0, arg1) {
469
- const ret = new Function(getStringFromWasm0(arg0, arg1));
470
- return ret;
471
- };
472
- imports.wbg.__wbg_new_with_length_01aa0dc35aa13543 = function(arg0) {
473
- const ret = new Uint8Array(arg0 >>> 0);
474
- return ret;
475
- };
476
- imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) {
477
- const ret = arg0.node;
478
- return ret;
479
- };
480
- imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
481
- const ret = arg0.process;
482
- return ret;
483
- };
484
- imports.wbg.__wbg_prototypesetcall_2a6620b6922694b2 = function(arg0, arg1, arg2) {
485
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
486
- };
487
- imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
488
- arg0.randomFillSync(arg1);
489
- }, arguments) };
490
- imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
491
- const ret = module.require;
492
- return ret;
493
- }, arguments) };
494
- imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
495
- arg0[arg1] = arg2;
496
- };
497
- imports.wbg.__wbg_set_c213c871859d6500 = function(arg0, arg1, arg2) {
498
- arg0[arg1 >>> 0] = arg2;
499
- };
500
- imports.wbg.__wbg_static_accessor_GLOBAL_89e1d9ac6a1b250e = function() {
501
- const ret = typeof global === 'undefined' ? null : global;
502
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
503
- };
504
- imports.wbg.__wbg_static_accessor_GLOBAL_THIS_8b530f326a9e48ac = function() {
505
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
506
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
507
- };
508
- imports.wbg.__wbg_static_accessor_SELF_6fdf4b64710cc91b = function() {
509
- const ret = typeof self === 'undefined' ? null : self;
510
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
511
- };
512
- imports.wbg.__wbg_static_accessor_WINDOW_b45bfc5a37f6cfa2 = function() {
513
- const ret = typeof window === 'undefined' ? null : window;
514
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
515
- };
516
- imports.wbg.__wbg_subarray_480600f3d6a9f26c = function(arg0, arg1, arg2) {
517
- const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
518
- return ret;
519
- };
520
- imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) {
521
- const ret = arg0.versions;
522
- return ret;
523
- };
524
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
525
- // Cast intrinsic for `Ref(String) -> Externref`.
526
- const ret = getStringFromWasm0(arg0, arg1);
527
- return ret;
528
- };
529
- imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
530
- // Cast intrinsic for `U64 -> Externref`.
531
- const ret = BigInt.asUintN(64, arg0);
532
- return ret;
533
- };
534
- imports.wbg.__wbindgen_cast_77bc3e92745e9a35 = function(arg0, arg1) {
535
- var v0 = getArrayU8FromWasm0(arg0, arg1).slice();
536
- wasm.__wbindgen_free(arg0, arg1 * 1, 1);
537
- // Cast intrinsic for `Vector(U8) -> Externref`.
538
- const ret = v0;
539
- return ret;
540
- };
541
- imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
542
- // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
543
- const ret = getArrayU8FromWasm0(arg0, arg1);
544
- return ret;
545
- };
546
- imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
547
- // Cast intrinsic for `F64 -> Externref`.
548
- const ret = arg0;
549
- return ret;
550
- };
551
- imports.wbg.__wbindgen_init_externref_table = function() {
552
- const table = wasm.__wbindgen_externrefs;
553
- const offset = table.grow(4);
554
- table.set(0, undefined);
555
- table.set(offset + 0, undefined);
556
- table.set(offset + 1, null);
557
- table.set(offset + 2, true);
558
- table.set(offset + 3, false);
559
- ;
560
- };
561
-
562
- return imports;
563
- }
564
-
565
- function __wbg_finalize_init(instance, module) {
566
- wasm = instance.exports;
567
- __wbg_init.__wbindgen_wasm_module = module;
568
- cachedBigUint64ArrayMemory0 = null;
569
- cachedDataViewMemory0 = null;
570
- cachedUint8ArrayMemory0 = null;
571
-
572
-
573
- wasm.__wbindgen_start();
574
- return wasm;
617
+ function expectedResponseType(type) {
618
+ switch (type) {
619
+ case 'basic': case 'cors': case 'default': return true;
620
+ }
621
+ return false;
622
+ }
575
623
  }
576
624
 
577
625
  function initSync(module) {
578
626
  if (wasm !== undefined) return wasm;
579
627
 
580
628
 
581
- if (typeof module !== 'undefined') {
629
+ if (module !== undefined) {
582
630
  if (Object.getPrototypeOf(module) === Object.prototype) {
583
631
  ({module} = module)
584
632
  } else {
@@ -587,13 +635,10 @@ function initSync(module) {
587
635
  }
588
636
 
589
637
  const imports = __wbg_get_imports();
590
-
591
638
  if (!(module instanceof WebAssembly.Module)) {
592
639
  module = new WebAssembly.Module(module);
593
640
  }
594
-
595
641
  const instance = new WebAssembly.Instance(module, imports);
596
-
597
642
  return __wbg_finalize_init(instance, module);
598
643
  }
599
644
 
@@ -601,7 +646,7 @@ async function __wbg_init(module_or_path) {
601
646
  if (wasm !== undefined) return wasm;
602
647
 
603
648
 
604
- if (typeof module_or_path !== 'undefined') {
649
+ if (module_or_path !== undefined) {
605
650
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
606
651
  ({module_or_path} = module_or_path)
607
652
  } else {
@@ -609,7 +654,7 @@ async function __wbg_init(module_or_path) {
609
654
  }
610
655
  }
611
656
 
612
- if (typeof module_or_path === 'undefined') {
657
+ if (module_or_path === undefined) {
613
658
  /* wasm URL disabled: load via @enclave-e3/wasm/init */
614
659
  }
615
660
  const imports = __wbg_get_imports();
@@ -623,5 +668,4 @@ async function __wbg_init(module_or_path) {
623
668
  return __wbg_finalize_init(instance, module);
624
669
  }
625
670
 
626
- export { initSync };
627
- export default __wbg_init;
671
+ export { initSync, __wbg_init as default };