@auditable/privacy-pool-zk-sdk 0.0.2-rc.6 → 0.0.2-rc.8

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/dist/cli.js CHANGED
@@ -2,7 +2,6 @@
2
2
  'use strict';
3
3
 
4
4
  var fs = require('fs');
5
- var wasmBindings = require('privacy-pool-client-sdk/pkg/client_sdk_wasm.js');
6
5
  var snarkjs = require('snarkjs');
7
6
 
8
7
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
@@ -24,9 +23,579 @@ function _interopNamespaceDefault(e) {
24
23
  }
25
24
 
26
25
  var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
27
- var wasmBindings__namespace = /*#__PURE__*/_interopNamespaceDefault(wasmBindings);
28
26
  var snarkjs__namespace = /*#__PURE__*/_interopNamespaceDefault(snarkjs);
29
27
 
28
+ let wasm;
29
+
30
+ const heap = new Array(128).fill(undefined);
31
+
32
+ heap.push(undefined, null, true, false);
33
+
34
+ function getObject(idx) { return heap[idx]; }
35
+
36
+ let heap_next = heap.length;
37
+
38
+ function addHeapObject(obj) {
39
+ if (heap_next === heap.length) heap.push(heap.length + 1);
40
+ const idx = heap_next;
41
+ heap_next = heap[idx];
42
+
43
+ heap[idx] = obj;
44
+ return idx;
45
+ }
46
+
47
+ function handleError(f, args) {
48
+ try {
49
+ return f.apply(this, args);
50
+ } catch (e) {
51
+ wasm.__wbindgen_export_0(addHeapObject(e));
52
+ }
53
+ }
54
+
55
+ let cachedUint8ArrayMemory0 = null;
56
+
57
+ function getUint8ArrayMemory0() {
58
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
59
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
60
+ }
61
+ return cachedUint8ArrayMemory0;
62
+ }
63
+
64
+ let cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
65
+
66
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
67
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
68
+ let numBytesDecoded = 0;
69
+ function decodeText(ptr, len) {
70
+ numBytesDecoded += len;
71
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
72
+ cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
73
+ cachedTextDecoder.decode();
74
+ numBytesDecoded = len;
75
+ }
76
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
77
+ }
78
+
79
+ function getStringFromWasm0(ptr, len) {
80
+ ptr = ptr >>> 0;
81
+ return decodeText(ptr, len);
82
+ }
83
+
84
+ function dropObject(idx) {
85
+ if (idx < 132) return;
86
+ heap[idx] = heap_next;
87
+ heap_next = idx;
88
+ }
89
+
90
+ function takeObject(idx) {
91
+ const ret = getObject(idx);
92
+ dropObject(idx);
93
+ return ret;
94
+ }
95
+
96
+ function isLikeNone(x) {
97
+ return x === undefined || x === null;
98
+ }
99
+
100
+ function debugString(val) {
101
+ // primitive types
102
+ const type = typeof val;
103
+ if (type == 'number' || type == 'boolean' || val == null) {
104
+ return `${val}`;
105
+ }
106
+ if (type == 'string') {
107
+ return `"${val}"`;
108
+ }
109
+ if (type == 'symbol') {
110
+ const description = val.description;
111
+ if (description == null) {
112
+ return 'Symbol';
113
+ } else {
114
+ return `Symbol(${description})`;
115
+ }
116
+ }
117
+ if (type == 'function') {
118
+ const name = val.name;
119
+ if (typeof name == 'string' && name.length > 0) {
120
+ return `Function(${name})`;
121
+ } else {
122
+ return 'Function';
123
+ }
124
+ }
125
+ // objects
126
+ if (Array.isArray(val)) {
127
+ const length = val.length;
128
+ let debug = '[';
129
+ if (length > 0) {
130
+ debug += debugString(val[0]);
131
+ }
132
+ for(let i = 1; i < length; i++) {
133
+ debug += ', ' + debugString(val[i]);
134
+ }
135
+ debug += ']';
136
+ return debug;
137
+ }
138
+ // Test for built-in
139
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
140
+ let className;
141
+ if (builtInMatches && builtInMatches.length > 1) {
142
+ className = builtInMatches[1];
143
+ } else {
144
+ // Failed to match the standard '[object ClassName]'
145
+ return toString.call(val);
146
+ }
147
+ if (className == 'Object') {
148
+ // we're a user defined class or Object
149
+ // JSON.stringify avoids problems with cycles, and is generally much
150
+ // easier than looping through ownProperties of `val`.
151
+ try {
152
+ return 'Object(' + JSON.stringify(val) + ')';
153
+ } catch (_) {
154
+ return 'Object';
155
+ }
156
+ }
157
+ // errors
158
+ if (val instanceof Error) {
159
+ return `${val.name}: ${val.message}\n${val.stack}`;
160
+ }
161
+ // TODO we could test for more things here, like `Set`s and `Map`s.
162
+ return className;
163
+ }
164
+
165
+ let WASM_VECTOR_LEN = 0;
166
+
167
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
168
+
169
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
170
+ ? function (arg, view) {
171
+ return cachedTextEncoder.encodeInto(arg, view);
172
+ }
173
+ : function (arg, view) {
174
+ const buf = cachedTextEncoder.encode(arg);
175
+ view.set(buf);
176
+ return {
177
+ read: arg.length,
178
+ written: buf.length
179
+ };
180
+ });
181
+
182
+ function passStringToWasm0(arg, malloc, realloc) {
183
+
184
+ if (realloc === undefined) {
185
+ const buf = cachedTextEncoder.encode(arg);
186
+ const ptr = malloc(buf.length, 1) >>> 0;
187
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
188
+ WASM_VECTOR_LEN = buf.length;
189
+ return ptr;
190
+ }
191
+
192
+ let len = arg.length;
193
+ let ptr = malloc(len, 1) >>> 0;
194
+
195
+ const mem = getUint8ArrayMemory0();
196
+
197
+ let offset = 0;
198
+
199
+ for (; offset < len; offset++) {
200
+ const code = arg.charCodeAt(offset);
201
+ if (code > 0x7F) break;
202
+ mem[ptr + offset] = code;
203
+ }
204
+
205
+ if (offset !== len) {
206
+ if (offset !== 0) {
207
+ arg = arg.slice(offset);
208
+ }
209
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
210
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
211
+ const ret = encodeString(arg, view);
212
+
213
+ offset += ret.written;
214
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
215
+ }
216
+
217
+ WASM_VECTOR_LEN = offset;
218
+ return ptr;
219
+ }
220
+
221
+ let cachedDataViewMemory0 = null;
222
+
223
+ function getDataViewMemory0() {
224
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
225
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
226
+ }
227
+ return cachedDataViewMemory0;
228
+ }
229
+ /**
230
+ * Convert snarkjs public signals JSON to hex bytes for Soroban contract.
231
+ * @param {string} public_json
232
+ * @returns {string}
233
+ */
234
+ function publicToHex(public_json) {
235
+ let deferred2_0;
236
+ let deferred2_1;
237
+ try {
238
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
239
+ const ptr0 = passStringToWasm0(public_json, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
240
+ const len0 = WASM_VECTOR_LEN;
241
+ wasm.publicToHex(retptr, ptr0, len0);
242
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
243
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
244
+ deferred2_0 = r0;
245
+ deferred2_1 = r1;
246
+ return getStringFromWasm0(r0, r1);
247
+ } finally {
248
+ wasm.__wbindgen_add_to_stack_pointer(16);
249
+ wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
250
+ }
251
+ }
252
+
253
+ /**
254
+ * Calculate nullifier hash from nullifier decimal string.
255
+ * Returns hex string (0x...)
256
+ * @param {string} nullifier_decimal
257
+ * @returns {string}
258
+ */
259
+ function calculateNullifierHash(nullifier_decimal) {
260
+ let deferred3_0;
261
+ let deferred3_1;
262
+ try {
263
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
264
+ const ptr0 = passStringToWasm0(nullifier_decimal, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
265
+ const len0 = WASM_VECTOR_LEN;
266
+ wasm.calculateNullifierHash(retptr, ptr0, len0);
267
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
268
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
269
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
270
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
271
+ var ptr2 = r0;
272
+ var len2 = r1;
273
+ if (r3) {
274
+ ptr2 = 0; len2 = 0;
275
+ throw takeObject(r2);
276
+ }
277
+ deferred3_0 = ptr2;
278
+ deferred3_1 = len2;
279
+ return getStringFromWasm0(ptr2, len2);
280
+ } finally {
281
+ wasm.__wbindgen_add_to_stack_pointer(16);
282
+ wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
283
+ }
284
+ }
285
+
286
+ /**
287
+ * Generate withdrawal SNARK input from coin and state JSON strings.
288
+ * Returns JSON string of SnarkInput.
289
+ * @param {string} coin_json
290
+ * @param {string} state_json
291
+ * @returns {string}
292
+ */
293
+ function generateWithdrawalInput(coin_json, state_json) {
294
+ let deferred4_0;
295
+ let deferred4_1;
296
+ try {
297
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
298
+ const ptr0 = passStringToWasm0(coin_json, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
299
+ const len0 = WASM_VECTOR_LEN;
300
+ const ptr1 = passStringToWasm0(state_json, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
301
+ const len1 = WASM_VECTOR_LEN;
302
+ wasm.generateWithdrawalInput(retptr, ptr0, len0, ptr1, len1);
303
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
304
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
305
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
306
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
307
+ var ptr3 = r0;
308
+ var len3 = r1;
309
+ if (r3) {
310
+ ptr3 = 0; len3 = 0;
311
+ throw takeObject(r2);
312
+ }
313
+ deferred4_0 = ptr3;
314
+ deferred4_1 = len3;
315
+ return getStringFromWasm0(ptr3, len3);
316
+ } finally {
317
+ wasm.__wbindgen_add_to_stack_pointer(16);
318
+ wasm.__wbindgen_export_3(deferred4_0, deferred4_1, 1);
319
+ }
320
+ }
321
+
322
+ /**
323
+ * Generate a new coin with random nullifier and secret.
324
+ * Returns JSON: { coin: { value, nullifier, secret, commitment }, commitment_hex }
325
+ * @returns {any}
326
+ */
327
+ function generateCoin() {
328
+ const ret = wasm.generateCoin();
329
+ return takeObject(ret);
330
+ }
331
+
332
+ /**
333
+ * Convert snarkjs proof JSON to hex bytes for Soroban contract.
334
+ * @param {string} proof_json
335
+ * @returns {string}
336
+ */
337
+ function proofToHex(proof_json) {
338
+ let deferred2_0;
339
+ let deferred2_1;
340
+ try {
341
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
342
+ const ptr0 = passStringToWasm0(proof_json, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
343
+ const len0 = WASM_VECTOR_LEN;
344
+ wasm.proofToHex(retptr, ptr0, len0);
345
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
346
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
347
+ deferred2_0 = r0;
348
+ deferred2_1 = r1;
349
+ return getStringFromWasm0(r0, r1);
350
+ } finally {
351
+ wasm.__wbindgen_add_to_stack_pointer(16);
352
+ wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
353
+ }
354
+ }
355
+
356
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
357
+
358
+ async function __wbg_load(module, imports) {
359
+ if (typeof Response === 'function' && module instanceof Response) {
360
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
361
+ try {
362
+ return await WebAssembly.instantiateStreaming(module, imports);
363
+
364
+ } catch (e) {
365
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
366
+
367
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
368
+ 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);
369
+
370
+ } else {
371
+ throw e;
372
+ }
373
+ }
374
+ }
375
+
376
+ const bytes = await module.arrayBuffer();
377
+ return await WebAssembly.instantiate(bytes, imports);
378
+
379
+ } else {
380
+ const instance = await WebAssembly.instantiate(module, imports);
381
+
382
+ if (instance instanceof WebAssembly.Instance) {
383
+ return { instance, module };
384
+
385
+ } else {
386
+ return instance;
387
+ }
388
+ }
389
+ }
390
+
391
+ function __wbg_get_imports() {
392
+ const imports = {};
393
+ imports.wbg = {};
394
+ imports.wbg.__wbg_buffer_a1a27a0dfa70165d = function(arg0) {
395
+ const ret = getObject(arg0).buffer;
396
+ return addHeapObject(ret);
397
+ };
398
+ imports.wbg.__wbg_call_f2db6205e5c51dc8 = function() { return handleError(function (arg0, arg1, arg2) {
399
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
400
+ return addHeapObject(ret);
401
+ }, arguments) };
402
+ imports.wbg.__wbg_call_fbe8be8bf6436ce5 = function() { return handleError(function (arg0, arg1) {
403
+ const ret = getObject(arg0).call(getObject(arg1));
404
+ return addHeapObject(ret);
405
+ }, arguments) };
406
+ imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
407
+ const ret = getObject(arg0).crypto;
408
+ return addHeapObject(ret);
409
+ };
410
+ imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
411
+ getObject(arg0).getRandomValues(getObject(arg1));
412
+ }, arguments) };
413
+ imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
414
+ const ret = getObject(arg0).msCrypto;
415
+ return addHeapObject(ret);
416
+ };
417
+ imports.wbg.__wbg_new_07b483f72211fd66 = function() {
418
+ const ret = new Object();
419
+ return addHeapObject(ret);
420
+ };
421
+ imports.wbg.__wbg_new_e52b3efaaa774f96 = function(arg0) {
422
+ const ret = new Uint8Array(getObject(arg0));
423
+ return addHeapObject(ret);
424
+ };
425
+ imports.wbg.__wbg_newnoargs_ff528e72d35de39a = function(arg0, arg1) {
426
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
427
+ return addHeapObject(ret);
428
+ };
429
+ imports.wbg.__wbg_newwithbyteoffsetandlength_3b01ecda099177e8 = function(arg0, arg1, arg2) {
430
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
431
+ return addHeapObject(ret);
432
+ };
433
+ imports.wbg.__wbg_newwithlength_08f872dc1e3ada2e = function(arg0) {
434
+ const ret = new Uint8Array(arg0 >>> 0);
435
+ return addHeapObject(ret);
436
+ };
437
+ imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) {
438
+ const ret = getObject(arg0).node;
439
+ return addHeapObject(ret);
440
+ };
441
+ imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
442
+ const ret = getObject(arg0).process;
443
+ return addHeapObject(ret);
444
+ };
445
+ imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
446
+ getObject(arg0).randomFillSync(takeObject(arg1));
447
+ }, arguments) };
448
+ imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
449
+ const ret = module.require;
450
+ return addHeapObject(ret);
451
+ }, arguments) };
452
+ imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
453
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
454
+ };
455
+ imports.wbg.__wbg_set_fe4e79d1ed3b0e9b = function(arg0, arg1, arg2) {
456
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
457
+ };
458
+ imports.wbg.__wbg_static_accessor_GLOBAL_487c52c58d65314d = function() {
459
+ const ret = typeof global === 'undefined' ? null : global;
460
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
461
+ };
462
+ imports.wbg.__wbg_static_accessor_GLOBAL_THIS_ee9704f328b6b291 = function() {
463
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
464
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
465
+ };
466
+ imports.wbg.__wbg_static_accessor_SELF_78c9e3071b912620 = function() {
467
+ const ret = typeof self === 'undefined' ? null : self;
468
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
469
+ };
470
+ imports.wbg.__wbg_static_accessor_WINDOW_a093d21393777366 = function() {
471
+ const ret = typeof window === 'undefined' ? null : window;
472
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
473
+ };
474
+ imports.wbg.__wbg_subarray_dd4ade7d53bd8e26 = function(arg0, arg1, arg2) {
475
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
476
+ return addHeapObject(ret);
477
+ };
478
+ imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) {
479
+ const ret = getObject(arg0).versions;
480
+ return addHeapObject(ret);
481
+ };
482
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
483
+ const ret = debugString(getObject(arg1));
484
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
485
+ const len1 = WASM_VECTOR_LEN;
486
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
487
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
488
+ };
489
+ imports.wbg.__wbindgen_is_function = function(arg0) {
490
+ const ret = typeof(getObject(arg0)) === 'function';
491
+ return ret;
492
+ };
493
+ imports.wbg.__wbindgen_is_object = function(arg0) {
494
+ const val = getObject(arg0);
495
+ const ret = typeof(val) === 'object' && val !== null;
496
+ return ret;
497
+ };
498
+ imports.wbg.__wbindgen_is_string = function(arg0) {
499
+ const ret = typeof(getObject(arg0)) === 'string';
500
+ return ret;
501
+ };
502
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
503
+ const ret = getObject(arg0) === undefined;
504
+ return ret;
505
+ };
506
+ imports.wbg.__wbindgen_memory = function() {
507
+ const ret = wasm.memory;
508
+ return addHeapObject(ret);
509
+ };
510
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
511
+ const ret = getObject(arg0);
512
+ return addHeapObject(ret);
513
+ };
514
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
515
+ takeObject(arg0);
516
+ };
517
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
518
+ const ret = getStringFromWasm0(arg0, arg1);
519
+ return addHeapObject(ret);
520
+ };
521
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
522
+ throw new Error(getStringFromWasm0(arg0, arg1));
523
+ };
524
+
525
+ return imports;
526
+ }
527
+
528
+ function __wbg_finalize_init(instance, module) {
529
+ wasm = instance.exports;
530
+ __wbg_init.__wbindgen_wasm_module = module;
531
+ cachedDataViewMemory0 = null;
532
+ cachedUint8ArrayMemory0 = null;
533
+
534
+
535
+
536
+ return wasm;
537
+ }
538
+
539
+ function initSync(module) {
540
+ if (wasm !== undefined) return wasm;
541
+
542
+
543
+ if (typeof module !== 'undefined') {
544
+ if (Object.getPrototypeOf(module) === Object.prototype) {
545
+ ({module} = module);
546
+ } else {
547
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead');
548
+ }
549
+ }
550
+
551
+ const imports = __wbg_get_imports();
552
+
553
+ if (!(module instanceof WebAssembly.Module)) {
554
+ module = new WebAssembly.Module(module);
555
+ }
556
+
557
+ const instance = new WebAssembly.Instance(module, imports);
558
+
559
+ return __wbg_finalize_init(instance, module);
560
+ }
561
+
562
+ async function __wbg_init(module_or_path) {
563
+ if (wasm !== undefined) return wasm;
564
+
565
+
566
+ if (typeof module_or_path !== 'undefined') {
567
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
568
+ ({module_or_path} = module_or_path);
569
+ } else {
570
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead');
571
+ }
572
+ }
573
+
574
+ if (typeof module_or_path === 'undefined') {
575
+ module_or_path = new URL('client_sdk_wasm_bg.wasm', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
576
+ }
577
+ const imports = __wbg_get_imports();
578
+
579
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
580
+ module_or_path = fetch(module_or_path);
581
+ }
582
+
583
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
584
+
585
+ return __wbg_finalize_init(instance, module);
586
+ }
587
+
588
+ var wasmBindings = /*#__PURE__*/Object.freeze({
589
+ __proto__: null,
590
+ calculateNullifierHash: calculateNullifierHash,
591
+ default: __wbg_init,
592
+ generateCoin: generateCoin,
593
+ generateWithdrawalInput: generateWithdrawalInput,
594
+ initSync: initSync,
595
+ proofToHex: proofToHex,
596
+ publicToHex: publicToHex
597
+ });
598
+
30
599
  const isNode$2 = typeof process !== 'undefined' && !!process.versions?.node;
31
600
  let wasmModule = null;
32
601
  async function loadWasm(wasmBinary) {
@@ -34,7 +603,7 @@ async function loadWasm(wasmBinary) {
34
603
  return wasmModule;
35
604
  if (isNode$2) {
36
605
  if (wasmBinary) {
37
- wasmBindings__namespace.initSync(wasmBinary);
606
+ initSync(wasmBinary);
38
607
  }
39
608
  else {
40
609
  const path = await import('path');
@@ -43,18 +612,18 @@ async function loadWasm(wasmBinary) {
43
612
  const dir = path.dirname(fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href))));
44
613
  const wasmPath = path.resolve(dir, '..', 'pkg', 'client_sdk_wasm_bg.wasm');
45
614
  const buffer = fs.readFileSync(wasmPath);
46
- wasmBindings__namespace.initSync(buffer);
615
+ initSync(buffer);
47
616
  }
48
- wasmModule = wasmBindings__namespace;
617
+ wasmModule = wasmBindings;
49
618
  }
50
619
  else {
51
620
  if (wasmBinary) {
52
- wasmBindings__namespace.initSync(wasmBinary);
621
+ initSync(wasmBinary);
53
622
  }
54
623
  else {
55
- await wasmBindings__namespace.default();
624
+ await __wbg_init();
56
625
  }
57
- wasmModule = wasmBindings__namespace;
626
+ wasmModule = wasmBindings;
58
627
  }
59
628
  return wasmModule;
60
629
  }