wasm-pqc-subtle 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "wasm-pqc-subtle",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "files": [
6
+ "wasm_pqc_subtle_bg.wasm",
7
+ "wasm_pqc_subtle.js",
8
+ "wasm_pqc_subtle.d.ts"
9
+ ],
10
+ "main": "wasm_pqc_subtle.js",
11
+ "types": "wasm_pqc_subtle.d.ts",
12
+ "sideEffects": [
13
+ "./snippets/*"
14
+ ]
15
+ }
@@ -0,0 +1,86 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class CiphertextAndSharedSecret {
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ readonly ciphertext: Uint8Array;
9
+ readonly shared_secret: Uint8Array;
10
+ }
11
+
12
+ export class KemKeyPair {
13
+ private constructor();
14
+ free(): void;
15
+ [Symbol.dispose](): void;
16
+ readonly public_key: Uint8Array;
17
+ readonly secret_key: Uint8Array;
18
+ }
19
+
20
+ export function kem_decapsulate(secret_key_bytes: Uint8Array, ciphertext_bytes: Uint8Array): Uint8Array;
21
+
22
+ export function kem_encapsulate(public_key_bytes: Uint8Array): CiphertextAndSharedSecret;
23
+
24
+ export function kem_generate_keypair(): KemKeyPair;
25
+
26
+ export function ml_kem_1024_decapsulate(secret_key_bytes: Uint8Array, ciphertext_bytes: Uint8Array): Uint8Array;
27
+
28
+ export function ml_kem_1024_encapsulate(public_key_bytes: Uint8Array): CiphertextAndSharedSecret;
29
+
30
+ export function ml_kem_1024_generate_keypair(): KemKeyPair;
31
+
32
+ export function ml_kem_768_decapsulate(secret_key_bytes: Uint8Array, ciphertext_bytes: Uint8Array): Uint8Array;
33
+
34
+ export function ml_kem_768_encapsulate(public_key_bytes: Uint8Array): CiphertextAndSharedSecret;
35
+
36
+ export function ml_kem_768_generate_keypair(): KemKeyPair;
37
+
38
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
39
+
40
+ export interface InitOutput {
41
+ readonly memory: WebAssembly.Memory;
42
+ readonly __wbg_kemkeypair_free: (a: number, b: number) => void;
43
+ readonly kemkeypair_public_key: (a: number) => [number, number];
44
+ readonly kemkeypair_secret_key: (a: number) => [number, number];
45
+ readonly __wbg_ciphertextandsharedsecret_free: (a: number, b: number) => void;
46
+ readonly ciphertextandsharedsecret_ciphertext: (a: number) => [number, number];
47
+ readonly ciphertextandsharedsecret_shared_secret: (a: number) => [number, number];
48
+ readonly ml_kem_1024_generate_keypair: () => [number, number, number];
49
+ readonly ml_kem_1024_encapsulate: (a: number, b: number) => [number, number, number];
50
+ readonly ml_kem_1024_decapsulate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
51
+ readonly kem_generate_keypair: () => [number, number, number];
52
+ readonly kem_encapsulate: (a: number, b: number) => [number, number, number];
53
+ readonly kem_decapsulate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
54
+ readonly ml_kem_768_encapsulate: (a: number, b: number) => [number, number, number];
55
+ readonly ml_kem_768_decapsulate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
56
+ readonly ml_kem_768_generate_keypair: () => [number, number, number];
57
+ readonly __wbindgen_exn_store: (a: number) => void;
58
+ readonly __externref_table_alloc: () => number;
59
+ readonly __wbindgen_externrefs: WebAssembly.Table;
60
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
61
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
62
+ readonly __externref_table_dealloc: (a: number) => void;
63
+ readonly __wbindgen_start: () => void;
64
+ }
65
+
66
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
67
+
68
+ /**
69
+ * Instantiates the given `module`, which can either be bytes or
70
+ * a precompiled `WebAssembly.Module`.
71
+ *
72
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
73
+ *
74
+ * @returns {InitOutput}
75
+ */
76
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
77
+
78
+ /**
79
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
80
+ * for everything else, calls `WebAssembly.instantiate` directly.
81
+ *
82
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
83
+ *
84
+ * @returns {Promise<InitOutput>}
85
+ */
86
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,498 @@
1
+ /* @ts-self-types="./wasm_pqc_subtle.d.ts" */
2
+
3
+ export class CiphertextAndSharedSecret {
4
+ static __wrap(ptr) {
5
+ ptr = ptr >>> 0;
6
+ const obj = Object.create(CiphertextAndSharedSecret.prototype);
7
+ obj.__wbg_ptr = ptr;
8
+ CiphertextAndSharedSecretFinalization.register(obj, obj.__wbg_ptr, obj);
9
+ return obj;
10
+ }
11
+ __destroy_into_raw() {
12
+ const ptr = this.__wbg_ptr;
13
+ this.__wbg_ptr = 0;
14
+ CiphertextAndSharedSecretFinalization.unregister(this);
15
+ return ptr;
16
+ }
17
+ free() {
18
+ const ptr = this.__destroy_into_raw();
19
+ wasm.__wbg_ciphertextandsharedsecret_free(ptr, 0);
20
+ }
21
+ /**
22
+ * @returns {Uint8Array}
23
+ */
24
+ get ciphertext() {
25
+ const ret = wasm.ciphertextandsharedsecret_ciphertext(this.__wbg_ptr);
26
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
27
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
28
+ return v1;
29
+ }
30
+ /**
31
+ * @returns {Uint8Array}
32
+ */
33
+ get shared_secret() {
34
+ const ret = wasm.ciphertextandsharedsecret_shared_secret(this.__wbg_ptr);
35
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
36
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
37
+ return v1;
38
+ }
39
+ }
40
+ if (Symbol.dispose) CiphertextAndSharedSecret.prototype[Symbol.dispose] = CiphertextAndSharedSecret.prototype.free;
41
+
42
+ export class KemKeyPair {
43
+ static __wrap(ptr) {
44
+ ptr = ptr >>> 0;
45
+ const obj = Object.create(KemKeyPair.prototype);
46
+ obj.__wbg_ptr = ptr;
47
+ KemKeyPairFinalization.register(obj, obj.__wbg_ptr, obj);
48
+ return obj;
49
+ }
50
+ __destroy_into_raw() {
51
+ const ptr = this.__wbg_ptr;
52
+ this.__wbg_ptr = 0;
53
+ KemKeyPairFinalization.unregister(this);
54
+ return ptr;
55
+ }
56
+ free() {
57
+ const ptr = this.__destroy_into_raw();
58
+ wasm.__wbg_kemkeypair_free(ptr, 0);
59
+ }
60
+ /**
61
+ * @returns {Uint8Array}
62
+ */
63
+ get public_key() {
64
+ const ret = wasm.kemkeypair_public_key(this.__wbg_ptr);
65
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
66
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
67
+ return v1;
68
+ }
69
+ /**
70
+ * @returns {Uint8Array}
71
+ */
72
+ get secret_key() {
73
+ const ret = wasm.kemkeypair_secret_key(this.__wbg_ptr);
74
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
75
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
76
+ return v1;
77
+ }
78
+ }
79
+ if (Symbol.dispose) KemKeyPair.prototype[Symbol.dispose] = KemKeyPair.prototype.free;
80
+
81
+ /**
82
+ * @param {Uint8Array} secret_key_bytes
83
+ * @param {Uint8Array} ciphertext_bytes
84
+ * @returns {Uint8Array}
85
+ */
86
+ export function kem_decapsulate(secret_key_bytes, ciphertext_bytes) {
87
+ const ptr0 = passArray8ToWasm0(secret_key_bytes, wasm.__wbindgen_malloc);
88
+ const len0 = WASM_VECTOR_LEN;
89
+ const ptr1 = passArray8ToWasm0(ciphertext_bytes, wasm.__wbindgen_malloc);
90
+ const len1 = WASM_VECTOR_LEN;
91
+ const ret = wasm.kem_decapsulate(ptr0, len0, ptr1, len1);
92
+ if (ret[3]) {
93
+ throw takeFromExternrefTable0(ret[2]);
94
+ }
95
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
96
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
97
+ return v3;
98
+ }
99
+
100
+ /**
101
+ * @param {Uint8Array} public_key_bytes
102
+ * @returns {CiphertextAndSharedSecret}
103
+ */
104
+ export function kem_encapsulate(public_key_bytes) {
105
+ const ptr0 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc);
106
+ const len0 = WASM_VECTOR_LEN;
107
+ const ret = wasm.kem_encapsulate(ptr0, len0);
108
+ if (ret[2]) {
109
+ throw takeFromExternrefTable0(ret[1]);
110
+ }
111
+ return CiphertextAndSharedSecret.__wrap(ret[0]);
112
+ }
113
+
114
+ /**
115
+ * @returns {KemKeyPair}
116
+ */
117
+ export function kem_generate_keypair() {
118
+ const ret = wasm.kem_generate_keypair();
119
+ if (ret[2]) {
120
+ throw takeFromExternrefTable0(ret[1]);
121
+ }
122
+ return KemKeyPair.__wrap(ret[0]);
123
+ }
124
+
125
+ /**
126
+ * @param {Uint8Array} secret_key_bytes
127
+ * @param {Uint8Array} ciphertext_bytes
128
+ * @returns {Uint8Array}
129
+ */
130
+ export function ml_kem_1024_decapsulate(secret_key_bytes, ciphertext_bytes) {
131
+ const ptr0 = passArray8ToWasm0(secret_key_bytes, wasm.__wbindgen_malloc);
132
+ const len0 = WASM_VECTOR_LEN;
133
+ const ptr1 = passArray8ToWasm0(ciphertext_bytes, wasm.__wbindgen_malloc);
134
+ const len1 = WASM_VECTOR_LEN;
135
+ const ret = wasm.ml_kem_1024_decapsulate(ptr0, len0, ptr1, len1);
136
+ if (ret[3]) {
137
+ throw takeFromExternrefTable0(ret[2]);
138
+ }
139
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
140
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
141
+ return v3;
142
+ }
143
+
144
+ /**
145
+ * @param {Uint8Array} public_key_bytes
146
+ * @returns {CiphertextAndSharedSecret}
147
+ */
148
+ export function ml_kem_1024_encapsulate(public_key_bytes) {
149
+ const ptr0 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc);
150
+ const len0 = WASM_VECTOR_LEN;
151
+ const ret = wasm.ml_kem_1024_encapsulate(ptr0, len0);
152
+ if (ret[2]) {
153
+ throw takeFromExternrefTable0(ret[1]);
154
+ }
155
+ return CiphertextAndSharedSecret.__wrap(ret[0]);
156
+ }
157
+
158
+ /**
159
+ * @returns {KemKeyPair}
160
+ */
161
+ export function ml_kem_1024_generate_keypair() {
162
+ const ret = wasm.ml_kem_1024_generate_keypair();
163
+ if (ret[2]) {
164
+ throw takeFromExternrefTable0(ret[1]);
165
+ }
166
+ return KemKeyPair.__wrap(ret[0]);
167
+ }
168
+
169
+ /**
170
+ * @param {Uint8Array} secret_key_bytes
171
+ * @param {Uint8Array} ciphertext_bytes
172
+ * @returns {Uint8Array}
173
+ */
174
+ export function ml_kem_768_decapsulate(secret_key_bytes, ciphertext_bytes) {
175
+ const ptr0 = passArray8ToWasm0(secret_key_bytes, wasm.__wbindgen_malloc);
176
+ const len0 = WASM_VECTOR_LEN;
177
+ const ptr1 = passArray8ToWasm0(ciphertext_bytes, wasm.__wbindgen_malloc);
178
+ const len1 = WASM_VECTOR_LEN;
179
+ const ret = wasm.ml_kem_768_decapsulate(ptr0, len0, ptr1, len1);
180
+ if (ret[3]) {
181
+ throw takeFromExternrefTable0(ret[2]);
182
+ }
183
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
184
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
185
+ return v3;
186
+ }
187
+
188
+ /**
189
+ * @param {Uint8Array} public_key_bytes
190
+ * @returns {CiphertextAndSharedSecret}
191
+ */
192
+ export function ml_kem_768_encapsulate(public_key_bytes) {
193
+ const ptr0 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc);
194
+ const len0 = WASM_VECTOR_LEN;
195
+ const ret = wasm.ml_kem_768_encapsulate(ptr0, len0);
196
+ if (ret[2]) {
197
+ throw takeFromExternrefTable0(ret[1]);
198
+ }
199
+ return CiphertextAndSharedSecret.__wrap(ret[0]);
200
+ }
201
+
202
+ /**
203
+ * @returns {KemKeyPair}
204
+ */
205
+ export function ml_kem_768_generate_keypair() {
206
+ const ret = wasm.ml_kem_768_generate_keypair();
207
+ if (ret[2]) {
208
+ throw takeFromExternrefTable0(ret[1]);
209
+ }
210
+ return KemKeyPair.__wrap(ret[0]);
211
+ }
212
+
213
+ function __wbg_get_imports() {
214
+ const import0 = {
215
+ __proto__: null,
216
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
217
+ const ret = typeof(arg0) === 'function';
218
+ return ret;
219
+ },
220
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
221
+ const val = arg0;
222
+ const ret = typeof(val) === 'object' && val !== null;
223
+ return ret;
224
+ },
225
+ __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
226
+ const ret = typeof(arg0) === 'string';
227
+ return ret;
228
+ },
229
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
230
+ const ret = arg0 === undefined;
231
+ return ret;
232
+ },
233
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
234
+ throw new Error(getStringFromWasm0(arg0, arg1));
235
+ },
236
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
237
+ const ret = arg0.call(arg1);
238
+ return ret;
239
+ }, arguments); },
240
+ __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
241
+ const ret = arg0.call(arg1, arg2);
242
+ return ret;
243
+ }, arguments); },
244
+ __wbg_crypto_86f2631e91b51511: function(arg0) {
245
+ const ret = arg0.crypto;
246
+ return ret;
247
+ },
248
+ __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
249
+ arg0.getRandomValues(arg1);
250
+ }, arguments); },
251
+ __wbg_length_32ed9a279acd054c: function(arg0) {
252
+ const ret = arg0.length;
253
+ return ret;
254
+ },
255
+ __wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
256
+ const ret = arg0.msCrypto;
257
+ return ret;
258
+ },
259
+ __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
260
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
261
+ return ret;
262
+ },
263
+ __wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
264
+ const ret = new Uint8Array(arg0 >>> 0);
265
+ return ret;
266
+ },
267
+ __wbg_node_e1f24f89a7336c2e: function(arg0) {
268
+ const ret = arg0.node;
269
+ return ret;
270
+ },
271
+ __wbg_process_3975fd6c72f520aa: function(arg0) {
272
+ const ret = arg0.process;
273
+ return ret;
274
+ },
275
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
276
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
277
+ },
278
+ __wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
279
+ arg0.randomFillSync(arg1);
280
+ }, arguments); },
281
+ __wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
282
+ const ret = module.require;
283
+ return ret;
284
+ }, arguments); },
285
+ __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
286
+ const ret = typeof global === 'undefined' ? null : global;
287
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
288
+ },
289
+ __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
290
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
291
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
292
+ },
293
+ __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
294
+ const ret = typeof self === 'undefined' ? null : self;
295
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
296
+ },
297
+ __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
298
+ const ret = typeof window === 'undefined' ? null : window;
299
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
300
+ },
301
+ __wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
302
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
303
+ return ret;
304
+ },
305
+ __wbg_versions_4e31226f5e8dc909: function(arg0) {
306
+ const ret = arg0.versions;
307
+ return ret;
308
+ },
309
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
310
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
311
+ const ret = getArrayU8FromWasm0(arg0, arg1);
312
+ return ret;
313
+ },
314
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
315
+ // Cast intrinsic for `Ref(String) -> Externref`.
316
+ const ret = getStringFromWasm0(arg0, arg1);
317
+ return ret;
318
+ },
319
+ __wbindgen_init_externref_table: function() {
320
+ const table = wasm.__wbindgen_externrefs;
321
+ const offset = table.grow(4);
322
+ table.set(0, undefined);
323
+ table.set(offset + 0, undefined);
324
+ table.set(offset + 1, null);
325
+ table.set(offset + 2, true);
326
+ table.set(offset + 3, false);
327
+ },
328
+ };
329
+ return {
330
+ __proto__: null,
331
+ "./wasm_pqc_subtle_bg.js": import0,
332
+ };
333
+ }
334
+
335
+ const CiphertextAndSharedSecretFinalization = (typeof FinalizationRegistry === 'undefined')
336
+ ? { register: () => {}, unregister: () => {} }
337
+ : new FinalizationRegistry(ptr => wasm.__wbg_ciphertextandsharedsecret_free(ptr >>> 0, 1));
338
+ const KemKeyPairFinalization = (typeof FinalizationRegistry === 'undefined')
339
+ ? { register: () => {}, unregister: () => {} }
340
+ : new FinalizationRegistry(ptr => wasm.__wbg_kemkeypair_free(ptr >>> 0, 1));
341
+
342
+ function addToExternrefTable0(obj) {
343
+ const idx = wasm.__externref_table_alloc();
344
+ wasm.__wbindgen_externrefs.set(idx, obj);
345
+ return idx;
346
+ }
347
+
348
+ function getArrayU8FromWasm0(ptr, len) {
349
+ ptr = ptr >>> 0;
350
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
351
+ }
352
+
353
+ function getStringFromWasm0(ptr, len) {
354
+ ptr = ptr >>> 0;
355
+ return decodeText(ptr, len);
356
+ }
357
+
358
+ let cachedUint8ArrayMemory0 = null;
359
+ function getUint8ArrayMemory0() {
360
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
361
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
362
+ }
363
+ return cachedUint8ArrayMemory0;
364
+ }
365
+
366
+ function handleError(f, args) {
367
+ try {
368
+ return f.apply(this, args);
369
+ } catch (e) {
370
+ const idx = addToExternrefTable0(e);
371
+ wasm.__wbindgen_exn_store(idx);
372
+ }
373
+ }
374
+
375
+ function isLikeNone(x) {
376
+ return x === undefined || x === null;
377
+ }
378
+
379
+ function passArray8ToWasm0(arg, malloc) {
380
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
381
+ getUint8ArrayMemory0().set(arg, ptr / 1);
382
+ WASM_VECTOR_LEN = arg.length;
383
+ return ptr;
384
+ }
385
+
386
+ function takeFromExternrefTable0(idx) {
387
+ const value = wasm.__wbindgen_externrefs.get(idx);
388
+ wasm.__externref_table_dealloc(idx);
389
+ return value;
390
+ }
391
+
392
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
393
+ cachedTextDecoder.decode();
394
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
395
+ let numBytesDecoded = 0;
396
+ function decodeText(ptr, len) {
397
+ numBytesDecoded += len;
398
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
399
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
400
+ cachedTextDecoder.decode();
401
+ numBytesDecoded = len;
402
+ }
403
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
404
+ }
405
+
406
+ let WASM_VECTOR_LEN = 0;
407
+
408
+ let wasmModule, wasm;
409
+ function __wbg_finalize_init(instance, module) {
410
+ wasm = instance.exports;
411
+ wasmModule = module;
412
+ cachedUint8ArrayMemory0 = null;
413
+ wasm.__wbindgen_start();
414
+ return wasm;
415
+ }
416
+
417
+ async function __wbg_load(module, imports) {
418
+ if (typeof Response === 'function' && module instanceof Response) {
419
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
420
+ try {
421
+ return await WebAssembly.instantiateStreaming(module, imports);
422
+ } catch (e) {
423
+ const validResponse = module.ok && expectedResponseType(module.type);
424
+
425
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
426
+ 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);
427
+
428
+ } else { throw e; }
429
+ }
430
+ }
431
+
432
+ const bytes = await module.arrayBuffer();
433
+ return await WebAssembly.instantiate(bytes, imports);
434
+ } else {
435
+ const instance = await WebAssembly.instantiate(module, imports);
436
+
437
+ if (instance instanceof WebAssembly.Instance) {
438
+ return { instance, module };
439
+ } else {
440
+ return instance;
441
+ }
442
+ }
443
+
444
+ function expectedResponseType(type) {
445
+ switch (type) {
446
+ case 'basic': case 'cors': case 'default': return true;
447
+ }
448
+ return false;
449
+ }
450
+ }
451
+
452
+ function initSync(module) {
453
+ if (wasm !== undefined) return wasm;
454
+
455
+
456
+ if (module !== undefined) {
457
+ if (Object.getPrototypeOf(module) === Object.prototype) {
458
+ ({module} = module)
459
+ } else {
460
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
461
+ }
462
+ }
463
+
464
+ const imports = __wbg_get_imports();
465
+ if (!(module instanceof WebAssembly.Module)) {
466
+ module = new WebAssembly.Module(module);
467
+ }
468
+ const instance = new WebAssembly.Instance(module, imports);
469
+ return __wbg_finalize_init(instance, module);
470
+ }
471
+
472
+ async function __wbg_init(module_or_path) {
473
+ if (wasm !== undefined) return wasm;
474
+
475
+
476
+ if (module_or_path !== undefined) {
477
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
478
+ ({module_or_path} = module_or_path)
479
+ } else {
480
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
481
+ }
482
+ }
483
+
484
+ if (module_or_path === undefined) {
485
+ module_or_path = new URL('wasm_pqc_subtle_bg.wasm', import.meta.url);
486
+ }
487
+ const imports = __wbg_get_imports();
488
+
489
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
490
+ module_or_path = fetch(module_or_path);
491
+ }
492
+
493
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
494
+
495
+ return __wbg_finalize_init(instance, module);
496
+ }
497
+
498
+ export { initSync, __wbg_init as default };
Binary file