node-tkms 0.9.0-rc11

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/kms_lib.js ADDED
@@ -0,0 +1,2065 @@
1
+
2
+ let imports = {};
3
+ imports['__wbindgen_placeholder__'] = module.exports;
4
+ let wasm;
5
+ const { TextDecoder, TextEncoder } = require(`util`);
6
+
7
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
8
+
9
+ cachedTextDecoder.decode();
10
+
11
+ let cachedUint8ArrayMemory0 = null;
12
+
13
+ function getUint8ArrayMemory0() {
14
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
15
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
16
+ }
17
+ return cachedUint8ArrayMemory0;
18
+ }
19
+
20
+ function getStringFromWasm0(ptr, len) {
21
+ ptr = ptr >>> 0;
22
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
23
+ }
24
+
25
+ const heap = new Array(128).fill(undefined);
26
+
27
+ heap.push(undefined, null, true, false);
28
+
29
+ let heap_next = heap.length;
30
+
31
+ function addHeapObject(obj) {
32
+ if (heap_next === heap.length) heap.push(heap.length + 1);
33
+ const idx = heap_next;
34
+ heap_next = heap[idx];
35
+
36
+ heap[idx] = obj;
37
+ return idx;
38
+ }
39
+
40
+ function getObject(idx) { return heap[idx]; }
41
+
42
+ function dropObject(idx) {
43
+ if (idx < 132) return;
44
+ heap[idx] = heap_next;
45
+ heap_next = idx;
46
+ }
47
+
48
+ function takeObject(idx) {
49
+ const ret = getObject(idx);
50
+ dropObject(idx);
51
+ return ret;
52
+ }
53
+
54
+ function isLikeNone(x) {
55
+ return x === undefined || x === null;
56
+ }
57
+
58
+ let cachedDataViewMemory0 = null;
59
+
60
+ function getDataViewMemory0() {
61
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
62
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
63
+ }
64
+ return cachedDataViewMemory0;
65
+ }
66
+
67
+ let WASM_VECTOR_LEN = 0;
68
+
69
+ let cachedTextEncoder = new TextEncoder('utf-8');
70
+
71
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
72
+ ? function (arg, view) {
73
+ return cachedTextEncoder.encodeInto(arg, view);
74
+ }
75
+ : function (arg, view) {
76
+ const buf = cachedTextEncoder.encode(arg);
77
+ view.set(buf);
78
+ return {
79
+ read: arg.length,
80
+ written: buf.length
81
+ };
82
+ });
83
+
84
+ function passStringToWasm0(arg, malloc, realloc) {
85
+
86
+ if (realloc === undefined) {
87
+ const buf = cachedTextEncoder.encode(arg);
88
+ const ptr = malloc(buf.length, 1) >>> 0;
89
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
90
+ WASM_VECTOR_LEN = buf.length;
91
+ return ptr;
92
+ }
93
+
94
+ let len = arg.length;
95
+ let ptr = malloc(len, 1) >>> 0;
96
+
97
+ const mem = getUint8ArrayMemory0();
98
+
99
+ let offset = 0;
100
+
101
+ for (; offset < len; offset++) {
102
+ const code = arg.charCodeAt(offset);
103
+ if (code > 0x7F) break;
104
+ mem[ptr + offset] = code;
105
+ }
106
+
107
+ if (offset !== len) {
108
+ if (offset !== 0) {
109
+ arg = arg.slice(offset);
110
+ }
111
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
112
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
113
+ const ret = encodeString(arg, view);
114
+
115
+ offset += ret.written;
116
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
117
+ }
118
+
119
+ WASM_VECTOR_LEN = offset;
120
+ return ptr;
121
+ }
122
+
123
+ function debugString(val) {
124
+ // primitive types
125
+ const type = typeof val;
126
+ if (type == 'number' || type == 'boolean' || val == null) {
127
+ return `${val}`;
128
+ }
129
+ if (type == 'string') {
130
+ return `"${val}"`;
131
+ }
132
+ if (type == 'symbol') {
133
+ const description = val.description;
134
+ if (description == null) {
135
+ return 'Symbol';
136
+ } else {
137
+ return `Symbol(${description})`;
138
+ }
139
+ }
140
+ if (type == 'function') {
141
+ const name = val.name;
142
+ if (typeof name == 'string' && name.length > 0) {
143
+ return `Function(${name})`;
144
+ } else {
145
+ return 'Function';
146
+ }
147
+ }
148
+ // objects
149
+ if (Array.isArray(val)) {
150
+ const length = val.length;
151
+ let debug = '[';
152
+ if (length > 0) {
153
+ debug += debugString(val[0]);
154
+ }
155
+ for(let i = 1; i < length; i++) {
156
+ debug += ', ' + debugString(val[i]);
157
+ }
158
+ debug += ']';
159
+ return debug;
160
+ }
161
+ // Test for built-in
162
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
163
+ let className;
164
+ if (builtInMatches.length > 1) {
165
+ className = builtInMatches[1];
166
+ } else {
167
+ // Failed to match the standard '[object ClassName]'
168
+ return toString.call(val);
169
+ }
170
+ if (className == 'Object') {
171
+ // we're a user defined class or Object
172
+ // JSON.stringify avoids problems with cycles, and is generally much
173
+ // easier than looping through ownProperties of `val`.
174
+ try {
175
+ return 'Object(' + JSON.stringify(val) + ')';
176
+ } catch (_) {
177
+ return 'Object';
178
+ }
179
+ }
180
+ // errors
181
+ if (val instanceof Error) {
182
+ return `${val.name}: ${val.message}\n${val.stack}`;
183
+ }
184
+ // TODO we could test for more things here, like `Set`s and `Map`s.
185
+ return className;
186
+ }
187
+
188
+ function getArrayU8FromWasm0(ptr, len) {
189
+ ptr = ptr >>> 0;
190
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
191
+ }
192
+
193
+ function passArray8ToWasm0(arg, malloc) {
194
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
195
+ getUint8ArrayMemory0().set(arg, ptr / 1);
196
+ WASM_VECTOR_LEN = arg.length;
197
+ return ptr;
198
+ }
199
+
200
+ function _assertClass(instance, klass) {
201
+ if (!(instance instanceof klass)) {
202
+ throw new Error(`expected instance of ${klass.name}`);
203
+ }
204
+ return instance.ptr;
205
+ }
206
+ /**
207
+ * @param {PublicSigKey} pk
208
+ * @returns {Uint8Array}
209
+ */
210
+ module.exports.public_sig_key_to_u8vec = function(pk) {
211
+ try {
212
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
213
+ _assertClass(pk, PublicSigKey);
214
+ wasm.public_sig_key_to_u8vec(retptr, pk.__wbg_ptr);
215
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
216
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
217
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
218
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
219
+ return v1;
220
+ } finally {
221
+ wasm.__wbindgen_add_to_stack_pointer(16);
222
+ }
223
+ };
224
+
225
+ /**
226
+ * @param {Uint8Array} v
227
+ * @returns {PublicSigKey}
228
+ */
229
+ module.exports.u8vec_to_public_sig_key = function(v) {
230
+ try {
231
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
232
+ const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
233
+ const len0 = WASM_VECTOR_LEN;
234
+ wasm.u8vec_to_public_sig_key(retptr, ptr0, len0);
235
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
236
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
237
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
238
+ if (r2) {
239
+ throw takeObject(r1);
240
+ }
241
+ return PublicSigKey.__wrap(r0);
242
+ } finally {
243
+ wasm.__wbindgen_add_to_stack_pointer(16);
244
+ }
245
+ };
246
+
247
+ /**
248
+ * @param {PrivateSigKey} sk
249
+ * @returns {Uint8Array}
250
+ */
251
+ module.exports.private_sig_key_to_u8vec = function(sk) {
252
+ try {
253
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
254
+ _assertClass(sk, PrivateSigKey);
255
+ wasm.private_sig_key_to_u8vec(retptr, sk.__wbg_ptr);
256
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
257
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
258
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
259
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
260
+ if (r3) {
261
+ throw takeObject(r2);
262
+ }
263
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
264
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
265
+ return v1;
266
+ } finally {
267
+ wasm.__wbindgen_add_to_stack_pointer(16);
268
+ }
269
+ };
270
+
271
+ /**
272
+ * @param {Uint8Array} v
273
+ * @returns {PrivateSigKey}
274
+ */
275
+ module.exports.u8vec_to_private_sig_key = function(v) {
276
+ try {
277
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
278
+ const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
279
+ const len0 = WASM_VECTOR_LEN;
280
+ wasm.u8vec_to_private_sig_key(retptr, ptr0, len0);
281
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
282
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
283
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
284
+ if (r2) {
285
+ throw takeObject(r1);
286
+ }
287
+ return PrivateSigKey.__wrap(r0);
288
+ } finally {
289
+ wasm.__wbindgen_add_to_stack_pointer(16);
290
+ }
291
+ };
292
+
293
+ function passArrayJsValueToWasm0(array, malloc) {
294
+ const ptr = malloc(array.length * 4, 4) >>> 0;
295
+ const mem = getDataViewMemory0();
296
+ for (let i = 0; i < array.length; i++) {
297
+ mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
298
+ }
299
+ WASM_VECTOR_LEN = array.length;
300
+ return ptr;
301
+ }
302
+ /**
303
+ * Instantiate a new client.
304
+ *
305
+ * * `server_pks` - a list of KMS server signature public keys,
306
+ * which can parsed using [u8vec_to_public_sig_key].
307
+ *
308
+ * * `client_address_hex` - the client (wallet) address in hex,
309
+ * must be prefixed with "0x".
310
+ *
311
+ * * `param_choice` - the parameter choice, which can be either `"test"` or `"default"`.
312
+ * The "default" parameter choice is selected if no matching string is found.
313
+ * @param {(string)[]} server_addrs
314
+ * @param {string} client_address_hex
315
+ * @param {string} param_choice
316
+ * @returns {Client}
317
+ */
318
+ module.exports.new_client = function(server_addrs, client_address_hex, param_choice) {
319
+ try {
320
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
321
+ const ptr0 = passArrayJsValueToWasm0(server_addrs, wasm.__wbindgen_malloc);
322
+ const len0 = WASM_VECTOR_LEN;
323
+ const ptr1 = passStringToWasm0(client_address_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
324
+ const len1 = WASM_VECTOR_LEN;
325
+ const ptr2 = passStringToWasm0(param_choice, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
326
+ const len2 = WASM_VECTOR_LEN;
327
+ wasm.new_client(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
328
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
329
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
330
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
331
+ if (r2) {
332
+ throw takeObject(r1);
333
+ }
334
+ return Client.__wrap(r0);
335
+ } finally {
336
+ wasm.__wbindgen_add_to_stack_pointer(16);
337
+ }
338
+ };
339
+
340
+ function getArrayJsValueFromWasm0(ptr, len) {
341
+ ptr = ptr >>> 0;
342
+ const mem = getDataViewMemory0();
343
+ const result = [];
344
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
345
+ result.push(takeObject(mem.getUint32(i, true)));
346
+ }
347
+ return result;
348
+ }
349
+ /**
350
+ * @param {Client} client
351
+ * @returns {(string)[]}
352
+ */
353
+ module.exports.get_server_addrs = function(client) {
354
+ try {
355
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
356
+ _assertClass(client, Client);
357
+ wasm.get_server_addrs(retptr, client.__wbg_ptr);
358
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
359
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
360
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
361
+ wasm.__wbindgen_free(r0, r1 * 4, 4);
362
+ return v1;
363
+ } finally {
364
+ wasm.__wbindgen_add_to_stack_pointer(16);
365
+ }
366
+ };
367
+
368
+ /**
369
+ * @param {Client} client
370
+ * @returns {PrivateSigKey | undefined}
371
+ */
372
+ module.exports.get_client_secret_key = function(client) {
373
+ _assertClass(client, Client);
374
+ const ret = wasm.get_client_secret_key(client.__wbg_ptr);
375
+ return ret === 0 ? undefined : PrivateSigKey.__wrap(ret);
376
+ };
377
+
378
+ /**
379
+ * @param {Client} client
380
+ * @returns {string}
381
+ */
382
+ module.exports.get_client_address = function(client) {
383
+ let deferred1_0;
384
+ let deferred1_1;
385
+ try {
386
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
387
+ _assertClass(client, Client);
388
+ wasm.get_client_address(retptr, client.__wbg_ptr);
389
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
390
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
391
+ deferred1_0 = r0;
392
+ deferred1_1 = r1;
393
+ return getStringFromWasm0(r0, r1);
394
+ } finally {
395
+ wasm.__wbindgen_add_to_stack_pointer(16);
396
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
397
+ }
398
+ };
399
+
400
+ /**
401
+ * @returns {PrivateEncKey}
402
+ */
403
+ module.exports.cryptobox_keygen = function() {
404
+ const ret = wasm.cryptobox_keygen();
405
+ return PrivateEncKey.__wrap(ret);
406
+ };
407
+
408
+ /**
409
+ * @param {PrivateEncKey} sk
410
+ * @returns {PublicEncKey}
411
+ */
412
+ module.exports.cryptobox_get_pk = function(sk) {
413
+ _assertClass(sk, PrivateEncKey);
414
+ const ret = wasm.cryptobox_get_pk(sk.__wbg_ptr);
415
+ return PublicEncKey.__wrap(ret);
416
+ };
417
+
418
+ /**
419
+ * @param {PublicEncKey} pk
420
+ * @returns {Uint8Array}
421
+ */
422
+ module.exports.cryptobox_pk_to_u8vec = function(pk) {
423
+ try {
424
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
425
+ _assertClass(pk, PublicEncKey);
426
+ wasm.cryptobox_pk_to_u8vec(retptr, pk.__wbg_ptr);
427
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
428
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
429
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
430
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
431
+ if (r3) {
432
+ throw takeObject(r2);
433
+ }
434
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
435
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
436
+ return v1;
437
+ } finally {
438
+ wasm.__wbindgen_add_to_stack_pointer(16);
439
+ }
440
+ };
441
+
442
+ /**
443
+ * @param {PrivateEncKey} sk
444
+ * @returns {Uint8Array}
445
+ */
446
+ module.exports.cryptobox_sk_to_u8vec = function(sk) {
447
+ try {
448
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
449
+ _assertClass(sk, PrivateEncKey);
450
+ wasm.cryptobox_sk_to_u8vec(retptr, sk.__wbg_ptr);
451
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
452
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
453
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
454
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
455
+ if (r3) {
456
+ throw takeObject(r2);
457
+ }
458
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
459
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
460
+ return v1;
461
+ } finally {
462
+ wasm.__wbindgen_add_to_stack_pointer(16);
463
+ }
464
+ };
465
+
466
+ /**
467
+ * @param {Uint8Array} v
468
+ * @returns {PublicEncKey}
469
+ */
470
+ module.exports.u8vec_to_cryptobox_pk = function(v) {
471
+ try {
472
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
473
+ const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
474
+ const len0 = WASM_VECTOR_LEN;
475
+ wasm.u8vec_to_cryptobox_pk(retptr, ptr0, len0);
476
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
477
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
478
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
479
+ if (r2) {
480
+ throw takeObject(r1);
481
+ }
482
+ return PublicEncKey.__wrap(r0);
483
+ } finally {
484
+ wasm.__wbindgen_add_to_stack_pointer(16);
485
+ }
486
+ };
487
+
488
+ /**
489
+ * @param {Uint8Array} v
490
+ * @returns {PrivateEncKey}
491
+ */
492
+ module.exports.u8vec_to_cryptobox_sk = function(v) {
493
+ try {
494
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
495
+ const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
496
+ const len0 = WASM_VECTOR_LEN;
497
+ wasm.u8vec_to_cryptobox_sk(retptr, ptr0, len0);
498
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
499
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
500
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
501
+ if (r2) {
502
+ throw takeObject(r1);
503
+ }
504
+ return PrivateEncKey.__wrap(r0);
505
+ } finally {
506
+ wasm.__wbindgen_add_to_stack_pointer(16);
507
+ }
508
+ };
509
+
510
+ /**
511
+ * @param {Uint8Array} msg
512
+ * @param {PublicEncKey} their_pk
513
+ * @param {PrivateEncKey} my_sk
514
+ * @returns {CryptoBoxCt}
515
+ */
516
+ module.exports.cryptobox_encrypt = function(msg, their_pk, my_sk) {
517
+ const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
518
+ const len0 = WASM_VECTOR_LEN;
519
+ _assertClass(their_pk, PublicEncKey);
520
+ _assertClass(my_sk, PrivateEncKey);
521
+ const ret = wasm.cryptobox_encrypt(ptr0, len0, their_pk.__wbg_ptr, my_sk.__wbg_ptr);
522
+ return CryptoBoxCt.__wrap(ret);
523
+ };
524
+
525
+ /**
526
+ * @param {CryptoBoxCt} ct
527
+ * @param {PrivateEncKey} my_sk
528
+ * @param {PublicEncKey} their_pk
529
+ * @returns {Uint8Array}
530
+ */
531
+ module.exports.cryptobox_decrypt = function(ct, my_sk, their_pk) {
532
+ try {
533
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
534
+ _assertClass(ct, CryptoBoxCt);
535
+ _assertClass(my_sk, PrivateEncKey);
536
+ _assertClass(their_pk, PublicEncKey);
537
+ wasm.cryptobox_decrypt(retptr, ct.__wbg_ptr, my_sk.__wbg_ptr, their_pk.__wbg_ptr);
538
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
539
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
540
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
541
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
542
+ return v1;
543
+ } finally {
544
+ wasm.__wbindgen_add_to_stack_pointer(16);
545
+ }
546
+ };
547
+
548
+ /**
549
+ * Process the reencryption response from JavaScript objects.
550
+ * The result is a byte array representing a plaintext of any length.
551
+ *
552
+ * * `client` - client that wants to perform reencryption.
553
+ *
554
+ * * `request` - the initial reencryption request JS object.
555
+ * It can be set to null if `verify` is false.
556
+ * Otherwise the caller needs to give the following JS object.
557
+ * Note that `client_address` and `eip712_verifying_contract` follow EIP-55.
558
+ * ```
559
+ * {
560
+ * signature: '15a4f9a8eb61459cfba7d103d8f911fb04ce91ecf841b34c49c0d56a70b896d20cbc31986188f91efc3842b7df215cee8acb40178daedb8b63d0ba5d199bce121c',
561
+ * client_address: '0x17853A630aAe15AED549B2B874de08B73C0F59c5',
562
+ * enc_key: '2000000000000000df2fcacb774f03187f3802a27259f45c06d33cefa68d9c53426b15ad531aa822',
563
+ * ciphertext_digest: '0748b542afe2353c86cb707e3d21044b0be1fd18efc7cbaa6a415af055bfb358',
564
+ * eip712_verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657'
565
+ * }
566
+ * ```
567
+ *
568
+ * * `eip712_domain` - the EIP-712 domain JS object.
569
+ * It can be set to null if `verify` is false.
570
+ * Otherwise the caller needs to give the following JS object.
571
+ * Note that `salt` is optional and `verifying_contract` follows EIP-55,
572
+ * additionally, `chain_id` is an array of u8.
573
+ * ```
574
+ * {
575
+ * name: 'Authorization token',
576
+ * version: '1',
577
+ * chain_id: [
578
+ * 70, 31, 0, 0, 0, 0, 0, 0, 0,
579
+ * 0, 0, 0, 0, 0, 0, 0, 0, 0,
580
+ * 0, 0, 0, 0, 0, 0, 0, 0, 0,
581
+ * 0, 0, 0, 0, 0
582
+ * ],
583
+ * verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657',
584
+ * salt: []
585
+ * }
586
+ * ```
587
+ *
588
+ * * `agg_resp` - the response JS object from the gateway.
589
+ * It has two fields like so, both are hex encoded byte arrays.
590
+ * ```
591
+ * [
592
+ * {
593
+ * signature: '69e7e040cab157aa819015b321c012dccb1545ffefd325b359b492653f0347517e28e66c572cdc299e259024329859ff9fcb0096e1ce072af0b6e1ca1fe25ec6',
594
+ * payload: '0100000029...'
595
+ * }
596
+ * ]
597
+ * ```
598
+ *
599
+ * * `enc_pk` - The ephemeral public key.
600
+ *
601
+ * * `enc_sk` - The ephemeral secret key.
602
+ *
603
+ * * `verify` - Whether to perform signature verification for the response.
604
+ * It is insecure if `verify = false`!
605
+ * @param {Client} client
606
+ * @param {any} request
607
+ * @param {any} eip712_domain
608
+ * @param {any} agg_resp
609
+ * @param {PublicEncKey} enc_pk
610
+ * @param {PrivateEncKey} enc_sk
611
+ * @param {boolean} verify
612
+ * @returns {Uint8Array}
613
+ */
614
+ module.exports.process_reencryption_resp_from_js = function(client, request, eip712_domain, agg_resp, enc_pk, enc_sk, verify) {
615
+ try {
616
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
617
+ _assertClass(client, Client);
618
+ _assertClass(enc_pk, PublicEncKey);
619
+ _assertClass(enc_sk, PrivateEncKey);
620
+ wasm.process_reencryption_resp_from_js(retptr, client.__wbg_ptr, addHeapObject(request), addHeapObject(eip712_domain), addHeapObject(agg_resp), enc_pk.__wbg_ptr, enc_sk.__wbg_ptr, verify);
621
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
622
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
623
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
624
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
625
+ if (r3) {
626
+ throw takeObject(r2);
627
+ }
628
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
629
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
630
+ return v1;
631
+ } finally {
632
+ wasm.__wbindgen_add_to_stack_pointer(16);
633
+ }
634
+ };
635
+
636
+ /**
637
+ * Process the reencryption response from Rust objects.
638
+ * Consider using [process_reencryption_resp_from_js]
639
+ * when using the JS API.
640
+ * The result is a byte array representing a plaintext of any length.
641
+ *
642
+ * * `client` - client that wants to perform reencryption.
643
+ *
644
+ * * `request` - the initial reencryption request.
645
+ * Must be given if `verify` is true.
646
+ *
647
+ * * `eip712_domain` - the EIP-712 domain.
648
+ * Must be given if `verify` is true.
649
+ *
650
+ * * `agg_resp` - the vector of reencryption responses.
651
+ *
652
+ * * `enc_pk` - The ephemeral public key.
653
+ *
654
+ * * `enc_sk` - The ephemeral secret key.
655
+ *
656
+ * * `verify` - Whether to perform signature verification for the response.
657
+ * It is insecure if `verify = false`!
658
+ * @param {Client} client
659
+ * @param {ParsedReencryptionRequest | undefined} request
660
+ * @param {Eip712DomainMsg | undefined} eip712_domain
661
+ * @param {(ReencryptionResponse)[]} agg_resp
662
+ * @param {PublicEncKey} enc_pk
663
+ * @param {PrivateEncKey} enc_sk
664
+ * @param {boolean} verify
665
+ * @returns {Uint8Array}
666
+ */
667
+ module.exports.process_reencryption_resp = function(client, request, eip712_domain, agg_resp, enc_pk, enc_sk, verify) {
668
+ try {
669
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
670
+ _assertClass(client, Client);
671
+ let ptr0 = 0;
672
+ if (!isLikeNone(request)) {
673
+ _assertClass(request, ParsedReencryptionRequest);
674
+ ptr0 = request.__destroy_into_raw();
675
+ }
676
+ let ptr1 = 0;
677
+ if (!isLikeNone(eip712_domain)) {
678
+ _assertClass(eip712_domain, Eip712DomainMsg);
679
+ ptr1 = eip712_domain.__destroy_into_raw();
680
+ }
681
+ const ptr2 = passArrayJsValueToWasm0(agg_resp, wasm.__wbindgen_malloc);
682
+ const len2 = WASM_VECTOR_LEN;
683
+ _assertClass(enc_pk, PublicEncKey);
684
+ _assertClass(enc_sk, PrivateEncKey);
685
+ wasm.process_reencryption_resp(retptr, client.__wbg_ptr, ptr0, ptr1, ptr2, len2, enc_pk.__wbg_ptr, enc_sk.__wbg_ptr, verify);
686
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
687
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
688
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
689
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
690
+ if (r3) {
691
+ throw takeObject(r2);
692
+ }
693
+ var v4 = getArrayU8FromWasm0(r0, r1).slice();
694
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
695
+ return v4;
696
+ } finally {
697
+ wasm.__wbindgen_add_to_stack_pointer(16);
698
+ }
699
+ };
700
+
701
+ function handleError(f, args) {
702
+ try {
703
+ return f.apply(this, args);
704
+ } catch (e) {
705
+ wasm.__wbindgen_exn_store(addHeapObject(e));
706
+ }
707
+ }
708
+ /**
709
+ * The plaintext types that can be encrypted in a fhevm ciphertext.
710
+ */
711
+ module.exports.FheType = Object.freeze({ Ebool:0,"0":"Ebool",Euint4:1,"1":"Euint4",Euint8:2,"2":"Euint8",Euint16:3,"3":"Euint16",Euint32:4,"4":"Euint32",Euint64:5,"5":"Euint64",Euint128:6,"6":"Euint128",Euint160:7,"7":"Euint160",Euint256:8,"8":"Euint256",Euint512:9,"9":"Euint512",Euint1024:10,"10":"Euint1024",Euint2048:11,"11":"Euint2048", });
712
+
713
+ const ClientFinalization = (typeof FinalizationRegistry === 'undefined')
714
+ ? { register: () => {}, unregister: () => {} }
715
+ : new FinalizationRegistry(ptr => wasm.__wbg_client_free(ptr >>> 0, 1));
716
+ /**
717
+ * Simple client to interact with the KMS servers. This can be seen as a proof-of-concept
718
+ * and reference code for validating the KMS. The logic supplied by the client will be
719
+ * distributed across the aggregator/proxy and smart contracts.
720
+ */
721
+ class Client {
722
+
723
+ static __wrap(ptr) {
724
+ ptr = ptr >>> 0;
725
+ const obj = Object.create(Client.prototype);
726
+ obj.__wbg_ptr = ptr;
727
+ ClientFinalization.register(obj, obj.__wbg_ptr, obj);
728
+ return obj;
729
+ }
730
+
731
+ __destroy_into_raw() {
732
+ const ptr = this.__wbg_ptr;
733
+ this.__wbg_ptr = 0;
734
+ ClientFinalization.unregister(this);
735
+ return ptr;
736
+ }
737
+
738
+ free() {
739
+ const ptr = this.__destroy_into_raw();
740
+ wasm.__wbg_client_free(ptr, 0);
741
+ }
742
+ }
743
+ module.exports.Client = Client;
744
+
745
+ const CryptoBoxCtFinalization = (typeof FinalizationRegistry === 'undefined')
746
+ ? { register: () => {}, unregister: () => {} }
747
+ : new FinalizationRegistry(ptr => wasm.__wbg_cryptoboxct_free(ptr >>> 0, 1));
748
+ /**
749
+ */
750
+ class CryptoBoxCt {
751
+
752
+ static __wrap(ptr) {
753
+ ptr = ptr >>> 0;
754
+ const obj = Object.create(CryptoBoxCt.prototype);
755
+ obj.__wbg_ptr = ptr;
756
+ CryptoBoxCtFinalization.register(obj, obj.__wbg_ptr, obj);
757
+ return obj;
758
+ }
759
+
760
+ __destroy_into_raw() {
761
+ const ptr = this.__wbg_ptr;
762
+ this.__wbg_ptr = 0;
763
+ CryptoBoxCtFinalization.unregister(this);
764
+ return ptr;
765
+ }
766
+
767
+ free() {
768
+ const ptr = this.__destroy_into_raw();
769
+ wasm.__wbg_cryptoboxct_free(ptr, 0);
770
+ }
771
+ }
772
+ module.exports.CryptoBoxCt = CryptoBoxCt;
773
+
774
+ const Eip712DomainMsgFinalization = (typeof FinalizationRegistry === 'undefined')
775
+ ? { register: () => {}, unregister: () => {} }
776
+ : new FinalizationRegistry(ptr => wasm.__wbg_eip712domainmsg_free(ptr >>> 0, 1));
777
+ /**
778
+ * <https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator>
779
+ * eventually chain_id, verifying_contract and salt will be parsed in to
780
+ * solidity types
781
+ */
782
+ class Eip712DomainMsg {
783
+
784
+ static __wrap(ptr) {
785
+ ptr = ptr >>> 0;
786
+ const obj = Object.create(Eip712DomainMsg.prototype);
787
+ obj.__wbg_ptr = ptr;
788
+ Eip712DomainMsgFinalization.register(obj, obj.__wbg_ptr, obj);
789
+ return obj;
790
+ }
791
+
792
+ __destroy_into_raw() {
793
+ const ptr = this.__wbg_ptr;
794
+ this.__wbg_ptr = 0;
795
+ Eip712DomainMsgFinalization.unregister(this);
796
+ return ptr;
797
+ }
798
+
799
+ free() {
800
+ const ptr = this.__destroy_into_raw();
801
+ wasm.__wbg_eip712domainmsg_free(ptr, 0);
802
+ }
803
+ /**
804
+ * @returns {string}
805
+ */
806
+ get name() {
807
+ let deferred1_0;
808
+ let deferred1_1;
809
+ try {
810
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
811
+ wasm.__wbg_get_eip712domainmsg_name(retptr, this.__wbg_ptr);
812
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
813
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
814
+ deferred1_0 = r0;
815
+ deferred1_1 = r1;
816
+ return getStringFromWasm0(r0, r1);
817
+ } finally {
818
+ wasm.__wbindgen_add_to_stack_pointer(16);
819
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
820
+ }
821
+ }
822
+ /**
823
+ * @param {string} arg0
824
+ */
825
+ set name(arg0) {
826
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
827
+ const len0 = WASM_VECTOR_LEN;
828
+ wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
829
+ }
830
+ /**
831
+ * @returns {string}
832
+ */
833
+ get version() {
834
+ let deferred1_0;
835
+ let deferred1_1;
836
+ try {
837
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
838
+ wasm.__wbg_get_eip712domainmsg_version(retptr, this.__wbg_ptr);
839
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
840
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
841
+ deferred1_0 = r0;
842
+ deferred1_1 = r1;
843
+ return getStringFromWasm0(r0, r1);
844
+ } finally {
845
+ wasm.__wbindgen_add_to_stack_pointer(16);
846
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
847
+ }
848
+ }
849
+ /**
850
+ * @param {string} arg0
851
+ */
852
+ set version(arg0) {
853
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
854
+ const len0 = WASM_VECTOR_LEN;
855
+ wasm.__wbg_set_eip712domainmsg_version(this.__wbg_ptr, ptr0, len0);
856
+ }
857
+ /**
858
+ * @returns {Uint8Array}
859
+ */
860
+ get chain_id() {
861
+ try {
862
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
863
+ wasm.__wbg_get_eip712domainmsg_chain_id(retptr, this.__wbg_ptr);
864
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
865
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
866
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
867
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
868
+ return v1;
869
+ } finally {
870
+ wasm.__wbindgen_add_to_stack_pointer(16);
871
+ }
872
+ }
873
+ /**
874
+ * @param {Uint8Array} arg0
875
+ */
876
+ set chain_id(arg0) {
877
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
878
+ const len0 = WASM_VECTOR_LEN;
879
+ wasm.__wbg_set_eip712domainmsg_chain_id(this.__wbg_ptr, ptr0, len0);
880
+ }
881
+ /**
882
+ * @returns {string}
883
+ */
884
+ get verifying_contract() {
885
+ let deferred1_0;
886
+ let deferred1_1;
887
+ try {
888
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
889
+ wasm.__wbg_get_eip712domainmsg_verifying_contract(retptr, this.__wbg_ptr);
890
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
891
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
892
+ deferred1_0 = r0;
893
+ deferred1_1 = r1;
894
+ return getStringFromWasm0(r0, r1);
895
+ } finally {
896
+ wasm.__wbindgen_add_to_stack_pointer(16);
897
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
898
+ }
899
+ }
900
+ /**
901
+ * @param {string} arg0
902
+ */
903
+ set verifying_contract(arg0) {
904
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
905
+ const len0 = WASM_VECTOR_LEN;
906
+ wasm.__wbg_set_eip712domainmsg_verifying_contract(this.__wbg_ptr, ptr0, len0);
907
+ }
908
+ /**
909
+ * @returns {Uint8Array}
910
+ */
911
+ get salt() {
912
+ try {
913
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
914
+ wasm.__wbg_get_eip712domainmsg_salt(retptr, this.__wbg_ptr);
915
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
916
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
917
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
918
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
919
+ return v1;
920
+ } finally {
921
+ wasm.__wbindgen_add_to_stack_pointer(16);
922
+ }
923
+ }
924
+ /**
925
+ * @param {Uint8Array} arg0
926
+ */
927
+ set salt(arg0) {
928
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
929
+ const len0 = WASM_VECTOR_LEN;
930
+ wasm.__wbg_set_eip712domainmsg_salt(this.__wbg_ptr, ptr0, len0);
931
+ }
932
+ }
933
+ module.exports.Eip712DomainMsg = Eip712DomainMsg;
934
+
935
+ const ParsedReencryptionRequestFinalization = (typeof FinalizationRegistry === 'undefined')
936
+ ? { register: () => {}, unregister: () => {} }
937
+ : new FinalizationRegistry(ptr => wasm.__wbg_parsedreencryptionrequest_free(ptr >>> 0, 1));
938
+ /**
939
+ * Validity of this struct is not checked.
940
+ */
941
+ class ParsedReencryptionRequest {
942
+
943
+ __destroy_into_raw() {
944
+ const ptr = this.__wbg_ptr;
945
+ this.__wbg_ptr = 0;
946
+ ParsedReencryptionRequestFinalization.unregister(this);
947
+ return ptr;
948
+ }
949
+
950
+ free() {
951
+ const ptr = this.__destroy_into_raw();
952
+ wasm.__wbg_parsedreencryptionrequest_free(ptr, 0);
953
+ }
954
+ }
955
+ module.exports.ParsedReencryptionRequest = ParsedReencryptionRequest;
956
+
957
+ const PlaintextFinalization = (typeof FinalizationRegistry === 'undefined')
958
+ ? { register: () => {}, unregister: () => {} }
959
+ : new FinalizationRegistry(ptr => wasm.__wbg_plaintext_free(ptr >>> 0, 1));
960
+ /**
961
+ */
962
+ class Plaintext {
963
+
964
+ __destroy_into_raw() {
965
+ const ptr = this.__wbg_ptr;
966
+ this.__wbg_ptr = 0;
967
+ PlaintextFinalization.unregister(this);
968
+ return ptr;
969
+ }
970
+
971
+ free() {
972
+ const ptr = this.__destroy_into_raw();
973
+ wasm.__wbg_plaintext_free(ptr, 0);
974
+ }
975
+ /**
976
+ * @returns {Uint8Array}
977
+ */
978
+ get bytes() {
979
+ try {
980
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
981
+ wasm.__wbg_get_plaintext_bytes(retptr, this.__wbg_ptr);
982
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
983
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
984
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
985
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
986
+ return v1;
987
+ } finally {
988
+ wasm.__wbindgen_add_to_stack_pointer(16);
989
+ }
990
+ }
991
+ /**
992
+ * @param {Uint8Array} arg0
993
+ */
994
+ set bytes(arg0) {
995
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
996
+ const len0 = WASM_VECTOR_LEN;
997
+ wasm.__wbg_set_plaintext_bytes(this.__wbg_ptr, ptr0, len0);
998
+ }
999
+ }
1000
+ module.exports.Plaintext = Plaintext;
1001
+
1002
+ const PrivateEncKeyFinalization = (typeof FinalizationRegistry === 'undefined')
1003
+ ? { register: () => {}, unregister: () => {} }
1004
+ : new FinalizationRegistry(ptr => wasm.__wbg_privateenckey_free(ptr >>> 0, 1));
1005
+ /**
1006
+ */
1007
+ class PrivateEncKey {
1008
+
1009
+ static __wrap(ptr) {
1010
+ ptr = ptr >>> 0;
1011
+ const obj = Object.create(PrivateEncKey.prototype);
1012
+ obj.__wbg_ptr = ptr;
1013
+ PrivateEncKeyFinalization.register(obj, obj.__wbg_ptr, obj);
1014
+ return obj;
1015
+ }
1016
+
1017
+ __destroy_into_raw() {
1018
+ const ptr = this.__wbg_ptr;
1019
+ this.__wbg_ptr = 0;
1020
+ PrivateEncKeyFinalization.unregister(this);
1021
+ return ptr;
1022
+ }
1023
+
1024
+ free() {
1025
+ const ptr = this.__destroy_into_raw();
1026
+ wasm.__wbg_privateenckey_free(ptr, 0);
1027
+ }
1028
+ }
1029
+ module.exports.PrivateEncKey = PrivateEncKey;
1030
+
1031
+ const PrivateSigKeyFinalization = (typeof FinalizationRegistry === 'undefined')
1032
+ ? { register: () => {}, unregister: () => {} }
1033
+ : new FinalizationRegistry(ptr => wasm.__wbg_privatesigkey_free(ptr >>> 0, 1));
1034
+ /**
1035
+ */
1036
+ class PrivateSigKey {
1037
+
1038
+ static __wrap(ptr) {
1039
+ ptr = ptr >>> 0;
1040
+ const obj = Object.create(PrivateSigKey.prototype);
1041
+ obj.__wbg_ptr = ptr;
1042
+ PrivateSigKeyFinalization.register(obj, obj.__wbg_ptr, obj);
1043
+ return obj;
1044
+ }
1045
+
1046
+ __destroy_into_raw() {
1047
+ const ptr = this.__wbg_ptr;
1048
+ this.__wbg_ptr = 0;
1049
+ PrivateSigKeyFinalization.unregister(this);
1050
+ return ptr;
1051
+ }
1052
+
1053
+ free() {
1054
+ const ptr = this.__destroy_into_raw();
1055
+ wasm.__wbg_privatesigkey_free(ptr, 0);
1056
+ }
1057
+ }
1058
+ module.exports.PrivateSigKey = PrivateSigKey;
1059
+
1060
+ const PublicEncKeyFinalization = (typeof FinalizationRegistry === 'undefined')
1061
+ ? { register: () => {}, unregister: () => {} }
1062
+ : new FinalizationRegistry(ptr => wasm.__wbg_publicenckey_free(ptr >>> 0, 1));
1063
+ /**
1064
+ */
1065
+ class PublicEncKey {
1066
+
1067
+ static __wrap(ptr) {
1068
+ ptr = ptr >>> 0;
1069
+ const obj = Object.create(PublicEncKey.prototype);
1070
+ obj.__wbg_ptr = ptr;
1071
+ PublicEncKeyFinalization.register(obj, obj.__wbg_ptr, obj);
1072
+ return obj;
1073
+ }
1074
+
1075
+ __destroy_into_raw() {
1076
+ const ptr = this.__wbg_ptr;
1077
+ this.__wbg_ptr = 0;
1078
+ PublicEncKeyFinalization.unregister(this);
1079
+ return ptr;
1080
+ }
1081
+
1082
+ free() {
1083
+ const ptr = this.__destroy_into_raw();
1084
+ wasm.__wbg_publicenckey_free(ptr, 0);
1085
+ }
1086
+ }
1087
+ module.exports.PublicEncKey = PublicEncKey;
1088
+
1089
+ const PublicSigKeyFinalization = (typeof FinalizationRegistry === 'undefined')
1090
+ ? { register: () => {}, unregister: () => {} }
1091
+ : new FinalizationRegistry(ptr => wasm.__wbg_publicsigkey_free(ptr >>> 0, 1));
1092
+ /**
1093
+ */
1094
+ class PublicSigKey {
1095
+
1096
+ static __wrap(ptr) {
1097
+ ptr = ptr >>> 0;
1098
+ const obj = Object.create(PublicSigKey.prototype);
1099
+ obj.__wbg_ptr = ptr;
1100
+ PublicSigKeyFinalization.register(obj, obj.__wbg_ptr, obj);
1101
+ return obj;
1102
+ }
1103
+
1104
+ __destroy_into_raw() {
1105
+ const ptr = this.__wbg_ptr;
1106
+ this.__wbg_ptr = 0;
1107
+ PublicSigKeyFinalization.unregister(this);
1108
+ return ptr;
1109
+ }
1110
+
1111
+ free() {
1112
+ const ptr = this.__destroy_into_raw();
1113
+ wasm.__wbg_publicsigkey_free(ptr, 0);
1114
+ }
1115
+ }
1116
+ module.exports.PublicSigKey = PublicSigKey;
1117
+
1118
+ const ReencryptionRequestFinalization = (typeof FinalizationRegistry === 'undefined')
1119
+ ? { register: () => {}, unregister: () => {} }
1120
+ : new FinalizationRegistry(ptr => wasm.__wbg_reencryptionrequest_free(ptr >>> 0, 1));
1121
+ /**
1122
+ */
1123
+ class ReencryptionRequest {
1124
+
1125
+ __destroy_into_raw() {
1126
+ const ptr = this.__wbg_ptr;
1127
+ this.__wbg_ptr = 0;
1128
+ ReencryptionRequestFinalization.unregister(this);
1129
+ return ptr;
1130
+ }
1131
+
1132
+ free() {
1133
+ const ptr = this.__destroy_into_raw();
1134
+ wasm.__wbg_reencryptionrequest_free(ptr, 0);
1135
+ }
1136
+ /**
1137
+ * Signature of the serialization of \[ReencryptionRequestPayload\].
1138
+ * @returns {Uint8Array}
1139
+ */
1140
+ get signature() {
1141
+ try {
1142
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1143
+ wasm.__wbg_get_reencryptionrequest_signature(retptr, this.__wbg_ptr);
1144
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1145
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1146
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
1147
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
1148
+ return v1;
1149
+ } finally {
1150
+ wasm.__wbindgen_add_to_stack_pointer(16);
1151
+ }
1152
+ }
1153
+ /**
1154
+ * Signature of the serialization of \[ReencryptionRequestPayload\].
1155
+ * @param {Uint8Array} arg0
1156
+ */
1157
+ set signature(arg0) {
1158
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1159
+ const len0 = WASM_VECTOR_LEN;
1160
+ wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1161
+ }
1162
+ /**
1163
+ * @returns {ReencryptionRequestPayload | undefined}
1164
+ */
1165
+ get payload() {
1166
+ const ret = wasm.__wbg_get_reencryptionrequest_payload(this.__wbg_ptr);
1167
+ return ret === 0 ? undefined : ReencryptionRequestPayload.__wrap(ret);
1168
+ }
1169
+ /**
1170
+ * @param {ReencryptionRequestPayload | undefined} [arg0]
1171
+ */
1172
+ set payload(arg0) {
1173
+ let ptr0 = 0;
1174
+ if (!isLikeNone(arg0)) {
1175
+ _assertClass(arg0, ReencryptionRequestPayload);
1176
+ ptr0 = arg0.__destroy_into_raw();
1177
+ }
1178
+ wasm.__wbg_set_reencryptionrequest_payload(this.__wbg_ptr, ptr0);
1179
+ }
1180
+ /**
1181
+ * @returns {Eip712DomainMsg | undefined}
1182
+ */
1183
+ get domain() {
1184
+ const ret = wasm.__wbg_get_reencryptionrequest_domain(this.__wbg_ptr);
1185
+ return ret === 0 ? undefined : Eip712DomainMsg.__wrap(ret);
1186
+ }
1187
+ /**
1188
+ * @param {Eip712DomainMsg | undefined} [arg0]
1189
+ */
1190
+ set domain(arg0) {
1191
+ let ptr0 = 0;
1192
+ if (!isLikeNone(arg0)) {
1193
+ _assertClass(arg0, Eip712DomainMsg);
1194
+ ptr0 = arg0.__destroy_into_raw();
1195
+ }
1196
+ wasm.__wbg_set_reencryptionrequest_domain(this.__wbg_ptr, ptr0);
1197
+ }
1198
+ /**
1199
+ * The ID that identifies this request.
1200
+ * Future queries for the result must use this request ID.
1201
+ * @returns {RequestId | undefined}
1202
+ */
1203
+ get request_id() {
1204
+ const ret = wasm.__wbg_get_reencryptionrequest_request_id(this.__wbg_ptr);
1205
+ return ret === 0 ? undefined : RequestId.__wrap(ret);
1206
+ }
1207
+ /**
1208
+ * The ID that identifies this request.
1209
+ * Future queries for the result must use this request ID.
1210
+ * @param {RequestId | undefined} [arg0]
1211
+ */
1212
+ set request_id(arg0) {
1213
+ let ptr0 = 0;
1214
+ if (!isLikeNone(arg0)) {
1215
+ _assertClass(arg0, RequestId);
1216
+ ptr0 = arg0.__destroy_into_raw();
1217
+ }
1218
+ wasm.__wbg_set_reencryptionrequest_request_id(this.__wbg_ptr, ptr0);
1219
+ }
1220
+ }
1221
+ module.exports.ReencryptionRequest = ReencryptionRequest;
1222
+
1223
+ const ReencryptionRequestPayloadFinalization = (typeof FinalizationRegistry === 'undefined')
1224
+ ? { register: () => {}, unregister: () => {} }
1225
+ : new FinalizationRegistry(ptr => wasm.__wbg_reencryptionrequestpayload_free(ptr >>> 0, 1));
1226
+ /**
1227
+ */
1228
+ class ReencryptionRequestPayload {
1229
+
1230
+ static __wrap(ptr) {
1231
+ ptr = ptr >>> 0;
1232
+ const obj = Object.create(ReencryptionRequestPayload.prototype);
1233
+ obj.__wbg_ptr = ptr;
1234
+ ReencryptionRequestPayloadFinalization.register(obj, obj.__wbg_ptr, obj);
1235
+ return obj;
1236
+ }
1237
+
1238
+ __destroy_into_raw() {
1239
+ const ptr = this.__wbg_ptr;
1240
+ this.__wbg_ptr = 0;
1241
+ ReencryptionRequestPayloadFinalization.unregister(this);
1242
+ return ptr;
1243
+ }
1244
+
1245
+ free() {
1246
+ const ptr = this.__destroy_into_raw();
1247
+ wasm.__wbg_reencryptionrequestpayload_free(ptr, 0);
1248
+ }
1249
+ /**
1250
+ * Version of the request format.
1251
+ * @returns {number}
1252
+ */
1253
+ get version() {
1254
+ const ret = wasm.__wbg_get_reencryptionrequestpayload_version(this.__wbg_ptr);
1255
+ return ret >>> 0;
1256
+ }
1257
+ /**
1258
+ * Version of the request format.
1259
+ * @param {number} arg0
1260
+ */
1261
+ set version(arg0) {
1262
+ wasm.__wbg_set_reencryptionrequestpayload_version(this.__wbg_ptr, arg0);
1263
+ }
1264
+ /**
1265
+ * The client's (blockchain wallet) address,
1266
+ * encoded using EIP-55.
1267
+ * @returns {string}
1268
+ */
1269
+ get client_address() {
1270
+ let deferred1_0;
1271
+ let deferred1_1;
1272
+ try {
1273
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1274
+ wasm.__wbg_get_eip712domainmsg_name(retptr, this.__wbg_ptr);
1275
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1276
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1277
+ deferred1_0 = r0;
1278
+ deferred1_1 = r1;
1279
+ return getStringFromWasm0(r0, r1);
1280
+ } finally {
1281
+ wasm.__wbindgen_add_to_stack_pointer(16);
1282
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1283
+ }
1284
+ }
1285
+ /**
1286
+ * The client's (blockchain wallet) address,
1287
+ * encoded using EIP-55.
1288
+ * @param {string} arg0
1289
+ */
1290
+ set client_address(arg0) {
1291
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1292
+ const len0 = WASM_VECTOR_LEN;
1293
+ wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1294
+ }
1295
+ /**
1296
+ * Encoding of the user's public encryption key for this request.
1297
+ * Encoding using the default encoding of libsodium, i.e. the 32 bytes of a
1298
+ * Montgomery point.
1299
+ * @returns {Uint8Array}
1300
+ */
1301
+ get enc_key() {
1302
+ try {
1303
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1304
+ wasm.__wbg_get_reencryptionrequestpayload_enc_key(retptr, this.__wbg_ptr);
1305
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1306
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1307
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
1308
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
1309
+ return v1;
1310
+ } finally {
1311
+ wasm.__wbindgen_add_to_stack_pointer(16);
1312
+ }
1313
+ }
1314
+ /**
1315
+ * Encoding of the user's public encryption key for this request.
1316
+ * Encoding using the default encoding of libsodium, i.e. the 32 bytes of a
1317
+ * Montgomery point.
1318
+ * @param {Uint8Array} arg0
1319
+ */
1320
+ set enc_key(arg0) {
1321
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1322
+ const len0 = WASM_VECTOR_LEN;
1323
+ wasm.__wbg_set_eip712domainmsg_version(this.__wbg_ptr, ptr0, len0);
1324
+ }
1325
+ /**
1326
+ * The type of plaintext encrypted.
1327
+ * @returns {number}
1328
+ */
1329
+ get fhe_type() {
1330
+ const ret = wasm.__wbg_get_reencryptionrequestpayload_fhe_type(this.__wbg_ptr);
1331
+ return ret;
1332
+ }
1333
+ /**
1334
+ * The type of plaintext encrypted.
1335
+ * @param {number} arg0
1336
+ */
1337
+ set fhe_type(arg0) {
1338
+ wasm.__wbg_set_reencryptionrequestpayload_fhe_type(this.__wbg_ptr, arg0);
1339
+ }
1340
+ /**
1341
+ * The key id to use for decryption. Will be the request_id used during key
1342
+ * generation
1343
+ * @returns {RequestId | undefined}
1344
+ */
1345
+ get key_id() {
1346
+ const ret = wasm.__wbg_get_reencryptionrequestpayload_key_id(this.__wbg_ptr);
1347
+ return ret === 0 ? undefined : RequestId.__wrap(ret);
1348
+ }
1349
+ /**
1350
+ * The key id to use for decryption. Will be the request_id used during key
1351
+ * generation
1352
+ * @param {RequestId | undefined} [arg0]
1353
+ */
1354
+ set key_id(arg0) {
1355
+ let ptr0 = 0;
1356
+ if (!isLikeNone(arg0)) {
1357
+ _assertClass(arg0, RequestId);
1358
+ ptr0 = arg0.__destroy_into_raw();
1359
+ }
1360
+ wasm.__wbg_set_reencryptionrequestpayload_key_id(this.__wbg_ptr, ptr0);
1361
+ }
1362
+ /**
1363
+ * The actual ciphertext to decrypt, taken directly from the fhevm.
1364
+ * When creating the payload, this field may be empty,
1365
+ * it is the responsibility of the gateway to fetch the
1366
+ * ciphertext for the given digest below.
1367
+ * @returns {Uint8Array | undefined}
1368
+ */
1369
+ get ciphertext() {
1370
+ try {
1371
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1372
+ wasm.__wbg_get_reencryptionrequestpayload_ciphertext(retptr, this.__wbg_ptr);
1373
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1374
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1375
+ let v1;
1376
+ if (r0 !== 0) {
1377
+ v1 = getArrayU8FromWasm0(r0, r1).slice();
1378
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
1379
+ }
1380
+ return v1;
1381
+ } finally {
1382
+ wasm.__wbindgen_add_to_stack_pointer(16);
1383
+ }
1384
+ }
1385
+ /**
1386
+ * The actual ciphertext to decrypt, taken directly from the fhevm.
1387
+ * When creating the payload, this field may be empty,
1388
+ * it is the responsibility of the gateway to fetch the
1389
+ * ciphertext for the given digest below.
1390
+ * @param {Uint8Array | undefined} [arg0]
1391
+ */
1392
+ set ciphertext(arg0) {
1393
+ var ptr0 = isLikeNone(arg0) ? 0 : passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1394
+ var len0 = WASM_VECTOR_LEN;
1395
+ wasm.__wbg_set_reencryptionrequestpayload_ciphertext(this.__wbg_ptr, ptr0, len0);
1396
+ }
1397
+ /**
1398
+ * The SHA3 digest of the ciphertext above.
1399
+ * @returns {Uint8Array}
1400
+ */
1401
+ get ciphertext_digest() {
1402
+ try {
1403
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1404
+ wasm.__wbg_get_eip712domainmsg_chain_id(retptr, this.__wbg_ptr);
1405
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1406
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1407
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
1408
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
1409
+ return v1;
1410
+ } finally {
1411
+ wasm.__wbindgen_add_to_stack_pointer(16);
1412
+ }
1413
+ }
1414
+ /**
1415
+ * The SHA3 digest of the ciphertext above.
1416
+ * @param {Uint8Array} arg0
1417
+ */
1418
+ set ciphertext_digest(arg0) {
1419
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1420
+ const len0 = WASM_VECTOR_LEN;
1421
+ wasm.__wbg_set_eip712domainmsg_chain_id(this.__wbg_ptr, ptr0, len0);
1422
+ }
1423
+ }
1424
+ module.exports.ReencryptionRequestPayload = ReencryptionRequestPayload;
1425
+
1426
+ const ReencryptionResponseFinalization = (typeof FinalizationRegistry === 'undefined')
1427
+ ? { register: () => {}, unregister: () => {} }
1428
+ : new FinalizationRegistry(ptr => wasm.__wbg_reencryptionresponse_free(ptr >>> 0, 1));
1429
+ /**
1430
+ */
1431
+ class ReencryptionResponse {
1432
+
1433
+ static __unwrap(jsValue) {
1434
+ if (!(jsValue instanceof ReencryptionResponse)) {
1435
+ return 0;
1436
+ }
1437
+ return jsValue.__destroy_into_raw();
1438
+ }
1439
+
1440
+ __destroy_into_raw() {
1441
+ const ptr = this.__wbg_ptr;
1442
+ this.__wbg_ptr = 0;
1443
+ ReencryptionResponseFinalization.unregister(this);
1444
+ return ptr;
1445
+ }
1446
+
1447
+ free() {
1448
+ const ptr = this.__destroy_into_raw();
1449
+ wasm.__wbg_reencryptionresponse_free(ptr, 0);
1450
+ }
1451
+ /**
1452
+ * @returns {Uint8Array}
1453
+ */
1454
+ get signature() {
1455
+ try {
1456
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1457
+ wasm.__wbg_get_reencryptionrequest_signature(retptr, this.__wbg_ptr);
1458
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1459
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1460
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
1461
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
1462
+ return v1;
1463
+ } finally {
1464
+ wasm.__wbindgen_add_to_stack_pointer(16);
1465
+ }
1466
+ }
1467
+ /**
1468
+ * @param {Uint8Array} arg0
1469
+ */
1470
+ set signature(arg0) {
1471
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1472
+ const len0 = WASM_VECTOR_LEN;
1473
+ wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1474
+ }
1475
+ /**
1476
+ * Signature of the serialization of \[ReencryptionResponsePayload\].
1477
+ * @returns {ReencryptionResponsePayload | undefined}
1478
+ */
1479
+ get payload() {
1480
+ const ret = wasm.__wbg_get_reencryptionresponse_payload(this.__wbg_ptr);
1481
+ return ret === 0 ? undefined : ReencryptionResponsePayload.__wrap(ret);
1482
+ }
1483
+ /**
1484
+ * Signature of the serialization of \[ReencryptionResponsePayload\].
1485
+ * @param {ReencryptionResponsePayload | undefined} [arg0]
1486
+ */
1487
+ set payload(arg0) {
1488
+ let ptr0 = 0;
1489
+ if (!isLikeNone(arg0)) {
1490
+ _assertClass(arg0, ReencryptionResponsePayload);
1491
+ ptr0 = arg0.__destroy_into_raw();
1492
+ }
1493
+ wasm.__wbg_set_reencryptionresponse_payload(this.__wbg_ptr, ptr0);
1494
+ }
1495
+ }
1496
+ module.exports.ReencryptionResponse = ReencryptionResponse;
1497
+
1498
+ const ReencryptionResponsePayloadFinalization = (typeof FinalizationRegistry === 'undefined')
1499
+ ? { register: () => {}, unregister: () => {} }
1500
+ : new FinalizationRegistry(ptr => wasm.__wbg_reencryptionresponsepayload_free(ptr >>> 0, 1));
1501
+ /**
1502
+ */
1503
+ class ReencryptionResponsePayload {
1504
+
1505
+ static __wrap(ptr) {
1506
+ ptr = ptr >>> 0;
1507
+ const obj = Object.create(ReencryptionResponsePayload.prototype);
1508
+ obj.__wbg_ptr = ptr;
1509
+ ReencryptionResponsePayloadFinalization.register(obj, obj.__wbg_ptr, obj);
1510
+ return obj;
1511
+ }
1512
+
1513
+ __destroy_into_raw() {
1514
+ const ptr = this.__wbg_ptr;
1515
+ this.__wbg_ptr = 0;
1516
+ ReencryptionResponsePayloadFinalization.unregister(this);
1517
+ return ptr;
1518
+ }
1519
+
1520
+ free() {
1521
+ const ptr = this.__destroy_into_raw();
1522
+ wasm.__wbg_reencryptionresponsepayload_free(ptr, 0);
1523
+ }
1524
+ /**
1525
+ * Version of the response format.
1526
+ * @returns {number}
1527
+ */
1528
+ get version() {
1529
+ const ret = wasm.__wbg_get_reencryptionresponsepayload_version(this.__wbg_ptr);
1530
+ return ret >>> 0;
1531
+ }
1532
+ /**
1533
+ * Version of the response format.
1534
+ * @param {number} arg0
1535
+ */
1536
+ set version(arg0) {
1537
+ wasm.__wbg_set_reencryptionresponsepayload_version(this.__wbg_ptr, arg0);
1538
+ }
1539
+ /**
1540
+ * The server's signature verification key.
1541
+ * Encoded using SEC1.
1542
+ * Needed to validate the response, but MUST also be linked to a list of
1543
+ * trusted keys.
1544
+ * @returns {Uint8Array}
1545
+ */
1546
+ get verification_key() {
1547
+ try {
1548
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1549
+ wasm.__wbg_get_reencryptionrequest_signature(retptr, this.__wbg_ptr);
1550
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1551
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1552
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
1553
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
1554
+ return v1;
1555
+ } finally {
1556
+ wasm.__wbindgen_add_to_stack_pointer(16);
1557
+ }
1558
+ }
1559
+ /**
1560
+ * The server's signature verification key.
1561
+ * Encoded using SEC1.
1562
+ * Needed to validate the response, but MUST also be linked to a list of
1563
+ * trusted keys.
1564
+ * @param {Uint8Array} arg0
1565
+ */
1566
+ set verification_key(arg0) {
1567
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1568
+ const len0 = WASM_VECTOR_LEN;
1569
+ wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1570
+ }
1571
+ /**
1572
+ * The concatenation of two digests:
1573
+ * (eip712_signing_hash(pk, domain) || ciphertext digest).
1574
+ * This is needed to ensure the response corresponds to the request.
1575
+ * @returns {Uint8Array}
1576
+ */
1577
+ get digest() {
1578
+ try {
1579
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1580
+ wasm.__wbg_get_reencryptionrequestpayload_enc_key(retptr, this.__wbg_ptr);
1581
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1582
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1583
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
1584
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
1585
+ return v1;
1586
+ } finally {
1587
+ wasm.__wbindgen_add_to_stack_pointer(16);
1588
+ }
1589
+ }
1590
+ /**
1591
+ * The concatenation of two digests:
1592
+ * (eip712_signing_hash(pk, domain) || ciphertext digest).
1593
+ * This is needed to ensure the response corresponds to the request.
1594
+ * @param {Uint8Array} arg0
1595
+ */
1596
+ set digest(arg0) {
1597
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1598
+ const len0 = WASM_VECTOR_LEN;
1599
+ wasm.__wbg_set_eip712domainmsg_version(this.__wbg_ptr, ptr0, len0);
1600
+ }
1601
+ /**
1602
+ * The type of plaintext encrypted.
1603
+ * @returns {number}
1604
+ */
1605
+ get fhe_type() {
1606
+ const ret = wasm.__wbg_get_reencryptionresponsepayload_fhe_type(this.__wbg_ptr);
1607
+ return ret;
1608
+ }
1609
+ /**
1610
+ * The type of plaintext encrypted.
1611
+ * @param {number} arg0
1612
+ */
1613
+ set fhe_type(arg0) {
1614
+ wasm.__wbg_set_reencryptionresponsepayload_fhe_type(this.__wbg_ptr, arg0);
1615
+ }
1616
+ /**
1617
+ * The signcrypted payload, using a hybrid encryption approach in
1618
+ * sign-then-encrypt.
1619
+ * @returns {Uint8Array}
1620
+ */
1621
+ get signcrypted_ciphertext() {
1622
+ try {
1623
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1624
+ wasm.__wbg_get_eip712domainmsg_chain_id(retptr, this.__wbg_ptr);
1625
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1626
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1627
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
1628
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
1629
+ return v1;
1630
+ } finally {
1631
+ wasm.__wbindgen_add_to_stack_pointer(16);
1632
+ }
1633
+ }
1634
+ /**
1635
+ * The signcrypted payload, using a hybrid encryption approach in
1636
+ * sign-then-encrypt.
1637
+ * @param {Uint8Array} arg0
1638
+ */
1639
+ set signcrypted_ciphertext(arg0) {
1640
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1641
+ const len0 = WASM_VECTOR_LEN;
1642
+ wasm.__wbg_set_eip712domainmsg_chain_id(this.__wbg_ptr, ptr0, len0);
1643
+ }
1644
+ /**
1645
+ * The ID of the MPC party doing the reencryption. Used for polynomial
1646
+ * reconstruction.
1647
+ * @returns {number}
1648
+ */
1649
+ get party_id() {
1650
+ const ret = wasm.__wbg_get_reencryptionresponsepayload_party_id(this.__wbg_ptr);
1651
+ return ret >>> 0;
1652
+ }
1653
+ /**
1654
+ * The ID of the MPC party doing the reencryption. Used for polynomial
1655
+ * reconstruction.
1656
+ * @param {number} arg0
1657
+ */
1658
+ set party_id(arg0) {
1659
+ wasm.__wbg_set_reencryptionresponsepayload_party_id(this.__wbg_ptr, arg0);
1660
+ }
1661
+ /**
1662
+ * The degree of the sharing scheme used.
1663
+ * @returns {number}
1664
+ */
1665
+ get degree() {
1666
+ const ret = wasm.__wbg_get_reencryptionresponsepayload_degree(this.__wbg_ptr);
1667
+ return ret >>> 0;
1668
+ }
1669
+ /**
1670
+ * The degree of the sharing scheme used.
1671
+ * @param {number} arg0
1672
+ */
1673
+ set degree(arg0) {
1674
+ wasm.__wbg_set_reencryptionresponsepayload_degree(this.__wbg_ptr, arg0);
1675
+ }
1676
+ }
1677
+ module.exports.ReencryptionResponsePayload = ReencryptionResponsePayload;
1678
+
1679
+ const RequestIdFinalization = (typeof FinalizationRegistry === 'undefined')
1680
+ ? { register: () => {}, unregister: () => {} }
1681
+ : new FinalizationRegistry(ptr => wasm.__wbg_requestid_free(ptr >>> 0, 1));
1682
+ /**
1683
+ * Simple response to return an ID, to be used to retrieve the computed result
1684
+ * later on.
1685
+ */
1686
+ class RequestId {
1687
+
1688
+ static __wrap(ptr) {
1689
+ ptr = ptr >>> 0;
1690
+ const obj = Object.create(RequestId.prototype);
1691
+ obj.__wbg_ptr = ptr;
1692
+ RequestIdFinalization.register(obj, obj.__wbg_ptr, obj);
1693
+ return obj;
1694
+ }
1695
+
1696
+ __destroy_into_raw() {
1697
+ const ptr = this.__wbg_ptr;
1698
+ this.__wbg_ptr = 0;
1699
+ RequestIdFinalization.unregister(this);
1700
+ return ptr;
1701
+ }
1702
+
1703
+ free() {
1704
+ const ptr = this.__destroy_into_raw();
1705
+ wasm.__wbg_requestid_free(ptr, 0);
1706
+ }
1707
+ /**
1708
+ * @returns {string}
1709
+ */
1710
+ get request_id() {
1711
+ let deferred1_0;
1712
+ let deferred1_1;
1713
+ try {
1714
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1715
+ wasm.__wbg_get_eip712domainmsg_name(retptr, this.__wbg_ptr);
1716
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1717
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1718
+ deferred1_0 = r0;
1719
+ deferred1_1 = r1;
1720
+ return getStringFromWasm0(r0, r1);
1721
+ } finally {
1722
+ wasm.__wbindgen_add_to_stack_pointer(16);
1723
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1724
+ }
1725
+ }
1726
+ /**
1727
+ * @param {string} arg0
1728
+ */
1729
+ set request_id(arg0) {
1730
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1731
+ const len0 = WASM_VECTOR_LEN;
1732
+ wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1733
+ }
1734
+ }
1735
+ module.exports.RequestId = RequestId;
1736
+
1737
+ module.exports.__wbindgen_error_new = function(arg0, arg1) {
1738
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
1739
+ return addHeapObject(ret);
1740
+ };
1741
+
1742
+ module.exports.__wbindgen_object_drop_ref = function(arg0) {
1743
+ takeObject(arg0);
1744
+ };
1745
+
1746
+ module.exports.__wbg_reencryptionresponse_unwrap = function(arg0) {
1747
+ const ret = ReencryptionResponse.__unwrap(takeObject(arg0));
1748
+ return ret;
1749
+ };
1750
+
1751
+ module.exports.__wbindgen_number_get = function(arg0, arg1) {
1752
+ const obj = getObject(arg1);
1753
+ const ret = typeof(obj) === 'number' ? obj : undefined;
1754
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1755
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1756
+ };
1757
+
1758
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
1759
+ const obj = getObject(arg1);
1760
+ const ret = typeof(obj) === 'string' ? obj : undefined;
1761
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1762
+ var len1 = WASM_VECTOR_LEN;
1763
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1764
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1765
+ };
1766
+
1767
+ module.exports.__wbindgen_is_object = function(arg0) {
1768
+ const val = getObject(arg0);
1769
+ const ret = typeof(val) === 'object' && val !== null;
1770
+ return ret;
1771
+ };
1772
+
1773
+ module.exports.__wbindgen_is_undefined = function(arg0) {
1774
+ const ret = getObject(arg0) === undefined;
1775
+ return ret;
1776
+ };
1777
+
1778
+ module.exports.__wbindgen_in = function(arg0, arg1) {
1779
+ const ret = getObject(arg0) in getObject(arg1);
1780
+ return ret;
1781
+ };
1782
+
1783
+ module.exports.__wbindgen_is_null = function(arg0) {
1784
+ const ret = getObject(arg0) === null;
1785
+ return ret;
1786
+ };
1787
+
1788
+ module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
1789
+ const ret = getObject(arg0) == getObject(arg1);
1790
+ return ret;
1791
+ };
1792
+
1793
+ module.exports.__wbindgen_boolean_get = function(arg0) {
1794
+ const v = getObject(arg0);
1795
+ const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
1796
+ return ret;
1797
+ };
1798
+
1799
+ module.exports.__wbindgen_as_number = function(arg0) {
1800
+ const ret = +getObject(arg0);
1801
+ return ret;
1802
+ };
1803
+
1804
+ module.exports.__wbg_String_b9412f8799faab3e = function(arg0, arg1) {
1805
+ const ret = String(getObject(arg1));
1806
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1807
+ const len1 = WASM_VECTOR_LEN;
1808
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1809
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1810
+ };
1811
+
1812
+ module.exports.__wbindgen_object_clone_ref = function(arg0) {
1813
+ const ret = getObject(arg0);
1814
+ return addHeapObject(ret);
1815
+ };
1816
+
1817
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
1818
+ const ret = getStringFromWasm0(arg0, arg1);
1819
+ return addHeapObject(ret);
1820
+ };
1821
+
1822
+ module.exports.__wbg_getwithrefkey_edc2c8960f0f1191 = function(arg0, arg1) {
1823
+ const ret = getObject(arg0)[getObject(arg1)];
1824
+ return addHeapObject(ret);
1825
+ };
1826
+
1827
+ module.exports.__wbg_new_abda76e883ba8a5f = function() {
1828
+ const ret = new Error();
1829
+ return addHeapObject(ret);
1830
+ };
1831
+
1832
+ module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
1833
+ const ret = getObject(arg1).stack;
1834
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1835
+ const len1 = WASM_VECTOR_LEN;
1836
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1837
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1838
+ };
1839
+
1840
+ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
1841
+ let deferred0_0;
1842
+ let deferred0_1;
1843
+ try {
1844
+ deferred0_0 = arg0;
1845
+ deferred0_1 = arg1;
1846
+ console.error(getStringFromWasm0(arg0, arg1));
1847
+ } finally {
1848
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
1849
+ }
1850
+ };
1851
+
1852
+ module.exports.__wbg_crypto_1d1f22824a6a080c = function(arg0) {
1853
+ const ret = getObject(arg0).crypto;
1854
+ return addHeapObject(ret);
1855
+ };
1856
+
1857
+ module.exports.__wbg_process_4a72847cc503995b = function(arg0) {
1858
+ const ret = getObject(arg0).process;
1859
+ return addHeapObject(ret);
1860
+ };
1861
+
1862
+ module.exports.__wbg_versions_f686565e586dd935 = function(arg0) {
1863
+ const ret = getObject(arg0).versions;
1864
+ return addHeapObject(ret);
1865
+ };
1866
+
1867
+ module.exports.__wbg_node_104a2ff8d6ea03a2 = function(arg0) {
1868
+ const ret = getObject(arg0).node;
1869
+ return addHeapObject(ret);
1870
+ };
1871
+
1872
+ module.exports.__wbindgen_is_string = function(arg0) {
1873
+ const ret = typeof(getObject(arg0)) === 'string';
1874
+ return ret;
1875
+ };
1876
+
1877
+ module.exports.__wbg_require_cca90b1a94a0255b = function() { return handleError(function () {
1878
+ const ret = module.require;
1879
+ return addHeapObject(ret);
1880
+ }, arguments) };
1881
+
1882
+ module.exports.__wbindgen_is_function = function(arg0) {
1883
+ const ret = typeof(getObject(arg0)) === 'function';
1884
+ return ret;
1885
+ };
1886
+
1887
+ module.exports.__wbg_msCrypto_eb05e62b530a1508 = function(arg0) {
1888
+ const ret = getObject(arg0).msCrypto;
1889
+ return addHeapObject(ret);
1890
+ };
1891
+
1892
+ module.exports.__wbg_randomFillSync_5c9c955aa56b6049 = function() { return handleError(function (arg0, arg1) {
1893
+ getObject(arg0).randomFillSync(takeObject(arg1));
1894
+ }, arguments) };
1895
+
1896
+ module.exports.__wbg_getRandomValues_3aa56aa6edec874c = function() { return handleError(function (arg0, arg1) {
1897
+ getObject(arg0).getRandomValues(getObject(arg1));
1898
+ }, arguments) };
1899
+
1900
+ module.exports.__wbg_get_3baa728f9d58d3f6 = function(arg0, arg1) {
1901
+ const ret = getObject(arg0)[arg1 >>> 0];
1902
+ return addHeapObject(ret);
1903
+ };
1904
+
1905
+ module.exports.__wbg_length_ae22078168b726f5 = function(arg0) {
1906
+ const ret = getObject(arg0).length;
1907
+ return ret;
1908
+ };
1909
+
1910
+ module.exports.__wbg_newnoargs_76313bd6ff35d0f2 = function(arg0, arg1) {
1911
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
1912
+ return addHeapObject(ret);
1913
+ };
1914
+
1915
+ module.exports.__wbg_next_de3e9db4440638b2 = function(arg0) {
1916
+ const ret = getObject(arg0).next;
1917
+ return addHeapObject(ret);
1918
+ };
1919
+
1920
+ module.exports.__wbg_next_f9cb570345655b9a = function() { return handleError(function (arg0) {
1921
+ const ret = getObject(arg0).next();
1922
+ return addHeapObject(ret);
1923
+ }, arguments) };
1924
+
1925
+ module.exports.__wbg_done_bfda7aa8f252b39f = function(arg0) {
1926
+ const ret = getObject(arg0).done;
1927
+ return ret;
1928
+ };
1929
+
1930
+ module.exports.__wbg_value_6d39332ab4788d86 = function(arg0) {
1931
+ const ret = getObject(arg0).value;
1932
+ return addHeapObject(ret);
1933
+ };
1934
+
1935
+ module.exports.__wbg_iterator_888179a48810a9fe = function() {
1936
+ const ret = Symbol.iterator;
1937
+ return addHeapObject(ret);
1938
+ };
1939
+
1940
+ module.exports.__wbg_get_224d16597dbbfd96 = function() { return handleError(function (arg0, arg1) {
1941
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
1942
+ return addHeapObject(ret);
1943
+ }, arguments) };
1944
+
1945
+ module.exports.__wbg_call_1084a111329e68ce = function() { return handleError(function (arg0, arg1) {
1946
+ const ret = getObject(arg0).call(getObject(arg1));
1947
+ return addHeapObject(ret);
1948
+ }, arguments) };
1949
+
1950
+ module.exports.__wbg_self_3093d5d1f7bcb682 = function() { return handleError(function () {
1951
+ const ret = self.self;
1952
+ return addHeapObject(ret);
1953
+ }, arguments) };
1954
+
1955
+ module.exports.__wbg_window_3bcfc4d31bc012f8 = function() { return handleError(function () {
1956
+ const ret = window.window;
1957
+ return addHeapObject(ret);
1958
+ }, arguments) };
1959
+
1960
+ module.exports.__wbg_globalThis_86b222e13bdf32ed = function() { return handleError(function () {
1961
+ const ret = globalThis.globalThis;
1962
+ return addHeapObject(ret);
1963
+ }, arguments) };
1964
+
1965
+ module.exports.__wbg_global_e5a3fe56f8be9485 = function() { return handleError(function () {
1966
+ const ret = global.global;
1967
+ return addHeapObject(ret);
1968
+ }, arguments) };
1969
+
1970
+ module.exports.__wbg_isArray_8364a5371e9737d8 = function(arg0) {
1971
+ const ret = Array.isArray(getObject(arg0));
1972
+ return ret;
1973
+ };
1974
+
1975
+ module.exports.__wbg_instanceof_ArrayBuffer_61dfc3198373c902 = function(arg0) {
1976
+ let result;
1977
+ try {
1978
+ result = getObject(arg0) instanceof ArrayBuffer;
1979
+ } catch (_) {
1980
+ result = false;
1981
+ }
1982
+ const ret = result;
1983
+ return ret;
1984
+ };
1985
+
1986
+ module.exports.__wbg_call_89af060b4e1523f2 = function() { return handleError(function (arg0, arg1, arg2) {
1987
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1988
+ return addHeapObject(ret);
1989
+ }, arguments) };
1990
+
1991
+ module.exports.__wbg_isSafeInteger_7f1ed56200d90674 = function(arg0) {
1992
+ const ret = Number.isSafeInteger(getObject(arg0));
1993
+ return ret;
1994
+ };
1995
+
1996
+ module.exports.__wbg_buffer_b7b08af79b0b0974 = function(arg0) {
1997
+ const ret = getObject(arg0).buffer;
1998
+ return addHeapObject(ret);
1999
+ };
2000
+
2001
+ module.exports.__wbg_newwithbyteoffsetandlength_8a2cb9ca96b27ec9 = function(arg0, arg1, arg2) {
2002
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
2003
+ return addHeapObject(ret);
2004
+ };
2005
+
2006
+ module.exports.__wbg_new_ea1883e1e5e86686 = function(arg0) {
2007
+ const ret = new Uint8Array(getObject(arg0));
2008
+ return addHeapObject(ret);
2009
+ };
2010
+
2011
+ module.exports.__wbg_set_d1e79e2388520f18 = function(arg0, arg1, arg2) {
2012
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
2013
+ };
2014
+
2015
+ module.exports.__wbg_length_8339fcf5d8ecd12e = function(arg0) {
2016
+ const ret = getObject(arg0).length;
2017
+ return ret;
2018
+ };
2019
+
2020
+ module.exports.__wbg_instanceof_Uint8Array_247a91427532499e = function(arg0) {
2021
+ let result;
2022
+ try {
2023
+ result = getObject(arg0) instanceof Uint8Array;
2024
+ } catch (_) {
2025
+ result = false;
2026
+ }
2027
+ const ret = result;
2028
+ return ret;
2029
+ };
2030
+
2031
+ module.exports.__wbg_newwithlength_ec548f448387c968 = function(arg0) {
2032
+ const ret = new Uint8Array(arg0 >>> 0);
2033
+ return addHeapObject(ret);
2034
+ };
2035
+
2036
+ module.exports.__wbg_subarray_7c2e3576afe181d1 = function(arg0, arg1, arg2) {
2037
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
2038
+ return addHeapObject(ret);
2039
+ };
2040
+
2041
+ module.exports.__wbindgen_debug_string = function(arg0, arg1) {
2042
+ const ret = debugString(getObject(arg1));
2043
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2044
+ const len1 = WASM_VECTOR_LEN;
2045
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2046
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2047
+ };
2048
+
2049
+ module.exports.__wbindgen_throw = function(arg0, arg1) {
2050
+ throw new Error(getStringFromWasm0(arg0, arg1));
2051
+ };
2052
+
2053
+ module.exports.__wbindgen_memory = function() {
2054
+ const ret = wasm.memory;
2055
+ return addHeapObject(ret);
2056
+ };
2057
+
2058
+ const path = require('path').join(__dirname, 'kms_lib_bg.wasm');
2059
+ const bytes = require('fs').readFileSync(path);
2060
+
2061
+ const wasmModule = new WebAssembly.Module(bytes);
2062
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
2063
+ wasm = wasmInstance.exports;
2064
+ module.exports.__wasm = wasm;
2065
+