@aptos-labs/confidential-assets-bindings 0.0.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.
|
@@ -0,0 +1,644 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
6
|
+
let wasm;
|
|
7
|
+
|
|
8
|
+
function addToExternrefTable0(obj) {
|
|
9
|
+
const idx = wasm.__externref_table_alloc();
|
|
10
|
+
wasm.__wbindgen_export_2.set(idx, obj);
|
|
11
|
+
return idx;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function handleError(f, args) {
|
|
15
|
+
try {
|
|
16
|
+
return f.apply(this, args);
|
|
17
|
+
} catch (e) {
|
|
18
|
+
const idx = addToExternrefTable0(e);
|
|
19
|
+
wasm.__wbindgen_exn_store(idx);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
24
|
+
|
|
25
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
|
|
26
|
+
let cachedUint8ArrayMemory0 = null;
|
|
27
|
+
|
|
28
|
+
function getUint8ArrayMemory0() {
|
|
29
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
30
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
31
|
+
}
|
|
32
|
+
return cachedUint8ArrayMemory0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getStringFromWasm0(ptr, len) {
|
|
36
|
+
ptr = ptr >>> 0;
|
|
37
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isLikeNone(x) {
|
|
41
|
+
return x === undefined || x === null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let cachedDataViewMemory0 = null;
|
|
45
|
+
|
|
46
|
+
function getDataViewMemory0() {
|
|
47
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
48
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
49
|
+
}
|
|
50
|
+
return cachedDataViewMemory0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
54
|
+
ptr = ptr >>> 0;
|
|
55
|
+
const mem = getDataViewMemory0();
|
|
56
|
+
const result = [];
|
|
57
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
58
|
+
result.push(wasm.__wbindgen_export_2.get(mem.getUint32(i, true)));
|
|
59
|
+
}
|
|
60
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
65
|
+
ptr = ptr >>> 0;
|
|
66
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let WASM_VECTOR_LEN = 0;
|
|
70
|
+
|
|
71
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
72
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
73
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
74
|
+
WASM_VECTOR_LEN = arg.length;
|
|
75
|
+
return ptr;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
79
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
80
|
+
for (let i = 0; i < array.length; i++) {
|
|
81
|
+
const add = addToExternrefTable0(array[i]);
|
|
82
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
83
|
+
}
|
|
84
|
+
WASM_VECTOR_LEN = array.length;
|
|
85
|
+
return ptr;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function takeFromExternrefTable0(idx) {
|
|
89
|
+
const value = wasm.__wbindgen_export_2.get(idx);
|
|
90
|
+
wasm.__externref_table_dealloc(idx);
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Verify a batch range proof.
|
|
95
|
+
* @param {Uint8Array} proof
|
|
96
|
+
* @param {Uint8Array[]} comms
|
|
97
|
+
* @param {Uint8Array} val_base
|
|
98
|
+
* @param {Uint8Array} rand_base
|
|
99
|
+
* @param {number} num_bits
|
|
100
|
+
* @returns {boolean}
|
|
101
|
+
*/
|
|
102
|
+
function batch_verify_proof(proof, comms, val_base, rand_base, num_bits) {
|
|
103
|
+
const ptr0 = passArray8ToWasm0(proof, wasm.__wbindgen_malloc);
|
|
104
|
+
const len0 = WASM_VECTOR_LEN;
|
|
105
|
+
const ptr1 = passArrayJsValueToWasm0(comms, wasm.__wbindgen_malloc);
|
|
106
|
+
const len1 = WASM_VECTOR_LEN;
|
|
107
|
+
const ptr2 = passArray8ToWasm0(val_base, wasm.__wbindgen_malloc);
|
|
108
|
+
const len2 = WASM_VECTOR_LEN;
|
|
109
|
+
const ptr3 = passArray8ToWasm0(rand_base, wasm.__wbindgen_malloc);
|
|
110
|
+
const len3 = WASM_VECTOR_LEN;
|
|
111
|
+
const ret = wasm.batch_verify_proof(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, num_bits);
|
|
112
|
+
if (ret[2]) {
|
|
113
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
114
|
+
}
|
|
115
|
+
return ret[0] !== 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Verify a single range proof.
|
|
120
|
+
* @param {Uint8Array} proof
|
|
121
|
+
* @param {Uint8Array} comm
|
|
122
|
+
* @param {Uint8Array} val_base
|
|
123
|
+
* @param {Uint8Array} rand_base
|
|
124
|
+
* @param {number} num_bits
|
|
125
|
+
* @returns {boolean}
|
|
126
|
+
*/
|
|
127
|
+
function verify_proof(proof, comm, val_base, rand_base, num_bits) {
|
|
128
|
+
const ptr0 = passArray8ToWasm0(proof, wasm.__wbindgen_malloc);
|
|
129
|
+
const len0 = WASM_VECTOR_LEN;
|
|
130
|
+
const ptr1 = passArray8ToWasm0(comm, wasm.__wbindgen_malloc);
|
|
131
|
+
const len1 = WASM_VECTOR_LEN;
|
|
132
|
+
const ptr2 = passArray8ToWasm0(val_base, wasm.__wbindgen_malloc);
|
|
133
|
+
const len2 = WASM_VECTOR_LEN;
|
|
134
|
+
const ptr3 = passArray8ToWasm0(rand_base, wasm.__wbindgen_malloc);
|
|
135
|
+
const len3 = WASM_VECTOR_LEN;
|
|
136
|
+
const ret = wasm.verify_proof(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, num_bits);
|
|
137
|
+
if (ret[2]) {
|
|
138
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
139
|
+
}
|
|
140
|
+
return ret[0] !== 0;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Generate a single range proof.
|
|
145
|
+
*
|
|
146
|
+
* # Arguments
|
|
147
|
+
* * `v` - The secret value to prove is in range [0, 2^num_bits)
|
|
148
|
+
* * `r` - The blinding factor (32-byte scalar)
|
|
149
|
+
* * `val_base` - Value base point for Pedersen commitment (32-byte compressed point)
|
|
150
|
+
* * `rand_base` - Randomness base point for Pedersen commitment (32-byte compressed point)
|
|
151
|
+
* * `num_bits` - Bit length for range proof (8, 16, 32, or 64)
|
|
152
|
+
* @param {bigint} v
|
|
153
|
+
* @param {Uint8Array} r
|
|
154
|
+
* @param {Uint8Array} val_base
|
|
155
|
+
* @param {Uint8Array} rand_base
|
|
156
|
+
* @param {number} num_bits
|
|
157
|
+
* @returns {SingleRangeProof}
|
|
158
|
+
*/
|
|
159
|
+
function range_proof(v, r, val_base, rand_base, num_bits) {
|
|
160
|
+
const ptr0 = passArray8ToWasm0(r, wasm.__wbindgen_malloc);
|
|
161
|
+
const len0 = WASM_VECTOR_LEN;
|
|
162
|
+
const ptr1 = passArray8ToWasm0(val_base, wasm.__wbindgen_malloc);
|
|
163
|
+
const len1 = WASM_VECTOR_LEN;
|
|
164
|
+
const ptr2 = passArray8ToWasm0(rand_base, wasm.__wbindgen_malloc);
|
|
165
|
+
const len2 = WASM_VECTOR_LEN;
|
|
166
|
+
const ret = wasm.range_proof(v, ptr0, len0, ptr1, len1, ptr2, len2, num_bits);
|
|
167
|
+
if (ret[2]) {
|
|
168
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
169
|
+
}
|
|
170
|
+
return SingleRangeProof.__wrap(ret[0]);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
let cachedBigUint64ArrayMemory0 = null;
|
|
174
|
+
|
|
175
|
+
function getBigUint64ArrayMemory0() {
|
|
176
|
+
if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
|
|
177
|
+
cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
|
|
178
|
+
}
|
|
179
|
+
return cachedBigUint64ArrayMemory0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function passArray64ToWasm0(arg, malloc) {
|
|
183
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
184
|
+
getBigUint64ArrayMemory0().set(arg, ptr / 8);
|
|
185
|
+
WASM_VECTOR_LEN = arg.length;
|
|
186
|
+
return ptr;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Generate a batch range proof for multiple values.
|
|
190
|
+
*
|
|
191
|
+
* # Arguments
|
|
192
|
+
* * `v` - The secret values to prove are in range [0, 2^num_bits)
|
|
193
|
+
* * `rs` - The blinding factors (each 32-byte scalar)
|
|
194
|
+
* * `val_base` - Value base point for Pedersen commitment (32-byte compressed point)
|
|
195
|
+
* * `rand_base` - Randomness base point for Pedersen commitment (32-byte compressed point)
|
|
196
|
+
* * `num_bits` - Bit length for range proof (8, 16, 32, or 64)
|
|
197
|
+
* @param {BigUint64Array} v
|
|
198
|
+
* @param {Uint8Array[]} rs
|
|
199
|
+
* @param {Uint8Array} val_base
|
|
200
|
+
* @param {Uint8Array} rand_base
|
|
201
|
+
* @param {number} num_bits
|
|
202
|
+
* @returns {BatchRangeProof}
|
|
203
|
+
*/
|
|
204
|
+
function batch_range_proof(v, rs, val_base, rand_base, num_bits) {
|
|
205
|
+
const ptr0 = passArray64ToWasm0(v, wasm.__wbindgen_malloc);
|
|
206
|
+
const len0 = WASM_VECTOR_LEN;
|
|
207
|
+
const ptr1 = passArrayJsValueToWasm0(rs, wasm.__wbindgen_malloc);
|
|
208
|
+
const len1 = WASM_VECTOR_LEN;
|
|
209
|
+
const ptr2 = passArray8ToWasm0(val_base, wasm.__wbindgen_malloc);
|
|
210
|
+
const len2 = WASM_VECTOR_LEN;
|
|
211
|
+
const ptr3 = passArray8ToWasm0(rand_base, wasm.__wbindgen_malloc);
|
|
212
|
+
const len3 = WASM_VECTOR_LEN;
|
|
213
|
+
const ret = wasm.batch_range_proof(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, num_bits);
|
|
214
|
+
if (ret[2]) {
|
|
215
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
216
|
+
}
|
|
217
|
+
return BatchRangeProof.__wrap(ret[0]);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Installs a panic hook that forwards Rust panic messages to `console.error`.
|
|
222
|
+
* Called automatically on WASM init. Without this, panics surface as an
|
|
223
|
+
* opaque `RuntimeError: unreachable` with no message.
|
|
224
|
+
*/
|
|
225
|
+
function init() {
|
|
226
|
+
wasm.init();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const BatchRangeProofFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
230
|
+
? { register: () => {}, unregister: () => {} }
|
|
231
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_batchrangeproof_free(ptr >>> 0, 1));
|
|
232
|
+
/**
|
|
233
|
+
* Result of a batch range proof generation
|
|
234
|
+
*/
|
|
235
|
+
class BatchRangeProof {
|
|
236
|
+
|
|
237
|
+
static __wrap(ptr) {
|
|
238
|
+
ptr = ptr >>> 0;
|
|
239
|
+
const obj = Object.create(BatchRangeProof.prototype);
|
|
240
|
+
obj.__wbg_ptr = ptr;
|
|
241
|
+
BatchRangeProofFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
242
|
+
return obj;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
__destroy_into_raw() {
|
|
246
|
+
const ptr = this.__wbg_ptr;
|
|
247
|
+
this.__wbg_ptr = 0;
|
|
248
|
+
BatchRangeProofFinalization.unregister(this);
|
|
249
|
+
return ptr;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
free() {
|
|
253
|
+
const ptr = this.__destroy_into_raw();
|
|
254
|
+
wasm.__wbg_batchrangeproof_free(ptr, 0);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Returns the serialized commitments (each 32 bytes)
|
|
258
|
+
* @returns {Uint8Array[]}
|
|
259
|
+
*/
|
|
260
|
+
comms() {
|
|
261
|
+
const ret = wasm.batchrangeproof_comms(this.__wbg_ptr);
|
|
262
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
263
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
264
|
+
return v1;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Returns the serialized proof bytes
|
|
268
|
+
* @returns {Uint8Array}
|
|
269
|
+
*/
|
|
270
|
+
proof() {
|
|
271
|
+
const ret = wasm.batchrangeproof_proof(this.__wbg_ptr);
|
|
272
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
273
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
274
|
+
return v1;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const DiscreteLogSolverFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
279
|
+
? { register: () => {}, unregister: () => {} }
|
|
280
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_discretelogsolver_free(ptr >>> 0, 1));
|
|
281
|
+
/**
|
|
282
|
+
* Discrete log solver supporting 16-bit and 32-bit secrets.
|
|
283
|
+
*/
|
|
284
|
+
class DiscreteLogSolver {
|
|
285
|
+
|
|
286
|
+
__destroy_into_raw() {
|
|
287
|
+
const ptr = this.__wbg_ptr;
|
|
288
|
+
this.__wbg_ptr = 0;
|
|
289
|
+
DiscreteLogSolverFinalization.unregister(this);
|
|
290
|
+
return ptr;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
free() {
|
|
294
|
+
const ptr = this.__destroy_into_raw();
|
|
295
|
+
wasm.__wbg_discretelogsolver_free(ptr, 0);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Returns the supported bit sizes as an array [16, 32].
|
|
299
|
+
* @returns {Uint8Array}
|
|
300
|
+
*/
|
|
301
|
+
max_num_bits() {
|
|
302
|
+
const ret = wasm.discretelogsolver_max_num_bits(this.__wbg_ptr);
|
|
303
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
304
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
305
|
+
return v1;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Creates a new solver with precomputed tables.
|
|
309
|
+
*/
|
|
310
|
+
constructor() {
|
|
311
|
+
const ret = wasm.discretelogsolver_new();
|
|
312
|
+
this.__wbg_ptr = ret >>> 0;
|
|
313
|
+
DiscreteLogSolverFinalization.register(this, this.__wbg_ptr, this);
|
|
314
|
+
return this;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Solves the discrete log problem.
|
|
318
|
+
*
|
|
319
|
+
* Given a compressed Ristretto point y = g^x (32 bytes), finds x.
|
|
320
|
+
*
|
|
321
|
+
* # Arguments
|
|
322
|
+
* * `y` - The compressed Ristretto point (32 bytes)
|
|
323
|
+
* * `max_num_bits` - Maximum bits of the secret: 16 or 32
|
|
324
|
+
*
|
|
325
|
+
* # Returns
|
|
326
|
+
* The discrete log x, or an error if not found or invalid input.
|
|
327
|
+
* @param {Uint8Array} y
|
|
328
|
+
* @param {number} max_num_bits
|
|
329
|
+
* @returns {bigint}
|
|
330
|
+
*/
|
|
331
|
+
solve(y, max_num_bits) {
|
|
332
|
+
const ptr0 = passArray8ToWasm0(y, wasm.__wbindgen_malloc);
|
|
333
|
+
const len0 = WASM_VECTOR_LEN;
|
|
334
|
+
const ret = wasm.discretelogsolver_solve(this.__wbg_ptr, ptr0, len0, max_num_bits);
|
|
335
|
+
if (ret[2]) {
|
|
336
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
337
|
+
}
|
|
338
|
+
return BigInt.asUintN(64, ret[0]);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Returns the algorithm name.
|
|
342
|
+
* @returns {string}
|
|
343
|
+
*/
|
|
344
|
+
algorithm() {
|
|
345
|
+
let deferred1_0;
|
|
346
|
+
let deferred1_1;
|
|
347
|
+
try {
|
|
348
|
+
const ret = wasm.discretelogsolver_algorithm(this.__wbg_ptr);
|
|
349
|
+
deferred1_0 = ret[0];
|
|
350
|
+
deferred1_1 = ret[1];
|
|
351
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
352
|
+
} finally {
|
|
353
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const SingleRangeProofFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
359
|
+
? { register: () => {}, unregister: () => {} }
|
|
360
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_singlerangeproof_free(ptr >>> 0, 1));
|
|
361
|
+
/**
|
|
362
|
+
* Result of a single range proof generation
|
|
363
|
+
*/
|
|
364
|
+
class SingleRangeProof {
|
|
365
|
+
|
|
366
|
+
static __wrap(ptr) {
|
|
367
|
+
ptr = ptr >>> 0;
|
|
368
|
+
const obj = Object.create(SingleRangeProof.prototype);
|
|
369
|
+
obj.__wbg_ptr = ptr;
|
|
370
|
+
SingleRangeProofFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
371
|
+
return obj;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
__destroy_into_raw() {
|
|
375
|
+
const ptr = this.__wbg_ptr;
|
|
376
|
+
this.__wbg_ptr = 0;
|
|
377
|
+
SingleRangeProofFinalization.unregister(this);
|
|
378
|
+
return ptr;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
free() {
|
|
382
|
+
const ptr = this.__destroy_into_raw();
|
|
383
|
+
wasm.__wbg_singlerangeproof_free(ptr, 0);
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Returns the serialized commitment (32 bytes)
|
|
387
|
+
* @returns {Uint8Array}
|
|
388
|
+
*/
|
|
389
|
+
comm() {
|
|
390
|
+
const ret = wasm.singlerangeproof_comm(this.__wbg_ptr);
|
|
391
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
392
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
393
|
+
return v1;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Returns the serialized proof bytes
|
|
397
|
+
* @returns {Uint8Array}
|
|
398
|
+
*/
|
|
399
|
+
proof() {
|
|
400
|
+
const ret = wasm.singlerangeproof_proof(this.__wbg_ptr);
|
|
401
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
402
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
403
|
+
return v1;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
async function __wbg_load(module, imports) {
|
|
408
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
409
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
410
|
+
try {
|
|
411
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
412
|
+
|
|
413
|
+
} catch (e) {
|
|
414
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
415
|
+
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);
|
|
416
|
+
|
|
417
|
+
} else {
|
|
418
|
+
throw e;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
const bytes = await module.arrayBuffer();
|
|
424
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
425
|
+
|
|
426
|
+
} else {
|
|
427
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
428
|
+
|
|
429
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
430
|
+
return { instance, module };
|
|
431
|
+
|
|
432
|
+
} else {
|
|
433
|
+
return instance;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function __wbg_get_imports() {
|
|
439
|
+
const imports = {};
|
|
440
|
+
imports.wbg = {};
|
|
441
|
+
imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
|
|
442
|
+
const ret = arg0.buffer;
|
|
443
|
+
return ret;
|
|
444
|
+
};
|
|
445
|
+
imports.wbg.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
|
|
446
|
+
const ret = arg0.call(arg1);
|
|
447
|
+
return ret;
|
|
448
|
+
}, arguments) };
|
|
449
|
+
imports.wbg.__wbg_call_7cccdd69e0791ae2 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
450
|
+
const ret = arg0.call(arg1, arg2);
|
|
451
|
+
return ret;
|
|
452
|
+
}, arguments) };
|
|
453
|
+
imports.wbg.__wbg_crypto_ed58b8e10a292839 = function(arg0) {
|
|
454
|
+
const ret = arg0.crypto;
|
|
455
|
+
return ret;
|
|
456
|
+
};
|
|
457
|
+
imports.wbg.__wbg_error_524f506f44df1645 = function(arg0) {
|
|
458
|
+
console.error(arg0);
|
|
459
|
+
};
|
|
460
|
+
imports.wbg.__wbg_getRandomValues_bcb4912f16000dc4 = function() { return handleError(function (arg0, arg1) {
|
|
461
|
+
arg0.getRandomValues(arg1);
|
|
462
|
+
}, arguments) };
|
|
463
|
+
imports.wbg.__wbg_length_a446193dc22c12f8 = function(arg0) {
|
|
464
|
+
const ret = arg0.length;
|
|
465
|
+
return ret;
|
|
466
|
+
};
|
|
467
|
+
imports.wbg.__wbg_msCrypto_0a36e2ec3a343d26 = function(arg0) {
|
|
468
|
+
const ret = arg0.msCrypto;
|
|
469
|
+
return ret;
|
|
470
|
+
};
|
|
471
|
+
imports.wbg.__wbg_new_a12002a7f91c75be = function(arg0) {
|
|
472
|
+
const ret = new Uint8Array(arg0);
|
|
473
|
+
return ret;
|
|
474
|
+
};
|
|
475
|
+
imports.wbg.__wbg_newnoargs_105ed471475aaf50 = function(arg0, arg1) {
|
|
476
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
477
|
+
return ret;
|
|
478
|
+
};
|
|
479
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(arg0, arg1, arg2) {
|
|
480
|
+
const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
|
481
|
+
return ret;
|
|
482
|
+
};
|
|
483
|
+
imports.wbg.__wbg_newwithlength_a381634e90c276d4 = function(arg0) {
|
|
484
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
485
|
+
return ret;
|
|
486
|
+
};
|
|
487
|
+
imports.wbg.__wbg_node_02999533c4ea02e3 = function(arg0) {
|
|
488
|
+
const ret = arg0.node;
|
|
489
|
+
return ret;
|
|
490
|
+
};
|
|
491
|
+
imports.wbg.__wbg_process_5c1d670bc53614b8 = function(arg0) {
|
|
492
|
+
const ret = arg0.process;
|
|
493
|
+
return ret;
|
|
494
|
+
};
|
|
495
|
+
imports.wbg.__wbg_randomFillSync_ab2cfe79ebbf2740 = function() { return handleError(function (arg0, arg1) {
|
|
496
|
+
arg0.randomFillSync(arg1);
|
|
497
|
+
}, arguments) };
|
|
498
|
+
imports.wbg.__wbg_require_79b1e9274cde3c87 = function() { return handleError(function () {
|
|
499
|
+
const ret = module.require;
|
|
500
|
+
return ret;
|
|
501
|
+
}, arguments) };
|
|
502
|
+
imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
|
|
503
|
+
arg0.set(arg1, arg2 >>> 0);
|
|
504
|
+
};
|
|
505
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {
|
|
506
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
507
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
508
|
+
};
|
|
509
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() {
|
|
510
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
511
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
512
|
+
};
|
|
513
|
+
imports.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() {
|
|
514
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
515
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
516
|
+
};
|
|
517
|
+
imports.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() {
|
|
518
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
519
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
520
|
+
};
|
|
521
|
+
imports.wbg.__wbg_subarray_aa9065fa9dc5df96 = function(arg0, arg1, arg2) {
|
|
522
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
523
|
+
return ret;
|
|
524
|
+
};
|
|
525
|
+
imports.wbg.__wbg_versions_c71aa1626a93e0a1 = function(arg0) {
|
|
526
|
+
const ret = arg0.versions;
|
|
527
|
+
return ret;
|
|
528
|
+
};
|
|
529
|
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
530
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
531
|
+
return ret;
|
|
532
|
+
};
|
|
533
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
534
|
+
const table = wasm.__wbindgen_export_2;
|
|
535
|
+
const offset = table.grow(4);
|
|
536
|
+
table.set(0, undefined);
|
|
537
|
+
table.set(offset + 0, undefined);
|
|
538
|
+
table.set(offset + 1, null);
|
|
539
|
+
table.set(offset + 2, true);
|
|
540
|
+
table.set(offset + 3, false);
|
|
541
|
+
};
|
|
542
|
+
imports.wbg.__wbindgen_is_function = function(arg0) {
|
|
543
|
+
const ret = typeof(arg0) === 'function';
|
|
544
|
+
return ret;
|
|
545
|
+
};
|
|
546
|
+
imports.wbg.__wbindgen_is_object = function(arg0) {
|
|
547
|
+
const val = arg0;
|
|
548
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
549
|
+
return ret;
|
|
550
|
+
};
|
|
551
|
+
imports.wbg.__wbindgen_is_string = function(arg0) {
|
|
552
|
+
const ret = typeof(arg0) === 'string';
|
|
553
|
+
return ret;
|
|
554
|
+
};
|
|
555
|
+
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
556
|
+
const ret = arg0 === undefined;
|
|
557
|
+
return ret;
|
|
558
|
+
};
|
|
559
|
+
imports.wbg.__wbindgen_memory = function() {
|
|
560
|
+
const ret = wasm.memory;
|
|
561
|
+
return ret;
|
|
562
|
+
};
|
|
563
|
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
564
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
565
|
+
return ret;
|
|
566
|
+
};
|
|
567
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
568
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
return imports;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
function __wbg_finalize_init(instance, module) {
|
|
575
|
+
wasm = instance.exports;
|
|
576
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
577
|
+
cachedBigUint64ArrayMemory0 = null;
|
|
578
|
+
cachedDataViewMemory0 = null;
|
|
579
|
+
cachedUint8ArrayMemory0 = null;
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
wasm.__wbindgen_start();
|
|
583
|
+
return wasm;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function initSync(module) {
|
|
587
|
+
if (wasm !== undefined) return wasm;
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
if (typeof module !== 'undefined') {
|
|
591
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
592
|
+
({module} = module);
|
|
593
|
+
} else {
|
|
594
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead');
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
const imports = __wbg_get_imports();
|
|
599
|
+
|
|
600
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
601
|
+
module = new WebAssembly.Module(module);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
605
|
+
|
|
606
|
+
return __wbg_finalize_init(instance, module);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
async function __wbg_init(module_or_path) {
|
|
610
|
+
if (wasm !== undefined) return wasm;
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
if (typeof module_or_path !== 'undefined') {
|
|
614
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
615
|
+
({module_or_path} = module_or_path);
|
|
616
|
+
} else {
|
|
617
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead');
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
if (typeof module_or_path === 'undefined') {
|
|
622
|
+
module_or_path = new URL('aptos_confidential_asset_wasm_bg.wasm', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('aptos_confidential_asset_wasm-cjs.js', document.baseURI).href)));
|
|
623
|
+
}
|
|
624
|
+
const imports = __wbg_get_imports();
|
|
625
|
+
|
|
626
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
627
|
+
module_or_path = fetch(module_or_path);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
631
|
+
|
|
632
|
+
return __wbg_finalize_init(instance, module);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
exports.BatchRangeProof = BatchRangeProof;
|
|
636
|
+
exports.DiscreteLogSolver = DiscreteLogSolver;
|
|
637
|
+
exports.SingleRangeProof = SingleRangeProof;
|
|
638
|
+
exports.batch_range_proof = batch_range_proof;
|
|
639
|
+
exports.batch_verify_proof = batch_verify_proof;
|
|
640
|
+
exports.default = __wbg_init;
|
|
641
|
+
exports.init = init;
|
|
642
|
+
exports.initSync = initSync;
|
|
643
|
+
exports.range_proof = range_proof;
|
|
644
|
+
exports.verify_proof = verify_proof;
|