@noir-lang/acvm_js 0.50.0 → 0.51.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 +53 -52
- package/nodejs/acvm_js.js +135 -113
- package/nodejs/acvm_js_bg.wasm +0 -0
- package/nodejs/acvm_js_bg.wasm.d.ts +5 -5
- package/package.json +2 -2
- package/web/acvm_js.d.ts +58 -57
- package/web/acvm_js.js +134 -111
- package/web/acvm_js_bg.wasm +0 -0
- package/web/acvm_js_bg.wasm.d.ts +5 -5
package/nodejs/acvm_js.d.ts
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
+
* Sets the package's logging level.
|
|
5
|
+
*
|
|
6
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
7
|
+
*/
|
|
8
|
+
export function initLogLevel(filter: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
11
|
+
*
|
|
12
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
13
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
14
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
15
|
+
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
16
|
+
*/
|
|
17
|
+
export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
|
|
18
|
+
/**
|
|
19
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
20
|
+
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
21
|
+
*
|
|
22
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
23
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
24
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
25
|
+
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit.
|
|
26
|
+
*/
|
|
27
|
+
export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
|
|
28
|
+
/**
|
|
29
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
30
|
+
*
|
|
31
|
+
* @param {Uint8Array} program - A serialized representation of an ACIR program
|
|
32
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
|
|
33
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
|
|
34
|
+
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
35
|
+
*/
|
|
36
|
+
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
|
|
37
|
+
/**
|
|
4
38
|
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
5
39
|
* @param {string} lhs
|
|
6
40
|
* @param {string} rhs
|
|
@@ -15,11 +49,12 @@ export function and(lhs: string, rhs: string): string;
|
|
|
15
49
|
*/
|
|
16
50
|
export function xor(lhs: string, rhs: string): string;
|
|
17
51
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @param {
|
|
20
|
-
* @
|
|
52
|
+
* Sha256 compression function
|
|
53
|
+
* @param {Uint32Array} inputs
|
|
54
|
+
* @param {Uint32Array} state
|
|
55
|
+
* @returns {Uint32Array}
|
|
21
56
|
*/
|
|
22
|
-
export function
|
|
57
|
+
export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
|
|
23
58
|
/**
|
|
24
59
|
* Calculates the Blake2s256 hash of the input bytes
|
|
25
60
|
* @param {Uint8Array} inputs
|
|
@@ -80,12 +115,6 @@ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
|
|
|
80
115
|
*/
|
|
81
116
|
export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
|
|
82
117
|
/**
|
|
83
|
-
* Sets the package's logging level.
|
|
84
|
-
*
|
|
85
|
-
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
86
|
-
*/
|
|
87
|
-
export function initLogLevel(filter: string): void;
|
|
88
|
-
/**
|
|
89
118
|
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
90
119
|
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
91
120
|
*/
|
|
@@ -123,48 +152,6 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
|
|
|
123
152
|
* @returns {WitnessMap}
|
|
124
153
|
*/
|
|
125
154
|
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
126
|
-
/**
|
|
127
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
128
|
-
*
|
|
129
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
130
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
131
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
132
|
-
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
133
|
-
*/
|
|
134
|
-
export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
|
|
135
|
-
/**
|
|
136
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
137
|
-
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
138
|
-
*
|
|
139
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
140
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
141
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
142
|
-
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit.
|
|
143
|
-
*/
|
|
144
|
-
export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
|
|
145
|
-
/**
|
|
146
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
147
|
-
*
|
|
148
|
-
* @param {Uint8Array} program - A serialized representation of an ACIR program
|
|
149
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
|
|
150
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
|
|
151
|
-
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
152
|
-
*/
|
|
153
|
-
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
|
|
154
|
-
|
|
155
|
-
export type ForeignCallInput = string[]
|
|
156
|
-
export type ForeignCallOutput = string | string[]
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* A callback which performs an foreign call and returns the response.
|
|
160
|
-
* @callback ForeignCallHandler
|
|
161
|
-
* @param {string} name - The identifier for the type of foreign call being performed.
|
|
162
|
-
* @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
|
|
163
|
-
* @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
|
|
164
|
-
*/
|
|
165
|
-
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
|
|
166
|
-
|
|
167
|
-
|
|
168
155
|
|
|
169
156
|
// Map from witness index to hex string value of witness.
|
|
170
157
|
export type WitnessMap = Map<number, string>;
|
|
@@ -181,6 +168,20 @@ export type SolvedAndReturnWitness = {
|
|
|
181
168
|
|
|
182
169
|
|
|
183
170
|
|
|
171
|
+
export type ForeignCallInput = string[]
|
|
172
|
+
export type ForeignCallOutput = string | string[]
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* A callback which performs an foreign call and returns the response.
|
|
176
|
+
* @callback ForeignCallHandler
|
|
177
|
+
* @param {string} name - The identifier for the type of foreign call being performed.
|
|
178
|
+
* @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
|
|
179
|
+
* @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
|
|
180
|
+
*/
|
|
181
|
+
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
184
185
|
/**
|
|
185
186
|
* @typedef {Object} BuildInfo - Information about how the installed package was built
|
|
186
187
|
* @property {string} gitHash - The hash of the git commit from which the package was built.
|
package/nodejs/acvm_js.js
CHANGED
|
@@ -9,6 +9,20 @@ heap.push(undefined, null, true, false);
|
|
|
9
9
|
|
|
10
10
|
function getObject(idx) { return heap[idx]; }
|
|
11
11
|
|
|
12
|
+
let heap_next = heap.length;
|
|
13
|
+
|
|
14
|
+
function dropObject(idx) {
|
|
15
|
+
if (idx < 132) return;
|
|
16
|
+
heap[idx] = heap_next;
|
|
17
|
+
heap_next = idx;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function takeObject(idx) {
|
|
21
|
+
const ret = getObject(idx);
|
|
22
|
+
dropObject(idx);
|
|
23
|
+
return ret;
|
|
24
|
+
}
|
|
25
|
+
|
|
12
26
|
function isLikeNone(x) {
|
|
13
27
|
return x === undefined || x === null;
|
|
14
28
|
}
|
|
@@ -31,20 +45,6 @@ function getInt32Memory0() {
|
|
|
31
45
|
return cachedInt32Memory0;
|
|
32
46
|
}
|
|
33
47
|
|
|
34
|
-
let heap_next = heap.length;
|
|
35
|
-
|
|
36
|
-
function dropObject(idx) {
|
|
37
|
-
if (idx < 132) return;
|
|
38
|
-
heap[idx] = heap_next;
|
|
39
|
-
heap_next = idx;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function takeObject(idx) {
|
|
43
|
-
const ret = getObject(idx);
|
|
44
|
-
dropObject(idx);
|
|
45
|
-
return ret;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
48
|
function addHeapObject(obj) {
|
|
49
49
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
50
50
|
const idx = heap_next;
|
|
@@ -220,6 +220,79 @@ function __wbg_adapter_22(arg0, arg1, arg2) {
|
|
|
220
220
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h21c8ca3eb6ab9385(arg0, arg1, addHeapObject(arg2));
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Sets the package's logging level.
|
|
225
|
+
*
|
|
226
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
227
|
+
*/
|
|
228
|
+
module.exports.initLogLevel = function(filter) {
|
|
229
|
+
try {
|
|
230
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
231
|
+
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
232
|
+
const len0 = WASM_VECTOR_LEN;
|
|
233
|
+
wasm.initLogLevel(retptr, ptr0, len0);
|
|
234
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
235
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
236
|
+
if (r1) {
|
|
237
|
+
throw takeObject(r0);
|
|
238
|
+
}
|
|
239
|
+
} finally {
|
|
240
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
245
|
+
const ptr = malloc(arg.length * 1) >>> 0;
|
|
246
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
247
|
+
WASM_VECTOR_LEN = arg.length;
|
|
248
|
+
return ptr;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
252
|
+
*
|
|
253
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
254
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
255
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
256
|
+
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
257
|
+
*/
|
|
258
|
+
module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
|
|
259
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
260
|
+
const len0 = WASM_VECTOR_LEN;
|
|
261
|
+
const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
262
|
+
return takeObject(ret);
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
267
|
+
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
268
|
+
*
|
|
269
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
270
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
271
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
272
|
+
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit.
|
|
273
|
+
*/
|
|
274
|
+
module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
|
|
275
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
276
|
+
const len0 = WASM_VECTOR_LEN;
|
|
277
|
+
const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
278
|
+
return takeObject(ret);
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
283
|
+
*
|
|
284
|
+
* @param {Uint8Array} program - A serialized representation of an ACIR program
|
|
285
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
|
|
286
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
|
|
287
|
+
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
288
|
+
*/
|
|
289
|
+
module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
|
|
290
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
291
|
+
const len0 = WASM_VECTOR_LEN;
|
|
292
|
+
const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
293
|
+
return takeObject(ret);
|
|
294
|
+
};
|
|
295
|
+
|
|
223
296
|
/**
|
|
224
297
|
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
225
298
|
* @param {string} lhs
|
|
@@ -242,38 +315,54 @@ module.exports.xor = function(lhs, rhs) {
|
|
|
242
315
|
return takeObject(ret);
|
|
243
316
|
};
|
|
244
317
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
318
|
+
let cachedUint32Memory0 = null;
|
|
319
|
+
|
|
320
|
+
function getUint32Memory0() {
|
|
321
|
+
if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
|
|
322
|
+
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
|
|
323
|
+
}
|
|
324
|
+
return cachedUint32Memory0;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
328
|
+
const ptr = malloc(arg.length * 4) >>> 0;
|
|
329
|
+
getUint32Memory0().set(arg, ptr / 4);
|
|
248
330
|
WASM_VECTOR_LEN = arg.length;
|
|
249
331
|
return ptr;
|
|
250
332
|
}
|
|
251
333
|
|
|
252
|
-
function
|
|
334
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
253
335
|
ptr = ptr >>> 0;
|
|
254
|
-
return
|
|
336
|
+
return getUint32Memory0().subarray(ptr / 4, ptr / 4 + len);
|
|
255
337
|
}
|
|
256
338
|
/**
|
|
257
|
-
*
|
|
258
|
-
* @param {
|
|
259
|
-
* @
|
|
339
|
+
* Sha256 compression function
|
|
340
|
+
* @param {Uint32Array} inputs
|
|
341
|
+
* @param {Uint32Array} state
|
|
342
|
+
* @returns {Uint32Array}
|
|
260
343
|
*/
|
|
261
|
-
module.exports.
|
|
344
|
+
module.exports.sha256_compression = function(inputs, state) {
|
|
262
345
|
try {
|
|
263
346
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
264
|
-
const ptr0 =
|
|
347
|
+
const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
265
348
|
const len0 = WASM_VECTOR_LEN;
|
|
266
|
-
|
|
349
|
+
const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
|
|
350
|
+
const len1 = WASM_VECTOR_LEN;
|
|
351
|
+
wasm.sha256_compression(retptr, ptr0, len0, ptr1, len1);
|
|
267
352
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
268
353
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
269
|
-
var
|
|
270
|
-
wasm.__wbindgen_free(r0, r1 *
|
|
271
|
-
return
|
|
354
|
+
var v3 = getArrayU32FromWasm0(r0, r1).slice();
|
|
355
|
+
wasm.__wbindgen_free(r0, r1 * 4);
|
|
356
|
+
return v3;
|
|
272
357
|
} finally {
|
|
273
358
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
274
359
|
}
|
|
275
360
|
};
|
|
276
361
|
|
|
362
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
363
|
+
ptr = ptr >>> 0;
|
|
364
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
365
|
+
}
|
|
277
366
|
/**
|
|
278
367
|
* Calculates the Blake2s256 hash of the input bytes
|
|
279
368
|
* @param {Uint8Array} inputs
|
|
@@ -457,27 +546,6 @@ module.exports.decompressWitnessStack = function(compressed_witness) {
|
|
|
457
546
|
}
|
|
458
547
|
};
|
|
459
548
|
|
|
460
|
-
/**
|
|
461
|
-
* Sets the package's logging level.
|
|
462
|
-
*
|
|
463
|
-
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
464
|
-
*/
|
|
465
|
-
module.exports.initLogLevel = function(filter) {
|
|
466
|
-
try {
|
|
467
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
468
|
-
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
469
|
-
const len0 = WASM_VECTOR_LEN;
|
|
470
|
-
wasm.initLogLevel(retptr, ptr0, len0);
|
|
471
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
472
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
473
|
-
if (r1) {
|
|
474
|
-
throw takeObject(r0);
|
|
475
|
-
}
|
|
476
|
-
} finally {
|
|
477
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
|
|
481
549
|
/**
|
|
482
550
|
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
483
551
|
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
@@ -571,52 +639,6 @@ module.exports.getPublicWitness = function(program, solved_witness) {
|
|
|
571
639
|
}
|
|
572
640
|
};
|
|
573
641
|
|
|
574
|
-
/**
|
|
575
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
576
|
-
*
|
|
577
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
578
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
579
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
580
|
-
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
581
|
-
*/
|
|
582
|
-
module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
|
|
583
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
584
|
-
const len0 = WASM_VECTOR_LEN;
|
|
585
|
-
const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
586
|
-
return takeObject(ret);
|
|
587
|
-
};
|
|
588
|
-
|
|
589
|
-
/**
|
|
590
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
591
|
-
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
592
|
-
*
|
|
593
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
594
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
595
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
596
|
-
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit.
|
|
597
|
-
*/
|
|
598
|
-
module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
|
|
599
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
600
|
-
const len0 = WASM_VECTOR_LEN;
|
|
601
|
-
const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
602
|
-
return takeObject(ret);
|
|
603
|
-
};
|
|
604
|
-
|
|
605
|
-
/**
|
|
606
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
607
|
-
*
|
|
608
|
-
* @param {Uint8Array} program - A serialized representation of an ACIR program
|
|
609
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
|
|
610
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
|
|
611
|
-
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
612
|
-
*/
|
|
613
|
-
module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
|
|
614
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
615
|
-
const len0 = WASM_VECTOR_LEN;
|
|
616
|
-
const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
617
|
-
return takeObject(ret);
|
|
618
|
-
};
|
|
619
|
-
|
|
620
642
|
function __wbg_adapter_76(arg0, arg1, arg2, arg3, arg4) {
|
|
621
643
|
wasm.wasm_bindgen__convert__closures__invoke3_mut__h17fc532521b46256(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
|
|
622
644
|
}
|
|
@@ -632,6 +654,16 @@ function __wbg_adapter_93(arg0, arg1, arg2, arg3) {
|
|
|
632
654
|
wasm.wasm_bindgen__convert__closures__invoke2_mut__h0d187b0f08495587(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
633
655
|
}
|
|
634
656
|
|
|
657
|
+
module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
658
|
+
const obj = takeObject(arg0).original;
|
|
659
|
+
if (obj.cnt-- == 1) {
|
|
660
|
+
obj.a = 0;
|
|
661
|
+
return true;
|
|
662
|
+
}
|
|
663
|
+
const ret = false;
|
|
664
|
+
return ret;
|
|
665
|
+
};
|
|
666
|
+
|
|
635
667
|
module.exports.__wbindgen_number_get = function(arg0, arg1) {
|
|
636
668
|
const obj = getObject(arg1);
|
|
637
669
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
@@ -643,17 +675,7 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
|
643
675
|
takeObject(arg0);
|
|
644
676
|
};
|
|
645
677
|
|
|
646
|
-
module.exports.
|
|
647
|
-
const obj = takeObject(arg0).original;
|
|
648
|
-
if (obj.cnt-- == 1) {
|
|
649
|
-
obj.a = 0;
|
|
650
|
-
return true;
|
|
651
|
-
}
|
|
652
|
-
const ret = false;
|
|
653
|
-
return ret;
|
|
654
|
-
};
|
|
655
|
-
|
|
656
|
-
module.exports.__wbg_new_7c63fcfa4f1f863b = function() {
|
|
678
|
+
module.exports.__wbg_new_3b3e21164d5381ca = function() {
|
|
657
679
|
const ret = new Map();
|
|
658
680
|
return addHeapObject(ret);
|
|
659
681
|
};
|
|
@@ -677,16 +699,11 @@ module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
|
677
699
|
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
678
700
|
};
|
|
679
701
|
|
|
680
|
-
module.exports.
|
|
702
|
+
module.exports.__wbg_constructor_f4bcf4c70838c703 = function(arg0) {
|
|
681
703
|
const ret = new Error(takeObject(arg0));
|
|
682
704
|
return addHeapObject(ret);
|
|
683
705
|
};
|
|
684
706
|
|
|
685
|
-
module.exports.__wbg_new_76b464e4772843b0 = function() {
|
|
686
|
-
const ret = new Array();
|
|
687
|
-
return addHeapObject(ret);
|
|
688
|
-
};
|
|
689
|
-
|
|
690
707
|
module.exports.__wbindgen_is_array = function(arg0) {
|
|
691
708
|
const ret = Array.isArray(getObject(arg0));
|
|
692
709
|
return ret;
|
|
@@ -697,6 +714,11 @@ module.exports.__wbindgen_is_string = function(arg0) {
|
|
|
697
714
|
return ret;
|
|
698
715
|
};
|
|
699
716
|
|
|
717
|
+
module.exports.__wbg_new_e14625531a95427d = function() {
|
|
718
|
+
const ret = new Array();
|
|
719
|
+
return addHeapObject(ret);
|
|
720
|
+
};
|
|
721
|
+
|
|
700
722
|
module.exports.__wbg_new_abda76e883ba8a5f = function() {
|
|
701
723
|
const ret = new Error();
|
|
702
724
|
return addHeapObject(ret);
|
|
@@ -916,7 +938,7 @@ module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
|
916
938
|
};
|
|
917
939
|
|
|
918
940
|
module.exports.__wbindgen_closure_wrapper747 = function(arg0, arg1, arg2) {
|
|
919
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
941
|
+
const ret = makeMutClosure(arg0, arg1, 266, __wbg_adapter_22);
|
|
920
942
|
return addHeapObject(ret);
|
|
921
943
|
};
|
|
922
944
|
|
package/nodejs/acvm_js_bg.wasm
CHANGED
|
Binary file
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export function initLogLevel(a: number, b: number, c: number): void;
|
|
5
|
+
export function executeCircuit(a: number, b: number, c: number, d: number): number;
|
|
6
|
+
export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number;
|
|
7
|
+
export function executeProgram(a: number, b: number, c: number, d: number): number;
|
|
4
8
|
export function and(a: number, b: number): number;
|
|
5
9
|
export function xor(a: number, b: number): number;
|
|
6
|
-
export function
|
|
10
|
+
export function sha256_compression(a: number, b: number, c: number, d: number, e: number): void;
|
|
7
11
|
export function blake2s256(a: number, b: number, c: number): void;
|
|
8
12
|
export function keccak256(a: number, b: number, c: number): void;
|
|
9
13
|
export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
|
|
@@ -12,14 +16,10 @@ export function compressWitness(a: number, b: number): void;
|
|
|
12
16
|
export function decompressWitness(a: number, b: number, c: number): void;
|
|
13
17
|
export function compressWitnessStack(a: number, b: number): void;
|
|
14
18
|
export function decompressWitnessStack(a: number, b: number, c: number): void;
|
|
15
|
-
export function initLogLevel(a: number, b: number, c: number): void;
|
|
16
19
|
export function buildInfo(): number;
|
|
17
20
|
export function getReturnWitness(a: number, b: number, c: number, d: number): void;
|
|
18
21
|
export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
|
|
19
22
|
export function getPublicWitness(a: number, b: number, c: number, d: number): void;
|
|
20
|
-
export function executeCircuit(a: number, b: number, c: number, d: number): number;
|
|
21
|
-
export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number;
|
|
22
|
-
export function executeProgram(a: number, b: number, c: number, d: number): number;
|
|
23
23
|
export function __wbindgen_malloc(a: number): number;
|
|
24
24
|
export function __wbindgen_realloc(a: number, b: number, c: number): number;
|
|
25
25
|
export const __wbindgen_export_2: WebAssembly.Table;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noir-lang/acvm_js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@esm-bundle/chai": "^4.3.4-fix.0",
|
|
41
41
|
"@web/dev-server-esbuild": "^0.3.6",
|
|
42
42
|
"@web/test-runner": "^0.18.1",
|
|
43
|
-
"@web/test-runner-playwright": "^0.
|
|
43
|
+
"@web/test-runner-playwright": "^0.11.0",
|
|
44
44
|
"chai": "^4.4.1",
|
|
45
45
|
"eslint": "^8.57.0",
|
|
46
46
|
"eslint-plugin-prettier": "^5.1.3",
|
package/web/acvm_js.d.ts
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
+
* Sets the package's logging level.
|
|
5
|
+
*
|
|
6
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
7
|
+
*/
|
|
8
|
+
export function initLogLevel(filter: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
11
|
+
*
|
|
12
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
13
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
14
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
15
|
+
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
16
|
+
*/
|
|
17
|
+
export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
|
|
18
|
+
/**
|
|
19
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
20
|
+
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
21
|
+
*
|
|
22
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
23
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
24
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
25
|
+
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit.
|
|
26
|
+
*/
|
|
27
|
+
export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
|
|
28
|
+
/**
|
|
29
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
30
|
+
*
|
|
31
|
+
* @param {Uint8Array} program - A serialized representation of an ACIR program
|
|
32
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
|
|
33
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
|
|
34
|
+
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
35
|
+
*/
|
|
36
|
+
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
|
|
37
|
+
/**
|
|
4
38
|
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
5
39
|
* @param {string} lhs
|
|
6
40
|
* @param {string} rhs
|
|
@@ -15,11 +49,12 @@ export function and(lhs: string, rhs: string): string;
|
|
|
15
49
|
*/
|
|
16
50
|
export function xor(lhs: string, rhs: string): string;
|
|
17
51
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @param {
|
|
20
|
-
* @
|
|
52
|
+
* Sha256 compression function
|
|
53
|
+
* @param {Uint32Array} inputs
|
|
54
|
+
* @param {Uint32Array} state
|
|
55
|
+
* @returns {Uint32Array}
|
|
21
56
|
*/
|
|
22
|
-
export function
|
|
57
|
+
export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
|
|
23
58
|
/**
|
|
24
59
|
* Calculates the Blake2s256 hash of the input bytes
|
|
25
60
|
* @param {Uint8Array} inputs
|
|
@@ -80,12 +115,6 @@ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
|
|
|
80
115
|
*/
|
|
81
116
|
export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
|
|
82
117
|
/**
|
|
83
|
-
* Sets the package's logging level.
|
|
84
|
-
*
|
|
85
|
-
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
86
|
-
*/
|
|
87
|
-
export function initLogLevel(filter: string): void;
|
|
88
|
-
/**
|
|
89
118
|
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
90
119
|
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
91
120
|
*/
|
|
@@ -123,48 +152,6 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
|
|
|
123
152
|
* @returns {WitnessMap}
|
|
124
153
|
*/
|
|
125
154
|
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
126
|
-
/**
|
|
127
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
128
|
-
*
|
|
129
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
130
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
131
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
132
|
-
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
133
|
-
*/
|
|
134
|
-
export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
|
|
135
|
-
/**
|
|
136
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
137
|
-
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
138
|
-
*
|
|
139
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
140
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
141
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
142
|
-
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit.
|
|
143
|
-
*/
|
|
144
|
-
export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
|
|
145
|
-
/**
|
|
146
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
147
|
-
*
|
|
148
|
-
* @param {Uint8Array} program - A serialized representation of an ACIR program
|
|
149
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
|
|
150
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
|
|
151
|
-
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
152
|
-
*/
|
|
153
|
-
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
|
|
154
|
-
|
|
155
|
-
export type ForeignCallInput = string[]
|
|
156
|
-
export type ForeignCallOutput = string | string[]
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* A callback which performs an foreign call and returns the response.
|
|
160
|
-
* @callback ForeignCallHandler
|
|
161
|
-
* @param {string} name - The identifier for the type of foreign call being performed.
|
|
162
|
-
* @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
|
|
163
|
-
* @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
|
|
164
|
-
*/
|
|
165
|
-
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
|
|
166
|
-
|
|
167
|
-
|
|
168
155
|
|
|
169
156
|
// Map from witness index to hex string value of witness.
|
|
170
157
|
export type WitnessMap = Map<number, string>;
|
|
@@ -181,6 +168,20 @@ export type SolvedAndReturnWitness = {
|
|
|
181
168
|
|
|
182
169
|
|
|
183
170
|
|
|
171
|
+
export type ForeignCallInput = string[]
|
|
172
|
+
export type ForeignCallOutput = string | string[]
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* A callback which performs an foreign call and returns the response.
|
|
176
|
+
* @callback ForeignCallHandler
|
|
177
|
+
* @param {string} name - The identifier for the type of foreign call being performed.
|
|
178
|
+
* @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
|
|
179
|
+
* @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
|
|
180
|
+
*/
|
|
181
|
+
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
184
185
|
/**
|
|
185
186
|
* @typedef {Object} BuildInfo - Information about how the installed package was built
|
|
186
187
|
* @property {string} gitHash - The hash of the git commit from which the package was built.
|
|
@@ -221,9 +222,13 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
221
222
|
|
|
222
223
|
export interface InitOutput {
|
|
223
224
|
readonly memory: WebAssembly.Memory;
|
|
225
|
+
readonly initLogLevel: (a: number, b: number, c: number) => void;
|
|
226
|
+
readonly executeCircuit: (a: number, b: number, c: number, d: number) => number;
|
|
227
|
+
readonly executeCircuitWithReturnWitness: (a: number, b: number, c: number, d: number) => number;
|
|
228
|
+
readonly executeProgram: (a: number, b: number, c: number, d: number) => number;
|
|
224
229
|
readonly and: (a: number, b: number) => number;
|
|
225
230
|
readonly xor: (a: number, b: number) => number;
|
|
226
|
-
readonly
|
|
231
|
+
readonly sha256_compression: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
227
232
|
readonly blake2s256: (a: number, b: number, c: number) => void;
|
|
228
233
|
readonly keccak256: (a: number, b: number, c: number) => void;
|
|
229
234
|
readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
@@ -232,14 +237,10 @@ export interface InitOutput {
|
|
|
232
237
|
readonly decompressWitness: (a: number, b: number, c: number) => void;
|
|
233
238
|
readonly compressWitnessStack: (a: number, b: number) => void;
|
|
234
239
|
readonly decompressWitnessStack: (a: number, b: number, c: number) => void;
|
|
235
|
-
readonly initLogLevel: (a: number, b: number, c: number) => void;
|
|
236
240
|
readonly buildInfo: () => number;
|
|
237
241
|
readonly getReturnWitness: (a: number, b: number, c: number, d: number) => void;
|
|
238
242
|
readonly getPublicParametersWitness: (a: number, b: number, c: number, d: number) => void;
|
|
239
243
|
readonly getPublicWitness: (a: number, b: number, c: number, d: number) => void;
|
|
240
|
-
readonly executeCircuit: (a: number, b: number, c: number, d: number) => number;
|
|
241
|
-
readonly executeCircuitWithReturnWitness: (a: number, b: number, c: number, d: number) => number;
|
|
242
|
-
readonly executeProgram: (a: number, b: number, c: number, d: number) => number;
|
|
243
244
|
readonly __wbindgen_malloc: (a: number) => number;
|
|
244
245
|
readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
|
|
245
246
|
readonly __wbindgen_export_2: WebAssembly.Table;
|
package/web/acvm_js.js
CHANGED
|
@@ -6,6 +6,20 @@ heap.push(undefined, null, true, false);
|
|
|
6
6
|
|
|
7
7
|
function getObject(idx) { return heap[idx]; }
|
|
8
8
|
|
|
9
|
+
let heap_next = heap.length;
|
|
10
|
+
|
|
11
|
+
function dropObject(idx) {
|
|
12
|
+
if (idx < 132) return;
|
|
13
|
+
heap[idx] = heap_next;
|
|
14
|
+
heap_next = idx;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function takeObject(idx) {
|
|
18
|
+
const ret = getObject(idx);
|
|
19
|
+
dropObject(idx);
|
|
20
|
+
return ret;
|
|
21
|
+
}
|
|
22
|
+
|
|
9
23
|
function isLikeNone(x) {
|
|
10
24
|
return x === undefined || x === null;
|
|
11
25
|
}
|
|
@@ -28,20 +42,6 @@ function getInt32Memory0() {
|
|
|
28
42
|
return cachedInt32Memory0;
|
|
29
43
|
}
|
|
30
44
|
|
|
31
|
-
let heap_next = heap.length;
|
|
32
|
-
|
|
33
|
-
function dropObject(idx) {
|
|
34
|
-
if (idx < 132) return;
|
|
35
|
-
heap[idx] = heap_next;
|
|
36
|
-
heap_next = idx;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function takeObject(idx) {
|
|
40
|
-
const ret = getObject(idx);
|
|
41
|
-
dropObject(idx);
|
|
42
|
-
return ret;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
45
|
function addHeapObject(obj) {
|
|
46
46
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
47
47
|
const idx = heap_next;
|
|
@@ -217,6 +217,79 @@ function __wbg_adapter_22(arg0, arg1, arg2) {
|
|
|
217
217
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h21c8ca3eb6ab9385(arg0, arg1, addHeapObject(arg2));
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Sets the package's logging level.
|
|
222
|
+
*
|
|
223
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
224
|
+
*/
|
|
225
|
+
export function initLogLevel(filter) {
|
|
226
|
+
try {
|
|
227
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
228
|
+
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
229
|
+
const len0 = WASM_VECTOR_LEN;
|
|
230
|
+
wasm.initLogLevel(retptr, ptr0, len0);
|
|
231
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
232
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
233
|
+
if (r1) {
|
|
234
|
+
throw takeObject(r0);
|
|
235
|
+
}
|
|
236
|
+
} finally {
|
|
237
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
242
|
+
const ptr = malloc(arg.length * 1) >>> 0;
|
|
243
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
244
|
+
WASM_VECTOR_LEN = arg.length;
|
|
245
|
+
return ptr;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
249
|
+
*
|
|
250
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
251
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
252
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
253
|
+
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
254
|
+
*/
|
|
255
|
+
export function executeCircuit(program, initial_witness, foreign_call_handler) {
|
|
256
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
257
|
+
const len0 = WASM_VECTOR_LEN;
|
|
258
|
+
const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
259
|
+
return takeObject(ret);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
264
|
+
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
265
|
+
*
|
|
266
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
267
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
268
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
269
|
+
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit.
|
|
270
|
+
*/
|
|
271
|
+
export function executeCircuitWithReturnWitness(program, initial_witness, foreign_call_handler) {
|
|
272
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
273
|
+
const len0 = WASM_VECTOR_LEN;
|
|
274
|
+
const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
275
|
+
return takeObject(ret);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
280
|
+
*
|
|
281
|
+
* @param {Uint8Array} program - A serialized representation of an ACIR program
|
|
282
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
|
|
283
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
|
|
284
|
+
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
285
|
+
*/
|
|
286
|
+
export function executeProgram(program, initial_witness, foreign_call_handler) {
|
|
287
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
288
|
+
const len0 = WASM_VECTOR_LEN;
|
|
289
|
+
const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
290
|
+
return takeObject(ret);
|
|
291
|
+
}
|
|
292
|
+
|
|
220
293
|
/**
|
|
221
294
|
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
222
295
|
* @param {string} lhs
|
|
@@ -239,38 +312,54 @@ export function xor(lhs, rhs) {
|
|
|
239
312
|
return takeObject(ret);
|
|
240
313
|
}
|
|
241
314
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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);
|
|
245
327
|
WASM_VECTOR_LEN = arg.length;
|
|
246
328
|
return ptr;
|
|
247
329
|
}
|
|
248
330
|
|
|
249
|
-
function
|
|
331
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
250
332
|
ptr = ptr >>> 0;
|
|
251
|
-
return
|
|
333
|
+
return getUint32Memory0().subarray(ptr / 4, ptr / 4 + len);
|
|
252
334
|
}
|
|
253
335
|
/**
|
|
254
|
-
*
|
|
255
|
-
* @param {
|
|
256
|
-
* @
|
|
336
|
+
* Sha256 compression function
|
|
337
|
+
* @param {Uint32Array} inputs
|
|
338
|
+
* @param {Uint32Array} state
|
|
339
|
+
* @returns {Uint32Array}
|
|
257
340
|
*/
|
|
258
|
-
export function
|
|
341
|
+
export function sha256_compression(inputs, state) {
|
|
259
342
|
try {
|
|
260
343
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
261
|
-
const ptr0 =
|
|
344
|
+
const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
262
345
|
const len0 = WASM_VECTOR_LEN;
|
|
263
|
-
|
|
346
|
+
const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
|
|
347
|
+
const len1 = WASM_VECTOR_LEN;
|
|
348
|
+
wasm.sha256_compression(retptr, ptr0, len0, ptr1, len1);
|
|
264
349
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
265
350
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
266
|
-
var
|
|
267
|
-
wasm.__wbindgen_free(r0, r1 *
|
|
268
|
-
return
|
|
351
|
+
var v3 = getArrayU32FromWasm0(r0, r1).slice();
|
|
352
|
+
wasm.__wbindgen_free(r0, r1 * 4);
|
|
353
|
+
return v3;
|
|
269
354
|
} finally {
|
|
270
355
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
271
356
|
}
|
|
272
357
|
}
|
|
273
358
|
|
|
359
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
360
|
+
ptr = ptr >>> 0;
|
|
361
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
362
|
+
}
|
|
274
363
|
/**
|
|
275
364
|
* Calculates the Blake2s256 hash of the input bytes
|
|
276
365
|
* @param {Uint8Array} inputs
|
|
@@ -454,27 +543,6 @@ export function decompressWitnessStack(compressed_witness) {
|
|
|
454
543
|
}
|
|
455
544
|
}
|
|
456
545
|
|
|
457
|
-
/**
|
|
458
|
-
* Sets the package's logging level.
|
|
459
|
-
*
|
|
460
|
-
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
461
|
-
*/
|
|
462
|
-
export function initLogLevel(filter) {
|
|
463
|
-
try {
|
|
464
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
465
|
-
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
466
|
-
const len0 = WASM_VECTOR_LEN;
|
|
467
|
-
wasm.initLogLevel(retptr, ptr0, len0);
|
|
468
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
469
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
470
|
-
if (r1) {
|
|
471
|
-
throw takeObject(r0);
|
|
472
|
-
}
|
|
473
|
-
} finally {
|
|
474
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
|
|
478
546
|
/**
|
|
479
547
|
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
480
548
|
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
@@ -568,52 +636,6 @@ export function getPublicWitness(program, solved_witness) {
|
|
|
568
636
|
}
|
|
569
637
|
}
|
|
570
638
|
|
|
571
|
-
/**
|
|
572
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
573
|
-
*
|
|
574
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
575
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
576
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
577
|
-
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
578
|
-
*/
|
|
579
|
-
export function executeCircuit(program, initial_witness, foreign_call_handler) {
|
|
580
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
581
|
-
const len0 = WASM_VECTOR_LEN;
|
|
582
|
-
const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
583
|
-
return takeObject(ret);
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
/**
|
|
587
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
588
|
-
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
589
|
-
*
|
|
590
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
591
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
592
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
593
|
-
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit.
|
|
594
|
-
*/
|
|
595
|
-
export function executeCircuitWithReturnWitness(program, initial_witness, foreign_call_handler) {
|
|
596
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
597
|
-
const len0 = WASM_VECTOR_LEN;
|
|
598
|
-
const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
599
|
-
return takeObject(ret);
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
/**
|
|
603
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
604
|
-
*
|
|
605
|
-
* @param {Uint8Array} program - A serialized representation of an ACIR program
|
|
606
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
|
|
607
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
|
|
608
|
-
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
609
|
-
*/
|
|
610
|
-
export function executeProgram(program, initial_witness, foreign_call_handler) {
|
|
611
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
612
|
-
const len0 = WASM_VECTOR_LEN;
|
|
613
|
-
const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
614
|
-
return takeObject(ret);
|
|
615
|
-
}
|
|
616
|
-
|
|
617
639
|
function __wbg_adapter_76(arg0, arg1, arg2, arg3, arg4) {
|
|
618
640
|
wasm.wasm_bindgen__convert__closures__invoke3_mut__h17fc532521b46256(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
|
|
619
641
|
}
|
|
@@ -663,15 +685,6 @@ async function __wbg_load(module, imports) {
|
|
|
663
685
|
function __wbg_get_imports() {
|
|
664
686
|
const imports = {};
|
|
665
687
|
imports.wbg = {};
|
|
666
|
-
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
|
667
|
-
const obj = getObject(arg1);
|
|
668
|
-
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
669
|
-
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
|
|
670
|
-
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
|
|
671
|
-
};
|
|
672
|
-
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
673
|
-
takeObject(arg0);
|
|
674
|
-
};
|
|
675
688
|
imports.wbg.__wbindgen_cb_drop = function(arg0) {
|
|
676
689
|
const obj = takeObject(arg0).original;
|
|
677
690
|
if (obj.cnt-- == 1) {
|
|
@@ -681,7 +694,16 @@ function __wbg_get_imports() {
|
|
|
681
694
|
const ret = false;
|
|
682
695
|
return ret;
|
|
683
696
|
};
|
|
684
|
-
imports.wbg.
|
|
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
|
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
704
|
+
takeObject(arg0);
|
|
705
|
+
};
|
|
706
|
+
imports.wbg.__wbg_new_3b3e21164d5381ca = function() {
|
|
685
707
|
const ret = new Map();
|
|
686
708
|
return addHeapObject(ret);
|
|
687
709
|
};
|
|
@@ -701,14 +723,10 @@ function __wbg_get_imports() {
|
|
|
701
723
|
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
702
724
|
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
703
725
|
};
|
|
704
|
-
imports.wbg.
|
|
726
|
+
imports.wbg.__wbg_constructor_f4bcf4c70838c703 = function(arg0) {
|
|
705
727
|
const ret = new Error(takeObject(arg0));
|
|
706
728
|
return addHeapObject(ret);
|
|
707
729
|
};
|
|
708
|
-
imports.wbg.__wbg_new_76b464e4772843b0 = function() {
|
|
709
|
-
const ret = new Array();
|
|
710
|
-
return addHeapObject(ret);
|
|
711
|
-
};
|
|
712
730
|
imports.wbg.__wbindgen_is_array = function(arg0) {
|
|
713
731
|
const ret = Array.isArray(getObject(arg0));
|
|
714
732
|
return ret;
|
|
@@ -717,6 +735,10 @@ function __wbg_get_imports() {
|
|
|
717
735
|
const ret = typeof(getObject(arg0)) === 'string';
|
|
718
736
|
return ret;
|
|
719
737
|
};
|
|
738
|
+
imports.wbg.__wbg_new_e14625531a95427d = function() {
|
|
739
|
+
const ret = new Array();
|
|
740
|
+
return addHeapObject(ret);
|
|
741
|
+
};
|
|
720
742
|
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
|
|
721
743
|
const ret = new Error();
|
|
722
744
|
return addHeapObject(ret);
|
|
@@ -901,7 +923,7 @@ function __wbg_get_imports() {
|
|
|
901
923
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
902
924
|
};
|
|
903
925
|
imports.wbg.__wbindgen_closure_wrapper747 = function(arg0, arg1, arg2) {
|
|
904
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
926
|
+
const ret = makeMutClosure(arg0, arg1, 266, __wbg_adapter_22);
|
|
905
927
|
return addHeapObject(ret);
|
|
906
928
|
};
|
|
907
929
|
|
|
@@ -917,6 +939,7 @@ function __wbg_finalize_init(instance, module) {
|
|
|
917
939
|
__wbg_init.__wbindgen_wasm_module = module;
|
|
918
940
|
cachedFloat64Memory0 = null;
|
|
919
941
|
cachedInt32Memory0 = null;
|
|
942
|
+
cachedUint32Memory0 = null;
|
|
920
943
|
cachedUint8Memory0 = null;
|
|
921
944
|
|
|
922
945
|
|
package/web/acvm_js_bg.wasm
CHANGED
|
Binary file
|
package/web/acvm_js_bg.wasm.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export function initLogLevel(a: number, b: number, c: number): void;
|
|
5
|
+
export function executeCircuit(a: number, b: number, c: number, d: number): number;
|
|
6
|
+
export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number;
|
|
7
|
+
export function executeProgram(a: number, b: number, c: number, d: number): number;
|
|
4
8
|
export function and(a: number, b: number): number;
|
|
5
9
|
export function xor(a: number, b: number): number;
|
|
6
|
-
export function
|
|
10
|
+
export function sha256_compression(a: number, b: number, c: number, d: number, e: number): void;
|
|
7
11
|
export function blake2s256(a: number, b: number, c: number): void;
|
|
8
12
|
export function keccak256(a: number, b: number, c: number): void;
|
|
9
13
|
export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
|
|
@@ -12,14 +16,10 @@ export function compressWitness(a: number, b: number): void;
|
|
|
12
16
|
export function decompressWitness(a: number, b: number, c: number): void;
|
|
13
17
|
export function compressWitnessStack(a: number, b: number): void;
|
|
14
18
|
export function decompressWitnessStack(a: number, b: number, c: number): void;
|
|
15
|
-
export function initLogLevel(a: number, b: number, c: number): void;
|
|
16
19
|
export function buildInfo(): number;
|
|
17
20
|
export function getReturnWitness(a: number, b: number, c: number, d: number): void;
|
|
18
21
|
export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
|
|
19
22
|
export function getPublicWitness(a: number, b: number, c: number, d: number): void;
|
|
20
|
-
export function executeCircuit(a: number, b: number, c: number, d: number): number;
|
|
21
|
-
export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number;
|
|
22
|
-
export function executeProgram(a: number, b: number, c: number, d: number): number;
|
|
23
23
|
export function __wbindgen_malloc(a: number): number;
|
|
24
24
|
export function __wbindgen_realloc(a: number, b: number, c: number): number;
|
|
25
25
|
export const __wbindgen_export_2: WebAssembly.Table;
|