@noir-lang/acvm_js 0.41.0 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/nodejs/acvm_js.d.ts +75 -75
- package/nodejs/acvm_js.js +219 -220
- package/nodejs/acvm_js_bg.wasm +0 -0
- package/nodejs/acvm_js_bg.wasm.d.ts +8 -8
- package/package.json +7 -7
- package/web/acvm_js.d.ts +83 -83
- package/web/acvm_js.js +214 -215
- package/web/acvm_js_bg.wasm +0 -0
- package/web/acvm_js_bg.wasm.d.ts +8 -8
package/web/acvm_js.js
CHANGED
|
@@ -20,24 +20,6 @@ function takeObject(idx) {
|
|
|
20
20
|
return ret;
|
|
21
21
|
}
|
|
22
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
|
-
|
|
27
|
-
let cachedUint8Memory0 = null;
|
|
28
|
-
|
|
29
|
-
function getUint8Memory0() {
|
|
30
|
-
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
31
|
-
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
32
|
-
}
|
|
33
|
-
return cachedUint8Memory0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function getStringFromWasm0(ptr, len) {
|
|
37
|
-
ptr = ptr >>> 0;
|
|
38
|
-
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
23
|
function addHeapObject(obj) {
|
|
42
24
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
43
25
|
const idx = heap_next;
|
|
@@ -49,6 +31,15 @@ function addHeapObject(obj) {
|
|
|
49
31
|
|
|
50
32
|
let WASM_VECTOR_LEN = 0;
|
|
51
33
|
|
|
34
|
+
let cachedUint8Memory0 = null;
|
|
35
|
+
|
|
36
|
+
function getUint8Memory0() {
|
|
37
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
38
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
39
|
+
}
|
|
40
|
+
return cachedUint8Memory0;
|
|
41
|
+
}
|
|
42
|
+
|
|
52
43
|
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
53
44
|
|
|
54
45
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
@@ -115,6 +106,15 @@ function getInt32Memory0() {
|
|
|
115
106
|
return cachedInt32Memory0;
|
|
116
107
|
}
|
|
117
108
|
|
|
109
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
110
|
+
|
|
111
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
112
|
+
|
|
113
|
+
function getStringFromWasm0(ptr, len) {
|
|
114
|
+
ptr = ptr >>> 0;
|
|
115
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
118
|
let cachedFloat64Memory0 = null;
|
|
119
119
|
|
|
120
120
|
function getFloat64Memory0() {
|
|
@@ -226,13 +226,6 @@ function __wbg_adapter_52(arg0, arg1, arg2) {
|
|
|
226
226
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hfdf1d0fa4debaf70(arg0, arg1, addHeapObject(arg2));
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
function _assertClass(instance, klass) {
|
|
230
|
-
if (!(instance instanceof klass)) {
|
|
231
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
232
|
-
}
|
|
233
|
-
return instance.ptr;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
229
|
function passArray8ToWasm0(arg, malloc) {
|
|
237
230
|
const ptr = malloc(arg.length * 1) >>> 0;
|
|
238
231
|
getUint8Memory0().set(arg, ptr / 1);
|
|
@@ -240,6 +233,143 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
240
233
|
return ptr;
|
|
241
234
|
}
|
|
242
235
|
/**
|
|
236
|
+
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
237
|
+
* @param {Uint8Array} hashed_msg
|
|
238
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
239
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
240
|
+
* @param {Uint8Array} signature
|
|
241
|
+
* @returns {boolean}
|
|
242
|
+
*/
|
|
243
|
+
export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
244
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
245
|
+
const len0 = WASM_VECTOR_LEN;
|
|
246
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
247
|
+
const len1 = WASM_VECTOR_LEN;
|
|
248
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
249
|
+
const len2 = WASM_VECTOR_LEN;
|
|
250
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
251
|
+
const len3 = WASM_VECTOR_LEN;
|
|
252
|
+
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
253
|
+
return ret !== 0;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
258
|
+
* @param {Uint8Array} hashed_msg
|
|
259
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
260
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
261
|
+
* @param {Uint8Array} signature
|
|
262
|
+
* @returns {boolean}
|
|
263
|
+
*/
|
|
264
|
+
export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
265
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
266
|
+
const len0 = WASM_VECTOR_LEN;
|
|
267
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
268
|
+
const len1 = WASM_VECTOR_LEN;
|
|
269
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
270
|
+
const len2 = WASM_VECTOR_LEN;
|
|
271
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
272
|
+
const len3 = WASM_VECTOR_LEN;
|
|
273
|
+
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
274
|
+
return ret !== 0;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
278
|
+
ptr = ptr >>> 0;
|
|
279
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Calculates the Keccak256 hash of the input bytes
|
|
283
|
+
* @param {Uint8Array} inputs
|
|
284
|
+
* @returns {Uint8Array}
|
|
285
|
+
*/
|
|
286
|
+
export function keccak256(inputs) {
|
|
287
|
+
try {
|
|
288
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
289
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
290
|
+
const len0 = WASM_VECTOR_LEN;
|
|
291
|
+
wasm.keccak256(retptr, ptr0, len0);
|
|
292
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
293
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
294
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
295
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
296
|
+
return v2;
|
|
297
|
+
} finally {
|
|
298
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
304
|
+
* @param {Uint8Array} inputs
|
|
305
|
+
* @returns {Uint8Array}
|
|
306
|
+
*/
|
|
307
|
+
export function blake2s256(inputs) {
|
|
308
|
+
try {
|
|
309
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
310
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
311
|
+
const len0 = WASM_VECTOR_LEN;
|
|
312
|
+
wasm.blake2s256(retptr, ptr0, len0);
|
|
313
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
314
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
315
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
316
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
317
|
+
return v2;
|
|
318
|
+
} finally {
|
|
319
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Calculates the SHA256 hash of the input bytes
|
|
325
|
+
* @param {Uint8Array} inputs
|
|
326
|
+
* @returns {Uint8Array}
|
|
327
|
+
*/
|
|
328
|
+
export function sha256(inputs) {
|
|
329
|
+
try {
|
|
330
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
331
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
332
|
+
const len0 = WASM_VECTOR_LEN;
|
|
333
|
+
wasm.sha256(retptr, ptr0, len0);
|
|
334
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
335
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
336
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
337
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
338
|
+
return v2;
|
|
339
|
+
} finally {
|
|
340
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
346
|
+
* @param {string} lhs
|
|
347
|
+
* @param {string} rhs
|
|
348
|
+
* @returns {string}
|
|
349
|
+
*/
|
|
350
|
+
export function xor(lhs, rhs) {
|
|
351
|
+
const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs));
|
|
352
|
+
return takeObject(ret);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
357
|
+
* @param {string} lhs
|
|
358
|
+
* @param {string} rhs
|
|
359
|
+
* @returns {string}
|
|
360
|
+
*/
|
|
361
|
+
export function and(lhs, rhs) {
|
|
362
|
+
const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs));
|
|
363
|
+
return takeObject(ret);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function _assertClass(instance, klass) {
|
|
367
|
+
if (!(instance instanceof klass)) {
|
|
368
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
369
|
+
}
|
|
370
|
+
return instance.ptr;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
243
373
|
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
244
374
|
*
|
|
245
375
|
* @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
|
|
@@ -248,9 +378,9 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
248
378
|
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
249
379
|
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
250
380
|
*/
|
|
251
|
-
export function executeCircuitWithBlackBoxSolver(solver,
|
|
381
|
+
export function executeCircuitWithBlackBoxSolver(solver, program, initial_witness, foreign_call_handler) {
|
|
252
382
|
_assertClass(solver, WasmBlackBoxFunctionSolver);
|
|
253
|
-
const ptr0 = passArray8ToWasm0(
|
|
383
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
254
384
|
const len0 = WASM_VECTOR_LEN;
|
|
255
385
|
const ret = wasm.executeCircuitWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
256
386
|
return takeObject(ret);
|
|
@@ -264,8 +394,8 @@ export function executeCircuitWithBlackBoxSolver(solver, circuit, initial_witnes
|
|
|
264
394
|
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
265
395
|
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
266
396
|
*/
|
|
267
|
-
export function executeCircuit(
|
|
268
|
-
const ptr0 = passArray8ToWasm0(
|
|
397
|
+
export function executeCircuit(program, initial_witness, foreign_call_handler) {
|
|
398
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
269
399
|
const len0 = WASM_VECTOR_LEN;
|
|
270
400
|
const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
271
401
|
return takeObject(ret);
|
|
@@ -285,14 +415,14 @@ export function createBlackBoxSolver() {
|
|
|
285
415
|
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
286
416
|
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
287
417
|
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
288
|
-
* @param {Uint8Array}
|
|
418
|
+
* @param {Uint8Array} program
|
|
289
419
|
* @param {WitnessMap} solved_witness
|
|
290
420
|
* @returns {WitnessMap}
|
|
291
421
|
*/
|
|
292
|
-
export function getPublicWitness(
|
|
422
|
+
export function getPublicWitness(program, solved_witness) {
|
|
293
423
|
try {
|
|
294
424
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
295
|
-
const ptr0 = passArray8ToWasm0(
|
|
425
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
296
426
|
const len0 = WASM_VECTOR_LEN;
|
|
297
427
|
wasm.getPublicWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
|
|
298
428
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
@@ -313,14 +443,14 @@ export function getPublicWitness(circuit, solved_witness) {
|
|
|
313
443
|
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
314
444
|
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
315
445
|
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
316
|
-
* @param {Uint8Array}
|
|
446
|
+
* @param {Uint8Array} program
|
|
317
447
|
* @param {WitnessMap} solved_witness
|
|
318
448
|
* @returns {WitnessMap}
|
|
319
449
|
*/
|
|
320
|
-
export function getPublicParametersWitness(
|
|
450
|
+
export function getPublicParametersWitness(program, solved_witness) {
|
|
321
451
|
try {
|
|
322
452
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
323
|
-
const ptr0 = passArray8ToWasm0(
|
|
453
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
324
454
|
const len0 = WASM_VECTOR_LEN;
|
|
325
455
|
wasm.getPublicParametersWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
|
|
326
456
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
@@ -341,14 +471,14 @@ export function getPublicParametersWitness(circuit, solved_witness) {
|
|
|
341
471
|
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
342
472
|
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
343
473
|
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
344
|
-
* @param {Uint8Array}
|
|
474
|
+
* @param {Uint8Array} program
|
|
345
475
|
* @param {WitnessMap} witness_map
|
|
346
476
|
* @returns {WitnessMap}
|
|
347
477
|
*/
|
|
348
|
-
export function getReturnWitness(
|
|
478
|
+
export function getReturnWitness(program, witness_map) {
|
|
349
479
|
try {
|
|
350
480
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
351
|
-
const ptr0 = passArray8ToWasm0(
|
|
481
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
352
482
|
const len0 = WASM_VECTOR_LEN;
|
|
353
483
|
wasm.getReturnWitness(retptr, ptr0, len0, addHeapObject(witness_map));
|
|
354
484
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
@@ -363,6 +493,27 @@ export function getReturnWitness(circuit, witness_map) {
|
|
|
363
493
|
}
|
|
364
494
|
}
|
|
365
495
|
|
|
496
|
+
/**
|
|
497
|
+
* Sets the package's logging level.
|
|
498
|
+
*
|
|
499
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
500
|
+
*/
|
|
501
|
+
export function initLogLevel(filter) {
|
|
502
|
+
try {
|
|
503
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
504
|
+
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
505
|
+
const len0 = WASM_VECTOR_LEN;
|
|
506
|
+
wasm.initLogLevel(retptr, ptr0, len0);
|
|
507
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
508
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
509
|
+
if (r1) {
|
|
510
|
+
throw takeObject(r0);
|
|
511
|
+
}
|
|
512
|
+
} finally {
|
|
513
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
366
517
|
/**
|
|
367
518
|
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
|
|
368
519
|
*
|
|
@@ -387,10 +538,6 @@ export function decompressWitness(compressed_witness) {
|
|
|
387
538
|
}
|
|
388
539
|
}
|
|
389
540
|
|
|
390
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
391
|
-
ptr = ptr >>> 0;
|
|
392
|
-
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
393
|
-
}
|
|
394
541
|
/**
|
|
395
542
|
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
396
543
|
*
|
|
@@ -416,154 +563,6 @@ export function compressWitness(witness_map) {
|
|
|
416
563
|
}
|
|
417
564
|
}
|
|
418
565
|
|
|
419
|
-
/**
|
|
420
|
-
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
421
|
-
* @param {Uint8Array} hashed_msg
|
|
422
|
-
* @param {Uint8Array} public_key_x_bytes
|
|
423
|
-
* @param {Uint8Array} public_key_y_bytes
|
|
424
|
-
* @param {Uint8Array} signature
|
|
425
|
-
* @returns {boolean}
|
|
426
|
-
*/
|
|
427
|
-
export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
428
|
-
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
429
|
-
const len0 = WASM_VECTOR_LEN;
|
|
430
|
-
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
431
|
-
const len1 = WASM_VECTOR_LEN;
|
|
432
|
-
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
433
|
-
const len2 = WASM_VECTOR_LEN;
|
|
434
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
435
|
-
const len3 = WASM_VECTOR_LEN;
|
|
436
|
-
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
437
|
-
return ret !== 0;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
442
|
-
* @param {Uint8Array} hashed_msg
|
|
443
|
-
* @param {Uint8Array} public_key_x_bytes
|
|
444
|
-
* @param {Uint8Array} public_key_y_bytes
|
|
445
|
-
* @param {Uint8Array} signature
|
|
446
|
-
* @returns {boolean}
|
|
447
|
-
*/
|
|
448
|
-
export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
449
|
-
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
450
|
-
const len0 = WASM_VECTOR_LEN;
|
|
451
|
-
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
452
|
-
const len1 = WASM_VECTOR_LEN;
|
|
453
|
-
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
454
|
-
const len2 = WASM_VECTOR_LEN;
|
|
455
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
456
|
-
const len3 = WASM_VECTOR_LEN;
|
|
457
|
-
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
458
|
-
return ret !== 0;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* Calculates the Keccak256 hash of the input bytes
|
|
463
|
-
* @param {Uint8Array} inputs
|
|
464
|
-
* @returns {Uint8Array}
|
|
465
|
-
*/
|
|
466
|
-
export function keccak256(inputs) {
|
|
467
|
-
try {
|
|
468
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
469
|
-
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
470
|
-
const len0 = WASM_VECTOR_LEN;
|
|
471
|
-
wasm.keccak256(retptr, ptr0, len0);
|
|
472
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
473
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
474
|
-
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
475
|
-
wasm.__wbindgen_free(r0, r1 * 1);
|
|
476
|
-
return v2;
|
|
477
|
-
} finally {
|
|
478
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* Calculates the Blake2s256 hash of the input bytes
|
|
484
|
-
* @param {Uint8Array} inputs
|
|
485
|
-
* @returns {Uint8Array}
|
|
486
|
-
*/
|
|
487
|
-
export function blake2s256(inputs) {
|
|
488
|
-
try {
|
|
489
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
490
|
-
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
491
|
-
const len0 = WASM_VECTOR_LEN;
|
|
492
|
-
wasm.blake2s256(retptr, ptr0, len0);
|
|
493
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
494
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
495
|
-
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
496
|
-
wasm.__wbindgen_free(r0, r1 * 1);
|
|
497
|
-
return v2;
|
|
498
|
-
} finally {
|
|
499
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Calculates the SHA256 hash of the input bytes
|
|
505
|
-
* @param {Uint8Array} inputs
|
|
506
|
-
* @returns {Uint8Array}
|
|
507
|
-
*/
|
|
508
|
-
export function sha256(inputs) {
|
|
509
|
-
try {
|
|
510
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
511
|
-
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
512
|
-
const len0 = WASM_VECTOR_LEN;
|
|
513
|
-
wasm.sha256(retptr, ptr0, len0);
|
|
514
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
515
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
516
|
-
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
517
|
-
wasm.__wbindgen_free(r0, r1 * 1);
|
|
518
|
-
return v2;
|
|
519
|
-
} finally {
|
|
520
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
526
|
-
* @param {string} lhs
|
|
527
|
-
* @param {string} rhs
|
|
528
|
-
* @returns {string}
|
|
529
|
-
*/
|
|
530
|
-
export function xor(lhs, rhs) {
|
|
531
|
-
const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs));
|
|
532
|
-
return takeObject(ret);
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
/**
|
|
536
|
-
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
537
|
-
* @param {string} lhs
|
|
538
|
-
* @param {string} rhs
|
|
539
|
-
* @returns {string}
|
|
540
|
-
*/
|
|
541
|
-
export function and(lhs, rhs) {
|
|
542
|
-
const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs));
|
|
543
|
-
return takeObject(ret);
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
/**
|
|
547
|
-
* Sets the package's logging level.
|
|
548
|
-
*
|
|
549
|
-
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
550
|
-
*/
|
|
551
|
-
export function initLogLevel(filter) {
|
|
552
|
-
try {
|
|
553
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
554
|
-
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
555
|
-
const len0 = WASM_VECTOR_LEN;
|
|
556
|
-
wasm.initLogLevel(retptr, ptr0, len0);
|
|
557
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
558
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
559
|
-
if (r1) {
|
|
560
|
-
throw takeObject(r0);
|
|
561
|
-
}
|
|
562
|
-
} finally {
|
|
563
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
|
|
567
566
|
/**
|
|
568
567
|
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
569
568
|
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
@@ -670,32 +669,11 @@ function __wbg_get_imports() {
|
|
|
670
669
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
671
670
|
takeObject(arg0);
|
|
672
671
|
};
|
|
673
|
-
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
674
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
675
|
-
return addHeapObject(ret);
|
|
676
|
-
};
|
|
677
672
|
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
|
678
673
|
const ret = getObject(arg0);
|
|
679
674
|
return addHeapObject(ret);
|
|
680
675
|
};
|
|
681
|
-
imports.wbg.
|
|
682
|
-
const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
|
|
683
|
-
return addHeapObject(ret);
|
|
684
|
-
};
|
|
685
|
-
imports.wbg.__wbindgen_cb_drop = function(arg0) {
|
|
686
|
-
const obj = takeObject(arg0).original;
|
|
687
|
-
if (obj.cnt-- == 1) {
|
|
688
|
-
obj.a = 0;
|
|
689
|
-
return true;
|
|
690
|
-
}
|
|
691
|
-
const ret = false;
|
|
692
|
-
return ret;
|
|
693
|
-
};
|
|
694
|
-
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
695
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
696
|
-
return addHeapObject(ret);
|
|
697
|
-
};
|
|
698
|
-
imports.wbg.__wbg_new_ab82e8584bdd2143 = function() {
|
|
676
|
+
imports.wbg.__wbg_new_0d2c031c3755a625 = function() {
|
|
699
677
|
const ret = new Map();
|
|
700
678
|
return addHeapObject(ret);
|
|
701
679
|
};
|
|
@@ -711,10 +689,22 @@ function __wbg_get_imports() {
|
|
|
711
689
|
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
712
690
|
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
713
691
|
};
|
|
714
|
-
imports.wbg.
|
|
692
|
+
imports.wbg.__wbg_constructor_9a4af6ecd5050c55 = function(arg0) {
|
|
715
693
|
const ret = new Error(takeObject(arg0));
|
|
716
694
|
return addHeapObject(ret);
|
|
717
695
|
};
|
|
696
|
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
697
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
698
|
+
return addHeapObject(ret);
|
|
699
|
+
};
|
|
700
|
+
imports.wbg.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
|
|
701
|
+
const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
|
|
702
|
+
return addHeapObject(ret);
|
|
703
|
+
};
|
|
704
|
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
705
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
706
|
+
return addHeapObject(ret);
|
|
707
|
+
};
|
|
718
708
|
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
|
719
709
|
const obj = getObject(arg1);
|
|
720
710
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
@@ -733,6 +723,15 @@ function __wbg_get_imports() {
|
|
|
733
723
|
const ret = Array.isArray(getObject(arg0));
|
|
734
724
|
return ret;
|
|
735
725
|
};
|
|
726
|
+
imports.wbg.__wbindgen_cb_drop = function(arg0) {
|
|
727
|
+
const obj = takeObject(arg0).original;
|
|
728
|
+
if (obj.cnt-- == 1) {
|
|
729
|
+
obj.a = 0;
|
|
730
|
+
return true;
|
|
731
|
+
}
|
|
732
|
+
const ret = false;
|
|
733
|
+
return ret;
|
|
734
|
+
};
|
|
736
735
|
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
|
|
737
736
|
const ret = new Error();
|
|
738
737
|
return addHeapObject(ret);
|
|
@@ -1157,8 +1156,8 @@ function __wbg_get_imports() {
|
|
|
1157
1156
|
const ret = wasm.__wbindgen_export_2;
|
|
1158
1157
|
return addHeapObject(ret);
|
|
1159
1158
|
};
|
|
1160
|
-
imports.wbg.
|
|
1161
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1159
|
+
imports.wbg.__wbindgen_closure_wrapper1401 = function(arg0, arg1, arg2) {
|
|
1160
|
+
const ret = makeMutClosure(arg0, arg1, 486, __wbg_adapter_52);
|
|
1162
1161
|
return addHeapObject(ret);
|
|
1163
1162
|
};
|
|
1164
1163
|
|
package/web/acvm_js_bg.wasm
CHANGED
|
Binary file
|
package/web/acvm_js_bg.wasm.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
|
|
5
|
+
export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
|
|
6
|
+
export function keccak256(a: number, b: number, c: number): void;
|
|
7
|
+
export function blake2s256(a: number, b: number, c: number): void;
|
|
8
|
+
export function sha256(a: number, b: number, c: number): void;
|
|
9
|
+
export function xor(a: number, b: number): number;
|
|
10
|
+
export function and(a: number, b: number): number;
|
|
4
11
|
export function executeCircuitWithBlackBoxSolver(a: number, b: number, c: number, d: number, e: number): number;
|
|
5
12
|
export function executeCircuit(a: number, b: number, c: number, d: number): number;
|
|
6
13
|
export function createBlackBoxSolver(): number;
|
|
@@ -8,16 +15,9 @@ export function __wbg_wasmblackboxfunctionsolver_free(a: number): void;
|
|
|
8
15
|
export function getPublicWitness(a: number, b: number, c: number, d: number): void;
|
|
9
16
|
export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
|
|
10
17
|
export function getReturnWitness(a: number, b: number, c: number, d: number): void;
|
|
18
|
+
export function initLogLevel(a: number, b: number, c: number): void;
|
|
11
19
|
export function decompressWitness(a: number, b: number, c: number): void;
|
|
12
20
|
export function compressWitness(a: number, b: number): void;
|
|
13
|
-
export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
|
|
14
|
-
export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
|
|
15
|
-
export function keccak256(a: number, b: number, c: number): void;
|
|
16
|
-
export function blake2s256(a: number, b: number, c: number): void;
|
|
17
|
-
export function sha256(a: number, b: number, c: number): void;
|
|
18
|
-
export function xor(a: number, b: number): number;
|
|
19
|
-
export function and(a: number, b: number): number;
|
|
20
|
-
export function initLogLevel(a: number, b: number, c: number): void;
|
|
21
21
|
export function buildInfo(): number;
|
|
22
22
|
export function __wbg_trap_free(a: number): void;
|
|
23
23
|
export function trap___wbg_wasmer_trap(): void;
|