tfhe 0.0.1 → 0.2.4

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/tfhe.js ADDED
@@ -0,0 +1,1530 @@
1
+ let wasm;
2
+
3
+ const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
4
+
5
+ cachedTextDecoder.decode();
6
+
7
+ let cachedUint8Memory0 = null;
8
+
9
+ function getUint8Memory0() {
10
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
11
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
12
+ }
13
+ return cachedUint8Memory0;
14
+ }
15
+
16
+ function getStringFromWasm0(ptr, len) {
17
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
18
+ }
19
+
20
+ const heap = new Array(128).fill(undefined);
21
+
22
+ heap.push(undefined, null, true, false);
23
+
24
+ let heap_next = heap.length;
25
+
26
+ function addHeapObject(obj) {
27
+ if (heap_next === heap.length) heap.push(heap.length + 1);
28
+ const idx = heap_next;
29
+ heap_next = heap[idx];
30
+
31
+ heap[idx] = obj;
32
+ return idx;
33
+ }
34
+
35
+ function getObject(idx) { return heap[idx]; }
36
+
37
+ function dropObject(idx) {
38
+ if (idx < 132) return;
39
+ heap[idx] = heap_next;
40
+ heap_next = idx;
41
+ }
42
+
43
+ function takeObject(idx) {
44
+ const ret = getObject(idx);
45
+ dropObject(idx);
46
+ return ret;
47
+ }
48
+
49
+ let cachedInt32Memory0 = null;
50
+
51
+ function getInt32Memory0() {
52
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
53
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
54
+ }
55
+ return cachedInt32Memory0;
56
+ }
57
+
58
+ function _assertClass(instance, klass) {
59
+ if (!(instance instanceof klass)) {
60
+ throw new Error(`expected instance of ${klass.name}`);
61
+ }
62
+ return instance.ptr;
63
+ }
64
+
65
+ function getArrayU8FromWasm0(ptr, len) {
66
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
67
+ }
68
+
69
+ let WASM_VECTOR_LEN = 0;
70
+
71
+ function passArray8ToWasm0(arg, malloc) {
72
+ const ptr = malloc(arg.length * 1);
73
+ getUint8Memory0().set(arg, ptr / 1);
74
+ WASM_VECTOR_LEN = arg.length;
75
+ return ptr;
76
+ }
77
+
78
+ const cachedTextEncoder = new TextEncoder('utf-8');
79
+
80
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
81
+ ? function (arg, view) {
82
+ return cachedTextEncoder.encodeInto(arg, view);
83
+ }
84
+ : function (arg, view) {
85
+ const buf = cachedTextEncoder.encode(arg);
86
+ view.set(buf);
87
+ return {
88
+ read: arg.length,
89
+ written: buf.length
90
+ };
91
+ });
92
+
93
+ function passStringToWasm0(arg, malloc, realloc) {
94
+
95
+ if (realloc === undefined) {
96
+ const buf = cachedTextEncoder.encode(arg);
97
+ const ptr = malloc(buf.length);
98
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
99
+ WASM_VECTOR_LEN = buf.length;
100
+ return ptr;
101
+ }
102
+
103
+ let len = arg.length;
104
+ let ptr = malloc(len);
105
+
106
+ const mem = getUint8Memory0();
107
+
108
+ let offset = 0;
109
+
110
+ for (; offset < len; offset++) {
111
+ const code = arg.charCodeAt(offset);
112
+ if (code > 0x7F) break;
113
+ mem[ptr + offset] = code;
114
+ }
115
+
116
+ if (offset !== len) {
117
+ if (offset !== 0) {
118
+ arg = arg.slice(offset);
119
+ }
120
+ ptr = realloc(ptr, len, len = offset + arg.length * 3);
121
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
122
+ const ret = encodeString(arg, view);
123
+
124
+ offset += ret.written;
125
+ }
126
+
127
+ WASM_VECTOR_LEN = offset;
128
+ return ptr;
129
+ }
130
+
131
+ function handleError(f, args) {
132
+ try {
133
+ return f.apply(this, args);
134
+ } catch (e) {
135
+ wasm.__wbindgen_exn_store(addHeapObject(e));
136
+ }
137
+ }
138
+ /**
139
+ */
140
+ export const BooleanParameterSet = Object.freeze({ Default:0,"0":"Default",TfheLib:1,"1":"TfheLib", });
141
+ /**
142
+ */
143
+ export class Boolean {
144
+
145
+ __destroy_into_raw() {
146
+ const ptr = this.ptr;
147
+ this.ptr = 0;
148
+
149
+ return ptr;
150
+ }
151
+
152
+ free() {
153
+ const ptr = this.__destroy_into_raw();
154
+ wasm.__wbg_boolean_free(ptr);
155
+ }
156
+ /**
157
+ * @param {number} parameter_choice
158
+ * @returns {BooleanParameters}
159
+ */
160
+ static get_parameters(parameter_choice) {
161
+ try {
162
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
163
+ wasm.boolean_get_parameters(retptr, parameter_choice);
164
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
165
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
166
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
167
+ if (r2) {
168
+ throw takeObject(r1);
169
+ }
170
+ return BooleanParameters.__wrap(r0);
171
+ } finally {
172
+ wasm.__wbindgen_add_to_stack_pointer(16);
173
+ }
174
+ }
175
+ /**
176
+ * @param {number} lwe_dimension
177
+ * @param {number} glwe_dimension
178
+ * @param {number} polynomial_size
179
+ * @param {number} lwe_modular_std_dev
180
+ * @param {number} glwe_modular_std_dev
181
+ * @param {number} pbs_base_log
182
+ * @param {number} pbs_level
183
+ * @param {number} ks_base_log
184
+ * @param {number} ks_level
185
+ * @returns {BooleanParameters}
186
+ */
187
+ static new_parameters(lwe_dimension, glwe_dimension, polynomial_size, lwe_modular_std_dev, glwe_modular_std_dev, pbs_base_log, pbs_level, ks_base_log, ks_level) {
188
+ const ret = wasm.boolean_new_parameters(lwe_dimension, glwe_dimension, polynomial_size, lwe_modular_std_dev, glwe_modular_std_dev, pbs_base_log, pbs_level, ks_base_log, ks_level);
189
+ return BooleanParameters.__wrap(ret);
190
+ }
191
+ /**
192
+ * @param {bigint} seed_high_bytes
193
+ * @param {bigint} seed_low_bytes
194
+ * @param {BooleanParameters} parameters
195
+ * @returns {BooleanClientKey}
196
+ */
197
+ static new_client_key_from_seed_and_parameters(seed_high_bytes, seed_low_bytes, parameters) {
198
+ _assertClass(parameters, BooleanParameters);
199
+ const ret = wasm.boolean_new_client_key_from_seed_and_parameters(seed_high_bytes, seed_low_bytes, parameters.ptr);
200
+ return BooleanClientKey.__wrap(ret);
201
+ }
202
+ /**
203
+ * @param {BooleanParameters} parameters
204
+ * @returns {BooleanClientKey}
205
+ */
206
+ static new_client_key(parameters) {
207
+ _assertClass(parameters, BooleanParameters);
208
+ const ret = wasm.boolean_new_client_key(parameters.ptr);
209
+ return BooleanClientKey.__wrap(ret);
210
+ }
211
+ /**
212
+ * @param {BooleanClientKey} client_key
213
+ * @returns {BooleanPublicKey}
214
+ */
215
+ static new_public_key(client_key) {
216
+ _assertClass(client_key, BooleanClientKey);
217
+ const ret = wasm.boolean_new_public_key(client_key.ptr);
218
+ return BooleanPublicKey.__wrap(ret);
219
+ }
220
+ /**
221
+ * @param {BooleanClientKey} client_key
222
+ * @returns {BooleanCompressedServerKey}
223
+ */
224
+ static new_compressed_server_key(client_key) {
225
+ _assertClass(client_key, BooleanClientKey);
226
+ const ret = wasm.boolean_new_compressed_server_key(client_key.ptr);
227
+ return BooleanCompressedServerKey.__wrap(ret);
228
+ }
229
+ /**
230
+ * @param {BooleanClientKey} client_key
231
+ * @param {boolean} message
232
+ * @returns {BooleanCiphertext}
233
+ */
234
+ static encrypt(client_key, message) {
235
+ _assertClass(client_key, BooleanClientKey);
236
+ const ret = wasm.boolean_encrypt(client_key.ptr, message);
237
+ return BooleanCiphertext.__wrap(ret);
238
+ }
239
+ /**
240
+ * @param {BooleanClientKey} client_key
241
+ * @param {boolean} message
242
+ * @returns {BooleanCompressedCiphertext}
243
+ */
244
+ static encrypt_compressed(client_key, message) {
245
+ _assertClass(client_key, BooleanClientKey);
246
+ const ret = wasm.boolean_encrypt_compressed(client_key.ptr, message);
247
+ return BooleanCompressedCiphertext.__wrap(ret);
248
+ }
249
+ /**
250
+ * @param {BooleanCompressedCiphertext} compressed_ciphertext
251
+ * @returns {BooleanCiphertext}
252
+ */
253
+ static decompress_ciphertext(compressed_ciphertext) {
254
+ _assertClass(compressed_ciphertext, BooleanCompressedCiphertext);
255
+ const ret = wasm.boolean_decompress_ciphertext(compressed_ciphertext.ptr);
256
+ return BooleanCiphertext.__wrap(ret);
257
+ }
258
+ /**
259
+ * @param {BooleanPublicKey} public_key
260
+ * @param {boolean} message
261
+ * @returns {BooleanCiphertext}
262
+ */
263
+ static encrypt_with_public_key(public_key, message) {
264
+ _assertClass(public_key, BooleanPublicKey);
265
+ const ret = wasm.boolean_encrypt_with_public_key(public_key.ptr, message);
266
+ return BooleanCiphertext.__wrap(ret);
267
+ }
268
+ /**
269
+ * @param {boolean} message
270
+ * @returns {BooleanCiphertext}
271
+ */
272
+ trivial_encrypt(message) {
273
+ const ret = wasm.boolean_trivial_encrypt(this.ptr, message);
274
+ return BooleanCiphertext.__wrap(ret);
275
+ }
276
+ /**
277
+ * @param {BooleanClientKey} client_key
278
+ * @param {BooleanCiphertext} ct
279
+ * @returns {boolean}
280
+ */
281
+ static decrypt(client_key, ct) {
282
+ _assertClass(client_key, BooleanClientKey);
283
+ _assertClass(ct, BooleanCiphertext);
284
+ const ret = wasm.boolean_decrypt(client_key.ptr, ct.ptr);
285
+ return ret !== 0;
286
+ }
287
+ /**
288
+ * @param {BooleanCiphertext} ciphertext
289
+ * @returns {Uint8Array}
290
+ */
291
+ static serialize_ciphertext(ciphertext) {
292
+ try {
293
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
294
+ _assertClass(ciphertext, BooleanCiphertext);
295
+ wasm.boolean_serialize_ciphertext(retptr, ciphertext.ptr);
296
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
297
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
298
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
299
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
300
+ if (r3) {
301
+ throw takeObject(r2);
302
+ }
303
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
304
+ wasm.__wbindgen_free(r0, r1 * 1);
305
+ return v0;
306
+ } finally {
307
+ wasm.__wbindgen_add_to_stack_pointer(16);
308
+ }
309
+ }
310
+ /**
311
+ * @param {Uint8Array} buffer
312
+ * @returns {BooleanCiphertext}
313
+ */
314
+ static deserialize_ciphertext(buffer) {
315
+ try {
316
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
317
+ const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
318
+ const len0 = WASM_VECTOR_LEN;
319
+ wasm.boolean_deserialize_ciphertext(retptr, ptr0, len0);
320
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
321
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
322
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
323
+ if (r2) {
324
+ throw takeObject(r1);
325
+ }
326
+ return BooleanCiphertext.__wrap(r0);
327
+ } finally {
328
+ wasm.__wbindgen_add_to_stack_pointer(16);
329
+ }
330
+ }
331
+ /**
332
+ * @param {BooleanCompressedCiphertext} ciphertext
333
+ * @returns {Uint8Array}
334
+ */
335
+ static serialize_compressed_ciphertext(ciphertext) {
336
+ try {
337
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
338
+ _assertClass(ciphertext, BooleanCompressedCiphertext);
339
+ wasm.boolean_serialize_compressed_ciphertext(retptr, ciphertext.ptr);
340
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
341
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
342
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
343
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
344
+ if (r3) {
345
+ throw takeObject(r2);
346
+ }
347
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
348
+ wasm.__wbindgen_free(r0, r1 * 1);
349
+ return v0;
350
+ } finally {
351
+ wasm.__wbindgen_add_to_stack_pointer(16);
352
+ }
353
+ }
354
+ /**
355
+ * @param {Uint8Array} buffer
356
+ * @returns {BooleanCompressedCiphertext}
357
+ */
358
+ static deserialize_compressed_ciphertext(buffer) {
359
+ try {
360
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
361
+ const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
362
+ const len0 = WASM_VECTOR_LEN;
363
+ wasm.boolean_deserialize_compressed_ciphertext(retptr, ptr0, len0);
364
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
365
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
366
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
367
+ if (r2) {
368
+ throw takeObject(r1);
369
+ }
370
+ return BooleanCompressedCiphertext.__wrap(r0);
371
+ } finally {
372
+ wasm.__wbindgen_add_to_stack_pointer(16);
373
+ }
374
+ }
375
+ /**
376
+ * @param {BooleanClientKey} client_key
377
+ * @returns {Uint8Array}
378
+ */
379
+ static serialize_client_key(client_key) {
380
+ try {
381
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
382
+ _assertClass(client_key, BooleanClientKey);
383
+ wasm.boolean_serialize_client_key(retptr, client_key.ptr);
384
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
385
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
386
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
387
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
388
+ if (r3) {
389
+ throw takeObject(r2);
390
+ }
391
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
392
+ wasm.__wbindgen_free(r0, r1 * 1);
393
+ return v0;
394
+ } finally {
395
+ wasm.__wbindgen_add_to_stack_pointer(16);
396
+ }
397
+ }
398
+ /**
399
+ * @param {Uint8Array} buffer
400
+ * @returns {BooleanClientKey}
401
+ */
402
+ static deserialize_client_key(buffer) {
403
+ try {
404
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
405
+ const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
406
+ const len0 = WASM_VECTOR_LEN;
407
+ wasm.boolean_deserialize_client_key(retptr, ptr0, len0);
408
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
409
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
410
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
411
+ if (r2) {
412
+ throw takeObject(r1);
413
+ }
414
+ return BooleanClientKey.__wrap(r0);
415
+ } finally {
416
+ wasm.__wbindgen_add_to_stack_pointer(16);
417
+ }
418
+ }
419
+ /**
420
+ * @param {BooleanPublicKey} public_key
421
+ * @returns {Uint8Array}
422
+ */
423
+ static serialize_public_key(public_key) {
424
+ try {
425
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
426
+ _assertClass(public_key, BooleanPublicKey);
427
+ wasm.boolean_serialize_public_key(retptr, public_key.ptr);
428
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
429
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
430
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
431
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
432
+ if (r3) {
433
+ throw takeObject(r2);
434
+ }
435
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
436
+ wasm.__wbindgen_free(r0, r1 * 1);
437
+ return v0;
438
+ } finally {
439
+ wasm.__wbindgen_add_to_stack_pointer(16);
440
+ }
441
+ }
442
+ /**
443
+ * @param {Uint8Array} buffer
444
+ * @returns {BooleanPublicKey}
445
+ */
446
+ static deserialize_public_key(buffer) {
447
+ try {
448
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
449
+ const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
450
+ const len0 = WASM_VECTOR_LEN;
451
+ wasm.boolean_deserialize_public_key(retptr, ptr0, len0);
452
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
453
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
454
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
455
+ if (r2) {
456
+ throw takeObject(r1);
457
+ }
458
+ return BooleanPublicKey.__wrap(r0);
459
+ } finally {
460
+ wasm.__wbindgen_add_to_stack_pointer(16);
461
+ }
462
+ }
463
+ /**
464
+ * @param {BooleanCompressedServerKey} server_key
465
+ * @returns {Uint8Array}
466
+ */
467
+ static serialize_compressed_server_key(server_key) {
468
+ try {
469
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
470
+ _assertClass(server_key, BooleanCompressedServerKey);
471
+ wasm.boolean_serialize_compressed_server_key(retptr, server_key.ptr);
472
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
473
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
474
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
475
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
476
+ if (r3) {
477
+ throw takeObject(r2);
478
+ }
479
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
480
+ wasm.__wbindgen_free(r0, r1 * 1);
481
+ return v0;
482
+ } finally {
483
+ wasm.__wbindgen_add_to_stack_pointer(16);
484
+ }
485
+ }
486
+ /**
487
+ * @param {Uint8Array} buffer
488
+ * @returns {BooleanCompressedServerKey}
489
+ */
490
+ static deserialize_compressed_server_key(buffer) {
491
+ try {
492
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
493
+ const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
494
+ const len0 = WASM_VECTOR_LEN;
495
+ wasm.boolean_deserialize_compressed_server_key(retptr, ptr0, len0);
496
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
497
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
498
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
499
+ if (r2) {
500
+ throw takeObject(r1);
501
+ }
502
+ return BooleanCompressedServerKey.__wrap(r0);
503
+ } finally {
504
+ wasm.__wbindgen_add_to_stack_pointer(16);
505
+ }
506
+ }
507
+ }
508
+ /**
509
+ */
510
+ export class BooleanCiphertext {
511
+
512
+ static __wrap(ptr) {
513
+ const obj = Object.create(BooleanCiphertext.prototype);
514
+ obj.ptr = ptr;
515
+
516
+ return obj;
517
+ }
518
+
519
+ __destroy_into_raw() {
520
+ const ptr = this.ptr;
521
+ this.ptr = 0;
522
+
523
+ return ptr;
524
+ }
525
+
526
+ free() {
527
+ const ptr = this.__destroy_into_raw();
528
+ wasm.__wbg_booleanciphertext_free(ptr);
529
+ }
530
+ }
531
+ /**
532
+ */
533
+ export class BooleanClientKey {
534
+
535
+ static __wrap(ptr) {
536
+ const obj = Object.create(BooleanClientKey.prototype);
537
+ obj.ptr = ptr;
538
+
539
+ return obj;
540
+ }
541
+
542
+ __destroy_into_raw() {
543
+ const ptr = this.ptr;
544
+ this.ptr = 0;
545
+
546
+ return ptr;
547
+ }
548
+
549
+ free() {
550
+ const ptr = this.__destroy_into_raw();
551
+ wasm.__wbg_booleanclientkey_free(ptr);
552
+ }
553
+ }
554
+ /**
555
+ */
556
+ export class BooleanCompressedCiphertext {
557
+
558
+ static __wrap(ptr) {
559
+ const obj = Object.create(BooleanCompressedCiphertext.prototype);
560
+ obj.ptr = ptr;
561
+
562
+ return obj;
563
+ }
564
+
565
+ __destroy_into_raw() {
566
+ const ptr = this.ptr;
567
+ this.ptr = 0;
568
+
569
+ return ptr;
570
+ }
571
+
572
+ free() {
573
+ const ptr = this.__destroy_into_raw();
574
+ wasm.__wbg_booleancompressedciphertext_free(ptr);
575
+ }
576
+ }
577
+ /**
578
+ */
579
+ export class BooleanCompressedServerKey {
580
+
581
+ static __wrap(ptr) {
582
+ const obj = Object.create(BooleanCompressedServerKey.prototype);
583
+ obj.ptr = ptr;
584
+
585
+ return obj;
586
+ }
587
+
588
+ __destroy_into_raw() {
589
+ const ptr = this.ptr;
590
+ this.ptr = 0;
591
+
592
+ return ptr;
593
+ }
594
+
595
+ free() {
596
+ const ptr = this.__destroy_into_raw();
597
+ wasm.__wbg_booleancompressedserverkey_free(ptr);
598
+ }
599
+ }
600
+ /**
601
+ */
602
+ export class BooleanParameters {
603
+
604
+ static __wrap(ptr) {
605
+ const obj = Object.create(BooleanParameters.prototype);
606
+ obj.ptr = ptr;
607
+
608
+ return obj;
609
+ }
610
+
611
+ __destroy_into_raw() {
612
+ const ptr = this.ptr;
613
+ this.ptr = 0;
614
+
615
+ return ptr;
616
+ }
617
+
618
+ free() {
619
+ const ptr = this.__destroy_into_raw();
620
+ wasm.__wbg_booleanparameters_free(ptr);
621
+ }
622
+ }
623
+ /**
624
+ */
625
+ export class BooleanPublicKey {
626
+
627
+ static __wrap(ptr) {
628
+ const obj = Object.create(BooleanPublicKey.prototype);
629
+ obj.ptr = ptr;
630
+
631
+ return obj;
632
+ }
633
+
634
+ __destroy_into_raw() {
635
+ const ptr = this.ptr;
636
+ this.ptr = 0;
637
+
638
+ return ptr;
639
+ }
640
+
641
+ free() {
642
+ const ptr = this.__destroy_into_raw();
643
+ wasm.__wbg_booleanpublickey_free(ptr);
644
+ }
645
+ }
646
+ /**
647
+ */
648
+ export class Shortint {
649
+
650
+ __destroy_into_raw() {
651
+ const ptr = this.ptr;
652
+ this.ptr = 0;
653
+
654
+ return ptr;
655
+ }
656
+
657
+ free() {
658
+ const ptr = this.__destroy_into_raw();
659
+ wasm.__wbg_shortint_free(ptr);
660
+ }
661
+ /**
662
+ * @param {number} message_bits
663
+ * @param {number} carry_bits
664
+ * @returns {ShortintParameters}
665
+ */
666
+ static get_parameters(message_bits, carry_bits) {
667
+ try {
668
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
669
+ wasm.shortint_get_parameters(retptr, message_bits, carry_bits);
670
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
671
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
672
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
673
+ if (r2) {
674
+ throw takeObject(r1);
675
+ }
676
+ return ShortintParameters.__wrap(r0);
677
+ } finally {
678
+ wasm.__wbindgen_add_to_stack_pointer(16);
679
+ }
680
+ }
681
+ /**
682
+ * @param {number} message_bits
683
+ * @param {number} carry_bits
684
+ * @returns {ShortintParameters}
685
+ */
686
+ static get_parameters_small(message_bits, carry_bits) {
687
+ try {
688
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
689
+ wasm.shortint_get_parameters_small(retptr, message_bits, carry_bits);
690
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
691
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
692
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
693
+ if (r2) {
694
+ throw takeObject(r1);
695
+ }
696
+ return ShortintParameters.__wrap(r0);
697
+ } finally {
698
+ wasm.__wbindgen_add_to_stack_pointer(16);
699
+ }
700
+ }
701
+ /**
702
+ * @param {number} lwe_dimension
703
+ * @param {number} glwe_dimension
704
+ * @param {number} polynomial_size
705
+ * @param {number} lwe_modular_std_dev
706
+ * @param {number} glwe_modular_std_dev
707
+ * @param {number} pbs_base_log
708
+ * @param {number} pbs_level
709
+ * @param {number} ks_base_log
710
+ * @param {number} ks_level
711
+ * @param {number} pfks_level
712
+ * @param {number} pfks_base_log
713
+ * @param {number} pfks_modular_std_dev
714
+ * @param {number} cbs_level
715
+ * @param {number} cbs_base_log
716
+ * @param {number} message_modulus
717
+ * @param {number} carry_modulus
718
+ * @param {number} modulus_power_of_2_exponent
719
+ * @returns {ShortintParameters}
720
+ */
721
+ static new_parameters(lwe_dimension, glwe_dimension, polynomial_size, lwe_modular_std_dev, glwe_modular_std_dev, pbs_base_log, pbs_level, ks_base_log, ks_level, pfks_level, pfks_base_log, pfks_modular_std_dev, cbs_level, cbs_base_log, message_modulus, carry_modulus, modulus_power_of_2_exponent) {
722
+ const ret = wasm.shortint_new_parameters(lwe_dimension, glwe_dimension, polynomial_size, lwe_modular_std_dev, glwe_modular_std_dev, pbs_base_log, pbs_level, ks_base_log, ks_level, pfks_level, pfks_base_log, pfks_modular_std_dev, cbs_level, cbs_base_log, message_modulus, carry_modulus, modulus_power_of_2_exponent);
723
+ return ShortintParameters.__wrap(ret);
724
+ }
725
+ /**
726
+ * @param {bigint} seed_high_bytes
727
+ * @param {bigint} seed_low_bytes
728
+ * @param {ShortintParameters} parameters
729
+ * @returns {ShortintClientKey}
730
+ */
731
+ static new_client_key_from_seed_and_parameters(seed_high_bytes, seed_low_bytes, parameters) {
732
+ try {
733
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
734
+ _assertClass(parameters, ShortintParameters);
735
+ wasm.shortint_new_client_key_from_seed_and_parameters(retptr, seed_high_bytes, seed_low_bytes, parameters.ptr);
736
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
737
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
738
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
739
+ if (r2) {
740
+ throw takeObject(r1);
741
+ }
742
+ return ShortintClientKey.__wrap(r0);
743
+ } finally {
744
+ wasm.__wbindgen_add_to_stack_pointer(16);
745
+ }
746
+ }
747
+ /**
748
+ * @param {ShortintParameters} parameters
749
+ * @returns {ShortintClientKey}
750
+ */
751
+ static new_client_key(parameters) {
752
+ _assertClass(parameters, ShortintParameters);
753
+ const ret = wasm.shortint_new_client_key(parameters.ptr);
754
+ return ShortintClientKey.__wrap(ret);
755
+ }
756
+ /**
757
+ * @param {ShortintClientKey} client_key
758
+ * @returns {ShortintPublicKey}
759
+ */
760
+ static new_public_key(client_key) {
761
+ _assertClass(client_key, ShortintClientKey);
762
+ const ret = wasm.shortint_new_public_key(client_key.ptr);
763
+ return ShortintPublicKey.__wrap(ret);
764
+ }
765
+ /**
766
+ * @param {ShortintClientKey} client_key
767
+ * @returns {ShortintPublicKey}
768
+ */
769
+ static new_public_key_small(client_key) {
770
+ _assertClass(client_key, ShortintClientKey);
771
+ const ret = wasm.shortint_new_public_key_small(client_key.ptr);
772
+ return ShortintPublicKey.__wrap(ret);
773
+ }
774
+ /**
775
+ * @param {ShortintClientKey} client_key
776
+ * @returns {ShortintCompressedPublicKey}
777
+ */
778
+ static new_compressed_public_key(client_key) {
779
+ _assertClass(client_key, ShortintClientKey);
780
+ const ret = wasm.shortint_new_compressed_public_key(client_key.ptr);
781
+ return ShortintCompressedPublicKey.__wrap(ret);
782
+ }
783
+ /**
784
+ * @param {ShortintClientKey} client_key
785
+ * @returns {ShortintCompressedPublicKey}
786
+ */
787
+ static new_compressed_public_key_small(client_key) {
788
+ _assertClass(client_key, ShortintClientKey);
789
+ const ret = wasm.shortint_new_compressed_public_key_small(client_key.ptr);
790
+ return ShortintCompressedPublicKey.__wrap(ret);
791
+ }
792
+ /**
793
+ * @param {ShortintClientKey} client_key
794
+ * @returns {ShortintCompressedServerKey}
795
+ */
796
+ static new_compressed_server_key(client_key) {
797
+ _assertClass(client_key, ShortintClientKey);
798
+ const ret = wasm.shortint_new_compressed_server_key(client_key.ptr);
799
+ return ShortintCompressedServerKey.__wrap(ret);
800
+ }
801
+ /**
802
+ * @param {ShortintClientKey} client_key
803
+ * @param {bigint} message
804
+ * @returns {ShortintCiphertext}
805
+ */
806
+ static encrypt(client_key, message) {
807
+ _assertClass(client_key, ShortintClientKey);
808
+ const ret = wasm.shortint_encrypt(client_key.ptr, message);
809
+ return ShortintCiphertext.__wrap(ret);
810
+ }
811
+ /**
812
+ * @param {ShortintClientKey} client_key
813
+ * @param {bigint} message
814
+ * @returns {ShortintCiphertext}
815
+ */
816
+ static encrypt_small(client_key, message) {
817
+ _assertClass(client_key, ShortintClientKey);
818
+ const ret = wasm.shortint_encrypt_small(client_key.ptr, message);
819
+ return ShortintCiphertext.__wrap(ret);
820
+ }
821
+ /**
822
+ * @param {ShortintClientKey} client_key
823
+ * @param {bigint} message
824
+ * @returns {ShortintCompressedCiphertext}
825
+ */
826
+ static encrypt_compressed(client_key, message) {
827
+ _assertClass(client_key, ShortintClientKey);
828
+ const ret = wasm.shortint_encrypt_compressed(client_key.ptr, message);
829
+ return ShortintCompressedCiphertext.__wrap(ret);
830
+ }
831
+ /**
832
+ * @param {ShortintClientKey} client_key
833
+ * @param {bigint} message
834
+ * @returns {ShortintCompressedCiphertext}
835
+ */
836
+ static encrypt_compressed_small(client_key, message) {
837
+ _assertClass(client_key, ShortintClientKey);
838
+ const ret = wasm.shortint_encrypt_compressed_small(client_key.ptr, message);
839
+ return ShortintCompressedCiphertext.__wrap(ret);
840
+ }
841
+ /**
842
+ * @param {ShortintCompressedCiphertext} compressed_ciphertext
843
+ * @returns {ShortintCiphertext}
844
+ */
845
+ static decompress_ciphertext(compressed_ciphertext) {
846
+ _assertClass(compressed_ciphertext, ShortintCompressedCiphertext);
847
+ const ret = wasm.shortint_decompress_ciphertext(compressed_ciphertext.ptr);
848
+ return ShortintCiphertext.__wrap(ret);
849
+ }
850
+ /**
851
+ * @param {ShortintPublicKey} public_key
852
+ * @param {bigint} message
853
+ * @returns {ShortintCiphertext}
854
+ */
855
+ static encrypt_with_public_key(public_key, message) {
856
+ _assertClass(public_key, ShortintPublicKey);
857
+ const ret = wasm.shortint_encrypt_with_public_key(public_key.ptr, message);
858
+ return ShortintCiphertext.__wrap(ret);
859
+ }
860
+ /**
861
+ * @param {ShortintCompressedPublicKey} public_key
862
+ * @param {bigint} message
863
+ * @returns {ShortintCiphertext}
864
+ */
865
+ static encrypt_with_compressed_public_key(public_key, message) {
866
+ _assertClass(public_key, ShortintCompressedPublicKey);
867
+ const ret = wasm.shortint_encrypt_with_compressed_public_key(public_key.ptr, message);
868
+ return ShortintCiphertext.__wrap(ret);
869
+ }
870
+ /**
871
+ * @param {ShortintClientKey} client_key
872
+ * @param {ShortintCiphertext} ct
873
+ * @returns {bigint}
874
+ */
875
+ static decrypt(client_key, ct) {
876
+ _assertClass(client_key, ShortintClientKey);
877
+ _assertClass(ct, ShortintCiphertext);
878
+ const ret = wasm.shortint_decrypt(client_key.ptr, ct.ptr);
879
+ return BigInt.asUintN(64, ret);
880
+ }
881
+ /**
882
+ * @param {ShortintCiphertext} ciphertext
883
+ * @returns {Uint8Array}
884
+ */
885
+ static serialize_ciphertext(ciphertext) {
886
+ try {
887
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
888
+ _assertClass(ciphertext, ShortintCiphertext);
889
+ wasm.shortint_serialize_ciphertext(retptr, ciphertext.ptr);
890
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
891
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
892
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
893
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
894
+ if (r3) {
895
+ throw takeObject(r2);
896
+ }
897
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
898
+ wasm.__wbindgen_free(r0, r1 * 1);
899
+ return v0;
900
+ } finally {
901
+ wasm.__wbindgen_add_to_stack_pointer(16);
902
+ }
903
+ }
904
+ /**
905
+ * @param {Uint8Array} buffer
906
+ * @returns {ShortintCiphertext}
907
+ */
908
+ static deserialize_ciphertext(buffer) {
909
+ try {
910
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
911
+ const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
912
+ const len0 = WASM_VECTOR_LEN;
913
+ wasm.shortint_deserialize_ciphertext(retptr, ptr0, len0);
914
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
915
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
916
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
917
+ if (r2) {
918
+ throw takeObject(r1);
919
+ }
920
+ return ShortintCiphertext.__wrap(r0);
921
+ } finally {
922
+ wasm.__wbindgen_add_to_stack_pointer(16);
923
+ }
924
+ }
925
+ /**
926
+ * @param {ShortintCompressedCiphertext} ciphertext
927
+ * @returns {Uint8Array}
928
+ */
929
+ static serialize_compressed_ciphertext(ciphertext) {
930
+ try {
931
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
932
+ _assertClass(ciphertext, ShortintCompressedCiphertext);
933
+ wasm.shortint_serialize_compressed_ciphertext(retptr, ciphertext.ptr);
934
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
935
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
936
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
937
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
938
+ if (r3) {
939
+ throw takeObject(r2);
940
+ }
941
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
942
+ wasm.__wbindgen_free(r0, r1 * 1);
943
+ return v0;
944
+ } finally {
945
+ wasm.__wbindgen_add_to_stack_pointer(16);
946
+ }
947
+ }
948
+ /**
949
+ * @param {Uint8Array} buffer
950
+ * @returns {ShortintCompressedCiphertext}
951
+ */
952
+ static deserialize_compressed_ciphertext(buffer) {
953
+ try {
954
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
955
+ const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
956
+ const len0 = WASM_VECTOR_LEN;
957
+ wasm.shortint_deserialize_compressed_ciphertext(retptr, ptr0, len0);
958
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
959
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
960
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
961
+ if (r2) {
962
+ throw takeObject(r1);
963
+ }
964
+ return ShortintCompressedCiphertext.__wrap(r0);
965
+ } finally {
966
+ wasm.__wbindgen_add_to_stack_pointer(16);
967
+ }
968
+ }
969
+ /**
970
+ * @param {ShortintClientKey} client_key
971
+ * @returns {Uint8Array}
972
+ */
973
+ static serialize_client_key(client_key) {
974
+ try {
975
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
976
+ _assertClass(client_key, ShortintClientKey);
977
+ wasm.shortint_serialize_client_key(retptr, client_key.ptr);
978
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
979
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
980
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
981
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
982
+ if (r3) {
983
+ throw takeObject(r2);
984
+ }
985
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
986
+ wasm.__wbindgen_free(r0, r1 * 1);
987
+ return v0;
988
+ } finally {
989
+ wasm.__wbindgen_add_to_stack_pointer(16);
990
+ }
991
+ }
992
+ /**
993
+ * @param {Uint8Array} buffer
994
+ * @returns {ShortintClientKey}
995
+ */
996
+ static deserialize_client_key(buffer) {
997
+ try {
998
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
999
+ const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
1000
+ const len0 = WASM_VECTOR_LEN;
1001
+ wasm.shortint_deserialize_client_key(retptr, ptr0, len0);
1002
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1003
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1004
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1005
+ if (r2) {
1006
+ throw takeObject(r1);
1007
+ }
1008
+ return ShortintClientKey.__wrap(r0);
1009
+ } finally {
1010
+ wasm.__wbindgen_add_to_stack_pointer(16);
1011
+ }
1012
+ }
1013
+ /**
1014
+ * @param {ShortintPublicKey} public_key
1015
+ * @returns {Uint8Array}
1016
+ */
1017
+ static serialize_public_key(public_key) {
1018
+ try {
1019
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1020
+ _assertClass(public_key, ShortintPublicKey);
1021
+ wasm.shortint_serialize_public_key(retptr, public_key.ptr);
1022
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1023
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1024
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1025
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
1026
+ if (r3) {
1027
+ throw takeObject(r2);
1028
+ }
1029
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
1030
+ wasm.__wbindgen_free(r0, r1 * 1);
1031
+ return v0;
1032
+ } finally {
1033
+ wasm.__wbindgen_add_to_stack_pointer(16);
1034
+ }
1035
+ }
1036
+ /**
1037
+ * @param {Uint8Array} buffer
1038
+ * @returns {ShortintPublicKey}
1039
+ */
1040
+ static deserialize_public_key(buffer) {
1041
+ try {
1042
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1043
+ const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
1044
+ const len0 = WASM_VECTOR_LEN;
1045
+ wasm.shortint_deserialize_public_key(retptr, ptr0, len0);
1046
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1047
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1048
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1049
+ if (r2) {
1050
+ throw takeObject(r1);
1051
+ }
1052
+ return ShortintPublicKey.__wrap(r0);
1053
+ } finally {
1054
+ wasm.__wbindgen_add_to_stack_pointer(16);
1055
+ }
1056
+ }
1057
+ /**
1058
+ * @param {ShortintCompressedPublicKey} public_key
1059
+ * @returns {Uint8Array}
1060
+ */
1061
+ static serialize_compressed_public_key(public_key) {
1062
+ try {
1063
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1064
+ _assertClass(public_key, ShortintCompressedPublicKey);
1065
+ wasm.shortint_serialize_compressed_public_key(retptr, public_key.ptr);
1066
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1067
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1068
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1069
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
1070
+ if (r3) {
1071
+ throw takeObject(r2);
1072
+ }
1073
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
1074
+ wasm.__wbindgen_free(r0, r1 * 1);
1075
+ return v0;
1076
+ } finally {
1077
+ wasm.__wbindgen_add_to_stack_pointer(16);
1078
+ }
1079
+ }
1080
+ /**
1081
+ * @param {Uint8Array} buffer
1082
+ * @returns {ShortintCompressedPublicKey}
1083
+ */
1084
+ static deserialize_compressed_public_key(buffer) {
1085
+ try {
1086
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1087
+ const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
1088
+ const len0 = WASM_VECTOR_LEN;
1089
+ wasm.shortint_deserialize_compressed_public_key(retptr, ptr0, len0);
1090
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1091
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1092
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1093
+ if (r2) {
1094
+ throw takeObject(r1);
1095
+ }
1096
+ return ShortintCompressedPublicKey.__wrap(r0);
1097
+ } finally {
1098
+ wasm.__wbindgen_add_to_stack_pointer(16);
1099
+ }
1100
+ }
1101
+ /**
1102
+ * @param {ShortintCompressedServerKey} server_key
1103
+ * @returns {Uint8Array}
1104
+ */
1105
+ static serialize_compressed_server_key(server_key) {
1106
+ try {
1107
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1108
+ _assertClass(server_key, ShortintCompressedServerKey);
1109
+ wasm.shortint_serialize_compressed_server_key(retptr, server_key.ptr);
1110
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1111
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1112
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1113
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
1114
+ if (r3) {
1115
+ throw takeObject(r2);
1116
+ }
1117
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
1118
+ wasm.__wbindgen_free(r0, r1 * 1);
1119
+ return v0;
1120
+ } finally {
1121
+ wasm.__wbindgen_add_to_stack_pointer(16);
1122
+ }
1123
+ }
1124
+ /**
1125
+ * @param {Uint8Array} buffer
1126
+ * @returns {ShortintCompressedServerKey}
1127
+ */
1128
+ static deserialize_compressed_server_key(buffer) {
1129
+ try {
1130
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1131
+ const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
1132
+ const len0 = WASM_VECTOR_LEN;
1133
+ wasm.shortint_deserialize_compressed_server_key(retptr, ptr0, len0);
1134
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1135
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1136
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1137
+ if (r2) {
1138
+ throw takeObject(r1);
1139
+ }
1140
+ return ShortintCompressedServerKey.__wrap(r0);
1141
+ } finally {
1142
+ wasm.__wbindgen_add_to_stack_pointer(16);
1143
+ }
1144
+ }
1145
+ }
1146
+ /**
1147
+ */
1148
+ export class ShortintCiphertext {
1149
+
1150
+ static __wrap(ptr) {
1151
+ const obj = Object.create(ShortintCiphertext.prototype);
1152
+ obj.ptr = ptr;
1153
+
1154
+ return obj;
1155
+ }
1156
+
1157
+ __destroy_into_raw() {
1158
+ const ptr = this.ptr;
1159
+ this.ptr = 0;
1160
+
1161
+ return ptr;
1162
+ }
1163
+
1164
+ free() {
1165
+ const ptr = this.__destroy_into_raw();
1166
+ wasm.__wbg_shortintciphertext_free(ptr);
1167
+ }
1168
+ }
1169
+ /**
1170
+ */
1171
+ export class ShortintClientKey {
1172
+
1173
+ static __wrap(ptr) {
1174
+ const obj = Object.create(ShortintClientKey.prototype);
1175
+ obj.ptr = ptr;
1176
+
1177
+ return obj;
1178
+ }
1179
+
1180
+ __destroy_into_raw() {
1181
+ const ptr = this.ptr;
1182
+ this.ptr = 0;
1183
+
1184
+ return ptr;
1185
+ }
1186
+
1187
+ free() {
1188
+ const ptr = this.__destroy_into_raw();
1189
+ wasm.__wbg_shortintclientkey_free(ptr);
1190
+ }
1191
+ }
1192
+ /**
1193
+ */
1194
+ export class ShortintCompressedCiphertext {
1195
+
1196
+ static __wrap(ptr) {
1197
+ const obj = Object.create(ShortintCompressedCiphertext.prototype);
1198
+ obj.ptr = ptr;
1199
+
1200
+ return obj;
1201
+ }
1202
+
1203
+ __destroy_into_raw() {
1204
+ const ptr = this.ptr;
1205
+ this.ptr = 0;
1206
+
1207
+ return ptr;
1208
+ }
1209
+
1210
+ free() {
1211
+ const ptr = this.__destroy_into_raw();
1212
+ wasm.__wbg_shortintcompressedciphertext_free(ptr);
1213
+ }
1214
+ }
1215
+ /**
1216
+ */
1217
+ export class ShortintCompressedPublicKey {
1218
+
1219
+ static __wrap(ptr) {
1220
+ const obj = Object.create(ShortintCompressedPublicKey.prototype);
1221
+ obj.ptr = ptr;
1222
+
1223
+ return obj;
1224
+ }
1225
+
1226
+ __destroy_into_raw() {
1227
+ const ptr = this.ptr;
1228
+ this.ptr = 0;
1229
+
1230
+ return ptr;
1231
+ }
1232
+
1233
+ free() {
1234
+ const ptr = this.__destroy_into_raw();
1235
+ wasm.__wbg_shortintcompressedpublickey_free(ptr);
1236
+ }
1237
+ }
1238
+ /**
1239
+ */
1240
+ export class ShortintCompressedServerKey {
1241
+
1242
+ static __wrap(ptr) {
1243
+ const obj = Object.create(ShortintCompressedServerKey.prototype);
1244
+ obj.ptr = ptr;
1245
+
1246
+ return obj;
1247
+ }
1248
+
1249
+ __destroy_into_raw() {
1250
+ const ptr = this.ptr;
1251
+ this.ptr = 0;
1252
+
1253
+ return ptr;
1254
+ }
1255
+
1256
+ free() {
1257
+ const ptr = this.__destroy_into_raw();
1258
+ wasm.__wbg_shortintcompressedserverkey_free(ptr);
1259
+ }
1260
+ }
1261
+ /**
1262
+ */
1263
+ export class ShortintParameters {
1264
+
1265
+ static __wrap(ptr) {
1266
+ const obj = Object.create(ShortintParameters.prototype);
1267
+ obj.ptr = ptr;
1268
+
1269
+ return obj;
1270
+ }
1271
+
1272
+ __destroy_into_raw() {
1273
+ const ptr = this.ptr;
1274
+ this.ptr = 0;
1275
+
1276
+ return ptr;
1277
+ }
1278
+
1279
+ free() {
1280
+ const ptr = this.__destroy_into_raw();
1281
+ wasm.__wbg_shortintparameters_free(ptr);
1282
+ }
1283
+ }
1284
+ /**
1285
+ */
1286
+ export class ShortintPublicKey {
1287
+
1288
+ static __wrap(ptr) {
1289
+ const obj = Object.create(ShortintPublicKey.prototype);
1290
+ obj.ptr = ptr;
1291
+
1292
+ return obj;
1293
+ }
1294
+
1295
+ __destroy_into_raw() {
1296
+ const ptr = this.ptr;
1297
+ this.ptr = 0;
1298
+
1299
+ return ptr;
1300
+ }
1301
+
1302
+ free() {
1303
+ const ptr = this.__destroy_into_raw();
1304
+ wasm.__wbg_shortintpublickey_free(ptr);
1305
+ }
1306
+ }
1307
+
1308
+ async function load(module, imports) {
1309
+ if (typeof Response === 'function' && module instanceof Response) {
1310
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1311
+ try {
1312
+ return await WebAssembly.instantiateStreaming(module, imports);
1313
+
1314
+ } catch (e) {
1315
+ if (module.headers.get('Content-Type') != 'application/wasm') {
1316
+ 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);
1317
+
1318
+ } else {
1319
+ throw e;
1320
+ }
1321
+ }
1322
+ }
1323
+
1324
+ const bytes = await module.arrayBuffer();
1325
+ return await WebAssembly.instantiate(bytes, imports);
1326
+
1327
+ } else {
1328
+ const instance = await WebAssembly.instantiate(module, imports);
1329
+
1330
+ if (instance instanceof WebAssembly.Instance) {
1331
+ return { instance, module };
1332
+
1333
+ } else {
1334
+ return instance;
1335
+ }
1336
+ }
1337
+ }
1338
+
1339
+ function getImports() {
1340
+ const imports = {};
1341
+ imports.wbg = {};
1342
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
1343
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
1344
+ return addHeapObject(ret);
1345
+ };
1346
+ imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
1347
+ const ret = new Error();
1348
+ return addHeapObject(ret);
1349
+ };
1350
+ imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
1351
+ const ret = getObject(arg1).stack;
1352
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1353
+ const len0 = WASM_VECTOR_LEN;
1354
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
1355
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1356
+ };
1357
+ imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
1358
+ try {
1359
+ console.error(getStringFromWasm0(arg0, arg1));
1360
+ } finally {
1361
+ wasm.__wbindgen_free(arg0, arg1);
1362
+ }
1363
+ };
1364
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
1365
+ takeObject(arg0);
1366
+ };
1367
+ imports.wbg.__wbg_crypto_70a96de3b6b73dac = function(arg0) {
1368
+ const ret = getObject(arg0).crypto;
1369
+ return addHeapObject(ret);
1370
+ };
1371
+ imports.wbg.__wbindgen_is_object = function(arg0) {
1372
+ const val = getObject(arg0);
1373
+ const ret = typeof(val) === 'object' && val !== null;
1374
+ return ret;
1375
+ };
1376
+ imports.wbg.__wbg_process_dd1577445152112e = function(arg0) {
1377
+ const ret = getObject(arg0).process;
1378
+ return addHeapObject(ret);
1379
+ };
1380
+ imports.wbg.__wbg_versions_58036bec3add9e6f = function(arg0) {
1381
+ const ret = getObject(arg0).versions;
1382
+ return addHeapObject(ret);
1383
+ };
1384
+ imports.wbg.__wbg_node_6a9d28205ed5b0d8 = function(arg0) {
1385
+ const ret = getObject(arg0).node;
1386
+ return addHeapObject(ret);
1387
+ };
1388
+ imports.wbg.__wbindgen_is_string = function(arg0) {
1389
+ const ret = typeof(getObject(arg0)) === 'string';
1390
+ return ret;
1391
+ };
1392
+ imports.wbg.__wbg_msCrypto_adbc770ec9eca9c7 = function(arg0) {
1393
+ const ret = getObject(arg0).msCrypto;
1394
+ return addHeapObject(ret);
1395
+ };
1396
+ imports.wbg.__wbg_require_f05d779769764e82 = function() { return handleError(function () {
1397
+ const ret = module.require;
1398
+ return addHeapObject(ret);
1399
+ }, arguments) };
1400
+ imports.wbg.__wbindgen_is_function = function(arg0) {
1401
+ const ret = typeof(getObject(arg0)) === 'function';
1402
+ return ret;
1403
+ };
1404
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
1405
+ const ret = getStringFromWasm0(arg0, arg1);
1406
+ return addHeapObject(ret);
1407
+ };
1408
+ imports.wbg.__wbg_getRandomValues_3774744e221a22ad = function() { return handleError(function (arg0, arg1) {
1409
+ getObject(arg0).getRandomValues(getObject(arg1));
1410
+ }, arguments) };
1411
+ imports.wbg.__wbg_randomFillSync_e950366c42764a07 = function() { return handleError(function (arg0, arg1) {
1412
+ getObject(arg0).randomFillSync(takeObject(arg1));
1413
+ }, arguments) };
1414
+ imports.wbg.__wbg_newnoargs_2b8b6bd7753c76ba = function(arg0, arg1) {
1415
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
1416
+ return addHeapObject(ret);
1417
+ };
1418
+ imports.wbg.__wbg_call_95d1ea488d03e4e8 = function() { return handleError(function (arg0, arg1) {
1419
+ const ret = getObject(arg0).call(getObject(arg1));
1420
+ return addHeapObject(ret);
1421
+ }, arguments) };
1422
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
1423
+ const ret = getObject(arg0);
1424
+ return addHeapObject(ret);
1425
+ };
1426
+ imports.wbg.__wbg_self_e7c1f827057f6584 = function() { return handleError(function () {
1427
+ const ret = self.self;
1428
+ return addHeapObject(ret);
1429
+ }, arguments) };
1430
+ imports.wbg.__wbg_window_a09ec664e14b1b81 = function() { return handleError(function () {
1431
+ const ret = window.window;
1432
+ return addHeapObject(ret);
1433
+ }, arguments) };
1434
+ imports.wbg.__wbg_globalThis_87cbb8506fecf3a9 = function() { return handleError(function () {
1435
+ const ret = globalThis.globalThis;
1436
+ return addHeapObject(ret);
1437
+ }, arguments) };
1438
+ imports.wbg.__wbg_global_c85a9259e621f3db = function() { return handleError(function () {
1439
+ const ret = global.global;
1440
+ return addHeapObject(ret);
1441
+ }, arguments) };
1442
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
1443
+ const ret = getObject(arg0) === undefined;
1444
+ return ret;
1445
+ };
1446
+ imports.wbg.__wbg_call_9495de66fdbe016b = function() { return handleError(function (arg0, arg1, arg2) {
1447
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1448
+ return addHeapObject(ret);
1449
+ }, arguments) };
1450
+ imports.wbg.__wbg_buffer_cf65c07de34b9a08 = function(arg0) {
1451
+ const ret = getObject(arg0).buffer;
1452
+ return addHeapObject(ret);
1453
+ };
1454
+ imports.wbg.__wbg_newwithbyteoffsetandlength_9fb2f11355ecadf5 = function(arg0, arg1, arg2) {
1455
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
1456
+ return addHeapObject(ret);
1457
+ };
1458
+ imports.wbg.__wbg_new_537b7341ce90bb31 = function(arg0) {
1459
+ const ret = new Uint8Array(getObject(arg0));
1460
+ return addHeapObject(ret);
1461
+ };
1462
+ imports.wbg.__wbg_set_17499e8aa4003ebd = function(arg0, arg1, arg2) {
1463
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
1464
+ };
1465
+ imports.wbg.__wbg_newwithlength_b56c882b57805732 = function(arg0) {
1466
+ const ret = new Uint8Array(arg0 >>> 0);
1467
+ return addHeapObject(ret);
1468
+ };
1469
+ imports.wbg.__wbg_subarray_7526649b91a252a6 = function(arg0, arg1, arg2) {
1470
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
1471
+ return addHeapObject(ret);
1472
+ };
1473
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
1474
+ throw new Error(getStringFromWasm0(arg0, arg1));
1475
+ };
1476
+ imports.wbg.__wbindgen_memory = function() {
1477
+ const ret = wasm.memory;
1478
+ return addHeapObject(ret);
1479
+ };
1480
+
1481
+ return imports;
1482
+ }
1483
+
1484
+ function initMemory(imports, maybe_memory) {
1485
+
1486
+ }
1487
+
1488
+ function finalizeInit(instance, module) {
1489
+ wasm = instance.exports;
1490
+ init.__wbindgen_wasm_module = module;
1491
+ cachedInt32Memory0 = null;
1492
+ cachedUint8Memory0 = null;
1493
+
1494
+
1495
+ return wasm;
1496
+ }
1497
+
1498
+ function initSync(module) {
1499
+ const imports = getImports();
1500
+
1501
+ initMemory(imports);
1502
+
1503
+ if (!(module instanceof WebAssembly.Module)) {
1504
+ module = new WebAssembly.Module(module);
1505
+ }
1506
+
1507
+ const instance = new WebAssembly.Instance(module, imports);
1508
+
1509
+ return finalizeInit(instance, module);
1510
+ }
1511
+
1512
+ async function init(input) {
1513
+ if (typeof input === 'undefined') {
1514
+ input = new URL('tfhe_bg.wasm', import.meta.url);
1515
+ }
1516
+ const imports = getImports();
1517
+
1518
+ if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
1519
+ input = fetch(input);
1520
+ }
1521
+
1522
+ initMemory(imports);
1523
+
1524
+ const { instance, module } = await load(await input, imports);
1525
+
1526
+ return finalizeInit(instance, module);
1527
+ }
1528
+
1529
+ export { initSync }
1530
+ export default init;