node-tkms 0.13.3 → 0.13.10-rc.1

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