@crisp-e3/zk-inputs 0.5.8 → 0.5.10
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.d.ts +79 -76
- package/dist/index.js +386 -382
- package/dist/index_base64.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,367 @@
|
|
|
1
|
-
|
|
1
|
+
/* @ts-self-types="./index.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* JavaScript-compatible CRISP ZK inputs generator.
|
|
5
|
+
*/
|
|
6
|
+
export class ZKInputsGenerator {
|
|
7
|
+
static __wrap(ptr) {
|
|
8
|
+
ptr = ptr >>> 0;
|
|
9
|
+
const obj = Object.create(ZKInputsGenerator.prototype);
|
|
10
|
+
obj.__wbg_ptr = ptr;
|
|
11
|
+
ZKInputsGeneratorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
__destroy_into_raw() {
|
|
15
|
+
const ptr = this.__wbg_ptr;
|
|
16
|
+
this.__wbg_ptr = 0;
|
|
17
|
+
ZKInputsGeneratorFinalization.unregister(this);
|
|
18
|
+
return ptr;
|
|
19
|
+
}
|
|
20
|
+
free() {
|
|
21
|
+
const ptr = this.__destroy_into_raw();
|
|
22
|
+
wasm.__wbg_zkinputsgenerator_free(ptr, 0);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Compute the commitment to a set of ciphertext polynomials from JavaScript.
|
|
26
|
+
* @param {any} ct0is
|
|
27
|
+
* @param {any} ct1is
|
|
28
|
+
* @returns {string}
|
|
29
|
+
*/
|
|
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);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Encrypt a vote from JavaScript.
|
|
50
|
+
* @param {Uint8Array} public_key
|
|
51
|
+
* @param {BigInt64Array} vote
|
|
52
|
+
* @returns {Uint8Array}
|
|
53
|
+
*/
|
|
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]);
|
|
62
|
+
}
|
|
63
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
64
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
65
|
+
return v3;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Generate CRISP ZK inputs from JavaScript.
|
|
69
|
+
* @param {Uint8Array} prev_ciphertext
|
|
70
|
+
* @param {Uint8Array} public_key
|
|
71
|
+
* @param {BigInt64Array} vote
|
|
72
|
+
* @returns {any}
|
|
73
|
+
*/
|
|
74
|
+
generateInputs(prev_ciphertext, public_key, vote) {
|
|
75
|
+
const ptr0 = passArray8ToWasm0(prev_ciphertext, wasm.__wbindgen_malloc);
|
|
76
|
+
const len0 = WASM_VECTOR_LEN;
|
|
77
|
+
const ptr1 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
78
|
+
const len1 = WASM_VECTOR_LEN;
|
|
79
|
+
const ptr2 = passArray64ToWasm0(vote, wasm.__wbindgen_malloc);
|
|
80
|
+
const len2 = WASM_VECTOR_LEN;
|
|
81
|
+
const ret = wasm.zkinputsgenerator_generateInputs(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
82
|
+
if (ret[2]) {
|
|
83
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
84
|
+
}
|
|
85
|
+
return takeFromExternrefTable0(ret[0]);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Generate CRISP ZK inputs for a vote update (either from voter or as a masker) from JavaScript.
|
|
89
|
+
* @param {Uint8Array} prev_ciphertext
|
|
90
|
+
* @param {Uint8Array} public_key
|
|
91
|
+
* @param {BigInt64Array} vote
|
|
92
|
+
* @returns {any}
|
|
93
|
+
*/
|
|
94
|
+
generateInputsForUpdate(prev_ciphertext, public_key, vote) {
|
|
95
|
+
const ptr0 = passArray8ToWasm0(prev_ciphertext, wasm.__wbindgen_malloc);
|
|
96
|
+
const len0 = WASM_VECTOR_LEN;
|
|
97
|
+
const ptr1 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
98
|
+
const len1 = WASM_VECTOR_LEN;
|
|
99
|
+
const ptr2 = passArray64ToWasm0(vote, wasm.__wbindgen_malloc);
|
|
100
|
+
const len2 = WASM_VECTOR_LEN;
|
|
101
|
+
const ret = wasm.zkinputsgenerator_generateInputsForUpdate(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
102
|
+
if (ret[2]) {
|
|
103
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
104
|
+
}
|
|
105
|
+
return takeFromExternrefTable0(ret[0]);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Generate a public key from JavaScript.
|
|
109
|
+
* @returns {Uint8Array}
|
|
110
|
+
*/
|
|
111
|
+
generatePublicKey() {
|
|
112
|
+
const ret = wasm.zkinputsgenerator_generatePublicKey(this.__wbg_ptr);
|
|
113
|
+
if (ret[3]) {
|
|
114
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
115
|
+
}
|
|
116
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
117
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
118
|
+
return v1;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get the BFV parameters used by the generator.
|
|
122
|
+
* @returns {any}
|
|
123
|
+
*/
|
|
124
|
+
getBFVParams() {
|
|
125
|
+
const ret = wasm.zkinputsgenerator_getBFVParams(this.__wbg_ptr);
|
|
126
|
+
if (ret[2]) {
|
|
127
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
128
|
+
}
|
|
129
|
+
return takeFromExternrefTable0(ret[0]);
|
|
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
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get the version of the library.
|
|
155
|
+
* @returns {string}
|
|
156
|
+
*/
|
|
157
|
+
static version() {
|
|
158
|
+
let deferred1_0;
|
|
159
|
+
let deferred1_1;
|
|
160
|
+
try {
|
|
161
|
+
const ret = wasm.zkinputsgenerator_version();
|
|
162
|
+
deferred1_0 = ret[0];
|
|
163
|
+
deferred1_1 = ret[1];
|
|
164
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
165
|
+
} finally {
|
|
166
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
167
|
+
}
|
|
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
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (Symbol.dispose) ZKInputsGenerator.prototype[Symbol.dispose] = ZKInputsGenerator.prototype.free;
|
|
182
|
+
|
|
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));
|
|
2
365
|
|
|
3
366
|
function addToExternrefTable0(obj) {
|
|
4
367
|
const idx = wasm.__externref_table_alloc();
|
|
@@ -134,196 +497,21 @@ if (!('encodeInto' in cachedTextEncoder)) {
|
|
|
134
497
|
read: arg.length,
|
|
135
498
|
written: buf.length
|
|
136
499
|
};
|
|
137
|
-
}
|
|
500
|
+
};
|
|
138
501
|
}
|
|
139
502
|
|
|
140
503
|
let WASM_VECTOR_LEN = 0;
|
|
141
504
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
ptr = ptr >>> 0;
|
|
152
|
-
const obj = Object.create(ZKInputsGenerator.prototype);
|
|
153
|
-
obj.__wbg_ptr = ptr;
|
|
154
|
-
ZKInputsGeneratorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
155
|
-
return obj;
|
|
156
|
-
}
|
|
157
|
-
__destroy_into_raw() {
|
|
158
|
-
const ptr = this.__wbg_ptr;
|
|
159
|
-
this.__wbg_ptr = 0;
|
|
160
|
-
ZKInputsGeneratorFinalization.unregister(this);
|
|
161
|
-
return ptr;
|
|
162
|
-
}
|
|
163
|
-
free() {
|
|
164
|
-
const ptr = this.__destroy_into_raw();
|
|
165
|
-
wasm.__wbg_zkinputsgenerator_free(ptr, 0);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Create a new JavaScript CRISP ZK inputs generator with the specified BFV parameters.
|
|
169
|
-
*
|
|
170
|
-
* # Arguments
|
|
171
|
-
* - `degree`: Polynomial degree
|
|
172
|
-
* - `plaintext_modulus`: Plaintext modulus (will be converted to u64)
|
|
173
|
-
* - `moduli`: Array of moduli (will be converted to Vec<u64>)
|
|
174
|
-
* @param {number} degree
|
|
175
|
-
* @param {bigint} plaintext_modulus
|
|
176
|
-
* @param {BigInt64Array} moduli
|
|
177
|
-
*/
|
|
178
|
-
constructor(degree, plaintext_modulus, moduli) {
|
|
179
|
-
const ptr0 = passArray64ToWasm0(moduli, wasm.__wbindgen_malloc);
|
|
180
|
-
const len0 = WASM_VECTOR_LEN;
|
|
181
|
-
const ret = wasm.zkinputsgenerator_new(degree, plaintext_modulus, ptr0, len0);
|
|
182
|
-
if (ret[2]) {
|
|
183
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
184
|
-
}
|
|
185
|
-
this.__wbg_ptr = ret[0] >>> 0;
|
|
186
|
-
ZKInputsGeneratorFinalization.register(this, this.__wbg_ptr, this);
|
|
187
|
-
return this;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Create a new JavaScript CRISP ZK inputs generator with default BFV parameters.
|
|
191
|
-
* @returns {ZKInputsGenerator}
|
|
192
|
-
*/
|
|
193
|
-
static withDefaults() {
|
|
194
|
-
const ret = wasm.zkinputsgenerator_withDefaults();
|
|
195
|
-
if (ret[2]) {
|
|
196
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
197
|
-
}
|
|
198
|
-
return ZKInputsGenerator.__wrap(ret[0]);
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Generate CRISP ZK inputs from JavaScript.
|
|
202
|
-
* @param {Uint8Array} prev_ciphertext
|
|
203
|
-
* @param {Uint8Array} public_key
|
|
204
|
-
* @param {BigInt64Array} vote
|
|
205
|
-
* @returns {any}
|
|
206
|
-
*/
|
|
207
|
-
generateInputs(prev_ciphertext, public_key, vote) {
|
|
208
|
-
const ptr0 = passArray8ToWasm0(prev_ciphertext, wasm.__wbindgen_malloc);
|
|
209
|
-
const len0 = WASM_VECTOR_LEN;
|
|
210
|
-
const ptr1 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
211
|
-
const len1 = WASM_VECTOR_LEN;
|
|
212
|
-
const ptr2 = passArray64ToWasm0(vote, wasm.__wbindgen_malloc);
|
|
213
|
-
const len2 = WASM_VECTOR_LEN;
|
|
214
|
-
const ret = wasm.zkinputsgenerator_generateInputs(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
215
|
-
if (ret[2]) {
|
|
216
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
217
|
-
}
|
|
218
|
-
return takeFromExternrefTable0(ret[0]);
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Generate CRISP ZK inputs for a vote update (either from voter or as a masker) from JavaScript.
|
|
222
|
-
* @param {Uint8Array} prev_ciphertext
|
|
223
|
-
* @param {Uint8Array} public_key
|
|
224
|
-
* @param {BigInt64Array} vote
|
|
225
|
-
* @returns {any}
|
|
226
|
-
*/
|
|
227
|
-
generateInputsForUpdate(prev_ciphertext, public_key, vote) {
|
|
228
|
-
const ptr0 = passArray8ToWasm0(prev_ciphertext, wasm.__wbindgen_malloc);
|
|
229
|
-
const len0 = WASM_VECTOR_LEN;
|
|
230
|
-
const ptr1 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
231
|
-
const len1 = WASM_VECTOR_LEN;
|
|
232
|
-
const ptr2 = passArray64ToWasm0(vote, wasm.__wbindgen_malloc);
|
|
233
|
-
const len2 = WASM_VECTOR_LEN;
|
|
234
|
-
const ret = wasm.zkinputsgenerator_generateInputsForUpdate(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
235
|
-
if (ret[2]) {
|
|
236
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
237
|
-
}
|
|
238
|
-
return takeFromExternrefTable0(ret[0]);
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Generate a public key from JavaScript.
|
|
242
|
-
* @returns {Uint8Array}
|
|
243
|
-
*/
|
|
244
|
-
generatePublicKey() {
|
|
245
|
-
const ret = wasm.zkinputsgenerator_generatePublicKey(this.__wbg_ptr);
|
|
246
|
-
if (ret[3]) {
|
|
247
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
248
|
-
}
|
|
249
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
250
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
251
|
-
return v1;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Compute the commitment to a set of ciphertext polynomials from JavaScript.
|
|
255
|
-
* @param {any} ct0is
|
|
256
|
-
* @param {any} ct1is
|
|
257
|
-
* @returns {string}
|
|
258
|
-
*/
|
|
259
|
-
computeCommitment(ct0is, ct1is) {
|
|
260
|
-
let deferred2_0;
|
|
261
|
-
let deferred2_1;
|
|
262
|
-
try {
|
|
263
|
-
const ret = wasm.zkinputsgenerator_computeCommitment(this.__wbg_ptr, ct0is, ct1is);
|
|
264
|
-
var ptr1 = ret[0];
|
|
265
|
-
var len1 = ret[1];
|
|
266
|
-
if (ret[3]) {
|
|
267
|
-
ptr1 = 0; len1 = 0;
|
|
268
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
269
|
-
}
|
|
270
|
-
deferred2_0 = ptr1;
|
|
271
|
-
deferred2_1 = len1;
|
|
272
|
-
return getStringFromWasm0(ptr1, len1);
|
|
273
|
-
} finally {
|
|
274
|
-
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Encrypt a vote from JavaScript.
|
|
279
|
-
* @param {Uint8Array} public_key
|
|
280
|
-
* @param {BigInt64Array} vote
|
|
281
|
-
* @returns {Uint8Array}
|
|
282
|
-
*/
|
|
283
|
-
encryptVote(public_key, vote) {
|
|
284
|
-
const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
285
|
-
const len0 = WASM_VECTOR_LEN;
|
|
286
|
-
const ptr1 = passArray64ToWasm0(vote, wasm.__wbindgen_malloc);
|
|
287
|
-
const len1 = WASM_VECTOR_LEN;
|
|
288
|
-
const ret = wasm.zkinputsgenerator_encryptVote(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
289
|
-
if (ret[3]) {
|
|
290
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
291
|
-
}
|
|
292
|
-
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
293
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
294
|
-
return v3;
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Get the BFV parameters used by the generator.
|
|
298
|
-
* @returns {any}
|
|
299
|
-
*/
|
|
300
|
-
getBFVParams() {
|
|
301
|
-
const ret = wasm.zkinputsgenerator_getBFVParams(this.__wbg_ptr);
|
|
302
|
-
if (ret[2]) {
|
|
303
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
304
|
-
}
|
|
305
|
-
return takeFromExternrefTable0(ret[0]);
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Get the version of the library.
|
|
309
|
-
* @returns {string}
|
|
310
|
-
*/
|
|
311
|
-
static version() {
|
|
312
|
-
let deferred1_0;
|
|
313
|
-
let deferred1_1;
|
|
314
|
-
try {
|
|
315
|
-
const ret = wasm.zkinputsgenerator_version();
|
|
316
|
-
deferred1_0 = ret[0];
|
|
317
|
-
deferred1_1 = ret[1];
|
|
318
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
319
|
-
} finally {
|
|
320
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
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;
|
|
323
514
|
}
|
|
324
|
-
if (Symbol.dispose) ZKInputsGenerator.prototype[Symbol.dispose] = ZKInputsGenerator.prototype.free;
|
|
325
|
-
|
|
326
|
-
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
327
515
|
|
|
328
516
|
async function __wbg_load(module, imports) {
|
|
329
517
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
@@ -331,14 +519,12 @@ async function __wbg_load(module, imports) {
|
|
|
331
519
|
try {
|
|
332
520
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
333
521
|
} catch (e) {
|
|
334
|
-
const validResponse = module.ok &&
|
|
522
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
335
523
|
|
|
336
524
|
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
337
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);
|
|
338
526
|
|
|
339
|
-
} else {
|
|
340
|
-
throw e;
|
|
341
|
-
}
|
|
527
|
+
} else { throw e; }
|
|
342
528
|
}
|
|
343
529
|
}
|
|
344
530
|
|
|
@@ -353,201 +539,20 @@ async function __wbg_load(module, imports) {
|
|
|
353
539
|
return instance;
|
|
354
540
|
}
|
|
355
541
|
}
|
|
356
|
-
}
|
|
357
542
|
|
|
358
|
-
function
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}, arguments) };
|
|
365
|
-
imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
|
|
366
|
-
const ret = typeof(arg0) === 'function';
|
|
367
|
-
return ret;
|
|
368
|
-
};
|
|
369
|
-
imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
|
|
370
|
-
const val = arg0;
|
|
371
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
372
|
-
return ret;
|
|
373
|
-
};
|
|
374
|
-
imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
|
|
375
|
-
const ret = typeof(arg0) === 'string';
|
|
376
|
-
return ret;
|
|
377
|
-
};
|
|
378
|
-
imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
|
|
379
|
-
const ret = arg0 === undefined;
|
|
380
|
-
return ret;
|
|
381
|
-
};
|
|
382
|
-
imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
|
|
383
|
-
const obj = arg1;
|
|
384
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
385
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
386
|
-
var len1 = WASM_VECTOR_LEN;
|
|
387
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
388
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
389
|
-
};
|
|
390
|
-
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
391
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
392
|
-
};
|
|
393
|
-
imports.wbg.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
394
|
-
const ret = arg0.call(arg1, arg2);
|
|
395
|
-
return ret;
|
|
396
|
-
}, arguments) };
|
|
397
|
-
imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
|
|
398
|
-
const ret = arg0.call(arg1);
|
|
399
|
-
return ret;
|
|
400
|
-
}, arguments) };
|
|
401
|
-
imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
|
|
402
|
-
const ret = arg0.crypto;
|
|
403
|
-
return ret;
|
|
404
|
-
};
|
|
405
|
-
imports.wbg.__wbg_from_29a8414a7a7cd19d = function(arg0) {
|
|
406
|
-
const ret = Array.from(arg0);
|
|
407
|
-
return ret;
|
|
408
|
-
};
|
|
409
|
-
imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
|
|
410
|
-
arg0.getRandomValues(arg1);
|
|
411
|
-
}, arguments) };
|
|
412
|
-
imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
|
|
413
|
-
const ret = arg0[arg1 >>> 0];
|
|
414
|
-
return ret;
|
|
415
|
-
};
|
|
416
|
-
imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
|
|
417
|
-
const ret = Array.isArray(arg0);
|
|
418
|
-
return ret;
|
|
419
|
-
};
|
|
420
|
-
imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
|
|
421
|
-
const ret = arg0.length;
|
|
422
|
-
return ret;
|
|
423
|
-
};
|
|
424
|
-
imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
|
|
425
|
-
const ret = arg0.length;
|
|
426
|
-
return ret;
|
|
427
|
-
};
|
|
428
|
-
imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
|
|
429
|
-
const ret = arg0.msCrypto;
|
|
430
|
-
return ret;
|
|
431
|
-
};
|
|
432
|
-
imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
|
|
433
|
-
const ret = new Object();
|
|
434
|
-
return ret;
|
|
435
|
-
};
|
|
436
|
-
imports.wbg.__wbg_new_25f239778d6112b9 = function() {
|
|
437
|
-
const ret = new Array();
|
|
438
|
-
return ret;
|
|
439
|
-
};
|
|
440
|
-
imports.wbg.__wbg_new_from_slice_f9c22b9153b26992 = function(arg0, arg1) {
|
|
441
|
-
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
442
|
-
return ret;
|
|
443
|
-
};
|
|
444
|
-
imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
|
|
445
|
-
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
446
|
-
return ret;
|
|
447
|
-
};
|
|
448
|
-
imports.wbg.__wbg_new_with_length_aa5eaf41d35235e5 = function(arg0) {
|
|
449
|
-
const ret = new Uint8Array(arg0 >>> 0);
|
|
450
|
-
return ret;
|
|
451
|
-
};
|
|
452
|
-
imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) {
|
|
453
|
-
const ret = arg0.node;
|
|
454
|
-
return ret;
|
|
455
|
-
};
|
|
456
|
-
imports.wbg.__wbg_parse_a09a54cf72639456 = function() { return handleError(function (arg0, arg1) {
|
|
457
|
-
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
458
|
-
return ret;
|
|
459
|
-
}, arguments) };
|
|
460
|
-
imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
|
|
461
|
-
const ret = arg0.process;
|
|
462
|
-
return ret;
|
|
463
|
-
};
|
|
464
|
-
imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
|
|
465
|
-
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
466
|
-
};
|
|
467
|
-
imports.wbg.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) {
|
|
468
|
-
const ret = arg0.push(arg1);
|
|
469
|
-
return ret;
|
|
470
|
-
};
|
|
471
|
-
imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
|
|
472
|
-
arg0.randomFillSync(arg1);
|
|
473
|
-
}, arguments) };
|
|
474
|
-
imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
|
|
475
|
-
const ret = module.require;
|
|
476
|
-
return ret;
|
|
477
|
-
}, arguments) };
|
|
478
|
-
imports.wbg.__wbg_set_781438a03c0c3c81 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
479
|
-
const ret = Reflect.set(arg0, arg1, arg2);
|
|
480
|
-
return ret;
|
|
481
|
-
}, arguments) };
|
|
482
|
-
imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
|
|
483
|
-
const ret = typeof global === 'undefined' ? null : global;
|
|
484
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
485
|
-
};
|
|
486
|
-
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
|
|
487
|
-
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
488
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
489
|
-
};
|
|
490
|
-
imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
|
|
491
|
-
const ret = typeof self === 'undefined' ? null : self;
|
|
492
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
493
|
-
};
|
|
494
|
-
imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
|
|
495
|
-
const ret = typeof window === 'undefined' ? null : window;
|
|
496
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
497
|
-
};
|
|
498
|
-
imports.wbg.__wbg_subarray_845f2f5bce7d061a = function(arg0, arg1, arg2) {
|
|
499
|
-
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
500
|
-
return ret;
|
|
501
|
-
};
|
|
502
|
-
imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) {
|
|
503
|
-
const ret = arg0.versions;
|
|
504
|
-
return ret;
|
|
505
|
-
};
|
|
506
|
-
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
507
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
508
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
509
|
-
return ret;
|
|
510
|
-
};
|
|
511
|
-
imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
|
|
512
|
-
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
513
|
-
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
514
|
-
return ret;
|
|
515
|
-
};
|
|
516
|
-
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
517
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
518
|
-
const ret = arg0;
|
|
519
|
-
return ret;
|
|
520
|
-
};
|
|
521
|
-
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
522
|
-
const table = wasm.__wbindgen_externrefs;
|
|
523
|
-
const offset = table.grow(4);
|
|
524
|
-
table.set(0, undefined);
|
|
525
|
-
table.set(offset + 0, undefined);
|
|
526
|
-
table.set(offset + 1, null);
|
|
527
|
-
table.set(offset + 2, true);
|
|
528
|
-
table.set(offset + 3, false);
|
|
529
|
-
};
|
|
530
|
-
|
|
531
|
-
return imports;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
function __wbg_finalize_init(instance, module) {
|
|
535
|
-
wasm = instance.exports;
|
|
536
|
-
__wbg_init.__wbindgen_wasm_module = module;
|
|
537
|
-
cachedBigUint64ArrayMemory0 = null;
|
|
538
|
-
cachedDataViewMemory0 = null;
|
|
539
|
-
cachedUint8ArrayMemory0 = null;
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
wasm.__wbindgen_start();
|
|
543
|
-
return wasm;
|
|
543
|
+
function expectedResponseType(type) {
|
|
544
|
+
switch (type) {
|
|
545
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
546
|
+
}
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
544
549
|
}
|
|
545
550
|
|
|
546
551
|
function initSync(module) {
|
|
547
552
|
if (wasm !== undefined) return wasm;
|
|
548
553
|
|
|
549
554
|
|
|
550
|
-
if (
|
|
555
|
+
if (module !== undefined) {
|
|
551
556
|
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
552
557
|
({module} = module)
|
|
553
558
|
} else {
|
|
@@ -567,7 +572,7 @@ async function __wbg_init(module_or_path) {
|
|
|
567
572
|
if (wasm !== undefined) return wasm;
|
|
568
573
|
|
|
569
574
|
|
|
570
|
-
if (
|
|
575
|
+
if (module_or_path !== undefined) {
|
|
571
576
|
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
572
577
|
({module_or_path} = module_or_path)
|
|
573
578
|
} else {
|
|
@@ -575,7 +580,7 @@ async function __wbg_init(module_or_path) {
|
|
|
575
580
|
}
|
|
576
581
|
}
|
|
577
582
|
|
|
578
|
-
if (
|
|
583
|
+
if (module_or_path === undefined) {
|
|
579
584
|
/* wasm URL disabled */
|
|
580
585
|
}
|
|
581
586
|
const imports = __wbg_get_imports();
|
|
@@ -589,5 +594,4 @@ async function __wbg_init(module_or_path) {
|
|
|
589
594
|
return __wbg_finalize_init(instance, module);
|
|
590
595
|
}
|
|
591
596
|
|
|
592
|
-
export { initSync };
|
|
593
|
-
export default __wbg_init;
|
|
597
|
+
export { initSync, __wbg_init as default };
|