@noir-lang/acvm_js 0.51.0 → 0.52.0-600ffeb.nightly
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/nodejs/acvm_js.d.ts +99 -105
- package/nodejs/acvm_js.js +295 -316
- package/nodejs/acvm_js_bg.wasm +0 -0
- package/nodejs/acvm_js_bg.wasm.d.ts +9 -10
- package/package.json +1 -1
- package/web/acvm_js.d.ts +108 -115
- package/web/acvm_js.js +257 -278
- package/web/acvm_js_bg.wasm +0 -0
- package/web/acvm_js_bg.wasm.d.ts +9 -10
package/web/acvm_js.js
CHANGED
|
@@ -20,28 +20,6 @@ function takeObject(idx) {
|
|
|
20
20
|
return ret;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
function isLikeNone(x) {
|
|
24
|
-
return x === undefined || x === null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let cachedFloat64Memory0 = null;
|
|
28
|
-
|
|
29
|
-
function getFloat64Memory0() {
|
|
30
|
-
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
|
|
31
|
-
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
|
|
32
|
-
}
|
|
33
|
-
return cachedFloat64Memory0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let cachedInt32Memory0 = null;
|
|
37
|
-
|
|
38
|
-
function getInt32Memory0() {
|
|
39
|
-
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
40
|
-
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
41
|
-
}
|
|
42
|
-
return cachedInt32Memory0;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
23
|
function addHeapObject(obj) {
|
|
46
24
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
47
25
|
const idx = heap_next;
|
|
@@ -124,6 +102,28 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
124
102
|
return ptr;
|
|
125
103
|
}
|
|
126
104
|
|
|
105
|
+
function isLikeNone(x) {
|
|
106
|
+
return x === undefined || x === null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let cachedInt32Memory0 = null;
|
|
110
|
+
|
|
111
|
+
function getInt32Memory0() {
|
|
112
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
113
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
114
|
+
}
|
|
115
|
+
return cachedInt32Memory0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
let cachedFloat64Memory0 = null;
|
|
119
|
+
|
|
120
|
+
function getFloat64Memory0() {
|
|
121
|
+
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
|
|
122
|
+
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
|
|
123
|
+
}
|
|
124
|
+
return cachedFloat64Memory0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
127
|
function debugString(val) {
|
|
128
128
|
// primitive types
|
|
129
129
|
const type = typeof val;
|
|
@@ -218,32 +218,104 @@ function __wbg_adapter_22(arg0, arg1, arg2) {
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
/**
|
|
221
|
-
*
|
|
221
|
+
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
222
|
+
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
223
|
+
*/
|
|
224
|
+
export function buildInfo() {
|
|
225
|
+
const ret = wasm.buildInfo();
|
|
226
|
+
return takeObject(ret);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
230
|
+
const ptr = malloc(arg.length * 1) >>> 0;
|
|
231
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
232
|
+
WASM_VECTOR_LEN = arg.length;
|
|
233
|
+
return ptr;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
222
237
|
*
|
|
223
|
-
* @param {
|
|
238
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
239
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
240
|
+
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
241
|
+
* @param {Uint8Array} program
|
|
242
|
+
* @param {WitnessMap} witness_map
|
|
243
|
+
* @returns {WitnessMap}
|
|
224
244
|
*/
|
|
225
|
-
export function
|
|
245
|
+
export function getReturnWitness(program, witness_map) {
|
|
226
246
|
try {
|
|
227
247
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
228
|
-
const ptr0 =
|
|
248
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
229
249
|
const len0 = WASM_VECTOR_LEN;
|
|
230
|
-
wasm.
|
|
250
|
+
wasm.getReturnWitness(retptr, ptr0, len0, addHeapObject(witness_map));
|
|
231
251
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
232
252
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
233
|
-
|
|
234
|
-
|
|
253
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
254
|
+
if (r2) {
|
|
255
|
+
throw takeObject(r1);
|
|
235
256
|
}
|
|
257
|
+
return takeObject(r0);
|
|
236
258
|
} finally {
|
|
237
259
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
238
260
|
}
|
|
239
261
|
}
|
|
240
262
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
263
|
+
/**
|
|
264
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
265
|
+
*
|
|
266
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
267
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
268
|
+
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
269
|
+
* @param {Uint8Array} program
|
|
270
|
+
* @param {WitnessMap} solved_witness
|
|
271
|
+
* @returns {WitnessMap}
|
|
272
|
+
*/
|
|
273
|
+
export function getPublicParametersWitness(program, solved_witness) {
|
|
274
|
+
try {
|
|
275
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
276
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
277
|
+
const len0 = WASM_VECTOR_LEN;
|
|
278
|
+
wasm.getPublicParametersWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
|
|
279
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
280
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
281
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
282
|
+
if (r2) {
|
|
283
|
+
throw takeObject(r1);
|
|
284
|
+
}
|
|
285
|
+
return takeObject(r0);
|
|
286
|
+
} finally {
|
|
287
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
|
|
293
|
+
*
|
|
294
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
295
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
296
|
+
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
297
|
+
* @param {Uint8Array} program
|
|
298
|
+
* @param {WitnessMap} solved_witness
|
|
299
|
+
* @returns {WitnessMap}
|
|
300
|
+
*/
|
|
301
|
+
export function getPublicWitness(program, solved_witness) {
|
|
302
|
+
try {
|
|
303
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
304
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
305
|
+
const len0 = WASM_VECTOR_LEN;
|
|
306
|
+
wasm.getPublicWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
|
|
307
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
308
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
309
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
310
|
+
if (r2) {
|
|
311
|
+
throw takeObject(r1);
|
|
312
|
+
}
|
|
313
|
+
return takeObject(r0);
|
|
314
|
+
} finally {
|
|
315
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
316
|
+
}
|
|
246
317
|
}
|
|
318
|
+
|
|
247
319
|
/**
|
|
248
320
|
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
249
321
|
*
|
|
@@ -290,160 +362,10 @@ export function executeProgram(program, initial_witness, foreign_call_handler) {
|
|
|
290
362
|
return takeObject(ret);
|
|
291
363
|
}
|
|
292
364
|
|
|
293
|
-
/**
|
|
294
|
-
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
295
|
-
* @param {string} lhs
|
|
296
|
-
* @param {string} rhs
|
|
297
|
-
* @returns {string}
|
|
298
|
-
*/
|
|
299
|
-
export function and(lhs, rhs) {
|
|
300
|
-
const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs));
|
|
301
|
-
return takeObject(ret);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
306
|
-
* @param {string} lhs
|
|
307
|
-
* @param {string} rhs
|
|
308
|
-
* @returns {string}
|
|
309
|
-
*/
|
|
310
|
-
export function xor(lhs, rhs) {
|
|
311
|
-
const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs));
|
|
312
|
-
return takeObject(ret);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
let cachedUint32Memory0 = null;
|
|
316
|
-
|
|
317
|
-
function getUint32Memory0() {
|
|
318
|
-
if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
|
|
319
|
-
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
|
|
320
|
-
}
|
|
321
|
-
return cachedUint32Memory0;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
function passArray32ToWasm0(arg, malloc) {
|
|
325
|
-
const ptr = malloc(arg.length * 4) >>> 0;
|
|
326
|
-
getUint32Memory0().set(arg, ptr / 4);
|
|
327
|
-
WASM_VECTOR_LEN = arg.length;
|
|
328
|
-
return ptr;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
function getArrayU32FromWasm0(ptr, len) {
|
|
332
|
-
ptr = ptr >>> 0;
|
|
333
|
-
return getUint32Memory0().subarray(ptr / 4, ptr / 4 + len);
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Sha256 compression function
|
|
337
|
-
* @param {Uint32Array} inputs
|
|
338
|
-
* @param {Uint32Array} state
|
|
339
|
-
* @returns {Uint32Array}
|
|
340
|
-
*/
|
|
341
|
-
export function sha256_compression(inputs, state) {
|
|
342
|
-
try {
|
|
343
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
344
|
-
const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
345
|
-
const len0 = WASM_VECTOR_LEN;
|
|
346
|
-
const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
|
|
347
|
-
const len1 = WASM_VECTOR_LEN;
|
|
348
|
-
wasm.sha256_compression(retptr, ptr0, len0, ptr1, len1);
|
|
349
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
350
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
351
|
-
var v3 = getArrayU32FromWasm0(r0, r1).slice();
|
|
352
|
-
wasm.__wbindgen_free(r0, r1 * 4);
|
|
353
|
-
return v3;
|
|
354
|
-
} finally {
|
|
355
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
365
|
function getArrayU8FromWasm0(ptr, len) {
|
|
360
366
|
ptr = ptr >>> 0;
|
|
361
367
|
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
362
368
|
}
|
|
363
|
-
/**
|
|
364
|
-
* Calculates the Blake2s256 hash of the input bytes
|
|
365
|
-
* @param {Uint8Array} inputs
|
|
366
|
-
* @returns {Uint8Array}
|
|
367
|
-
*/
|
|
368
|
-
export function blake2s256(inputs) {
|
|
369
|
-
try {
|
|
370
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
371
|
-
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
372
|
-
const len0 = WASM_VECTOR_LEN;
|
|
373
|
-
wasm.blake2s256(retptr, ptr0, len0);
|
|
374
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
375
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
376
|
-
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
377
|
-
wasm.__wbindgen_free(r0, r1 * 1);
|
|
378
|
-
return v2;
|
|
379
|
-
} finally {
|
|
380
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Calculates the Keccak256 hash of the input bytes
|
|
386
|
-
* @param {Uint8Array} inputs
|
|
387
|
-
* @returns {Uint8Array}
|
|
388
|
-
*/
|
|
389
|
-
export function keccak256(inputs) {
|
|
390
|
-
try {
|
|
391
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
392
|
-
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
393
|
-
const len0 = WASM_VECTOR_LEN;
|
|
394
|
-
wasm.keccak256(retptr, ptr0, len0);
|
|
395
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
396
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
397
|
-
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
398
|
-
wasm.__wbindgen_free(r0, r1 * 1);
|
|
399
|
-
return v2;
|
|
400
|
-
} finally {
|
|
401
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
407
|
-
* @param {Uint8Array} hashed_msg
|
|
408
|
-
* @param {Uint8Array} public_key_x_bytes
|
|
409
|
-
* @param {Uint8Array} public_key_y_bytes
|
|
410
|
-
* @param {Uint8Array} signature
|
|
411
|
-
* @returns {boolean}
|
|
412
|
-
*/
|
|
413
|
-
export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
414
|
-
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
415
|
-
const len0 = WASM_VECTOR_LEN;
|
|
416
|
-
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
417
|
-
const len1 = WASM_VECTOR_LEN;
|
|
418
|
-
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
419
|
-
const len2 = WASM_VECTOR_LEN;
|
|
420
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
421
|
-
const len3 = WASM_VECTOR_LEN;
|
|
422
|
-
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
423
|
-
return ret !== 0;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
428
|
-
* @param {Uint8Array} hashed_msg
|
|
429
|
-
* @param {Uint8Array} public_key_x_bytes
|
|
430
|
-
* @param {Uint8Array} public_key_y_bytes
|
|
431
|
-
* @param {Uint8Array} signature
|
|
432
|
-
* @returns {boolean}
|
|
433
|
-
*/
|
|
434
|
-
export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
435
|
-
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
436
|
-
const len0 = WASM_VECTOR_LEN;
|
|
437
|
-
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
438
|
-
const len1 = WASM_VECTOR_LEN;
|
|
439
|
-
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
440
|
-
const len2 = WASM_VECTOR_LEN;
|
|
441
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
442
|
-
const len3 = WASM_VECTOR_LEN;
|
|
443
|
-
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
444
|
-
return ret !== 0;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
369
|
/**
|
|
448
370
|
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
449
371
|
*
|
|
@@ -544,99 +466,156 @@ export function decompressWitnessStack(compressed_witness) {
|
|
|
544
466
|
}
|
|
545
467
|
|
|
546
468
|
/**
|
|
547
|
-
*
|
|
548
|
-
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
549
|
-
*/
|
|
550
|
-
export function buildInfo() {
|
|
551
|
-
const ret = wasm.buildInfo();
|
|
552
|
-
return takeObject(ret);
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
/**
|
|
556
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
469
|
+
* Sets the package's logging level.
|
|
557
470
|
*
|
|
558
|
-
* @param {
|
|
559
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
560
|
-
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
561
|
-
* @param {Uint8Array} program
|
|
562
|
-
* @param {WitnessMap} witness_map
|
|
563
|
-
* @returns {WitnessMap}
|
|
471
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
564
472
|
*/
|
|
565
|
-
export function
|
|
473
|
+
export function initLogLevel(filter) {
|
|
566
474
|
try {
|
|
567
475
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
568
|
-
const ptr0 =
|
|
476
|
+
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
569
477
|
const len0 = WASM_VECTOR_LEN;
|
|
570
|
-
wasm.
|
|
478
|
+
wasm.initLogLevel(retptr, ptr0, len0);
|
|
571
479
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
572
480
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
throw takeObject(r1);
|
|
481
|
+
if (r1) {
|
|
482
|
+
throw takeObject(r0);
|
|
576
483
|
}
|
|
577
|
-
return takeObject(r0);
|
|
578
484
|
} finally {
|
|
579
485
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
580
486
|
}
|
|
581
487
|
}
|
|
582
488
|
|
|
583
489
|
/**
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
* @param {
|
|
587
|
-
* @
|
|
588
|
-
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
589
|
-
* @param {Uint8Array} program
|
|
590
|
-
* @param {WitnessMap} solved_witness
|
|
591
|
-
* @returns {WitnessMap}
|
|
490
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
491
|
+
* @param {string} lhs
|
|
492
|
+
* @param {string} rhs
|
|
493
|
+
* @returns {string}
|
|
592
494
|
*/
|
|
593
|
-
export function
|
|
495
|
+
export function and(lhs, rhs) {
|
|
496
|
+
const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs));
|
|
497
|
+
return takeObject(ret);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
502
|
+
* @param {string} lhs
|
|
503
|
+
* @param {string} rhs
|
|
504
|
+
* @returns {string}
|
|
505
|
+
*/
|
|
506
|
+
export function xor(lhs, rhs) {
|
|
507
|
+
const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs));
|
|
508
|
+
return takeObject(ret);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
let cachedUint32Memory0 = null;
|
|
512
|
+
|
|
513
|
+
function getUint32Memory0() {
|
|
514
|
+
if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
|
|
515
|
+
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
|
|
516
|
+
}
|
|
517
|
+
return cachedUint32Memory0;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
521
|
+
const ptr = malloc(arg.length * 4) >>> 0;
|
|
522
|
+
getUint32Memory0().set(arg, ptr / 4);
|
|
523
|
+
WASM_VECTOR_LEN = arg.length;
|
|
524
|
+
return ptr;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
528
|
+
ptr = ptr >>> 0;
|
|
529
|
+
return getUint32Memory0().subarray(ptr / 4, ptr / 4 + len);
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Sha256 compression function
|
|
533
|
+
* @param {Uint32Array} inputs
|
|
534
|
+
* @param {Uint32Array} state
|
|
535
|
+
* @returns {Uint32Array}
|
|
536
|
+
*/
|
|
537
|
+
export function sha256_compression(inputs, state) {
|
|
594
538
|
try {
|
|
595
539
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
596
|
-
const ptr0 =
|
|
540
|
+
const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
597
541
|
const len0 = WASM_VECTOR_LEN;
|
|
598
|
-
|
|
542
|
+
const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
|
|
543
|
+
const len1 = WASM_VECTOR_LEN;
|
|
544
|
+
wasm.sha256_compression(retptr, ptr0, len0, ptr1, len1);
|
|
599
545
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
600
546
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
601
|
-
var
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
}
|
|
605
|
-
return takeObject(r0);
|
|
547
|
+
var v3 = getArrayU32FromWasm0(r0, r1).slice();
|
|
548
|
+
wasm.__wbindgen_free(r0, r1 * 4);
|
|
549
|
+
return v3;
|
|
606
550
|
} finally {
|
|
607
551
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
608
552
|
}
|
|
609
553
|
}
|
|
610
554
|
|
|
611
555
|
/**
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
* @
|
|
615
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
616
|
-
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
617
|
-
* @param {Uint8Array} program
|
|
618
|
-
* @param {WitnessMap} solved_witness
|
|
619
|
-
* @returns {WitnessMap}
|
|
556
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
557
|
+
* @param {Uint8Array} inputs
|
|
558
|
+
* @returns {Uint8Array}
|
|
620
559
|
*/
|
|
621
|
-
export function
|
|
560
|
+
export function blake2s256(inputs) {
|
|
622
561
|
try {
|
|
623
562
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
624
|
-
const ptr0 = passArray8ToWasm0(
|
|
563
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
625
564
|
const len0 = WASM_VECTOR_LEN;
|
|
626
|
-
wasm.
|
|
565
|
+
wasm.blake2s256(retptr, ptr0, len0);
|
|
627
566
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
628
567
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
629
|
-
var
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
}
|
|
633
|
-
return takeObject(r0);
|
|
568
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
569
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
570
|
+
return v2;
|
|
634
571
|
} finally {
|
|
635
572
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
636
573
|
}
|
|
637
574
|
}
|
|
638
575
|
|
|
639
|
-
|
|
576
|
+
/**
|
|
577
|
+
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
578
|
+
* @param {Uint8Array} hashed_msg
|
|
579
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
580
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
581
|
+
* @param {Uint8Array} signature
|
|
582
|
+
* @returns {boolean}
|
|
583
|
+
*/
|
|
584
|
+
export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
585
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
586
|
+
const len0 = WASM_VECTOR_LEN;
|
|
587
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
588
|
+
const len1 = WASM_VECTOR_LEN;
|
|
589
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
590
|
+
const len2 = WASM_VECTOR_LEN;
|
|
591
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
592
|
+
const len3 = WASM_VECTOR_LEN;
|
|
593
|
+
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
594
|
+
return ret !== 0;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
599
|
+
* @param {Uint8Array} hashed_msg
|
|
600
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
601
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
602
|
+
* @param {Uint8Array} signature
|
|
603
|
+
* @returns {boolean}
|
|
604
|
+
*/
|
|
605
|
+
export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
606
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
607
|
+
const len0 = WASM_VECTOR_LEN;
|
|
608
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
609
|
+
const len1 = WASM_VECTOR_LEN;
|
|
610
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
611
|
+
const len2 = WASM_VECTOR_LEN;
|
|
612
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
613
|
+
const len3 = WASM_VECTOR_LEN;
|
|
614
|
+
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
615
|
+
return ret !== 0;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function __wbg_adapter_75(arg0, arg1, arg2, arg3, arg4) {
|
|
640
619
|
wasm.wasm_bindgen__convert__closures__invoke3_mut__h17fc532521b46256(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
|
|
641
620
|
}
|
|
642
621
|
|
|
@@ -647,7 +626,7 @@ function handleError(f, args) {
|
|
|
647
626
|
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
648
627
|
}
|
|
649
628
|
}
|
|
650
|
-
function
|
|
629
|
+
function __wbg_adapter_92(arg0, arg1, arg2, arg3) {
|
|
651
630
|
wasm.wasm_bindgen__convert__closures__invoke2_mut__h0d187b0f08495587(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
652
631
|
}
|
|
653
632
|
|
|
@@ -685,26 +664,19 @@ async function __wbg_load(module, imports) {
|
|
|
685
664
|
function __wbg_get_imports() {
|
|
686
665
|
const imports = {};
|
|
687
666
|
imports.wbg = {};
|
|
688
|
-
imports.wbg.__wbindgen_cb_drop = function(arg0) {
|
|
689
|
-
const obj = takeObject(arg0).original;
|
|
690
|
-
if (obj.cnt-- == 1) {
|
|
691
|
-
obj.a = 0;
|
|
692
|
-
return true;
|
|
693
|
-
}
|
|
694
|
-
const ret = false;
|
|
695
|
-
return ret;
|
|
696
|
-
};
|
|
697
|
-
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
|
698
|
-
const obj = getObject(arg1);
|
|
699
|
-
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
700
|
-
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
|
|
701
|
-
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
|
|
702
|
-
};
|
|
703
667
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
704
668
|
takeObject(arg0);
|
|
705
669
|
};
|
|
706
|
-
imports.wbg.
|
|
707
|
-
const ret =
|
|
670
|
+
imports.wbg.__wbindgen_is_string = function(arg0) {
|
|
671
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
672
|
+
return ret;
|
|
673
|
+
};
|
|
674
|
+
imports.wbg.__wbindgen_is_array = function(arg0) {
|
|
675
|
+
const ret = Array.isArray(getObject(arg0));
|
|
676
|
+
return ret;
|
|
677
|
+
};
|
|
678
|
+
imports.wbg.__wbg_new_55c288bb849e1b31 = function() {
|
|
679
|
+
const ret = new Array();
|
|
708
680
|
return addHeapObject(ret);
|
|
709
681
|
};
|
|
710
682
|
imports.wbg.__wbindgen_number_new = function(arg0) {
|
|
@@ -715,6 +687,23 @@ function __wbg_get_imports() {
|
|
|
715
687
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
716
688
|
return addHeapObject(ret);
|
|
717
689
|
};
|
|
690
|
+
imports.wbg.__wbg_constructor_720343c738f4344c = function(arg0) {
|
|
691
|
+
const ret = new Error(takeObject(arg0));
|
|
692
|
+
return addHeapObject(ret);
|
|
693
|
+
};
|
|
694
|
+
imports.wbg.__wbindgen_cb_drop = function(arg0) {
|
|
695
|
+
const obj = takeObject(arg0).original;
|
|
696
|
+
if (obj.cnt-- == 1) {
|
|
697
|
+
obj.a = 0;
|
|
698
|
+
return true;
|
|
699
|
+
}
|
|
700
|
+
const ret = false;
|
|
701
|
+
return ret;
|
|
702
|
+
};
|
|
703
|
+
imports.wbg.__wbg_new_7379c57bfbea14d0 = function() {
|
|
704
|
+
const ret = new Map();
|
|
705
|
+
return addHeapObject(ret);
|
|
706
|
+
};
|
|
718
707
|
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
719
708
|
const obj = getObject(arg1);
|
|
720
709
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
@@ -723,21 +712,11 @@ function __wbg_get_imports() {
|
|
|
723
712
|
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
724
713
|
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
725
714
|
};
|
|
726
|
-
imports.wbg.
|
|
727
|
-
const
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
const ret = Array.isArray(getObject(arg0));
|
|
732
|
-
return ret;
|
|
733
|
-
};
|
|
734
|
-
imports.wbg.__wbindgen_is_string = function(arg0) {
|
|
735
|
-
const ret = typeof(getObject(arg0)) === 'string';
|
|
736
|
-
return ret;
|
|
737
|
-
};
|
|
738
|
-
imports.wbg.__wbg_new_e14625531a95427d = function() {
|
|
739
|
-
const ret = new Array();
|
|
740
|
-
return addHeapObject(ret);
|
|
715
|
+
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
|
716
|
+
const obj = getObject(arg1);
|
|
717
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
718
|
+
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
|
|
719
|
+
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
|
|
741
720
|
};
|
|
742
721
|
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
|
|
743
722
|
const ret = new Error();
|
|
@@ -812,7 +791,7 @@ function __wbg_get_imports() {
|
|
|
812
791
|
const a = state0.a;
|
|
813
792
|
state0.a = 0;
|
|
814
793
|
try {
|
|
815
|
-
return
|
|
794
|
+
return __wbg_adapter_75(a, state0.b, arg0, arg1, arg2);
|
|
816
795
|
} finally {
|
|
817
796
|
state0.a = a;
|
|
818
797
|
}
|
|
@@ -852,7 +831,7 @@ function __wbg_get_imports() {
|
|
|
852
831
|
const a = state0.a;
|
|
853
832
|
state0.a = 0;
|
|
854
833
|
try {
|
|
855
|
-
return
|
|
834
|
+
return __wbg_adapter_92(a, state0.b, arg0, arg1);
|
|
856
835
|
} finally {
|
|
857
836
|
state0.a = a;
|
|
858
837
|
}
|
|
@@ -881,7 +860,7 @@ function __wbg_get_imports() {
|
|
|
881
860
|
const a = state0.a;
|
|
882
861
|
state0.a = 0;
|
|
883
862
|
try {
|
|
884
|
-
return
|
|
863
|
+
return __wbg_adapter_92(a, state0.b, arg0, arg1);
|
|
885
864
|
} finally {
|
|
886
865
|
state0.a = a;
|
|
887
866
|
}
|
|
@@ -922,8 +901,8 @@ function __wbg_get_imports() {
|
|
|
922
901
|
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
923
902
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
924
903
|
};
|
|
925
|
-
imports.wbg.
|
|
926
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
904
|
+
imports.wbg.__wbindgen_closure_wrapper738 = function(arg0, arg1, arg2) {
|
|
905
|
+
const ret = makeMutClosure(arg0, arg1, 270, __wbg_adapter_22);
|
|
927
906
|
return addHeapObject(ret);
|
|
928
907
|
};
|
|
929
908
|
|
package/web/acvm_js_bg.wasm
CHANGED
|
Binary file
|