@quilibrium/quilibrium-js-bulletproofs-sdk 2.1.0-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.
@@ -0,0 +1,843 @@
1
+ import { Buffer as Buffer$1 } from 'buffer';
2
+
3
+ let wasm;
4
+
5
+ const heap = new Array(128).fill(undefined);
6
+
7
+ heap.push(undefined, null, true, false);
8
+
9
+ heap.length;
10
+
11
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
12
+
13
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
14
+ let cachedUint8Memory0 = null;
15
+
16
+ function getUint8Memory0() {
17
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
18
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
19
+ }
20
+ return cachedUint8Memory0;
21
+ }
22
+
23
+ function getStringFromWasm0(ptr, len) {
24
+ ptr = ptr >>> 0;
25
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
26
+ }
27
+
28
+ let WASM_VECTOR_LEN = 0;
29
+
30
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
31
+
32
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
33
+ ? function (arg, view) {
34
+ return cachedTextEncoder.encodeInto(arg, view);
35
+ }
36
+ : function (arg, view) {
37
+ const buf = cachedTextEncoder.encode(arg);
38
+ view.set(buf);
39
+ return {
40
+ read: arg.length,
41
+ written: buf.length
42
+ };
43
+ });
44
+
45
+ function passStringToWasm0(arg, malloc, realloc) {
46
+
47
+ if (realloc === undefined) {
48
+ const buf = cachedTextEncoder.encode(arg);
49
+ const ptr = malloc(buf.length, 1) >>> 0;
50
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
51
+ WASM_VECTOR_LEN = buf.length;
52
+ return ptr;
53
+ }
54
+
55
+ let len = arg.length;
56
+ let ptr = malloc(len, 1) >>> 0;
57
+
58
+ const mem = getUint8Memory0();
59
+
60
+ let offset = 0;
61
+
62
+ for (; offset < len; offset++) {
63
+ const code = arg.charCodeAt(offset);
64
+ if (code > 0x7F) break;
65
+ mem[ptr + offset] = code;
66
+ }
67
+
68
+ if (offset !== len) {
69
+ if (offset !== 0) {
70
+ arg = arg.slice(offset);
71
+ }
72
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
73
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
74
+ const ret = encodeString(arg, view);
75
+
76
+ offset += ret.written;
77
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
78
+ }
79
+
80
+ WASM_VECTOR_LEN = offset;
81
+ return ptr;
82
+ }
83
+
84
+ let cachedInt32Memory0 = null;
85
+
86
+ function getInt32Memory0() {
87
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
88
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
89
+ }
90
+ return cachedInt32Memory0;
91
+ }
92
+ /**
93
+ * @param {string} values
94
+ * @param {string} blinding
95
+ * @param {bigint} bit_size
96
+ * @returns {string}
97
+ */
98
+ function js_generate_range_proof(values, blinding, bit_size) {
99
+ let deferred3_0;
100
+ let deferred3_1;
101
+ try {
102
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
103
+ const ptr0 = passStringToWasm0(values, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
104
+ const len0 = WASM_VECTOR_LEN;
105
+ const ptr1 = passStringToWasm0(blinding, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
106
+ const len1 = WASM_VECTOR_LEN;
107
+ wasm.js_generate_range_proof(retptr, ptr0, len0, ptr1, len1, bit_size);
108
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
109
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
110
+ deferred3_0 = r0;
111
+ deferred3_1 = r1;
112
+ return getStringFromWasm0(r0, r1);
113
+ } finally {
114
+ wasm.__wbindgen_add_to_stack_pointer(16);
115
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
116
+ }
117
+ }
118
+
119
+ /**
120
+ * @param {string} proof
121
+ * @param {string} commitment
122
+ * @param {bigint} bit_size
123
+ * @returns {string}
124
+ */
125
+ function js_verify_range_proof(proof, commitment, bit_size) {
126
+ let deferred3_0;
127
+ let deferred3_1;
128
+ try {
129
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
130
+ const ptr0 = passStringToWasm0(proof, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
131
+ const len0 = WASM_VECTOR_LEN;
132
+ const ptr1 = passStringToWasm0(commitment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
133
+ const len1 = WASM_VECTOR_LEN;
134
+ wasm.js_verify_range_proof(retptr, ptr0, len0, ptr1, len1, bit_size);
135
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
136
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
137
+ deferred3_0 = r0;
138
+ deferred3_1 = r1;
139
+ return getStringFromWasm0(r0, r1);
140
+ } finally {
141
+ wasm.__wbindgen_add_to_stack_pointer(16);
142
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
143
+ }
144
+ }
145
+
146
+ /**
147
+ * @param {string} input_commitments
148
+ * @param {string} additional_input_values
149
+ * @param {string} output_commitments
150
+ * @param {string} additional_output_values
151
+ * @returns {string}
152
+ */
153
+ function js_sum_check(input_commitments, additional_input_values, output_commitments, additional_output_values) {
154
+ let deferred5_0;
155
+ let deferred5_1;
156
+ try {
157
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
158
+ const ptr0 = passStringToWasm0(input_commitments, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
159
+ const len0 = WASM_VECTOR_LEN;
160
+ const ptr1 = passStringToWasm0(additional_input_values, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
161
+ const len1 = WASM_VECTOR_LEN;
162
+ const ptr2 = passStringToWasm0(output_commitments, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
163
+ const len2 = WASM_VECTOR_LEN;
164
+ const ptr3 = passStringToWasm0(additional_output_values, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
165
+ const len3 = WASM_VECTOR_LEN;
166
+ wasm.js_sum_check(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
167
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
168
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
169
+ deferred5_0 = r0;
170
+ deferred5_1 = r1;
171
+ return getStringFromWasm0(r0, r1);
172
+ } finally {
173
+ wasm.__wbindgen_add_to_stack_pointer(16);
174
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
175
+ }
176
+ }
177
+
178
+ /**
179
+ * @param {string} values
180
+ * @param {string} blinding
181
+ * @returns {string}
182
+ */
183
+ function js_generate_input_commitments(values, blinding) {
184
+ let deferred3_0;
185
+ let deferred3_1;
186
+ try {
187
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
188
+ const ptr0 = passStringToWasm0(values, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
189
+ const len0 = WASM_VECTOR_LEN;
190
+ const ptr1 = passStringToWasm0(blinding, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
191
+ const len1 = WASM_VECTOR_LEN;
192
+ wasm.js_generate_input_commitments(retptr, ptr0, len0, ptr1, len1);
193
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
194
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
195
+ deferred3_0 = r0;
196
+ deferred3_1 = r1;
197
+ return getStringFromWasm0(r0, r1);
198
+ } finally {
199
+ wasm.__wbindgen_add_to_stack_pointer(16);
200
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
201
+ }
202
+ }
203
+
204
+ /**
205
+ * @returns {string}
206
+ */
207
+ function js_keygen() {
208
+ let deferred1_0;
209
+ let deferred1_1;
210
+ try {
211
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
212
+ wasm.js_keygen(retptr);
213
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
214
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
215
+ deferred1_0 = r0;
216
+ deferred1_1 = r1;
217
+ return getStringFromWasm0(r0, r1);
218
+ } finally {
219
+ wasm.__wbindgen_add_to_stack_pointer(16);
220
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
221
+ }
222
+ }
223
+
224
+ /**
225
+ * @param {string} input
226
+ * @returns {string}
227
+ */
228
+ function js_scalar_to_point(input) {
229
+ let deferred2_0;
230
+ let deferred2_1;
231
+ try {
232
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
233
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
234
+ const len0 = WASM_VECTOR_LEN;
235
+ wasm.js_scalar_to_point(retptr, ptr0, len0);
236
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
237
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
238
+ deferred2_0 = r0;
239
+ deferred2_1 = r1;
240
+ return getStringFromWasm0(r0, r1);
241
+ } finally {
242
+ wasm.__wbindgen_add_to_stack_pointer(16);
243
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
244
+ }
245
+ }
246
+
247
+ /**
248
+ * @returns {string}
249
+ */
250
+ function js_alt_generator() {
251
+ let deferred1_0;
252
+ let deferred1_1;
253
+ try {
254
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
255
+ wasm.js_alt_generator(retptr);
256
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
257
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
258
+ deferred1_0 = r0;
259
+ deferred1_1 = r1;
260
+ return getStringFromWasm0(r0, r1);
261
+ } finally {
262
+ wasm.__wbindgen_add_to_stack_pointer(16);
263
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
264
+ }
265
+ }
266
+
267
+ /**
268
+ * @param {string} lhs
269
+ * @param {string} rhs
270
+ * @returns {string}
271
+ */
272
+ function js_scalar_addition(lhs, rhs) {
273
+ let deferred3_0;
274
+ let deferred3_1;
275
+ try {
276
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
277
+ const ptr0 = passStringToWasm0(lhs, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
278
+ const len0 = WASM_VECTOR_LEN;
279
+ const ptr1 = passStringToWasm0(rhs, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
280
+ const len1 = WASM_VECTOR_LEN;
281
+ wasm.js_scalar_addition(retptr, ptr0, len0, ptr1, len1);
282
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
283
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
284
+ deferred3_0 = r0;
285
+ deferred3_1 = r1;
286
+ return getStringFromWasm0(r0, r1);
287
+ } finally {
288
+ wasm.__wbindgen_add_to_stack_pointer(16);
289
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
290
+ }
291
+ }
292
+
293
+ /**
294
+ * @param {string} lhs
295
+ * @param {string} rhs
296
+ * @returns {string}
297
+ */
298
+ function js_scalar_mult(lhs, rhs) {
299
+ let deferred3_0;
300
+ let deferred3_1;
301
+ try {
302
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
303
+ const ptr0 = passStringToWasm0(lhs, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
304
+ const len0 = WASM_VECTOR_LEN;
305
+ const ptr1 = passStringToWasm0(rhs, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
306
+ const len1 = WASM_VECTOR_LEN;
307
+ wasm.js_scalar_mult(retptr, ptr0, len0, ptr1, len1);
308
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
309
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
310
+ deferred3_0 = r0;
311
+ deferred3_1 = r1;
312
+ return getStringFromWasm0(r0, r1);
313
+ } finally {
314
+ wasm.__wbindgen_add_to_stack_pointer(16);
315
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
316
+ }
317
+ }
318
+
319
+ /**
320
+ * @param {string} input_scalar
321
+ * @param {string} public_point
322
+ * @returns {string}
323
+ */
324
+ function js_scalar_mult_point(input_scalar, public_point) {
325
+ let deferred3_0;
326
+ let deferred3_1;
327
+ try {
328
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
329
+ const ptr0 = passStringToWasm0(input_scalar, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
330
+ const len0 = WASM_VECTOR_LEN;
331
+ const ptr1 = passStringToWasm0(public_point, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
332
+ const len1 = WASM_VECTOR_LEN;
333
+ wasm.js_scalar_mult_point(retptr, ptr0, len0, ptr1, len1);
334
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
335
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
336
+ deferred3_0 = r0;
337
+ deferred3_1 = r1;
338
+ return getStringFromWasm0(r0, r1);
339
+ } finally {
340
+ wasm.__wbindgen_add_to_stack_pointer(16);
341
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
342
+ }
343
+ }
344
+
345
+ /**
346
+ * @param {string} input_scalar
347
+ * @returns {string}
348
+ */
349
+ function js_scalar_inverse(input_scalar) {
350
+ let deferred2_0;
351
+ let deferred2_1;
352
+ try {
353
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
354
+ const ptr0 = passStringToWasm0(input_scalar, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
355
+ const len0 = WASM_VECTOR_LEN;
356
+ wasm.js_scalar_inverse(retptr, ptr0, len0);
357
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
358
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
359
+ deferred2_0 = r0;
360
+ deferred2_1 = r1;
361
+ return getStringFromWasm0(r0, r1);
362
+ } finally {
363
+ wasm.__wbindgen_add_to_stack_pointer(16);
364
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
365
+ }
366
+ }
367
+
368
+ /**
369
+ * @param {string} lhs
370
+ * @param {string} rhs
371
+ * @returns {string}
372
+ */
373
+ function js_scalar_subtraction(lhs, rhs) {
374
+ let deferred3_0;
375
+ let deferred3_1;
376
+ try {
377
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
378
+ const ptr0 = passStringToWasm0(lhs, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
379
+ const len0 = WASM_VECTOR_LEN;
380
+ const ptr1 = passStringToWasm0(rhs, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
381
+ const len1 = WASM_VECTOR_LEN;
382
+ wasm.js_scalar_subtraction(retptr, ptr0, len0, ptr1, len1);
383
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
384
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
385
+ deferred3_0 = r0;
386
+ deferred3_1 = r1;
387
+ return getStringFromWasm0(r0, r1);
388
+ } finally {
389
+ wasm.__wbindgen_add_to_stack_pointer(16);
390
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
391
+ }
392
+ }
393
+
394
+ /**
395
+ * @param {string} input_scalar
396
+ * @param {string} public_point
397
+ * @returns {string}
398
+ */
399
+ function js_scalar_mult_hash_to_scalar(input_scalar, public_point) {
400
+ let deferred3_0;
401
+ let deferred3_1;
402
+ try {
403
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
404
+ const ptr0 = passStringToWasm0(input_scalar, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
405
+ const len0 = WASM_VECTOR_LEN;
406
+ const ptr1 = passStringToWasm0(public_point, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
407
+ const len1 = WASM_VECTOR_LEN;
408
+ wasm.js_scalar_mult_hash_to_scalar(retptr, ptr0, len0, ptr1, len1);
409
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
410
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
411
+ deferred3_0 = r0;
412
+ deferred3_1 = r1;
413
+ return getStringFromWasm0(r0, r1);
414
+ } finally {
415
+ wasm.__wbindgen_add_to_stack_pointer(16);
416
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
417
+ }
418
+ }
419
+
420
+ /**
421
+ * @param {string} input
422
+ * @returns {string}
423
+ */
424
+ function js_hash_to_scalar(input) {
425
+ let deferred2_0;
426
+ let deferred2_1;
427
+ try {
428
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
429
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
430
+ const len0 = WASM_VECTOR_LEN;
431
+ wasm.js_hash_to_scalar(retptr, ptr0, len0);
432
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
433
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
434
+ deferred2_0 = r0;
435
+ deferred2_1 = r1;
436
+ return getStringFromWasm0(r0, r1);
437
+ } finally {
438
+ wasm.__wbindgen_add_to_stack_pointer(16);
439
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
440
+ }
441
+ }
442
+
443
+ /**
444
+ * @param {string} input_point
445
+ * @param {string} public_point
446
+ * @returns {string}
447
+ */
448
+ function js_point_addition(input_point, public_point) {
449
+ let deferred3_0;
450
+ let deferred3_1;
451
+ try {
452
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
453
+ const ptr0 = passStringToWasm0(input_point, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
454
+ const len0 = WASM_VECTOR_LEN;
455
+ const ptr1 = passStringToWasm0(public_point, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
456
+ const len1 = WASM_VECTOR_LEN;
457
+ wasm.js_point_addition(retptr, ptr0, len0, ptr1, len1);
458
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
459
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
460
+ deferred3_0 = r0;
461
+ deferred3_1 = r1;
462
+ return getStringFromWasm0(r0, r1);
463
+ } finally {
464
+ wasm.__wbindgen_add_to_stack_pointer(16);
465
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
466
+ }
467
+ }
468
+
469
+ /**
470
+ * @param {string} input_point
471
+ * @param {string} public_point
472
+ * @returns {string}
473
+ */
474
+ function js_point_subtraction(input_point, public_point) {
475
+ let deferred3_0;
476
+ let deferred3_1;
477
+ try {
478
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
479
+ const ptr0 = passStringToWasm0(input_point, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
480
+ const len0 = WASM_VECTOR_LEN;
481
+ const ptr1 = passStringToWasm0(public_point, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
482
+ const len1 = WASM_VECTOR_LEN;
483
+ wasm.js_point_subtraction(retptr, ptr0, len0, ptr1, len1);
484
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
485
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
486
+ deferred3_0 = r0;
487
+ deferred3_1 = r1;
488
+ return getStringFromWasm0(r0, r1);
489
+ } finally {
490
+ wasm.__wbindgen_add_to_stack_pointer(16);
491
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
492
+ }
493
+ }
494
+
495
+ /**
496
+ * @param {string} x
497
+ * @param {string} t
498
+ * @param {string} a
499
+ * @param {string} r
500
+ * @returns {string}
501
+ */
502
+ function js_sign_hidden(x, t, a, r) {
503
+ let deferred5_0;
504
+ let deferred5_1;
505
+ try {
506
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
507
+ const ptr0 = passStringToWasm0(x, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
508
+ const len0 = WASM_VECTOR_LEN;
509
+ const ptr1 = passStringToWasm0(t, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
510
+ const len1 = WASM_VECTOR_LEN;
511
+ const ptr2 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
512
+ const len2 = WASM_VECTOR_LEN;
513
+ const ptr3 = passStringToWasm0(r, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
514
+ const len3 = WASM_VECTOR_LEN;
515
+ wasm.js_sign_hidden(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
516
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
517
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
518
+ deferred5_0 = r0;
519
+ deferred5_1 = r1;
520
+ return getStringFromWasm0(r0, r1);
521
+ } finally {
522
+ wasm.__wbindgen_add_to_stack_pointer(16);
523
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
524
+ }
525
+ }
526
+
527
+ /**
528
+ * @param {string} secret
529
+ * @param {string} message
530
+ * @returns {string}
531
+ */
532
+ function js_sign_simple(secret, message) {
533
+ let deferred3_0;
534
+ let deferred3_1;
535
+ try {
536
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
537
+ const ptr0 = passStringToWasm0(secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
538
+ const len0 = WASM_VECTOR_LEN;
539
+ const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
540
+ const len1 = WASM_VECTOR_LEN;
541
+ wasm.js_sign_simple(retptr, ptr0, len0, ptr1, len1);
542
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
543
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
544
+ deferred3_0 = r0;
545
+ deferred3_1 = r1;
546
+ return getStringFromWasm0(r0, r1);
547
+ } finally {
548
+ wasm.__wbindgen_add_to_stack_pointer(16);
549
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
550
+ }
551
+ }
552
+
553
+ /**
554
+ * @param {string} message
555
+ * @param {string} signature
556
+ * @param {string} public_point
557
+ * @returns {string}
558
+ */
559
+ function js_verify_simple(message, signature, public_point) {
560
+ let deferred4_0;
561
+ let deferred4_1;
562
+ try {
563
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
564
+ const ptr0 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
565
+ const len0 = WASM_VECTOR_LEN;
566
+ const ptr1 = passStringToWasm0(signature, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
567
+ const len1 = WASM_VECTOR_LEN;
568
+ const ptr2 = passStringToWasm0(public_point, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
569
+ const len2 = WASM_VECTOR_LEN;
570
+ wasm.js_verify_simple(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
571
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
572
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
573
+ deferred4_0 = r0;
574
+ deferred4_1 = r1;
575
+ return getStringFromWasm0(r0, r1);
576
+ } finally {
577
+ wasm.__wbindgen_add_to_stack_pointer(16);
578
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
579
+ }
580
+ }
581
+
582
+ /**
583
+ * @param {string} c
584
+ * @param {string} t
585
+ * @param {string} s1
586
+ * @param {string} s2
587
+ * @param {string} s3
588
+ * @param {string} p_point
589
+ * @param {string} c_point
590
+ * @returns {string}
591
+ */
592
+ function js_verify_hidden(c, t, s1, s2, s3, p_point, c_point) {
593
+ let deferred8_0;
594
+ let deferred8_1;
595
+ try {
596
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
597
+ const ptr0 = passStringToWasm0(c, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
598
+ const len0 = WASM_VECTOR_LEN;
599
+ const ptr1 = passStringToWasm0(t, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
600
+ const len1 = WASM_VECTOR_LEN;
601
+ const ptr2 = passStringToWasm0(s1, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
602
+ const len2 = WASM_VECTOR_LEN;
603
+ const ptr3 = passStringToWasm0(s2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
604
+ const len3 = WASM_VECTOR_LEN;
605
+ const ptr4 = passStringToWasm0(s3, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
606
+ const len4 = WASM_VECTOR_LEN;
607
+ const ptr5 = passStringToWasm0(p_point, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
608
+ const len5 = WASM_VECTOR_LEN;
609
+ const ptr6 = passStringToWasm0(c_point, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
610
+ const len6 = WASM_VECTOR_LEN;
611
+ wasm.js_verify_hidden(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
612
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
613
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
614
+ deferred8_0 = r0;
615
+ deferred8_1 = r1;
616
+ return getStringFromWasm0(r0, r1);
617
+ } finally {
618
+ wasm.__wbindgen_add_to_stack_pointer(16);
619
+ wasm.__wbindgen_free(deferred8_0, deferred8_1, 1);
620
+ }
621
+ }
622
+
623
+ class BulletproofsError extends Error {
624
+ }
625
+ function BulletproofsGenerateRangeProof(values, blinding, bitSize) {
626
+ const result = JSON.parse(js_generate_range_proof(JSON.stringify(values.map(v => Buffer.from(v).toString('hex'))), JSON.stringify(blinding.map(b => Buffer.from(b).toString('hex'))), BigInt(bitSize)));
627
+ if (typeof (result) == 'object') {
628
+ if (result.proof && result.commitment) {
629
+ return {
630
+ proof: Buffer.from(result.proof, 'hex'),
631
+ commitment: Buffer.from(result.commitment, 'hex'),
632
+ };
633
+ }
634
+ }
635
+ throw new BulletproofsError(result.error || "unknown response");
636
+ }
637
+ function BulletproofsVerifyRangeProof(proof, commitment, bitSize) {
638
+ const result = JSON.parse(js_verify_range_proof(Buffer.from(proof).toString('hex'), Buffer.from(commitment).toString('hex'), BigInt(bitSize)));
639
+ if (typeof (result) == 'boolean') {
640
+ return result;
641
+ }
642
+ else {
643
+ throw new BulletproofsError(result.error);
644
+ }
645
+ }
646
+ function BulletproofsSumCheck(inputCommitments, additionalInputValues, outputCommitments, additionalOutputValues) {
647
+ const result = JSON.parse(js_sum_check(JSON.stringify(inputCommitments.map(c => Buffer.from(c).toString('hex'))), JSON.stringify(additionalInputValues.map(v => Buffer.from(v).toString('hex'))), JSON.stringify(outputCommitments.map(c => Buffer.from(c).toString('hex'))), JSON.stringify(additionalOutputValues.map(v => Buffer.from(v).toString('hex')))));
648
+ if (typeof (result) == 'boolean') {
649
+ return result;
650
+ }
651
+ else {
652
+ throw new BulletproofsError(result.error);
653
+ }
654
+ }
655
+ function BulletproofsGenerateInputCommitments(values, blinding) {
656
+ const result = JSON.parse(js_generate_input_commitments(JSON.stringify(values.map(v => Buffer.from(v).toString('hex'))), JSON.stringify(blinding.map(b => Buffer.from(b).toString('hex')))));
657
+ if (Array.isArray(result)) {
658
+ return result.map(c => Buffer.from(c, 'hex'));
659
+ }
660
+ else {
661
+ throw new BulletproofsError(result.error);
662
+ }
663
+ }
664
+ function BulletproofsKeygen() {
665
+ const result = JSON.parse(js_keygen());
666
+ if (typeof (result) == 'object') {
667
+ if (result.secret_key && result.public_key) {
668
+ return {
669
+ secretKey: Buffer.from(result.secret_key, 'hex'),
670
+ publicKey: Buffer.from(result.public_key, 'hex'),
671
+ };
672
+ }
673
+ }
674
+ throw new BulletproofsError("unknown response");
675
+ }
676
+ function BulletproofsScalarToPoint(scalar) {
677
+ const result = JSON.parse(js_scalar_to_point(Buffer.from(scalar).toString('hex')));
678
+ if (typeof (result) == 'string') {
679
+ return Buffer.from(result, 'hex');
680
+ }
681
+ else {
682
+ throw new BulletproofsError(result.error);
683
+ }
684
+ }
685
+ function BulletproofsAltGenerator() {
686
+ const result = JSON.parse(js_alt_generator());
687
+ if (typeof (result) == 'string') {
688
+ return Buffer.from(result, 'hex');
689
+ }
690
+ else {
691
+ throw new BulletproofsError(result.error);
692
+ }
693
+ }
694
+ function BulletproofsScalarAddition(lhs, rhs) {
695
+ const result = JSON.parse(js_scalar_addition(Buffer.from(lhs).toString('hex'), Buffer.from(rhs).toString('hex')));
696
+ if (typeof (result) == 'string') {
697
+ return Buffer.from(result, 'hex');
698
+ }
699
+ else {
700
+ throw new BulletproofsError(result.error);
701
+ }
702
+ }
703
+ function BulletproofsScalarMult(lhs, rhs) {
704
+ const result = JSON.parse(js_scalar_mult(Buffer.from(lhs).toString('hex'), Buffer.from(rhs).toString('hex')));
705
+ if (typeof (result) == 'string') {
706
+ return Buffer.from(result, 'hex');
707
+ }
708
+ else {
709
+ throw new BulletproofsError(result.error);
710
+ }
711
+ }
712
+ function BulletproofsScalarMultPoint(scalar, point) {
713
+ const result = JSON.parse(js_scalar_mult_point(Buffer.from(scalar).toString('hex'), Buffer.from(point).toString('hex')));
714
+ if (typeof (result) == 'string') {
715
+ return Buffer.from(result, 'hex');
716
+ }
717
+ else {
718
+ throw new BulletproofsError(result.error);
719
+ }
720
+ }
721
+ function BulletproofsScalarInverse(scalar) {
722
+ const result = JSON.parse(js_scalar_inverse(Buffer.from(scalar).toString('hex')));
723
+ if (typeof (result) == 'string') {
724
+ return Buffer.from(result, 'hex');
725
+ }
726
+ else {
727
+ throw new BulletproofsError(result.error);
728
+ }
729
+ }
730
+ function BulletproofsScalarSubtraction(lhs, rhs) {
731
+ const result = JSON.parse(js_scalar_subtraction(Buffer.from(lhs).toString('hex'), Buffer.from(rhs).toString('hex')));
732
+ if (typeof (result) == 'string') {
733
+ return Buffer.from(result, 'hex');
734
+ }
735
+ else {
736
+ throw new BulletproofsError(result.error);
737
+ }
738
+ }
739
+ function BulletproofsScalarMultHashToScalar(scalar, point) {
740
+ const result = JSON.parse(js_scalar_mult_hash_to_scalar(Buffer.from(scalar).toString('hex'), Buffer.from(point).toString('hex')));
741
+ if (typeof (result) == 'string') {
742
+ return Buffer.from(result, 'hex');
743
+ }
744
+ else {
745
+ throw new BulletproofsError(result.error);
746
+ }
747
+ }
748
+ function BulletproofsHashToScalar(input) {
749
+ const result = JSON.parse(js_hash_to_scalar(Buffer.from(input).toString('hex')));
750
+ if (typeof (result) == 'string') {
751
+ return Buffer.from(result, 'hex');
752
+ }
753
+ else {
754
+ throw new BulletproofsError(result.error);
755
+ }
756
+ }
757
+ function BulletproofsPointAddition(lhs, rhs) {
758
+ const result = JSON.parse(js_point_addition(Buffer.from(lhs).toString('hex'), Buffer.from(rhs).toString('hex')));
759
+ if (typeof (result) == 'string') {
760
+ return Buffer.from(result, 'hex');
761
+ }
762
+ else {
763
+ throw new BulletproofsError(result.error);
764
+ }
765
+ }
766
+ function BulletproofsPointSubtraction(lhs, rhs) {
767
+ const result = JSON.parse(js_point_subtraction(Buffer.from(lhs).toString('hex'), Buffer.from(rhs).toString('hex')));
768
+ if (typeof (result) == 'string') {
769
+ return Buffer.from(result, 'hex');
770
+ }
771
+ else {
772
+ throw new BulletproofsError(result.error);
773
+ }
774
+ }
775
+ function BulletproofsSignHidden(x, t, a, r) {
776
+ const result = JSON.parse(js_sign_hidden(Buffer.from(x).toString('hex'), Buffer.from(t).toString('hex'), Buffer.from(a).toString('hex'), Buffer.from(r).toString('hex')));
777
+ if (typeof (result) == 'object') {
778
+ if (result.c && result.s1 && result.s2 && result.s3) {
779
+ return {
780
+ c: Buffer.from(result.c, 'hex'),
781
+ s1: Buffer.from(result.s1, 'hex'),
782
+ s2: Buffer.from(result.s2, 'hex'),
783
+ s3: Buffer.from(result.s3, 'hex'),
784
+ };
785
+ }
786
+ }
787
+ throw new BulletproofsError(result.error || "unknown response");
788
+ }
789
+ function BulletproofsSignSimple(secret, message) {
790
+ const result = JSON.parse(js_sign_simple(Buffer.from(secret).toString('hex'), Buffer.from(message).toString('hex')));
791
+ if (typeof (result) == 'string') {
792
+ return Buffer.from(result, 'hex');
793
+ }
794
+ else {
795
+ throw new BulletproofsError(result.error);
796
+ }
797
+ }
798
+ function BulletproofsVerifySimple(message, signature, publicKey) {
799
+ const result = JSON.parse(js_verify_simple(Buffer.from(message).toString('hex'), Buffer.from(signature).toString('hex'), Buffer.from(publicKey).toString('hex')));
800
+ if (typeof (result) == 'boolean') {
801
+ return result;
802
+ }
803
+ else {
804
+ throw new BulletproofsError(result.error);
805
+ }
806
+ }
807
+ function BulletproofsVerifyHidden(c, t, s1, s2, s3, pPoint, cPoint) {
808
+ const result = JSON.parse(js_verify_hidden(Buffer.from(c).toString('hex'), Buffer.from(t).toString('hex'), Buffer.from(s1).toString('hex'), Buffer.from(s2).toString('hex'), Buffer.from(s3).toString('hex'), Buffer.from(pPoint).toString('hex'), Buffer.from(cPoint).toString('hex')));
809
+ if (typeof (result) == 'boolean') {
810
+ return result;
811
+ }
812
+ else {
813
+ throw new BulletproofsError(result.error);
814
+ }
815
+ }
816
+
817
+ var bulletproofs = /*#__PURE__*/Object.freeze({
818
+ __proto__: null,
819
+ BulletproofsAltGenerator: BulletproofsAltGenerator,
820
+ BulletproofsGenerateInputCommitments: BulletproofsGenerateInputCommitments,
821
+ BulletproofsGenerateRangeProof: BulletproofsGenerateRangeProof,
822
+ BulletproofsHashToScalar: BulletproofsHashToScalar,
823
+ BulletproofsKeygen: BulletproofsKeygen,
824
+ BulletproofsPointAddition: BulletproofsPointAddition,
825
+ BulletproofsPointSubtraction: BulletproofsPointSubtraction,
826
+ BulletproofsScalarAddition: BulletproofsScalarAddition,
827
+ BulletproofsScalarInverse: BulletproofsScalarInverse,
828
+ BulletproofsScalarMult: BulletproofsScalarMult,
829
+ BulletproofsScalarMultHashToScalar: BulletproofsScalarMultHashToScalar,
830
+ BulletproofsScalarMultPoint: BulletproofsScalarMultPoint,
831
+ BulletproofsScalarSubtraction: BulletproofsScalarSubtraction,
832
+ BulletproofsScalarToPoint: BulletproofsScalarToPoint,
833
+ BulletproofsSignHidden: BulletproofsSignHidden,
834
+ BulletproofsSignSimple: BulletproofsSignSimple,
835
+ BulletproofsSumCheck: BulletproofsSumCheck,
836
+ BulletproofsVerifyHidden: BulletproofsVerifyHidden,
837
+ BulletproofsVerifyRangeProof: BulletproofsVerifyRangeProof,
838
+ BulletproofsVerifySimple: BulletproofsVerifySimple
839
+ });
840
+
841
+ window.Buffer = Buffer$1;
842
+
843
+ export { bulletproofs as verenc };