@vollcrypt/messages-wasm 0.9.0 → 0.9.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/CHANGELOG.md +49 -0
- package/LICENSE +16 -0
- package/LICENSE-COMMERCIAL.md +71 -0
- package/LICENSE-GPL +674 -0
- package/README.md +679 -34
- package/fast.d.ts +2 -2
- package/package.json +25 -3
- package/pkg/README.md +705 -0
- package/pkg/wasm.d.ts +328 -0
- package/pkg/wasm.js +1835 -0
- package/pkg/wasm_bg.wasm +0 -0
- package/pkg/wasm_bg.wasm.d.ts +100 -0
package/pkg/wasm.js
ADDED
|
@@ -0,0 +1,1835 @@
|
|
|
1
|
+
/* @ts-self-types="./wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
export class AuthenticatedKemResult {
|
|
4
|
+
static __wrap(ptr) {
|
|
5
|
+
const obj = Object.create(AuthenticatedKemResult.prototype);
|
|
6
|
+
obj.__wbg_ptr = ptr;
|
|
7
|
+
AuthenticatedKemResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
8
|
+
return obj;
|
|
9
|
+
}
|
|
10
|
+
__destroy_into_raw() {
|
|
11
|
+
const ptr = this.__wbg_ptr;
|
|
12
|
+
this.__wbg_ptr = 0;
|
|
13
|
+
AuthenticatedKemResultFinalization.unregister(this);
|
|
14
|
+
return ptr;
|
|
15
|
+
}
|
|
16
|
+
free() {
|
|
17
|
+
const ptr = this.__destroy_into_raw();
|
|
18
|
+
wasm.__wbg_authenticatedkemresult_free(ptr, 0);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @returns {Uint8Array}
|
|
22
|
+
*/
|
|
23
|
+
get ciphertext() {
|
|
24
|
+
const ret = wasm.authenticatedkemresult_ciphertext(this.__wbg_ptr);
|
|
25
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
26
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
27
|
+
return v1;
|
|
28
|
+
}
|
|
29
|
+
free() {
|
|
30
|
+
const ptr = this.__destroy_into_raw();
|
|
31
|
+
wasm.authenticatedkemresult_free(ptr);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* WARNING: shared_secret should only be used in SRK derivation,
|
|
35
|
+
* and should not be used as an encryption key directly.
|
|
36
|
+
* @returns {Uint8Array}
|
|
37
|
+
*/
|
|
38
|
+
get shared_secret() {
|
|
39
|
+
const ret = wasm.authenticatedkemresult_shared_secret(this.__wbg_ptr);
|
|
40
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
41
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
42
|
+
return v1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (Symbol.dispose) AuthenticatedKemResult.prototype[Symbol.dispose] = AuthenticatedKemResult.prototype.free;
|
|
46
|
+
|
|
47
|
+
export class Ed25519KeyPairObj {
|
|
48
|
+
static __wrap(ptr) {
|
|
49
|
+
const obj = Object.create(Ed25519KeyPairObj.prototype);
|
|
50
|
+
obj.__wbg_ptr = ptr;
|
|
51
|
+
Ed25519KeyPairObjFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
52
|
+
return obj;
|
|
53
|
+
}
|
|
54
|
+
__destroy_into_raw() {
|
|
55
|
+
const ptr = this.__wbg_ptr;
|
|
56
|
+
this.__wbg_ptr = 0;
|
|
57
|
+
Ed25519KeyPairObjFinalization.unregister(this);
|
|
58
|
+
return ptr;
|
|
59
|
+
}
|
|
60
|
+
free() {
|
|
61
|
+
const ptr = this.__destroy_into_raw();
|
|
62
|
+
wasm.__wbg_ed25519keypairobj_free(ptr, 0);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @returns {Uint8Array}
|
|
66
|
+
*/
|
|
67
|
+
get public_key() {
|
|
68
|
+
const ret = wasm.ed25519keypairobj_public_key(this.__wbg_ptr);
|
|
69
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
70
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
71
|
+
return v1;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* @returns {Uint8Array}
|
|
75
|
+
*/
|
|
76
|
+
get secret_key() {
|
|
77
|
+
const ret = wasm.ed25519keypairobj_secret_key(this.__wbg_ptr);
|
|
78
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
79
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
80
|
+
return v1;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* @param {Uint8Array} message
|
|
84
|
+
* @returns {Uint8Array}
|
|
85
|
+
*/
|
|
86
|
+
sign(message) {
|
|
87
|
+
const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
88
|
+
const len0 = WASM_VECTOR_LEN;
|
|
89
|
+
const ret = wasm.ed25519keypairobj_sign(this.__wbg_ptr, ptr0, len0);
|
|
90
|
+
if (ret[3]) {
|
|
91
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
92
|
+
}
|
|
93
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
94
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
95
|
+
return v2;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (Symbol.dispose) Ed25519KeyPairObj.prototype[Symbol.dispose] = Ed25519KeyPairObj.prototype.free;
|
|
99
|
+
|
|
100
|
+
export class HybridKemResult {
|
|
101
|
+
static __wrap(ptr) {
|
|
102
|
+
const obj = Object.create(HybridKemResult.prototype);
|
|
103
|
+
obj.__wbg_ptr = ptr;
|
|
104
|
+
HybridKemResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
105
|
+
return obj;
|
|
106
|
+
}
|
|
107
|
+
__destroy_into_raw() {
|
|
108
|
+
const ptr = this.__wbg_ptr;
|
|
109
|
+
this.__wbg_ptr = 0;
|
|
110
|
+
HybridKemResultFinalization.unregister(this);
|
|
111
|
+
return ptr;
|
|
112
|
+
}
|
|
113
|
+
free() {
|
|
114
|
+
const ptr = this.__destroy_into_raw();
|
|
115
|
+
wasm.__wbg_hybridkemresult_free(ptr, 0);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* @returns {Uint8Array}
|
|
119
|
+
*/
|
|
120
|
+
get ml_kem_ciphertext() {
|
|
121
|
+
const ret = wasm.hybridkemresult_ml_kem_ciphertext(this.__wbg_ptr);
|
|
122
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
123
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
124
|
+
return v1;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* @returns {Uint8Array}
|
|
128
|
+
*/
|
|
129
|
+
get shared_key() {
|
|
130
|
+
const ret = wasm.hybridkemresult_shared_key(this.__wbg_ptr);
|
|
131
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
132
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
133
|
+
return v1;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (Symbol.dispose) HybridKemResult.prototype[Symbol.dispose] = HybridKemResult.prototype.free;
|
|
137
|
+
|
|
138
|
+
export class MlKemEncapsulationResult {
|
|
139
|
+
static __wrap(ptr) {
|
|
140
|
+
const obj = Object.create(MlKemEncapsulationResult.prototype);
|
|
141
|
+
obj.__wbg_ptr = ptr;
|
|
142
|
+
MlKemEncapsulationResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
143
|
+
return obj;
|
|
144
|
+
}
|
|
145
|
+
__destroy_into_raw() {
|
|
146
|
+
const ptr = this.__wbg_ptr;
|
|
147
|
+
this.__wbg_ptr = 0;
|
|
148
|
+
MlKemEncapsulationResultFinalization.unregister(this);
|
|
149
|
+
return ptr;
|
|
150
|
+
}
|
|
151
|
+
free() {
|
|
152
|
+
const ptr = this.__destroy_into_raw();
|
|
153
|
+
wasm.__wbg_mlkemencapsulationresult_free(ptr, 0);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* @returns {Uint8Array}
|
|
157
|
+
*/
|
|
158
|
+
get ciphertext() {
|
|
159
|
+
const ret = wasm.mlkemencapsulationresult_ciphertext(this.__wbg_ptr);
|
|
160
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
161
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
162
|
+
return v1;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* @returns {Uint8Array}
|
|
166
|
+
*/
|
|
167
|
+
get shared_secret() {
|
|
168
|
+
const ret = wasm.mlkemencapsulationresult_shared_secret(this.__wbg_ptr);
|
|
169
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
170
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
171
|
+
return v1;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (Symbol.dispose) MlKemEncapsulationResult.prototype[Symbol.dispose] = MlKemEncapsulationResult.prototype.free;
|
|
175
|
+
|
|
176
|
+
export class MlKemKeyPairObj {
|
|
177
|
+
static __wrap(ptr) {
|
|
178
|
+
const obj = Object.create(MlKemKeyPairObj.prototype);
|
|
179
|
+
obj.__wbg_ptr = ptr;
|
|
180
|
+
MlKemKeyPairObjFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
181
|
+
return obj;
|
|
182
|
+
}
|
|
183
|
+
__destroy_into_raw() {
|
|
184
|
+
const ptr = this.__wbg_ptr;
|
|
185
|
+
this.__wbg_ptr = 0;
|
|
186
|
+
MlKemKeyPairObjFinalization.unregister(this);
|
|
187
|
+
return ptr;
|
|
188
|
+
}
|
|
189
|
+
free() {
|
|
190
|
+
const ptr = this.__destroy_into_raw();
|
|
191
|
+
wasm.__wbg_mlkemkeypairobj_free(ptr, 0);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* @returns {Uint8Array}
|
|
195
|
+
*/
|
|
196
|
+
get decapsulation_key() {
|
|
197
|
+
const ret = wasm.mlkemkeypairobj_decapsulation_key(this.__wbg_ptr);
|
|
198
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
199
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
200
|
+
return v1;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* @returns {Uint8Array}
|
|
204
|
+
*/
|
|
205
|
+
get encapsulation_key() {
|
|
206
|
+
const ret = wasm.mlkemkeypairobj_encapsulation_key(this.__wbg_ptr);
|
|
207
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
208
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
209
|
+
return v1;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (Symbol.dispose) MlKemKeyPairObj.prototype[Symbol.dispose] = MlKemKeyPairObj.prototype.free;
|
|
213
|
+
|
|
214
|
+
export class RatchetKeyPairObj {
|
|
215
|
+
static __wrap(ptr) {
|
|
216
|
+
const obj = Object.create(RatchetKeyPairObj.prototype);
|
|
217
|
+
obj.__wbg_ptr = ptr;
|
|
218
|
+
RatchetKeyPairObjFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
219
|
+
return obj;
|
|
220
|
+
}
|
|
221
|
+
__destroy_into_raw() {
|
|
222
|
+
const ptr = this.__wbg_ptr;
|
|
223
|
+
this.__wbg_ptr = 0;
|
|
224
|
+
RatchetKeyPairObjFinalization.unregister(this);
|
|
225
|
+
return ptr;
|
|
226
|
+
}
|
|
227
|
+
free() {
|
|
228
|
+
const ptr = this.__destroy_into_raw();
|
|
229
|
+
wasm.__wbg_ratchetkeypairobj_free(ptr, 0);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Computes SRK ratchet using this key pair.
|
|
233
|
+
* secret_key never crosses the WASM boundary.
|
|
234
|
+
* @param {Uint8Array} current_srk
|
|
235
|
+
* @param {Uint8Array} their_ratchet_pub
|
|
236
|
+
* @param {Uint8Array} chat_id
|
|
237
|
+
* @param {number} ratchet_step
|
|
238
|
+
* @returns {Uint8Array}
|
|
239
|
+
*/
|
|
240
|
+
compute_ratchet(current_srk, their_ratchet_pub, chat_id, ratchet_step) {
|
|
241
|
+
const ptr0 = passArray8ToWasm0(current_srk, wasm.__wbindgen_malloc);
|
|
242
|
+
const len0 = WASM_VECTOR_LEN;
|
|
243
|
+
const ptr1 = passArray8ToWasm0(their_ratchet_pub, wasm.__wbindgen_malloc);
|
|
244
|
+
const len1 = WASM_VECTOR_LEN;
|
|
245
|
+
const ptr2 = passArray8ToWasm0(chat_id, wasm.__wbindgen_malloc);
|
|
246
|
+
const len2 = WASM_VECTOR_LEN;
|
|
247
|
+
const ret = wasm.ratchetkeypairobj_compute_ratchet(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ratchet_step);
|
|
248
|
+
if (ret[3]) {
|
|
249
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
250
|
+
}
|
|
251
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
252
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
253
|
+
return v4;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* @returns {Uint8Array}
|
|
257
|
+
*/
|
|
258
|
+
get public_key() {
|
|
259
|
+
const ret = wasm.ratchetkeypairobj_public_key(this.__wbg_ptr);
|
|
260
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
261
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
262
|
+
return v1;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (Symbol.dispose) RatchetKeyPairObj.prototype[Symbol.dispose] = RatchetKeyPairObj.prototype.free;
|
|
266
|
+
|
|
267
|
+
export class UnpackedEnvelope {
|
|
268
|
+
static __wrap(ptr) {
|
|
269
|
+
const obj = Object.create(UnpackedEnvelope.prototype);
|
|
270
|
+
obj.__wbg_ptr = ptr;
|
|
271
|
+
UnpackedEnvelopeFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
272
|
+
return obj;
|
|
273
|
+
}
|
|
274
|
+
__destroy_into_raw() {
|
|
275
|
+
const ptr = this.__wbg_ptr;
|
|
276
|
+
this.__wbg_ptr = 0;
|
|
277
|
+
UnpackedEnvelopeFinalization.unregister(this);
|
|
278
|
+
return ptr;
|
|
279
|
+
}
|
|
280
|
+
free() {
|
|
281
|
+
const ptr = this.__destroy_into_raw();
|
|
282
|
+
wasm.__wbg_unpackedenvelope_free(ptr, 0);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* @returns {number}
|
|
286
|
+
*/
|
|
287
|
+
get window_index() {
|
|
288
|
+
const ret = wasm.__wbg_get_unpackedenvelope_window_index(this.__wbg_ptr);
|
|
289
|
+
return ret >>> 0;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* @param {number} arg0
|
|
293
|
+
*/
|
|
294
|
+
set window_index(arg0) {
|
|
295
|
+
wasm.__wbg_set_unpackedenvelope_window_index(this.__wbg_ptr, arg0);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* @returns {Uint8Array}
|
|
299
|
+
*/
|
|
300
|
+
get aad_hash() {
|
|
301
|
+
const ret = wasm.unpackedenvelope_aad_hash(this.__wbg_ptr);
|
|
302
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
303
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
304
|
+
return v1;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* @returns {Uint8Array}
|
|
308
|
+
*/
|
|
309
|
+
get encrypted_blob() {
|
|
310
|
+
const ret = wasm.unpackedenvelope_encrypted_blob(this.__wbg_ptr);
|
|
311
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
312
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
313
|
+
return v1;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (Symbol.dispose) UnpackedEnvelope.prototype[Symbol.dispose] = UnpackedEnvelope.prototype.free;
|
|
317
|
+
|
|
318
|
+
export class UnsealResult {
|
|
319
|
+
static __wrap(ptr) {
|
|
320
|
+
const obj = Object.create(UnsealResult.prototype);
|
|
321
|
+
obj.__wbg_ptr = ptr;
|
|
322
|
+
UnsealResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
323
|
+
return obj;
|
|
324
|
+
}
|
|
325
|
+
__destroy_into_raw() {
|
|
326
|
+
const ptr = this.__wbg_ptr;
|
|
327
|
+
this.__wbg_ptr = 0;
|
|
328
|
+
UnsealResultFinalization.unregister(this);
|
|
329
|
+
return ptr;
|
|
330
|
+
}
|
|
331
|
+
free() {
|
|
332
|
+
const ptr = this.__destroy_into_raw();
|
|
333
|
+
wasm.__wbg_unsealresult_free(ptr, 0);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* @returns {Uint8Array}
|
|
337
|
+
*/
|
|
338
|
+
get content() {
|
|
339
|
+
const ret = wasm.unsealresult_content(this.__wbg_ptr);
|
|
340
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
341
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
342
|
+
return v1;
|
|
343
|
+
}
|
|
344
|
+
free() {
|
|
345
|
+
const ptr = this.__destroy_into_raw();
|
|
346
|
+
wasm.unsealresult_free(ptr);
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* @returns {Uint8Array}
|
|
350
|
+
*/
|
|
351
|
+
get sender_id() {
|
|
352
|
+
const ret = wasm.unsealresult_sender_id(this.__wbg_ptr);
|
|
353
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
354
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
355
|
+
return v1;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (Symbol.dispose) UnsealResult.prototype[Symbol.dispose] = UnsealResult.prototype.free;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Verification code result (for WASM)
|
|
362
|
+
*/
|
|
363
|
+
export class VerificationCodeResult {
|
|
364
|
+
static __wrap(ptr) {
|
|
365
|
+
const obj = Object.create(VerificationCodeResult.prototype);
|
|
366
|
+
obj.__wbg_ptr = ptr;
|
|
367
|
+
VerificationCodeResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
368
|
+
return obj;
|
|
369
|
+
}
|
|
370
|
+
__destroy_into_raw() {
|
|
371
|
+
const ptr = this.__wbg_ptr;
|
|
372
|
+
this.__wbg_ptr = 0;
|
|
373
|
+
VerificationCodeResultFinalization.unregister(this);
|
|
374
|
+
return ptr;
|
|
375
|
+
}
|
|
376
|
+
free() {
|
|
377
|
+
const ptr = this.__destroy_into_raw();
|
|
378
|
+
wasm.__wbg_verificationcoderesult_free(ptr, 0);
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* @returns {string}
|
|
382
|
+
*/
|
|
383
|
+
get emoji_formatted() {
|
|
384
|
+
let deferred1_0;
|
|
385
|
+
let deferred1_1;
|
|
386
|
+
try {
|
|
387
|
+
const ret = wasm.verificationcoderesult_emoji_formatted(this.__wbg_ptr);
|
|
388
|
+
deferred1_0 = ret[0];
|
|
389
|
+
deferred1_1 = ret[1];
|
|
390
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
391
|
+
} finally {
|
|
392
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* @returns {Uint8Array}
|
|
397
|
+
*/
|
|
398
|
+
get fingerprint() {
|
|
399
|
+
const ret = wasm.verificationcoderesult_fingerprint(this.__wbg_ptr);
|
|
400
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
401
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
402
|
+
return v1;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* @returns {string}
|
|
406
|
+
*/
|
|
407
|
+
get numeric_digits() {
|
|
408
|
+
let deferred1_0;
|
|
409
|
+
let deferred1_1;
|
|
410
|
+
try {
|
|
411
|
+
const ret = wasm.verificationcoderesult_numeric_digits(this.__wbg_ptr);
|
|
412
|
+
deferred1_0 = ret[0];
|
|
413
|
+
deferred1_1 = ret[1];
|
|
414
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
415
|
+
} finally {
|
|
416
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* @returns {string}
|
|
421
|
+
*/
|
|
422
|
+
get numeric_formatted() {
|
|
423
|
+
let deferred1_0;
|
|
424
|
+
let deferred1_1;
|
|
425
|
+
try {
|
|
426
|
+
const ret = wasm.verificationcoderesult_numeric_formatted(this.__wbg_ptr);
|
|
427
|
+
deferred1_0 = ret[0];
|
|
428
|
+
deferred1_1 = ret[1];
|
|
429
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
430
|
+
} finally {
|
|
431
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
if (Symbol.dispose) VerificationCodeResult.prototype[Symbol.dispose] = VerificationCodeResult.prototype.free;
|
|
436
|
+
|
|
437
|
+
export class X25519KeyPairObj {
|
|
438
|
+
static __wrap(ptr) {
|
|
439
|
+
const obj = Object.create(X25519KeyPairObj.prototype);
|
|
440
|
+
obj.__wbg_ptr = ptr;
|
|
441
|
+
X25519KeyPairObjFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
442
|
+
return obj;
|
|
443
|
+
}
|
|
444
|
+
__destroy_into_raw() {
|
|
445
|
+
const ptr = this.__wbg_ptr;
|
|
446
|
+
this.__wbg_ptr = 0;
|
|
447
|
+
X25519KeyPairObjFinalization.unregister(this);
|
|
448
|
+
return ptr;
|
|
449
|
+
}
|
|
450
|
+
free() {
|
|
451
|
+
const ptr = this.__destroy_into_raw();
|
|
452
|
+
wasm.__wbg_x25519keypairobj_free(ptr, 0);
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* @returns {Uint8Array}
|
|
456
|
+
*/
|
|
457
|
+
get public() {
|
|
458
|
+
const ret = wasm.x25519keypairobj_public(this.__wbg_ptr);
|
|
459
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
460
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
461
|
+
return v1;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* @returns {Uint8Array}
|
|
465
|
+
*/
|
|
466
|
+
get secret() {
|
|
467
|
+
const ret = wasm.x25519keypairobj_secret(this.__wbg_ptr);
|
|
468
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
469
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
470
|
+
return v1;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
if (Symbol.dispose) X25519KeyPairObj.prototype[Symbol.dispose] = X25519KeyPairObj.prototype.free;
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* @param {Uint8Array} our_x25519_sk
|
|
477
|
+
* @param {Uint8Array} sender_x25519_pub
|
|
478
|
+
* @param {Uint8Array} our_mlkem_dk
|
|
479
|
+
* @param {Uint8Array} authenticated_ciphertext
|
|
480
|
+
* @param {Uint8Array} sender_identity_pk
|
|
481
|
+
* @returns {Uint8Array}
|
|
482
|
+
*/
|
|
483
|
+
export function authenticated_kem_decapsulate(our_x25519_sk, sender_x25519_pub, our_mlkem_dk, authenticated_ciphertext, sender_identity_pk) {
|
|
484
|
+
const ptr0 = passArray8ToWasm0(our_x25519_sk, wasm.__wbindgen_malloc);
|
|
485
|
+
const len0 = WASM_VECTOR_LEN;
|
|
486
|
+
const ptr1 = passArray8ToWasm0(sender_x25519_pub, wasm.__wbindgen_malloc);
|
|
487
|
+
const len1 = WASM_VECTOR_LEN;
|
|
488
|
+
const ptr2 = passArray8ToWasm0(our_mlkem_dk, wasm.__wbindgen_malloc);
|
|
489
|
+
const len2 = WASM_VECTOR_LEN;
|
|
490
|
+
const ptr3 = passArray8ToWasm0(authenticated_ciphertext, wasm.__wbindgen_malloc);
|
|
491
|
+
const len3 = WASM_VECTOR_LEN;
|
|
492
|
+
const ptr4 = passArray8ToWasm0(sender_identity_pk, wasm.__wbindgen_malloc);
|
|
493
|
+
const len4 = WASM_VECTOR_LEN;
|
|
494
|
+
const ret = wasm.authenticated_kem_decapsulate(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
495
|
+
if (ret[2]) {
|
|
496
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
497
|
+
}
|
|
498
|
+
return takeFromExternrefTable0(ret[0]);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* @param {Uint8Array} our_x25519_sk
|
|
503
|
+
* @param {Uint8Array} recipient_x25519_pub
|
|
504
|
+
* @param {Uint8Array} recipient_mlkem_pub
|
|
505
|
+
* @param {Uint8Array} sender_identity_sk
|
|
506
|
+
* @returns {AuthenticatedKemResult}
|
|
507
|
+
*/
|
|
508
|
+
export function authenticated_kem_encapsulate(our_x25519_sk, recipient_x25519_pub, recipient_mlkem_pub, sender_identity_sk) {
|
|
509
|
+
const ptr0 = passArray8ToWasm0(our_x25519_sk, wasm.__wbindgen_malloc);
|
|
510
|
+
const len0 = WASM_VECTOR_LEN;
|
|
511
|
+
const ptr1 = passArray8ToWasm0(recipient_x25519_pub, wasm.__wbindgen_malloc);
|
|
512
|
+
const len1 = WASM_VECTOR_LEN;
|
|
513
|
+
const ptr2 = passArray8ToWasm0(recipient_mlkem_pub, wasm.__wbindgen_malloc);
|
|
514
|
+
const len2 = WASM_VECTOR_LEN;
|
|
515
|
+
const ptr3 = passArray8ToWasm0(sender_identity_sk, wasm.__wbindgen_malloc);
|
|
516
|
+
const len3 = WASM_VECTOR_LEN;
|
|
517
|
+
const ret = wasm.authenticated_kem_encapsulate(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
518
|
+
if (ret[2]) {
|
|
519
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
520
|
+
}
|
|
521
|
+
return AuthenticatedKemResult.__wrap(ret[0]);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* @param {Uint8Array} key_a
|
|
526
|
+
* @param {Uint8Array} key_b
|
|
527
|
+
* @param {Uint8Array} conversation_id
|
|
528
|
+
* @returns {Uint8Array}
|
|
529
|
+
*/
|
|
530
|
+
export function compute_fingerprint(key_a, key_b, conversation_id) {
|
|
531
|
+
const ptr0 = passArray8ToWasm0(key_a, wasm.__wbindgen_malloc);
|
|
532
|
+
const len0 = WASM_VECTOR_LEN;
|
|
533
|
+
const ptr1 = passArray8ToWasm0(key_b, wasm.__wbindgen_malloc);
|
|
534
|
+
const len1 = WASM_VECTOR_LEN;
|
|
535
|
+
const ptr2 = passArray8ToWasm0(conversation_id, wasm.__wbindgen_malloc);
|
|
536
|
+
const len2 = WASM_VECTOR_LEN;
|
|
537
|
+
const ret = wasm.compute_fingerprint(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
538
|
+
if (ret[3]) {
|
|
539
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
540
|
+
}
|
|
541
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
542
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
543
|
+
return v4;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* @param {Uint8Array} key
|
|
548
|
+
* @param {Uint8Array} ciphertext
|
|
549
|
+
* @param {Uint8Array | null} [aad]
|
|
550
|
+
* @returns {Uint8Array}
|
|
551
|
+
*/
|
|
552
|
+
export function decrypt_aes_gcm(key, ciphertext, aad) {
|
|
553
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
554
|
+
const len0 = WASM_VECTOR_LEN;
|
|
555
|
+
const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
556
|
+
const len1 = WASM_VECTOR_LEN;
|
|
557
|
+
var ptr2 = isLikeNone(aad) ? 0 : passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
558
|
+
var len2 = WASM_VECTOR_LEN;
|
|
559
|
+
const ret = wasm.decrypt_aes_gcm(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
560
|
+
if (ret[2]) {
|
|
561
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
562
|
+
}
|
|
563
|
+
return takeFromExternrefTable0(ret[0]);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* @param {Uint8Array} key
|
|
568
|
+
* @param {Uint8Array} ciphertext
|
|
569
|
+
* @param {Uint8Array | null} [aad]
|
|
570
|
+
* @returns {Uint8Array}
|
|
571
|
+
*/
|
|
572
|
+
export function decrypt_aes_gcm_chunked(key, ciphertext, aad) {
|
|
573
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
574
|
+
const len0 = WASM_VECTOR_LEN;
|
|
575
|
+
const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
576
|
+
const len1 = WASM_VECTOR_LEN;
|
|
577
|
+
var ptr2 = isLikeNone(aad) ? 0 : passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
578
|
+
var len2 = WASM_VECTOR_LEN;
|
|
579
|
+
const ret = wasm.decrypt_aes_gcm_chunked(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
580
|
+
if (ret[2]) {
|
|
581
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
582
|
+
}
|
|
583
|
+
return takeFromExternrefTable0(ret[0]);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* @param {Uint8Array} key
|
|
588
|
+
* @param {Uint8Array} ciphertext
|
|
589
|
+
* @param {Uint8Array | null} [aad]
|
|
590
|
+
* @returns {Uint8Array}
|
|
591
|
+
*/
|
|
592
|
+
export function decrypt_aes_gcm_chunked_padded(key, ciphertext, aad) {
|
|
593
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
594
|
+
const len0 = WASM_VECTOR_LEN;
|
|
595
|
+
const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
596
|
+
const len1 = WASM_VECTOR_LEN;
|
|
597
|
+
var ptr2 = isLikeNone(aad) ? 0 : passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
598
|
+
var len2 = WASM_VECTOR_LEN;
|
|
599
|
+
const ret = wasm.decrypt_aes_gcm_chunked_padded(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
600
|
+
if (ret[2]) {
|
|
601
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
602
|
+
}
|
|
603
|
+
return takeFromExternrefTable0(ret[0]);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* @param {Uint8Array} key
|
|
608
|
+
* @param {Uint8Array} ciphertext
|
|
609
|
+
* @param {Uint8Array | null} [aad]
|
|
610
|
+
* @returns {Uint8Array}
|
|
611
|
+
*/
|
|
612
|
+
export function decrypt_aes_gcm_padded(key, ciphertext, aad) {
|
|
613
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
614
|
+
const len0 = WASM_VECTOR_LEN;
|
|
615
|
+
const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
616
|
+
const len1 = WASM_VECTOR_LEN;
|
|
617
|
+
var ptr2 = isLikeNone(aad) ? 0 : passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
618
|
+
var len2 = WASM_VECTOR_LEN;
|
|
619
|
+
const ret = wasm.decrypt_aes_gcm_padded(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
620
|
+
if (ret[2]) {
|
|
621
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
622
|
+
}
|
|
623
|
+
return takeFromExternrefTable0(ret[0]);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* @param {Uint8Array} ikm
|
|
628
|
+
* @param {Uint8Array | null | undefined} salt
|
|
629
|
+
* @param {Uint8Array | null | undefined} info
|
|
630
|
+
* @param {number} key_len
|
|
631
|
+
* @returns {Uint8Array}
|
|
632
|
+
*/
|
|
633
|
+
export function derive_hkdf(ikm, salt, info, key_len) {
|
|
634
|
+
const ptr0 = passArray8ToWasm0(ikm, wasm.__wbindgen_malloc);
|
|
635
|
+
const len0 = WASM_VECTOR_LEN;
|
|
636
|
+
var ptr1 = isLikeNone(salt) ? 0 : passArray8ToWasm0(salt, wasm.__wbindgen_malloc);
|
|
637
|
+
var len1 = WASM_VECTOR_LEN;
|
|
638
|
+
var ptr2 = isLikeNone(info) ? 0 : passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
639
|
+
var len2 = WASM_VECTOR_LEN;
|
|
640
|
+
const ret = wasm.derive_hkdf(ptr0, len0, ptr1, len1, ptr2, len2, key_len);
|
|
641
|
+
if (ret[2]) {
|
|
642
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
643
|
+
}
|
|
644
|
+
return takeFromExternrefTable0(ret[0]);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* @param {Uint8Array} password
|
|
649
|
+
* @param {Uint8Array} salt
|
|
650
|
+
* @param {number} iterations
|
|
651
|
+
* @param {number} key_len
|
|
652
|
+
* @returns {Uint8Array}
|
|
653
|
+
*/
|
|
654
|
+
export function derive_pbkdf2(password, salt, iterations, key_len) {
|
|
655
|
+
const ptr0 = passArray8ToWasm0(password, wasm.__wbindgen_malloc);
|
|
656
|
+
const len0 = WASM_VECTOR_LEN;
|
|
657
|
+
const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_malloc);
|
|
658
|
+
const len1 = WASM_VECTOR_LEN;
|
|
659
|
+
const ret = wasm.derive_pbkdf2(ptr0, len0, ptr1, len1, iterations, key_len);
|
|
660
|
+
if (ret[2]) {
|
|
661
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
662
|
+
}
|
|
663
|
+
return takeFromExternrefTable0(ret[0]);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* @param {Uint8Array} dek
|
|
668
|
+
* @param {Uint8Array} chat_id
|
|
669
|
+
* @returns {Uint8Array}
|
|
670
|
+
*/
|
|
671
|
+
export function derive_srk(dek, chat_id) {
|
|
672
|
+
const ptr0 = passArray8ToWasm0(dek, wasm.__wbindgen_malloc);
|
|
673
|
+
const len0 = WASM_VECTOR_LEN;
|
|
674
|
+
const ptr1 = passArray8ToWasm0(chat_id, wasm.__wbindgen_malloc);
|
|
675
|
+
const len1 = WASM_VECTOR_LEN;
|
|
676
|
+
const ret = wasm.derive_srk(ptr0, len0, ptr1, len1);
|
|
677
|
+
if (ret[2]) {
|
|
678
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
679
|
+
}
|
|
680
|
+
return takeFromExternrefTable0(ret[0]);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* @param {Uint8Array} srk
|
|
685
|
+
* @param {number} window_index
|
|
686
|
+
* @returns {Uint8Array}
|
|
687
|
+
*/
|
|
688
|
+
export function derive_window_key(srk, window_index) {
|
|
689
|
+
const ptr0 = passArray8ToWasm0(srk, wasm.__wbindgen_malloc);
|
|
690
|
+
const len0 = WASM_VECTOR_LEN;
|
|
691
|
+
const ret = wasm.derive_window_key(ptr0, len0, window_index);
|
|
692
|
+
if (ret[2]) {
|
|
693
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
694
|
+
}
|
|
695
|
+
return takeFromExternrefTable0(ret[0]);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* @param {Uint8Array} our_secret
|
|
700
|
+
* @param {Uint8Array} their_public
|
|
701
|
+
* @returns {Uint8Array}
|
|
702
|
+
*/
|
|
703
|
+
export function ecdh_shared_secret(our_secret, their_public) {
|
|
704
|
+
const ptr0 = passArray8ToWasm0(our_secret, wasm.__wbindgen_malloc);
|
|
705
|
+
const len0 = WASM_VECTOR_LEN;
|
|
706
|
+
const ptr1 = passArray8ToWasm0(their_public, wasm.__wbindgen_malloc);
|
|
707
|
+
const len1 = WASM_VECTOR_LEN;
|
|
708
|
+
const ret = wasm.ecdh_shared_secret(ptr0, len0, ptr1, len1);
|
|
709
|
+
if (ret[2]) {
|
|
710
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
711
|
+
}
|
|
712
|
+
return takeFromExternrefTable0(ret[0]);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* @param {Uint8Array} key
|
|
717
|
+
* @param {Uint8Array} plaintext
|
|
718
|
+
* @param {Uint8Array | null} [aad]
|
|
719
|
+
* @returns {Uint8Array}
|
|
720
|
+
*/
|
|
721
|
+
export function encrypt_aes_gcm(key, plaintext, aad) {
|
|
722
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
723
|
+
const len0 = WASM_VECTOR_LEN;
|
|
724
|
+
const ptr1 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
725
|
+
const len1 = WASM_VECTOR_LEN;
|
|
726
|
+
var ptr2 = isLikeNone(aad) ? 0 : passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
727
|
+
var len2 = WASM_VECTOR_LEN;
|
|
728
|
+
const ret = wasm.encrypt_aes_gcm(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
729
|
+
if (ret[3]) {
|
|
730
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
731
|
+
}
|
|
732
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
733
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
734
|
+
return v4;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* @param {Uint8Array} key
|
|
739
|
+
* @param {Uint8Array} plaintext
|
|
740
|
+
* @param {Uint8Array | null | undefined} aad
|
|
741
|
+
* @param {number} chunk_size
|
|
742
|
+
* @returns {Uint8Array}
|
|
743
|
+
*/
|
|
744
|
+
export function encrypt_aes_gcm_chunked(key, plaintext, aad, chunk_size) {
|
|
745
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
746
|
+
const len0 = WASM_VECTOR_LEN;
|
|
747
|
+
const ptr1 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
748
|
+
const len1 = WASM_VECTOR_LEN;
|
|
749
|
+
var ptr2 = isLikeNone(aad) ? 0 : passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
750
|
+
var len2 = WASM_VECTOR_LEN;
|
|
751
|
+
const ret = wasm.encrypt_aes_gcm_chunked(ptr0, len0, ptr1, len1, ptr2, len2, chunk_size);
|
|
752
|
+
if (ret[3]) {
|
|
753
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
754
|
+
}
|
|
755
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
756
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
757
|
+
return v4;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* @param {Uint8Array} key
|
|
762
|
+
* @param {Uint8Array} plaintext
|
|
763
|
+
* @param {Uint8Array | null | undefined} aad
|
|
764
|
+
* @param {number} chunk_size
|
|
765
|
+
* @returns {Uint8Array}
|
|
766
|
+
*/
|
|
767
|
+
export function encrypt_aes_gcm_chunked_padded(key, plaintext, aad, chunk_size) {
|
|
768
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
769
|
+
const len0 = WASM_VECTOR_LEN;
|
|
770
|
+
const ptr1 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
771
|
+
const len1 = WASM_VECTOR_LEN;
|
|
772
|
+
var ptr2 = isLikeNone(aad) ? 0 : passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
773
|
+
var len2 = WASM_VECTOR_LEN;
|
|
774
|
+
const ret = wasm.encrypt_aes_gcm_chunked_padded(ptr0, len0, ptr1, len1, ptr2, len2, chunk_size);
|
|
775
|
+
if (ret[3]) {
|
|
776
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
777
|
+
}
|
|
778
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
779
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
780
|
+
return v4;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* @param {Uint8Array} key
|
|
785
|
+
* @param {Uint8Array} plaintext
|
|
786
|
+
* @param {Uint8Array | null} [aad]
|
|
787
|
+
* @returns {Uint8Array}
|
|
788
|
+
*/
|
|
789
|
+
export function encrypt_aes_gcm_padded(key, plaintext, aad) {
|
|
790
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
791
|
+
const len0 = WASM_VECTOR_LEN;
|
|
792
|
+
const ptr1 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
793
|
+
const len1 = WASM_VECTOR_LEN;
|
|
794
|
+
var ptr2 = isLikeNone(aad) ? 0 : passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
795
|
+
var len2 = WASM_VECTOR_LEN;
|
|
796
|
+
const ret = wasm.encrypt_aes_gcm_padded(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
797
|
+
if (ret[3]) {
|
|
798
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
799
|
+
}
|
|
800
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
801
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
802
|
+
return v4;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* @returns {Ed25519KeyPairObj}
|
|
807
|
+
*/
|
|
808
|
+
export function generate_ed25519_keypair() {
|
|
809
|
+
const ret = wasm.generate_ed25519_keypair();
|
|
810
|
+
return Ed25519KeyPairObj.__wrap(ret);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* @returns {string}
|
|
815
|
+
*/
|
|
816
|
+
export function generate_mnemonic() {
|
|
817
|
+
let deferred1_0;
|
|
818
|
+
let deferred1_1;
|
|
819
|
+
try {
|
|
820
|
+
const ret = wasm.generate_mnemonic();
|
|
821
|
+
deferred1_0 = ret[0];
|
|
822
|
+
deferred1_1 = ret[1];
|
|
823
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
824
|
+
} finally {
|
|
825
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* @returns {RatchetKeyPairObj}
|
|
831
|
+
*/
|
|
832
|
+
export function generate_ratchet_keypair() {
|
|
833
|
+
const ret = wasm.generate_ratchet_keypair();
|
|
834
|
+
if (ret[2]) {
|
|
835
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
836
|
+
}
|
|
837
|
+
return RatchetKeyPairObj.__wrap(ret[0]);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* @param {Uint8Array} key_a
|
|
842
|
+
* @param {Uint8Array} key_b
|
|
843
|
+
* @param {Uint8Array} conversation_id
|
|
844
|
+
* @returns {VerificationCodeResult}
|
|
845
|
+
*/
|
|
846
|
+
export function generate_verification_code(key_a, key_b, conversation_id) {
|
|
847
|
+
const ptr0 = passArray8ToWasm0(key_a, wasm.__wbindgen_malloc);
|
|
848
|
+
const len0 = WASM_VECTOR_LEN;
|
|
849
|
+
const ptr1 = passArray8ToWasm0(key_b, wasm.__wbindgen_malloc);
|
|
850
|
+
const len1 = WASM_VECTOR_LEN;
|
|
851
|
+
const ptr2 = passArray8ToWasm0(conversation_id, wasm.__wbindgen_malloc);
|
|
852
|
+
const len2 = WASM_VECTOR_LEN;
|
|
853
|
+
const ret = wasm.generate_verification_code(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
854
|
+
if (ret[2]) {
|
|
855
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
856
|
+
}
|
|
857
|
+
return VerificationCodeResult.__wrap(ret[0]);
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* @returns {X25519KeyPairObj}
|
|
862
|
+
*/
|
|
863
|
+
export function generate_x25519_keypair() {
|
|
864
|
+
const ret = wasm.generate_x25519_keypair();
|
|
865
|
+
return X25519KeyPairObj.__wrap(ret);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* @param {Uint8Array} x25519_our_secret
|
|
870
|
+
* @param {Uint8Array} x25519_their_public
|
|
871
|
+
* @param {Uint8Array} ml_kem_dk
|
|
872
|
+
* @param {Uint8Array} ml_kem_ct
|
|
873
|
+
* @returns {Uint8Array}
|
|
874
|
+
*/
|
|
875
|
+
export function hybrid_kem_decapsulate(x25519_our_secret, x25519_their_public, ml_kem_dk, ml_kem_ct) {
|
|
876
|
+
const ptr0 = passArray8ToWasm0(x25519_our_secret, wasm.__wbindgen_malloc);
|
|
877
|
+
const len0 = WASM_VECTOR_LEN;
|
|
878
|
+
const ptr1 = passArray8ToWasm0(x25519_their_public, wasm.__wbindgen_malloc);
|
|
879
|
+
const len1 = WASM_VECTOR_LEN;
|
|
880
|
+
const ptr2 = passArray8ToWasm0(ml_kem_dk, wasm.__wbindgen_malloc);
|
|
881
|
+
const len2 = WASM_VECTOR_LEN;
|
|
882
|
+
const ptr3 = passArray8ToWasm0(ml_kem_ct, wasm.__wbindgen_malloc);
|
|
883
|
+
const len3 = WASM_VECTOR_LEN;
|
|
884
|
+
const ret = wasm.hybrid_kem_decapsulate(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
885
|
+
if (ret[2]) {
|
|
886
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
887
|
+
}
|
|
888
|
+
return takeFromExternrefTable0(ret[0]);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* @param {Uint8Array} x25519_our_secret
|
|
893
|
+
* @param {Uint8Array} x25519_their_public
|
|
894
|
+
* @param {Uint8Array} ml_kem_ek
|
|
895
|
+
* @returns {HybridKemResult}
|
|
896
|
+
*/
|
|
897
|
+
export function hybrid_kem_encapsulate(x25519_our_secret, x25519_their_public, ml_kem_ek) {
|
|
898
|
+
const ptr0 = passArray8ToWasm0(x25519_our_secret, wasm.__wbindgen_malloc);
|
|
899
|
+
const len0 = WASM_VECTOR_LEN;
|
|
900
|
+
const ptr1 = passArray8ToWasm0(x25519_their_public, wasm.__wbindgen_malloc);
|
|
901
|
+
const len1 = WASM_VECTOR_LEN;
|
|
902
|
+
const ptr2 = passArray8ToWasm0(ml_kem_ek, wasm.__wbindgen_malloc);
|
|
903
|
+
const len2 = WASM_VECTOR_LEN;
|
|
904
|
+
const ret = wasm.hybrid_kem_encapsulate(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
905
|
+
if (ret[2]) {
|
|
906
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
907
|
+
}
|
|
908
|
+
return HybridKemResult.__wrap(ret[0]);
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
export function init_logger() {
|
|
912
|
+
wasm.init_logger();
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* @param {string} entry_json
|
|
917
|
+
* @returns {Uint8Array}
|
|
918
|
+
*/
|
|
919
|
+
export function key_log_compute_entry_hash(entry_json) {
|
|
920
|
+
const ptr0 = passStringToWasm0(entry_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
921
|
+
const len0 = WASM_VECTOR_LEN;
|
|
922
|
+
const ret = wasm.key_log_compute_entry_hash(ptr0, len0);
|
|
923
|
+
if (ret[3]) {
|
|
924
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
925
|
+
}
|
|
926
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
927
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
928
|
+
return v2;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* @param {Uint8Array} user_id
|
|
933
|
+
* @param {Uint8Array} public_key
|
|
934
|
+
* @param {number} timestamp
|
|
935
|
+
* @param {Uint8Array} prev_entry_hash
|
|
936
|
+
* @param {number} action
|
|
937
|
+
* @param {Uint8Array} signing_key
|
|
938
|
+
* @returns {string}
|
|
939
|
+
*/
|
|
940
|
+
export function key_log_create_entry(user_id, public_key, timestamp, prev_entry_hash, action, signing_key) {
|
|
941
|
+
let deferred6_0;
|
|
942
|
+
let deferred6_1;
|
|
943
|
+
try {
|
|
944
|
+
const ptr0 = passArray8ToWasm0(user_id, wasm.__wbindgen_malloc);
|
|
945
|
+
const len0 = WASM_VECTOR_LEN;
|
|
946
|
+
const ptr1 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
947
|
+
const len1 = WASM_VECTOR_LEN;
|
|
948
|
+
const ptr2 = passArray8ToWasm0(prev_entry_hash, wasm.__wbindgen_malloc);
|
|
949
|
+
const len2 = WASM_VECTOR_LEN;
|
|
950
|
+
const ptr3 = passArray8ToWasm0(signing_key, wasm.__wbindgen_malloc);
|
|
951
|
+
const len3 = WASM_VECTOR_LEN;
|
|
952
|
+
const ret = wasm.key_log_create_entry(ptr0, len0, ptr1, len1, timestamp, ptr2, len2, action, ptr3, len3);
|
|
953
|
+
var ptr5 = ret[0];
|
|
954
|
+
var len5 = ret[1];
|
|
955
|
+
if (ret[3]) {
|
|
956
|
+
ptr5 = 0; len5 = 0;
|
|
957
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
958
|
+
}
|
|
959
|
+
deferred6_0 = ptr5;
|
|
960
|
+
deferred6_1 = len5;
|
|
961
|
+
return getStringFromWasm0(ptr5, len5);
|
|
962
|
+
} finally {
|
|
963
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* @param {string} entries_json
|
|
969
|
+
* @param {Uint8Array} user_id
|
|
970
|
+
* @returns {Uint8Array}
|
|
971
|
+
*/
|
|
972
|
+
export function key_log_current_key(entries_json, user_id) {
|
|
973
|
+
const ptr0 = passStringToWasm0(entries_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
974
|
+
const len0 = WASM_VECTOR_LEN;
|
|
975
|
+
const ptr1 = passArray8ToWasm0(user_id, wasm.__wbindgen_malloc);
|
|
976
|
+
const len1 = WASM_VECTOR_LEN;
|
|
977
|
+
const ret = wasm.key_log_current_key(ptr0, len0, ptr1, len1);
|
|
978
|
+
if (ret[3]) {
|
|
979
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
980
|
+
}
|
|
981
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
982
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
983
|
+
return v3;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* @param {string} entries_json
|
|
988
|
+
* @param {Uint8Array} user_id
|
|
989
|
+
* @param {number} timestamp
|
|
990
|
+
* @returns {Uint8Array}
|
|
991
|
+
*/
|
|
992
|
+
export function key_log_key_at_timestamp(entries_json, user_id, timestamp) {
|
|
993
|
+
const ptr0 = passStringToWasm0(entries_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
994
|
+
const len0 = WASM_VECTOR_LEN;
|
|
995
|
+
const ptr1 = passArray8ToWasm0(user_id, wasm.__wbindgen_malloc);
|
|
996
|
+
const len1 = WASM_VECTOR_LEN;
|
|
997
|
+
const ret = wasm.key_log_key_at_timestamp(ptr0, len0, ptr1, len1, timestamp);
|
|
998
|
+
if (ret[3]) {
|
|
999
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1000
|
+
}
|
|
1001
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1002
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1003
|
+
return v3;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
/**
|
|
1007
|
+
* @param {string} entries_json
|
|
1008
|
+
* @returns {boolean}
|
|
1009
|
+
*/
|
|
1010
|
+
export function key_log_verify_chain(entries_json) {
|
|
1011
|
+
const ptr0 = passStringToWasm0(entries_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1012
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1013
|
+
const ret = wasm.key_log_verify_chain(ptr0, len0);
|
|
1014
|
+
if (ret[2]) {
|
|
1015
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1016
|
+
}
|
|
1017
|
+
return ret[0] !== 0;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* @param {Uint8Array} decapsulation_key
|
|
1022
|
+
* @param {Uint8Array} ciphertext
|
|
1023
|
+
* @returns {Uint8Array}
|
|
1024
|
+
*/
|
|
1025
|
+
export function ml_kem_decapsulate(decapsulation_key, ciphertext) {
|
|
1026
|
+
const ptr0 = passArray8ToWasm0(decapsulation_key, wasm.__wbindgen_malloc);
|
|
1027
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1028
|
+
const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
1029
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1030
|
+
const ret = wasm.ml_kem_decapsulate(ptr0, len0, ptr1, len1);
|
|
1031
|
+
if (ret[2]) {
|
|
1032
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1033
|
+
}
|
|
1034
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* @param {Uint8Array} encapsulation_key
|
|
1039
|
+
* @returns {MlKemEncapsulationResult}
|
|
1040
|
+
*/
|
|
1041
|
+
export function ml_kem_encapsulate(encapsulation_key) {
|
|
1042
|
+
const ptr0 = passArray8ToWasm0(encapsulation_key, wasm.__wbindgen_malloc);
|
|
1043
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1044
|
+
const ret = wasm.ml_kem_encapsulate(ptr0, len0);
|
|
1045
|
+
if (ret[2]) {
|
|
1046
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1047
|
+
}
|
|
1048
|
+
return MlKemEncapsulationResult.__wrap(ret[0]);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* @returns {MlKemKeyPairObj}
|
|
1053
|
+
*/
|
|
1054
|
+
export function ml_kem_keygen() {
|
|
1055
|
+
const ret = wasm.ml_kem_keygen();
|
|
1056
|
+
return MlKemKeyPairObj.__wrap(ret);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
/**
|
|
1060
|
+
* @param {string} phrase
|
|
1061
|
+
* @param {string | null} [password]
|
|
1062
|
+
* @returns {Uint8Array}
|
|
1063
|
+
*/
|
|
1064
|
+
export function mnemonic_to_seed(phrase, password) {
|
|
1065
|
+
const ptr0 = passStringToWasm0(phrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1066
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1067
|
+
var ptr1 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1068
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1069
|
+
const ret = wasm.mnemonic_to_seed(ptr0, len0, ptr1, len1);
|
|
1070
|
+
if (ret[3]) {
|
|
1071
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1072
|
+
}
|
|
1073
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1074
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1075
|
+
return v3;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
/**
|
|
1079
|
+
* @param {number} window_index
|
|
1080
|
+
* @param {Uint8Array} aad_hash
|
|
1081
|
+
* @param {Uint8Array} encrypted_blob
|
|
1082
|
+
* @returns {Uint8Array}
|
|
1083
|
+
*/
|
|
1084
|
+
export function pack_envelope(window_index, aad_hash, encrypted_blob) {
|
|
1085
|
+
const ptr0 = passArray8ToWasm0(aad_hash, wasm.__wbindgen_malloc);
|
|
1086
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1087
|
+
const ptr1 = passArray8ToWasm0(encrypted_blob, wasm.__wbindgen_malloc);
|
|
1088
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1089
|
+
const ret = wasm.pack_envelope(window_index, ptr0, len0, ptr1, len1);
|
|
1090
|
+
if (ret[3]) {
|
|
1091
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1092
|
+
}
|
|
1093
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1094
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1095
|
+
return v3;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* @param {Uint8Array} content
|
|
1100
|
+
* @returns {Uint8Array}
|
|
1101
|
+
*/
|
|
1102
|
+
export function pad_message(content) {
|
|
1103
|
+
const ptr0 = passArray8ToWasm0(content, wasm.__wbindgen_malloc);
|
|
1104
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1105
|
+
const ret = wasm.pad_message(ptr0, len0);
|
|
1106
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1107
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1108
|
+
return v2;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* @param {string} registry_json
|
|
1113
|
+
* @param {string} device_id
|
|
1114
|
+
* @param {string} name
|
|
1115
|
+
* @param {number} added_at
|
|
1116
|
+
* @param {string} public_key
|
|
1117
|
+
* @returns {string}
|
|
1118
|
+
*/
|
|
1119
|
+
export function registry_add_device(registry_json, device_id, name, added_at, public_key) {
|
|
1120
|
+
let deferred6_0;
|
|
1121
|
+
let deferred6_1;
|
|
1122
|
+
try {
|
|
1123
|
+
const ptr0 = passStringToWasm0(registry_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1124
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1125
|
+
const ptr1 = passStringToWasm0(device_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1126
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1127
|
+
const ptr2 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1128
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1129
|
+
const ptr3 = passStringToWasm0(public_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1130
|
+
const len3 = WASM_VECTOR_LEN;
|
|
1131
|
+
const ret = wasm.registry_add_device(ptr0, len0, ptr1, len1, ptr2, len2, added_at, ptr3, len3);
|
|
1132
|
+
var ptr5 = ret[0];
|
|
1133
|
+
var len5 = ret[1];
|
|
1134
|
+
if (ret[3]) {
|
|
1135
|
+
ptr5 = 0; len5 = 0;
|
|
1136
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1137
|
+
}
|
|
1138
|
+
deferred6_0 = ptr5;
|
|
1139
|
+
deferred6_1 = len5;
|
|
1140
|
+
return getStringFromWasm0(ptr5, len5);
|
|
1141
|
+
} finally {
|
|
1142
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
/**
|
|
1147
|
+
* @returns {string}
|
|
1148
|
+
*/
|
|
1149
|
+
export function registry_empty() {
|
|
1150
|
+
let deferred1_0;
|
|
1151
|
+
let deferred1_1;
|
|
1152
|
+
try {
|
|
1153
|
+
const ret = wasm.registry_empty();
|
|
1154
|
+
deferred1_0 = ret[0];
|
|
1155
|
+
deferred1_1 = ret[1];
|
|
1156
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1157
|
+
} finally {
|
|
1158
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
/**
|
|
1163
|
+
* @param {string} registry_json
|
|
1164
|
+
* @returns {string}
|
|
1165
|
+
*/
|
|
1166
|
+
export function registry_get_active_devices(registry_json) {
|
|
1167
|
+
let deferred3_0;
|
|
1168
|
+
let deferred3_1;
|
|
1169
|
+
try {
|
|
1170
|
+
const ptr0 = passStringToWasm0(registry_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1171
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1172
|
+
const ret = wasm.registry_get_active_devices(ptr0, len0);
|
|
1173
|
+
var ptr2 = ret[0];
|
|
1174
|
+
var len2 = ret[1];
|
|
1175
|
+
if (ret[3]) {
|
|
1176
|
+
ptr2 = 0; len2 = 0;
|
|
1177
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1178
|
+
}
|
|
1179
|
+
deferred3_0 = ptr2;
|
|
1180
|
+
deferred3_1 = len2;
|
|
1181
|
+
return getStringFromWasm0(ptr2, len2);
|
|
1182
|
+
} finally {
|
|
1183
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* @param {string} registry_json
|
|
1189
|
+
* @param {string} device_id
|
|
1190
|
+
* @returns {string}
|
|
1191
|
+
*/
|
|
1192
|
+
export function registry_revoke_device(registry_json, device_id) {
|
|
1193
|
+
let deferred4_0;
|
|
1194
|
+
let deferred4_1;
|
|
1195
|
+
try {
|
|
1196
|
+
const ptr0 = passStringToWasm0(registry_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1197
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1198
|
+
const ptr1 = passStringToWasm0(device_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1199
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1200
|
+
const ret = wasm.registry_revoke_device(ptr0, len0, ptr1, len1);
|
|
1201
|
+
var ptr3 = ret[0];
|
|
1202
|
+
var len3 = ret[1];
|
|
1203
|
+
if (ret[3]) {
|
|
1204
|
+
ptr3 = 0; len3 = 0;
|
|
1205
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1206
|
+
}
|
|
1207
|
+
deferred4_0 = ptr3;
|
|
1208
|
+
deferred4_1 = len3;
|
|
1209
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1210
|
+
} finally {
|
|
1211
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* @param {Uint8Array} recipient_x25519_pub
|
|
1217
|
+
* @param {Uint8Array} sender_id
|
|
1218
|
+
* @param {Uint8Array} content
|
|
1219
|
+
* @returns {Uint8Array}
|
|
1220
|
+
*/
|
|
1221
|
+
export function seal_message(recipient_x25519_pub, sender_id, content) {
|
|
1222
|
+
const ptr0 = passArray8ToWasm0(recipient_x25519_pub, wasm.__wbindgen_malloc);
|
|
1223
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1224
|
+
const ptr1 = passArray8ToWasm0(sender_id, wasm.__wbindgen_malloc);
|
|
1225
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1226
|
+
const ptr2 = passArray8ToWasm0(content, wasm.__wbindgen_malloc);
|
|
1227
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1228
|
+
const ret = wasm.seal_message(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1229
|
+
if (ret[3]) {
|
|
1230
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1231
|
+
}
|
|
1232
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1233
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1234
|
+
return v4;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* @param {number} message_count
|
|
1239
|
+
* @param {boolean} window_changed
|
|
1240
|
+
* @param {number} messages_per_ratchet
|
|
1241
|
+
* @param {boolean} ratchet_on_new_window
|
|
1242
|
+
* @returns {boolean}
|
|
1243
|
+
*/
|
|
1244
|
+
export function should_ratchet(message_count, window_changed, messages_per_ratchet, ratchet_on_new_window) {
|
|
1245
|
+
const ret = wasm.should_ratchet(message_count, window_changed, messages_per_ratchet, ratchet_on_new_window);
|
|
1246
|
+
return ret !== 0;
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
/**
|
|
1250
|
+
* @param {Uint8Array} secret_key
|
|
1251
|
+
* @param {Uint8Array} message
|
|
1252
|
+
* @returns {Uint8Array}
|
|
1253
|
+
*/
|
|
1254
|
+
export function sign_message(secret_key, message) {
|
|
1255
|
+
const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
|
|
1256
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1257
|
+
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
1258
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1259
|
+
const ret = wasm.sign_message(ptr0, len0, ptr1, len1);
|
|
1260
|
+
if (ret[3]) {
|
|
1261
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1262
|
+
}
|
|
1263
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1264
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1265
|
+
return v3;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* @param {Uint8Array} message_id
|
|
1270
|
+
* @param {Uint8Array} sender_id
|
|
1271
|
+
* @param {number} timestamp
|
|
1272
|
+
* @param {Uint8Array} ciphertext
|
|
1273
|
+
* @returns {Uint8Array}
|
|
1274
|
+
*/
|
|
1275
|
+
export function transcript_compute_message_hash(message_id, sender_id, timestamp, ciphertext) {
|
|
1276
|
+
const ptr0 = passArray8ToWasm0(message_id, wasm.__wbindgen_malloc);
|
|
1277
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1278
|
+
const ptr1 = passArray8ToWasm0(sender_id, wasm.__wbindgen_malloc);
|
|
1279
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1280
|
+
const ptr2 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
1281
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1282
|
+
const ret = wasm.transcript_compute_message_hash(ptr0, len0, ptr1, len1, timestamp, ptr2, len2);
|
|
1283
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1284
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1285
|
+
return v4;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
/**
|
|
1289
|
+
* @param {Uint8Array} session_id
|
|
1290
|
+
* @returns {Uint8Array}
|
|
1291
|
+
*/
|
|
1292
|
+
export function transcript_new(session_id) {
|
|
1293
|
+
const ptr0 = passArray8ToWasm0(session_id, wasm.__wbindgen_malloc);
|
|
1294
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1295
|
+
const ret = wasm.transcript_new(ptr0, len0);
|
|
1296
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1297
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1298
|
+
return v2;
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* @param {Uint8Array} chain_state
|
|
1303
|
+
* @param {Uint8Array} message_hash
|
|
1304
|
+
* @returns {Uint8Array}
|
|
1305
|
+
*/
|
|
1306
|
+
export function transcript_update(chain_state, message_hash) {
|
|
1307
|
+
const ptr0 = passArray8ToWasm0(chain_state, wasm.__wbindgen_malloc);
|
|
1308
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1309
|
+
const ptr1 = passArray8ToWasm0(message_hash, wasm.__wbindgen_malloc);
|
|
1310
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1311
|
+
const ret = wasm.transcript_update(ptr0, len0, ptr1, len1);
|
|
1312
|
+
if (ret[3]) {
|
|
1313
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1314
|
+
}
|
|
1315
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1316
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1317
|
+
return v3;
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* @param {Uint8Array} hash_a
|
|
1322
|
+
* @param {Uint8Array} hash_b
|
|
1323
|
+
* @returns {boolean}
|
|
1324
|
+
*/
|
|
1325
|
+
export function transcript_verify_sync(hash_a, hash_b) {
|
|
1326
|
+
const ptr0 = passArray8ToWasm0(hash_a, wasm.__wbindgen_malloc);
|
|
1327
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1328
|
+
const ptr1 = passArray8ToWasm0(hash_b, wasm.__wbindgen_malloc);
|
|
1329
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1330
|
+
const ret = wasm.transcript_verify_sync(ptr0, len0, ptr1, len1);
|
|
1331
|
+
return ret !== 0;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* @param {Uint8Array} envelope
|
|
1336
|
+
* @returns {UnpackedEnvelope}
|
|
1337
|
+
*/
|
|
1338
|
+
export function unpack_envelope(envelope) {
|
|
1339
|
+
const ptr0 = passArray8ToWasm0(envelope, wasm.__wbindgen_malloc);
|
|
1340
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1341
|
+
const ret = wasm.unpack_envelope(ptr0, len0);
|
|
1342
|
+
if (ret[2]) {
|
|
1343
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1344
|
+
}
|
|
1345
|
+
return UnpackedEnvelope.__wrap(ret[0]);
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
/**
|
|
1349
|
+
* @param {Uint8Array} sealed_packet
|
|
1350
|
+
* @param {Uint8Array} our_x25519_sk
|
|
1351
|
+
* @returns {UnsealResult}
|
|
1352
|
+
*/
|
|
1353
|
+
export function unseal_message(sealed_packet, our_x25519_sk) {
|
|
1354
|
+
const ptr0 = passArray8ToWasm0(sealed_packet, wasm.__wbindgen_malloc);
|
|
1355
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1356
|
+
const ptr1 = passArray8ToWasm0(our_x25519_sk, wasm.__wbindgen_malloc);
|
|
1357
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1358
|
+
const ret = wasm.unseal_message(ptr0, len0, ptr1, len1);
|
|
1359
|
+
if (ret[2]) {
|
|
1360
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1361
|
+
}
|
|
1362
|
+
return UnsealResult.__wrap(ret[0]);
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* @param {Uint8Array} kek
|
|
1367
|
+
* @param {Uint8Array} wrapped_key
|
|
1368
|
+
* @returns {Uint8Array}
|
|
1369
|
+
*/
|
|
1370
|
+
export function unwrap_key(kek, wrapped_key) {
|
|
1371
|
+
const ptr0 = passArray8ToWasm0(kek, wasm.__wbindgen_malloc);
|
|
1372
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1373
|
+
const ptr1 = passArray8ToWasm0(wrapped_key, wasm.__wbindgen_malloc);
|
|
1374
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1375
|
+
const ret = wasm.unwrap_key(ptr0, len0, ptr1, len1);
|
|
1376
|
+
if (ret[2]) {
|
|
1377
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1378
|
+
}
|
|
1379
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* @param {Uint8Array} fingerprint_a
|
|
1384
|
+
* @param {Uint8Array} fingerprint_b
|
|
1385
|
+
* @returns {boolean}
|
|
1386
|
+
*/
|
|
1387
|
+
export function verify_fingerprints_match(fingerprint_a, fingerprint_b) {
|
|
1388
|
+
const ptr0 = passArray8ToWasm0(fingerprint_a, wasm.__wbindgen_malloc);
|
|
1389
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1390
|
+
const ptr1 = passArray8ToWasm0(fingerprint_b, wasm.__wbindgen_malloc);
|
|
1391
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1392
|
+
const ret = wasm.verify_fingerprints_match(ptr0, len0, ptr1, len1);
|
|
1393
|
+
if (ret[2]) {
|
|
1394
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1395
|
+
}
|
|
1396
|
+
return ret[0] !== 0;
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
/**
|
|
1400
|
+
* @param {Uint8Array} public_key
|
|
1401
|
+
* @param {Uint8Array} message
|
|
1402
|
+
* @param {Uint8Array} signature
|
|
1403
|
+
* @returns {boolean}
|
|
1404
|
+
*/
|
|
1405
|
+
export function verify_signature(public_key, message, signature) {
|
|
1406
|
+
const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
1407
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1408
|
+
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
1409
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1410
|
+
const ptr2 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
1411
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1412
|
+
const ret = wasm.verify_signature(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1413
|
+
return ret !== 0;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
/**
|
|
1417
|
+
* @param {Uint8Array} kek
|
|
1418
|
+
* @param {Uint8Array} key_to_wrap
|
|
1419
|
+
* @returns {Uint8Array}
|
|
1420
|
+
*/
|
|
1421
|
+
export function wrap_key(kek, key_to_wrap) {
|
|
1422
|
+
const ptr0 = passArray8ToWasm0(kek, wasm.__wbindgen_malloc);
|
|
1423
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1424
|
+
const ptr1 = passArray8ToWasm0(key_to_wrap, wasm.__wbindgen_malloc);
|
|
1425
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1426
|
+
const ret = wasm.wrap_key(ptr0, len0, ptr1, len1);
|
|
1427
|
+
if (ret[3]) {
|
|
1428
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1429
|
+
}
|
|
1430
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1431
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1432
|
+
return v3;
|
|
1433
|
+
}
|
|
1434
|
+
function __wbg_get_imports() {
|
|
1435
|
+
const import0 = {
|
|
1436
|
+
__proto__: null,
|
|
1437
|
+
__wbg___wbindgen_is_function_754e9f305ff6029e: function(arg0) {
|
|
1438
|
+
const ret = typeof(arg0) === 'function';
|
|
1439
|
+
return ret;
|
|
1440
|
+
},
|
|
1441
|
+
__wbg___wbindgen_is_object_56732c2bc353f41d: function(arg0) {
|
|
1442
|
+
const val = arg0;
|
|
1443
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
1444
|
+
return ret;
|
|
1445
|
+
},
|
|
1446
|
+
__wbg___wbindgen_is_string_c236cabd84a4d769: function(arg0) {
|
|
1447
|
+
const ret = typeof(arg0) === 'string';
|
|
1448
|
+
return ret;
|
|
1449
|
+
},
|
|
1450
|
+
__wbg___wbindgen_is_undefined_67b456be8673d3d7: function(arg0) {
|
|
1451
|
+
const ret = arg0 === undefined;
|
|
1452
|
+
return ret;
|
|
1453
|
+
},
|
|
1454
|
+
__wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
|
|
1455
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1456
|
+
},
|
|
1457
|
+
__wbg_call_9c758de292015997: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1458
|
+
const ret = arg0.call(arg1, arg2);
|
|
1459
|
+
return ret;
|
|
1460
|
+
}, arguments); },
|
|
1461
|
+
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
|
1462
|
+
const ret = arg0.crypto;
|
|
1463
|
+
return ret;
|
|
1464
|
+
},
|
|
1465
|
+
__wbg_debug_78b457f1effb3792: function(arg0) {
|
|
1466
|
+
console.debug(arg0);
|
|
1467
|
+
},
|
|
1468
|
+
__wbg_error_78ff5b3a29b770e0: function(arg0) {
|
|
1469
|
+
console.error(arg0);
|
|
1470
|
+
},
|
|
1471
|
+
__wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
|
|
1472
|
+
let deferred0_0;
|
|
1473
|
+
let deferred0_1;
|
|
1474
|
+
try {
|
|
1475
|
+
deferred0_0 = arg0;
|
|
1476
|
+
deferred0_1 = arg1;
|
|
1477
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
1478
|
+
} finally {
|
|
1479
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
1480
|
+
}
|
|
1481
|
+
},
|
|
1482
|
+
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
1483
|
+
arg0.getRandomValues(arg1);
|
|
1484
|
+
}, arguments); },
|
|
1485
|
+
__wbg_info_af7f45292ba9b0ea: function(arg0) {
|
|
1486
|
+
console.info(arg0);
|
|
1487
|
+
},
|
|
1488
|
+
__wbg_length_4a591ecaa01354d9: function(arg0) {
|
|
1489
|
+
const ret = arg0.length;
|
|
1490
|
+
return ret;
|
|
1491
|
+
},
|
|
1492
|
+
__wbg_log_cf2e968649f3384e: function(arg0) {
|
|
1493
|
+
console.log(arg0);
|
|
1494
|
+
},
|
|
1495
|
+
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
1496
|
+
const ret = arg0.msCrypto;
|
|
1497
|
+
return ret;
|
|
1498
|
+
},
|
|
1499
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
1500
|
+
const ret = new Error();
|
|
1501
|
+
return ret;
|
|
1502
|
+
},
|
|
1503
|
+
__wbg_new_with_length_36a4998e27b014c5: function(arg0) {
|
|
1504
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
1505
|
+
return ret;
|
|
1506
|
+
},
|
|
1507
|
+
__wbg_node_84ea875411254db1: function(arg0) {
|
|
1508
|
+
const ret = arg0.node;
|
|
1509
|
+
return ret;
|
|
1510
|
+
},
|
|
1511
|
+
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
1512
|
+
const ret = arg0.process;
|
|
1513
|
+
return ret;
|
|
1514
|
+
},
|
|
1515
|
+
__wbg_prototypesetcall_3249fc62a0fafa30: function(arg0, arg1, arg2) {
|
|
1516
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
1517
|
+
},
|
|
1518
|
+
__wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
|
|
1519
|
+
arg0.randomFillSync(arg1);
|
|
1520
|
+
}, arguments); },
|
|
1521
|
+
__wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
|
|
1522
|
+
const ret = module.require;
|
|
1523
|
+
return ret;
|
|
1524
|
+
}, arguments); },
|
|
1525
|
+
__wbg_slice_c87a896d40083a6c: function(arg0, arg1, arg2) {
|
|
1526
|
+
const ret = arg0.slice(arg1 >>> 0, arg2 >>> 0);
|
|
1527
|
+
return ret;
|
|
1528
|
+
},
|
|
1529
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
1530
|
+
const ret = arg1.stack;
|
|
1531
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1532
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1533
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1534
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1535
|
+
},
|
|
1536
|
+
__wbg_static_accessor_GLOBAL_9d53f2689e622ca1: function() {
|
|
1537
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
1538
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1539
|
+
},
|
|
1540
|
+
__wbg_static_accessor_GLOBAL_THIS_a1a35cec07001a8a: function() {
|
|
1541
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
1542
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1543
|
+
},
|
|
1544
|
+
__wbg_static_accessor_SELF_4c59f6c7ea29a144: function() {
|
|
1545
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
1546
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1547
|
+
},
|
|
1548
|
+
__wbg_static_accessor_WINDOW_e70ae9f2eb052253: function() {
|
|
1549
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
1550
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1551
|
+
},
|
|
1552
|
+
__wbg_subarray_4aa221f6a4f5ab22: function(arg0, arg1, arg2) {
|
|
1553
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
1554
|
+
return ret;
|
|
1555
|
+
},
|
|
1556
|
+
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
1557
|
+
const ret = arg0.versions;
|
|
1558
|
+
return ret;
|
|
1559
|
+
},
|
|
1560
|
+
__wbg_warn_410c3261e3c6d686: function(arg0) {
|
|
1561
|
+
console.warn(arg0);
|
|
1562
|
+
},
|
|
1563
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1564
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
1565
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
1566
|
+
return ret;
|
|
1567
|
+
},
|
|
1568
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1569
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1570
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1571
|
+
return ret;
|
|
1572
|
+
},
|
|
1573
|
+
__wbindgen_init_externref_table: function() {
|
|
1574
|
+
const table = wasm.__wbindgen_externrefs;
|
|
1575
|
+
const offset = table.grow(4);
|
|
1576
|
+
table.set(0, undefined);
|
|
1577
|
+
table.set(offset + 0, undefined);
|
|
1578
|
+
table.set(offset + 1, null);
|
|
1579
|
+
table.set(offset + 2, true);
|
|
1580
|
+
table.set(offset + 3, false);
|
|
1581
|
+
},
|
|
1582
|
+
};
|
|
1583
|
+
return {
|
|
1584
|
+
__proto__: null,
|
|
1585
|
+
"./wasm_bg.js": import0,
|
|
1586
|
+
};
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
const AuthenticatedKemResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1590
|
+
? { register: () => {}, unregister: () => {} }
|
|
1591
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_authenticatedkemresult_free(ptr, 1));
|
|
1592
|
+
const Ed25519KeyPairObjFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1593
|
+
? { register: () => {}, unregister: () => {} }
|
|
1594
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_ed25519keypairobj_free(ptr, 1));
|
|
1595
|
+
const HybridKemResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1596
|
+
? { register: () => {}, unregister: () => {} }
|
|
1597
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_hybridkemresult_free(ptr, 1));
|
|
1598
|
+
const MlKemEncapsulationResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1599
|
+
? { register: () => {}, unregister: () => {} }
|
|
1600
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_mlkemencapsulationresult_free(ptr, 1));
|
|
1601
|
+
const MlKemKeyPairObjFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1602
|
+
? { register: () => {}, unregister: () => {} }
|
|
1603
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_mlkemkeypairobj_free(ptr, 1));
|
|
1604
|
+
const RatchetKeyPairObjFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1605
|
+
? { register: () => {}, unregister: () => {} }
|
|
1606
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_ratchetkeypairobj_free(ptr, 1));
|
|
1607
|
+
const UnpackedEnvelopeFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1608
|
+
? { register: () => {}, unregister: () => {} }
|
|
1609
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_unpackedenvelope_free(ptr, 1));
|
|
1610
|
+
const UnsealResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1611
|
+
? { register: () => {}, unregister: () => {} }
|
|
1612
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_unsealresult_free(ptr, 1));
|
|
1613
|
+
const VerificationCodeResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1614
|
+
? { register: () => {}, unregister: () => {} }
|
|
1615
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_verificationcoderesult_free(ptr, 1));
|
|
1616
|
+
const X25519KeyPairObjFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1617
|
+
? { register: () => {}, unregister: () => {} }
|
|
1618
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_x25519keypairobj_free(ptr, 1));
|
|
1619
|
+
|
|
1620
|
+
function addToExternrefTable0(obj) {
|
|
1621
|
+
const idx = wasm.__externref_table_alloc();
|
|
1622
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
1623
|
+
return idx;
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
1627
|
+
ptr = ptr >>> 0;
|
|
1628
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
let cachedDataViewMemory0 = null;
|
|
1632
|
+
function getDataViewMemory0() {
|
|
1633
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
1634
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
1635
|
+
}
|
|
1636
|
+
return cachedDataViewMemory0;
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
function getStringFromWasm0(ptr, len) {
|
|
1640
|
+
return decodeText(ptr >>> 0, len);
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
let cachedUint8ArrayMemory0 = null;
|
|
1644
|
+
function getUint8ArrayMemory0() {
|
|
1645
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
1646
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
1647
|
+
}
|
|
1648
|
+
return cachedUint8ArrayMemory0;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
function handleError(f, args) {
|
|
1652
|
+
try {
|
|
1653
|
+
return f.apply(this, args);
|
|
1654
|
+
} catch (e) {
|
|
1655
|
+
const idx = addToExternrefTable0(e);
|
|
1656
|
+
wasm.__wbindgen_exn_store(idx);
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
function isLikeNone(x) {
|
|
1661
|
+
return x === undefined || x === null;
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
1665
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
1666
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
1667
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1668
|
+
return ptr;
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
1672
|
+
if (realloc === undefined) {
|
|
1673
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1674
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
1675
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
1676
|
+
WASM_VECTOR_LEN = buf.length;
|
|
1677
|
+
return ptr;
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
let len = arg.length;
|
|
1681
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
1682
|
+
|
|
1683
|
+
const mem = getUint8ArrayMemory0();
|
|
1684
|
+
|
|
1685
|
+
let offset = 0;
|
|
1686
|
+
|
|
1687
|
+
for (; offset < len; offset++) {
|
|
1688
|
+
const code = arg.charCodeAt(offset);
|
|
1689
|
+
if (code > 0x7F) break;
|
|
1690
|
+
mem[ptr + offset] = code;
|
|
1691
|
+
}
|
|
1692
|
+
if (offset !== len) {
|
|
1693
|
+
if (offset !== 0) {
|
|
1694
|
+
arg = arg.slice(offset);
|
|
1695
|
+
}
|
|
1696
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1697
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1698
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1699
|
+
|
|
1700
|
+
offset += ret.written;
|
|
1701
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
WASM_VECTOR_LEN = offset;
|
|
1705
|
+
return ptr;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
function takeFromExternrefTable0(idx) {
|
|
1709
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1710
|
+
wasm.__externref_table_dealloc(idx);
|
|
1711
|
+
return value;
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1715
|
+
cachedTextDecoder.decode();
|
|
1716
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
1717
|
+
let numBytesDecoded = 0;
|
|
1718
|
+
function decodeText(ptr, len) {
|
|
1719
|
+
numBytesDecoded += len;
|
|
1720
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1721
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1722
|
+
cachedTextDecoder.decode();
|
|
1723
|
+
numBytesDecoded = len;
|
|
1724
|
+
}
|
|
1725
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
const cachedTextEncoder = new TextEncoder();
|
|
1729
|
+
|
|
1730
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
1731
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1732
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1733
|
+
view.set(buf);
|
|
1734
|
+
return {
|
|
1735
|
+
read: arg.length,
|
|
1736
|
+
written: buf.length
|
|
1737
|
+
};
|
|
1738
|
+
};
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
let WASM_VECTOR_LEN = 0;
|
|
1742
|
+
|
|
1743
|
+
let wasmModule, wasmInstance, wasm;
|
|
1744
|
+
function __wbg_finalize_init(instance, module) {
|
|
1745
|
+
wasmInstance = instance;
|
|
1746
|
+
wasm = instance.exports;
|
|
1747
|
+
wasmModule = module;
|
|
1748
|
+
cachedDataViewMemory0 = null;
|
|
1749
|
+
cachedUint8ArrayMemory0 = null;
|
|
1750
|
+
wasm.__wbindgen_start();
|
|
1751
|
+
return wasm;
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
async function __wbg_load(module, imports) {
|
|
1755
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
1756
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1757
|
+
try {
|
|
1758
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1759
|
+
} catch (e) {
|
|
1760
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
1761
|
+
|
|
1762
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
1763
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
1764
|
+
|
|
1765
|
+
} else { throw e; }
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
const bytes = await module.arrayBuffer();
|
|
1770
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1771
|
+
} else {
|
|
1772
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1773
|
+
|
|
1774
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1775
|
+
return { instance, module };
|
|
1776
|
+
} else {
|
|
1777
|
+
return instance;
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
function expectedResponseType(type) {
|
|
1782
|
+
switch (type) {
|
|
1783
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
1784
|
+
}
|
|
1785
|
+
return false;
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
function initSync(module) {
|
|
1790
|
+
if (wasm !== undefined) return wasm;
|
|
1791
|
+
|
|
1792
|
+
|
|
1793
|
+
if (module !== undefined) {
|
|
1794
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1795
|
+
({module} = module)
|
|
1796
|
+
} else {
|
|
1797
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
const imports = __wbg_get_imports();
|
|
1802
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1803
|
+
module = new WebAssembly.Module(module);
|
|
1804
|
+
}
|
|
1805
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1806
|
+
return __wbg_finalize_init(instance, module);
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
async function __wbg_init(module_or_path) {
|
|
1810
|
+
if (wasm !== undefined) return wasm;
|
|
1811
|
+
|
|
1812
|
+
|
|
1813
|
+
if (module_or_path !== undefined) {
|
|
1814
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1815
|
+
({module_or_path} = module_or_path)
|
|
1816
|
+
} else {
|
|
1817
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
if (module_or_path === undefined) {
|
|
1822
|
+
module_or_path = new URL('wasm_bg.wasm', import.meta.url);
|
|
1823
|
+
}
|
|
1824
|
+
const imports = __wbg_get_imports();
|
|
1825
|
+
|
|
1826
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
1827
|
+
module_or_path = fetch(module_or_path);
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1831
|
+
|
|
1832
|
+
return __wbg_finalize_init(instance, module);
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
export { initSync, __wbg_init as default };
|