tkms 0.13.2 → 0.13.10-rc.0

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