node-tkms 0.13.0-rc.3 → 0.13.1

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