node-tkms 0.13.0-rc.1 → 0.13.0-rc.3

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