@crisp-e3/zk-inputs 0.5.7 → 0.5.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.
package/dist/index.js CHANGED
@@ -1,89 +1,4 @@
1
- let wasm;
2
-
3
- function addToExternrefTable0(obj) {
4
- const idx = wasm.__externref_table_alloc();
5
- wasm.__wbindgen_externrefs.set(idx, obj);
6
- return idx;
7
- }
8
-
9
- function getArrayU8FromWasm0(ptr, len) {
10
- ptr = ptr >>> 0;
11
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
12
- }
13
-
14
- let cachedBigUint64ArrayMemory0 = null;
15
- function getBigUint64ArrayMemory0() {
16
- if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
17
- cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
18
- }
19
- return cachedBigUint64ArrayMemory0;
20
- }
21
-
22
- function getStringFromWasm0(ptr, len) {
23
- ptr = ptr >>> 0;
24
- return decodeText(ptr, len);
25
- }
26
-
27
- let cachedUint8ArrayMemory0 = null;
28
- function getUint8ArrayMemory0() {
29
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
30
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
31
- }
32
- return cachedUint8ArrayMemory0;
33
- }
34
-
35
- function handleError(f, args) {
36
- try {
37
- return f.apply(this, args);
38
- } catch (e) {
39
- const idx = addToExternrefTable0(e);
40
- wasm.__wbindgen_exn_store(idx);
41
- }
42
- }
43
-
44
- function isLikeNone(x) {
45
- return x === undefined || x === null;
46
- }
47
-
48
- function passArray64ToWasm0(arg, malloc) {
49
- const ptr = malloc(arg.length * 8, 8) >>> 0;
50
- getBigUint64ArrayMemory0().set(arg, ptr / 8);
51
- WASM_VECTOR_LEN = arg.length;
52
- return ptr;
53
- }
54
-
55
- function passArray8ToWasm0(arg, malloc) {
56
- const ptr = malloc(arg.length * 1, 1) >>> 0;
57
- getUint8ArrayMemory0().set(arg, ptr / 1);
58
- WASM_VECTOR_LEN = arg.length;
59
- return ptr;
60
- }
61
-
62
- function takeFromExternrefTable0(idx) {
63
- const value = wasm.__wbindgen_externrefs.get(idx);
64
- wasm.__externref_table_dealloc(idx);
65
- return value;
66
- }
67
-
68
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
69
- cachedTextDecoder.decode();
70
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
71
- let numBytesDecoded = 0;
72
- function decodeText(ptr, len) {
73
- numBytesDecoded += len;
74
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
75
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
76
- cachedTextDecoder.decode();
77
- numBytesDecoded = len;
78
- }
79
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
80
- }
81
-
82
- let WASM_VECTOR_LEN = 0;
83
-
84
- const ZKInputsGeneratorFinalization = (typeof FinalizationRegistry === 'undefined')
85
- ? { register: () => {}, unregister: () => {} }
86
- : new FinalizationRegistry(ptr => wasm.__wbg_zkinputsgenerator_free(ptr >>> 0, 1));
1
+ /* @ts-self-types="./index.d.ts" */
87
2
 
88
3
  /**
89
4
  * JavaScript-compatible CRISP ZK inputs generator.
@@ -107,37 +22,47 @@ export class ZKInputsGenerator {
107
22
  wasm.__wbg_zkinputsgenerator_free(ptr, 0);
108
23
  }
109
24
  /**
110
- * Create a new JavaScript CRISP ZK inputs generator with the specified BFV parameters.
111
- *
112
- * # Arguments
113
- * - `degree`: Polynomial degree
114
- * - `plaintext_modulus`: Plaintext modulus (will be converted to u64)
115
- * - `moduli`: Array of moduli (will be converted to Vec<u64>)
116
- * @param {number} degree
117
- * @param {bigint} plaintext_modulus
118
- * @param {BigInt64Array} moduli
25
+ * Compute the commitment to a set of ciphertext polynomials from JavaScript.
26
+ * @param {any} ct0is
27
+ * @param {any} ct1is
28
+ * @returns {string}
119
29
  */
120
- constructor(degree, plaintext_modulus, moduli) {
121
- const ptr0 = passArray64ToWasm0(moduli, wasm.__wbindgen_malloc);
122
- const len0 = WASM_VECTOR_LEN;
123
- const ret = wasm.zkinputsgenerator_new(degree, plaintext_modulus, ptr0, len0);
124
- if (ret[2]) {
125
- throw takeFromExternrefTable0(ret[1]);
30
+ computeCiphertextCommitment(ct0is, ct1is) {
31
+ let deferred2_0;
32
+ let deferred2_1;
33
+ try {
34
+ const ret = wasm.zkinputsgenerator_computeCiphertextCommitment(this.__wbg_ptr, ct0is, ct1is);
35
+ var ptr1 = ret[0];
36
+ var len1 = ret[1];
37
+ if (ret[3]) {
38
+ ptr1 = 0; len1 = 0;
39
+ throw takeFromExternrefTable0(ret[2]);
40
+ }
41
+ deferred2_0 = ptr1;
42
+ deferred2_1 = len1;
43
+ return getStringFromWasm0(ptr1, len1);
44
+ } finally {
45
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
126
46
  }
127
- this.__wbg_ptr = ret[0] >>> 0;
128
- ZKInputsGeneratorFinalization.register(this, this.__wbg_ptr, this);
129
- return this;
130
47
  }
131
48
  /**
132
- * Create a new JavaScript CRISP ZK inputs generator with default BFV parameters.
133
- * @returns {ZKInputsGenerator}
49
+ * Encrypt a vote from JavaScript.
50
+ * @param {Uint8Array} public_key
51
+ * @param {BigInt64Array} vote
52
+ * @returns {Uint8Array}
134
53
  */
135
- static withDefaults() {
136
- const ret = wasm.zkinputsgenerator_withDefaults();
137
- if (ret[2]) {
138
- throw takeFromExternrefTable0(ret[1]);
54
+ encryptVote(public_key, vote) {
55
+ const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
56
+ const len0 = WASM_VECTOR_LEN;
57
+ const ptr1 = passArray64ToWasm0(vote, wasm.__wbindgen_malloc);
58
+ const len1 = WASM_VECTOR_LEN;
59
+ const ret = wasm.zkinputsgenerator_encryptVote(this.__wbg_ptr, ptr0, len0, ptr1, len1);
60
+ if (ret[3]) {
61
+ throw takeFromExternrefTable0(ret[2]);
139
62
  }
140
- return ZKInputsGenerator.__wrap(ret[0]);
63
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
64
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
65
+ return v3;
141
66
  }
142
67
  /**
143
68
  * Generate CRISP ZK inputs from JavaScript.
@@ -192,25 +117,6 @@ export class ZKInputsGenerator {
192
117
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
193
118
  return v1;
194
119
  }
195
- /**
196
- * Encrypt a vote from JavaScript.
197
- * @param {Uint8Array} public_key
198
- * @param {BigInt64Array} vote
199
- * @returns {Uint8Array}
200
- */
201
- encryptVote(public_key, vote) {
202
- const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
203
- const len0 = WASM_VECTOR_LEN;
204
- const ptr1 = passArray64ToWasm0(vote, wasm.__wbindgen_malloc);
205
- const len1 = WASM_VECTOR_LEN;
206
- const ret = wasm.zkinputsgenerator_encryptVote(this.__wbg_ptr, ptr0, len0, ptr1, len1);
207
- if (ret[3]) {
208
- throw takeFromExternrefTable0(ret[2]);
209
- }
210
- var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
211
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
212
- return v3;
213
- }
214
120
  /**
215
121
  * Get the BFV parameters used by the generator.
216
122
  * @returns {any}
@@ -222,6 +128,28 @@ export class ZKInputsGenerator {
222
128
  }
223
129
  return takeFromExternrefTable0(ret[0]);
224
130
  }
131
+ /**
132
+ * Create a new JavaScript CRISP ZK inputs generator with the specified BFV parameters.
133
+ *
134
+ * # Arguments
135
+ * - `degree`: Polynomial degree
136
+ * - `plaintext_modulus`: Plaintext modulus (will be converted to u64)
137
+ * - `moduli`: Array of moduli (will be converted to Vec<u64>)
138
+ * @param {number} degree
139
+ * @param {bigint} plaintext_modulus
140
+ * @param {BigInt64Array} moduli
141
+ */
142
+ constructor(degree, plaintext_modulus, moduli) {
143
+ const ptr0 = passArray64ToWasm0(moduli, wasm.__wbindgen_malloc);
144
+ const len0 = WASM_VECTOR_LEN;
145
+ const ret = wasm.zkinputsgenerator_new(degree, plaintext_modulus, ptr0, len0);
146
+ if (ret[2]) {
147
+ throw takeFromExternrefTable0(ret[1]);
148
+ }
149
+ this.__wbg_ptr = ret[0] >>> 0;
150
+ ZKInputsGeneratorFinalization.register(this, this.__wbg_ptr, this);
151
+ return this;
152
+ }
225
153
  /**
226
154
  * Get the version of the library.
227
155
  * @returns {string}
@@ -238,10 +166,352 @@ export class ZKInputsGenerator {
238
166
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
239
167
  }
240
168
  }
169
+ /**
170
+ * Create a new JavaScript CRISP ZK inputs generator with default BFV parameters.
171
+ * @returns {ZKInputsGenerator}
172
+ */
173
+ static withDefaults() {
174
+ const ret = wasm.zkinputsgenerator_withDefaults();
175
+ if (ret[2]) {
176
+ throw takeFromExternrefTable0(ret[1]);
177
+ }
178
+ return ZKInputsGenerator.__wrap(ret[0]);
179
+ }
241
180
  }
242
181
  if (Symbol.dispose) ZKInputsGenerator.prototype[Symbol.dispose] = ZKInputsGenerator.prototype.free;
243
182
 
244
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
183
+ function __wbg_get_imports() {
184
+ const import0 = {
185
+ __proto__: null,
186
+ __wbg_BigInt_7ea1e749ce6b92fd: function() { return handleError(function (arg0) {
187
+ const ret = BigInt(arg0);
188
+ return ret;
189
+ }, arguments); },
190
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
191
+ const ret = typeof(arg0) === 'function';
192
+ return ret;
193
+ },
194
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
195
+ const val = arg0;
196
+ const ret = typeof(val) === 'object' && val !== null;
197
+ return ret;
198
+ },
199
+ __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
200
+ const ret = typeof(arg0) === 'string';
201
+ return ret;
202
+ },
203
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
204
+ const ret = arg0 === undefined;
205
+ return ret;
206
+ },
207
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
208
+ const obj = arg1;
209
+ const ret = typeof(obj) === 'string' ? obj : undefined;
210
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
211
+ var len1 = WASM_VECTOR_LEN;
212
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
213
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
214
+ },
215
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
216
+ throw new Error(getStringFromWasm0(arg0, arg1));
217
+ },
218
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
219
+ const ret = arg0.call(arg1);
220
+ return ret;
221
+ }, arguments); },
222
+ __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
223
+ const ret = arg0.call(arg1, arg2);
224
+ return ret;
225
+ }, arguments); },
226
+ __wbg_crypto_86f2631e91b51511: function(arg0) {
227
+ const ret = arg0.crypto;
228
+ return ret;
229
+ },
230
+ __wbg_from_bddd64e7d5ff6941: function(arg0) {
231
+ const ret = Array.from(arg0);
232
+ return ret;
233
+ },
234
+ __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
235
+ arg0.getRandomValues(arg1);
236
+ }, arguments); },
237
+ __wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
238
+ const ret = arg0[arg1 >>> 0];
239
+ return ret;
240
+ },
241
+ __wbg_isArray_d314bb98fcf08331: function(arg0) {
242
+ const ret = Array.isArray(arg0);
243
+ return ret;
244
+ },
245
+ __wbg_length_32ed9a279acd054c: function(arg0) {
246
+ const ret = arg0.length;
247
+ return ret;
248
+ },
249
+ __wbg_length_35a7bace40f36eac: function(arg0) {
250
+ const ret = arg0.length;
251
+ return ret;
252
+ },
253
+ __wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
254
+ const ret = arg0.msCrypto;
255
+ return ret;
256
+ },
257
+ __wbg_new_361308b2356cecd0: function() {
258
+ const ret = new Object();
259
+ return ret;
260
+ },
261
+ __wbg_new_3eb36ae241fe6f44: function() {
262
+ const ret = new Array();
263
+ return ret;
264
+ },
265
+ __wbg_new_from_slice_a3d2629dc1826784: function(arg0, arg1) {
266
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
267
+ return ret;
268
+ },
269
+ __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
270
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
271
+ return ret;
272
+ },
273
+ __wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
274
+ const ret = new Uint8Array(arg0 >>> 0);
275
+ return ret;
276
+ },
277
+ __wbg_node_e1f24f89a7336c2e: function(arg0) {
278
+ const ret = arg0.node;
279
+ return ret;
280
+ },
281
+ __wbg_parse_708461a1feddfb38: function() { return handleError(function (arg0, arg1) {
282
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
283
+ return ret;
284
+ }, arguments); },
285
+ __wbg_process_3975fd6c72f520aa: function(arg0) {
286
+ const ret = arg0.process;
287
+ return ret;
288
+ },
289
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
290
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
291
+ },
292
+ __wbg_push_8ffdcb2063340ba5: function(arg0, arg1) {
293
+ const ret = arg0.push(arg1);
294
+ return ret;
295
+ },
296
+ __wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
297
+ arg0.randomFillSync(arg1);
298
+ }, arguments); },
299
+ __wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
300
+ const ret = module.require;
301
+ return ret;
302
+ }, arguments); },
303
+ __wbg_set_6cb8631f80447a67: function() { return handleError(function (arg0, arg1, arg2) {
304
+ const ret = Reflect.set(arg0, arg1, arg2);
305
+ return ret;
306
+ }, arguments); },
307
+ __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
308
+ const ret = typeof global === 'undefined' ? null : global;
309
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
310
+ },
311
+ __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
312
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
313
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
314
+ },
315
+ __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
316
+ const ret = typeof self === 'undefined' ? null : self;
317
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
318
+ },
319
+ __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
320
+ const ret = typeof window === 'undefined' ? null : window;
321
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
322
+ },
323
+ __wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
324
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
325
+ return ret;
326
+ },
327
+ __wbg_versions_4e31226f5e8dc909: function(arg0) {
328
+ const ret = arg0.versions;
329
+ return ret;
330
+ },
331
+ __wbindgen_cast_0000000000000001: function(arg0) {
332
+ // Cast intrinsic for `F64 -> Externref`.
333
+ const ret = arg0;
334
+ return ret;
335
+ },
336
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
337
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
338
+ const ret = getArrayU8FromWasm0(arg0, arg1);
339
+ return ret;
340
+ },
341
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
342
+ // Cast intrinsic for `Ref(String) -> Externref`.
343
+ const ret = getStringFromWasm0(arg0, arg1);
344
+ return ret;
345
+ },
346
+ __wbindgen_init_externref_table: function() {
347
+ const table = wasm.__wbindgen_externrefs;
348
+ const offset = table.grow(4);
349
+ table.set(0, undefined);
350
+ table.set(offset + 0, undefined);
351
+ table.set(offset + 1, null);
352
+ table.set(offset + 2, true);
353
+ table.set(offset + 3, false);
354
+ },
355
+ };
356
+ return {
357
+ __proto__: null,
358
+ "./index_bg.js": import0,
359
+ };
360
+ }
361
+
362
+ const ZKInputsGeneratorFinalization = (typeof FinalizationRegistry === 'undefined')
363
+ ? { register: () => {}, unregister: () => {} }
364
+ : new FinalizationRegistry(ptr => wasm.__wbg_zkinputsgenerator_free(ptr >>> 0, 1));
365
+
366
+ function addToExternrefTable0(obj) {
367
+ const idx = wasm.__externref_table_alloc();
368
+ wasm.__wbindgen_externrefs.set(idx, obj);
369
+ return idx;
370
+ }
371
+
372
+ function getArrayU8FromWasm0(ptr, len) {
373
+ ptr = ptr >>> 0;
374
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
375
+ }
376
+
377
+ let cachedBigUint64ArrayMemory0 = null;
378
+ function getBigUint64ArrayMemory0() {
379
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
380
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
381
+ }
382
+ return cachedBigUint64ArrayMemory0;
383
+ }
384
+
385
+ let cachedDataViewMemory0 = null;
386
+ function getDataViewMemory0() {
387
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
388
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
389
+ }
390
+ return cachedDataViewMemory0;
391
+ }
392
+
393
+ function getStringFromWasm0(ptr, len) {
394
+ ptr = ptr >>> 0;
395
+ return decodeText(ptr, len);
396
+ }
397
+
398
+ let cachedUint8ArrayMemory0 = null;
399
+ function getUint8ArrayMemory0() {
400
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
401
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
402
+ }
403
+ return cachedUint8ArrayMemory0;
404
+ }
405
+
406
+ function handleError(f, args) {
407
+ try {
408
+ return f.apply(this, args);
409
+ } catch (e) {
410
+ const idx = addToExternrefTable0(e);
411
+ wasm.__wbindgen_exn_store(idx);
412
+ }
413
+ }
414
+
415
+ function isLikeNone(x) {
416
+ return x === undefined || x === null;
417
+ }
418
+
419
+ function passArray64ToWasm0(arg, malloc) {
420
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
421
+ getBigUint64ArrayMemory0().set(arg, ptr / 8);
422
+ WASM_VECTOR_LEN = arg.length;
423
+ return ptr;
424
+ }
425
+
426
+ function passArray8ToWasm0(arg, malloc) {
427
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
428
+ getUint8ArrayMemory0().set(arg, ptr / 1);
429
+ WASM_VECTOR_LEN = arg.length;
430
+ return ptr;
431
+ }
432
+
433
+ function passStringToWasm0(arg, malloc, realloc) {
434
+ if (realloc === undefined) {
435
+ const buf = cachedTextEncoder.encode(arg);
436
+ const ptr = malloc(buf.length, 1) >>> 0;
437
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
438
+ WASM_VECTOR_LEN = buf.length;
439
+ return ptr;
440
+ }
441
+
442
+ let len = arg.length;
443
+ let ptr = malloc(len, 1) >>> 0;
444
+
445
+ const mem = getUint8ArrayMemory0();
446
+
447
+ let offset = 0;
448
+
449
+ for (; offset < len; offset++) {
450
+ const code = arg.charCodeAt(offset);
451
+ if (code > 0x7F) break;
452
+ mem[ptr + offset] = code;
453
+ }
454
+ if (offset !== len) {
455
+ if (offset !== 0) {
456
+ arg = arg.slice(offset);
457
+ }
458
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
459
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
460
+ const ret = cachedTextEncoder.encodeInto(arg, view);
461
+
462
+ offset += ret.written;
463
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
464
+ }
465
+
466
+ WASM_VECTOR_LEN = offset;
467
+ return ptr;
468
+ }
469
+
470
+ function takeFromExternrefTable0(idx) {
471
+ const value = wasm.__wbindgen_externrefs.get(idx);
472
+ wasm.__externref_table_dealloc(idx);
473
+ return value;
474
+ }
475
+
476
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
477
+ cachedTextDecoder.decode();
478
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
479
+ let numBytesDecoded = 0;
480
+ function decodeText(ptr, len) {
481
+ numBytesDecoded += len;
482
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
483
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
484
+ cachedTextDecoder.decode();
485
+ numBytesDecoded = len;
486
+ }
487
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
488
+ }
489
+
490
+ const cachedTextEncoder = new TextEncoder();
491
+
492
+ if (!('encodeInto' in cachedTextEncoder)) {
493
+ cachedTextEncoder.encodeInto = function (arg, view) {
494
+ const buf = cachedTextEncoder.encode(arg);
495
+ view.set(buf);
496
+ return {
497
+ read: arg.length,
498
+ written: buf.length
499
+ };
500
+ };
501
+ }
502
+
503
+ let WASM_VECTOR_LEN = 0;
504
+
505
+ let wasmModule, wasm;
506
+ function __wbg_finalize_init(instance, module) {
507
+ wasm = instance.exports;
508
+ wasmModule = module;
509
+ cachedBigUint64ArrayMemory0 = null;
510
+ cachedDataViewMemory0 = null;
511
+ cachedUint8ArrayMemory0 = null;
512
+ wasm.__wbindgen_start();
513
+ return wasm;
514
+ }
245
515
 
246
516
  async function __wbg_load(module, imports) {
247
517
  if (typeof Response === 'function' && module instanceof Response) {
@@ -249,14 +519,12 @@ async function __wbg_load(module, imports) {
249
519
  try {
250
520
  return await WebAssembly.instantiateStreaming(module, imports);
251
521
  } catch (e) {
252
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
522
+ const validResponse = module.ok && expectedResponseType(module.type);
253
523
 
254
524
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
255
525
  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);
256
526
 
257
- } else {
258
- throw e;
259
- }
527
+ } else { throw e; }
260
528
  }
261
529
  }
262
530
 
@@ -271,172 +539,20 @@ async function __wbg_load(module, imports) {
271
539
  return instance;
272
540
  }
273
541
  }
274
- }
275
-
276
- function __wbg_get_imports() {
277
- const imports = {};
278
- imports.wbg = {};
279
- imports.wbg.__wbg_BigInt_811579177bbea12d = function() { return handleError(function (arg0) {
280
- const ret = BigInt(arg0);
281
- return ret;
282
- }, arguments) };
283
- imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
284
- const ret = typeof(arg0) === 'function';
285
- return ret;
286
- };
287
- imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
288
- const val = arg0;
289
- const ret = typeof(val) === 'object' && val !== null;
290
- return ret;
291
- };
292
- imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
293
- const ret = typeof(arg0) === 'string';
294
- return ret;
295
- };
296
- imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
297
- const ret = arg0 === undefined;
298
- return ret;
299
- };
300
- imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
301
- throw new Error(getStringFromWasm0(arg0, arg1));
302
- };
303
- imports.wbg.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) {
304
- const ret = arg0.call(arg1, arg2);
305
- return ret;
306
- }, arguments) };
307
- imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
308
- const ret = arg0.call(arg1);
309
- return ret;
310
- }, arguments) };
311
- imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
312
- const ret = arg0.crypto;
313
- return ret;
314
- };
315
- imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
316
- arg0.getRandomValues(arg1);
317
- }, arguments) };
318
- imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
319
- const ret = arg0.length;
320
- return ret;
321
- };
322
- imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
323
- const ret = arg0.msCrypto;
324
- return ret;
325
- };
326
- imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
327
- const ret = new Object();
328
- return ret;
329
- };
330
- imports.wbg.__wbg_new_25f239778d6112b9 = function() {
331
- const ret = new Array();
332
- return ret;
333
- };
334
- imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
335
- const ret = new Function(getStringFromWasm0(arg0, arg1));
336
- return ret;
337
- };
338
- imports.wbg.__wbg_new_with_length_aa5eaf41d35235e5 = function(arg0) {
339
- const ret = new Uint8Array(arg0 >>> 0);
340
- return ret;
341
- };
342
- imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) {
343
- const ret = arg0.node;
344
- return ret;
345
- };
346
- imports.wbg.__wbg_parse_a09a54cf72639456 = function() { return handleError(function (arg0, arg1) {
347
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
348
- return ret;
349
- }, arguments) };
350
- imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
351
- const ret = arg0.process;
352
- return ret;
353
- };
354
- imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
355
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
356
- };
357
- imports.wbg.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) {
358
- const ret = arg0.push(arg1);
359
- return ret;
360
- };
361
- imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
362
- arg0.randomFillSync(arg1);
363
- }, arguments) };
364
- imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
365
- const ret = module.require;
366
- return ret;
367
- }, arguments) };
368
- imports.wbg.__wbg_set_781438a03c0c3c81 = function() { return handleError(function (arg0, arg1, arg2) {
369
- const ret = Reflect.set(arg0, arg1, arg2);
370
- return ret;
371
- }, arguments) };
372
- imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
373
- const ret = typeof global === 'undefined' ? null : global;
374
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
375
- };
376
- imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
377
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
378
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
379
- };
380
- imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
381
- const ret = typeof self === 'undefined' ? null : self;
382
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
383
- };
384
- imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
385
- const ret = typeof window === 'undefined' ? null : window;
386
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
387
- };
388
- imports.wbg.__wbg_subarray_845f2f5bce7d061a = function(arg0, arg1, arg2) {
389
- const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
390
- return ret;
391
- };
392
- imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) {
393
- const ret = arg0.versions;
394
- return ret;
395
- };
396
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
397
- // Cast intrinsic for `Ref(String) -> Externref`.
398
- const ret = getStringFromWasm0(arg0, arg1);
399
- return ret;
400
- };
401
- imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
402
- // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
403
- const ret = getArrayU8FromWasm0(arg0, arg1);
404
- return ret;
405
- };
406
- imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
407
- // Cast intrinsic for `F64 -> Externref`.
408
- const ret = arg0;
409
- return ret;
410
- };
411
- imports.wbg.__wbindgen_init_externref_table = function() {
412
- const table = wasm.__wbindgen_externrefs;
413
- const offset = table.grow(4);
414
- table.set(0, undefined);
415
- table.set(offset + 0, undefined);
416
- table.set(offset + 1, null);
417
- table.set(offset + 2, true);
418
- table.set(offset + 3, false);
419
- };
420
-
421
- return imports;
422
- }
423
542
 
424
- function __wbg_finalize_init(instance, module) {
425
- wasm = instance.exports;
426
- __wbg_init.__wbindgen_wasm_module = module;
427
- cachedBigUint64ArrayMemory0 = null;
428
- cachedUint8ArrayMemory0 = null;
429
-
430
-
431
- wasm.__wbindgen_start();
432
- return wasm;
543
+ function expectedResponseType(type) {
544
+ switch (type) {
545
+ case 'basic': case 'cors': case 'default': return true;
546
+ }
547
+ return false;
548
+ }
433
549
  }
434
550
 
435
551
  function initSync(module) {
436
552
  if (wasm !== undefined) return wasm;
437
553
 
438
554
 
439
- if (typeof module !== 'undefined') {
555
+ if (module !== undefined) {
440
556
  if (Object.getPrototypeOf(module) === Object.prototype) {
441
557
  ({module} = module)
442
558
  } else {
@@ -456,7 +572,7 @@ async function __wbg_init(module_or_path) {
456
572
  if (wasm !== undefined) return wasm;
457
573
 
458
574
 
459
- if (typeof module_or_path !== 'undefined') {
575
+ if (module_or_path !== undefined) {
460
576
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
461
577
  ({module_or_path} = module_or_path)
462
578
  } else {
@@ -464,7 +580,7 @@ async function __wbg_init(module_or_path) {
464
580
  }
465
581
  }
466
582
 
467
- if (typeof module_or_path === 'undefined') {
583
+ if (module_or_path === undefined) {
468
584
  /* wasm URL disabled */
469
585
  }
470
586
  const imports = __wbg_get_imports();
@@ -478,5 +594,4 @@ async function __wbg_init(module_or_path) {
478
594
  return __wbg_finalize_init(instance, module);
479
595
  }
480
596
 
481
- export { initSync };
482
- export default __wbg_init;
597
+ export { initSync, __wbg_init as default };