@aztec/noir-acvm_js 0.84.0-nightly.20250409 → 0.84.0-nightly.20250412
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 +62 -62
- package/nodejs/acvm_js.js +194 -194
- package/nodejs/acvm_js_bg.wasm +0 -0
- package/nodejs/acvm_js_bg.wasm.d.ts +9 -9
- package/package.json +5 -5
- package/web/acvm_js.d.ts +71 -71
- package/web/acvm_js.js +192 -192
- package/web/acvm_js_bg.wasm +0 -0
- package/web/acvm_js_bg.wasm.d.ts +9 -9
package/nodejs/acvm_js.d.ts
CHANGED
|
@@ -5,54 +5,6 @@
|
|
|
5
5
|
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
6
6
|
*/
|
|
7
7
|
export function buildInfo(): BuildInfo;
|
|
8
|
-
/**
|
|
9
|
-
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
10
|
-
*/
|
|
11
|
-
export function and(lhs: string, rhs: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
14
|
-
*/
|
|
15
|
-
export function xor(lhs: string, rhs: string): string;
|
|
16
|
-
/**
|
|
17
|
-
* Sha256 compression function
|
|
18
|
-
*/
|
|
19
|
-
export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
|
|
20
|
-
/**
|
|
21
|
-
* Calculates the Blake2s256 hash of the input bytes
|
|
22
|
-
*/
|
|
23
|
-
export function blake2s256(inputs: Uint8Array): Uint8Array;
|
|
24
|
-
/**
|
|
25
|
-
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
26
|
-
*/
|
|
27
|
-
export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
30
|
-
*/
|
|
31
|
-
export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
34
|
-
*
|
|
35
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
36
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
37
|
-
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
38
|
-
*/
|
|
39
|
-
export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
|
|
40
|
-
/**
|
|
41
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
42
|
-
*
|
|
43
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
44
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
45
|
-
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
46
|
-
*/
|
|
47
|
-
export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
48
|
-
/**
|
|
49
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
|
|
50
|
-
*
|
|
51
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
52
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
53
|
-
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
54
|
-
*/
|
|
55
|
-
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
56
8
|
/**
|
|
57
9
|
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
58
10
|
*
|
|
@@ -116,6 +68,54 @@ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_wit
|
|
|
116
68
|
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
117
69
|
*/
|
|
118
70
|
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
|
|
71
|
+
/**
|
|
72
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
73
|
+
*
|
|
74
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
75
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
76
|
+
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
77
|
+
*/
|
|
78
|
+
export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
|
|
79
|
+
/**
|
|
80
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
81
|
+
*
|
|
82
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
83
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
84
|
+
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
85
|
+
*/
|
|
86
|
+
export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
87
|
+
/**
|
|
88
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
|
|
89
|
+
*
|
|
90
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
91
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
92
|
+
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
93
|
+
*/
|
|
94
|
+
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
95
|
+
/**
|
|
96
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
97
|
+
*/
|
|
98
|
+
export function and(lhs: string, rhs: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
101
|
+
*/
|
|
102
|
+
export function xor(lhs: string, rhs: string): string;
|
|
103
|
+
/**
|
|
104
|
+
* Sha256 compression function
|
|
105
|
+
*/
|
|
106
|
+
export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
|
|
107
|
+
/**
|
|
108
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
109
|
+
*/
|
|
110
|
+
export function blake2s256(inputs: Uint8Array): Uint8Array;
|
|
111
|
+
/**
|
|
112
|
+
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
113
|
+
*/
|
|
114
|
+
export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
117
|
+
*/
|
|
118
|
+
export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
121
|
* @typedef {Object} BuildInfo - Information about how the installed package was built
|
|
@@ -131,20 +131,6 @@ export type BuildInfo = {
|
|
|
131
131
|
|
|
132
132
|
|
|
133
133
|
|
|
134
|
-
export type ForeignCallInput = string[]
|
|
135
|
-
export type ForeignCallOutput = string | string[]
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* A callback which performs an foreign call and returns the response.
|
|
139
|
-
* @callback ForeignCallHandler
|
|
140
|
-
* @param {string} name - The identifier for the type of foreign call being performed.
|
|
141
|
-
* @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
|
|
142
|
-
* @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
|
|
143
|
-
*/
|
|
144
|
-
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
134
|
// Map from witness index to hex string value of witness.
|
|
149
135
|
export type WitnessMap = Map<number, string>;
|
|
150
136
|
|
|
@@ -173,6 +159,20 @@ export type ExecutionError = Error & {
|
|
|
173
159
|
|
|
174
160
|
|
|
175
161
|
|
|
162
|
+
export type ForeignCallInput = string[]
|
|
163
|
+
export type ForeignCallOutput = string | string[]
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* A callback which performs an foreign call and returns the response.
|
|
167
|
+
* @callback ForeignCallHandler
|
|
168
|
+
* @param {string} name - The identifier for the type of foreign call being performed.
|
|
169
|
+
* @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
|
|
170
|
+
* @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
|
|
171
|
+
*/
|
|
172
|
+
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
176
|
export type StackItem = {
|
|
177
177
|
index: number;
|
|
178
178
|
witness: WitnessMap;
|
package/nodejs/acvm_js.js
CHANGED
|
@@ -210,197 +210,16 @@ module.exports.buildInfo = function() {
|
|
|
210
210
|
return ret;
|
|
211
211
|
};
|
|
212
212
|
|
|
213
|
-
/**
|
|
214
|
-
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
215
|
-
* @param {string} lhs
|
|
216
|
-
* @param {string} rhs
|
|
217
|
-
* @returns {string}
|
|
218
|
-
*/
|
|
219
|
-
module.exports.and = function(lhs, rhs) {
|
|
220
|
-
const ret = wasm.and(lhs, rhs);
|
|
221
|
-
return ret;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
226
|
-
* @param {string} lhs
|
|
227
|
-
* @param {string} rhs
|
|
228
|
-
* @returns {string}
|
|
229
|
-
*/
|
|
230
|
-
module.exports.xor = function(lhs, rhs) {
|
|
231
|
-
const ret = wasm.xor(lhs, rhs);
|
|
232
|
-
return ret;
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
let cachedUint32ArrayMemory0 = null;
|
|
236
|
-
|
|
237
|
-
function getUint32ArrayMemory0() {
|
|
238
|
-
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
239
|
-
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
240
|
-
}
|
|
241
|
-
return cachedUint32ArrayMemory0;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function passArray32ToWasm0(arg, malloc) {
|
|
245
|
-
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
246
|
-
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
247
|
-
WASM_VECTOR_LEN = arg.length;
|
|
248
|
-
return ptr;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function getArrayU32FromWasm0(ptr, len) {
|
|
252
|
-
ptr = ptr >>> 0;
|
|
253
|
-
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Sha256 compression function
|
|
257
|
-
* @param {Uint32Array} inputs
|
|
258
|
-
* @param {Uint32Array} state
|
|
259
|
-
* @returns {Uint32Array}
|
|
260
|
-
*/
|
|
261
|
-
module.exports.sha256_compression = function(inputs, state) {
|
|
262
|
-
const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
263
|
-
const len0 = WASM_VECTOR_LEN;
|
|
264
|
-
const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
|
|
265
|
-
const len1 = WASM_VECTOR_LEN;
|
|
266
|
-
const ret = wasm.sha256_compression(ptr0, len0, ptr1, len1);
|
|
267
|
-
var v3 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
268
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
269
|
-
return v3;
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
273
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
274
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
275
|
-
WASM_VECTOR_LEN = arg.length;
|
|
276
|
-
return ptr;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
280
|
-
ptr = ptr >>> 0;
|
|
281
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Calculates the Blake2s256 hash of the input bytes
|
|
285
|
-
* @param {Uint8Array} inputs
|
|
286
|
-
* @returns {Uint8Array}
|
|
287
|
-
*/
|
|
288
|
-
module.exports.blake2s256 = function(inputs) {
|
|
289
|
-
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
290
|
-
const len0 = WASM_VECTOR_LEN;
|
|
291
|
-
const ret = wasm.blake2s256(ptr0, len0);
|
|
292
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
293
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
294
|
-
return v2;
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
299
|
-
* @param {Uint8Array} hashed_msg
|
|
300
|
-
* @param {Uint8Array} public_key_x_bytes
|
|
301
|
-
* @param {Uint8Array} public_key_y_bytes
|
|
302
|
-
* @param {Uint8Array} signature
|
|
303
|
-
* @returns {boolean}
|
|
304
|
-
*/
|
|
305
|
-
module.exports.ecdsa_secp256k1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
306
|
-
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
307
|
-
const len0 = WASM_VECTOR_LEN;
|
|
308
|
-
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
309
|
-
const len1 = WASM_VECTOR_LEN;
|
|
310
|
-
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
311
|
-
const len2 = WASM_VECTOR_LEN;
|
|
312
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
313
|
-
const len3 = WASM_VECTOR_LEN;
|
|
314
|
-
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
315
|
-
return ret !== 0;
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
320
|
-
* @param {Uint8Array} hashed_msg
|
|
321
|
-
* @param {Uint8Array} public_key_x_bytes
|
|
322
|
-
* @param {Uint8Array} public_key_y_bytes
|
|
323
|
-
* @param {Uint8Array} signature
|
|
324
|
-
* @returns {boolean}
|
|
325
|
-
*/
|
|
326
|
-
module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
327
|
-
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
328
|
-
const len0 = WASM_VECTOR_LEN;
|
|
329
|
-
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
330
|
-
const len1 = WASM_VECTOR_LEN;
|
|
331
|
-
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
332
|
-
const len2 = WASM_VECTOR_LEN;
|
|
333
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
334
|
-
const len3 = WASM_VECTOR_LEN;
|
|
335
|
-
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
336
|
-
return ret !== 0;
|
|
337
|
-
};
|
|
338
|
-
|
|
339
213
|
function takeFromExternrefTable0(idx) {
|
|
340
214
|
const value = wasm.__wbindgen_export_2.get(idx);
|
|
341
215
|
wasm.__externref_table_dealloc(idx);
|
|
342
216
|
return value;
|
|
343
217
|
}
|
|
344
|
-
/**
|
|
345
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
346
|
-
*
|
|
347
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
348
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
349
|
-
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
350
|
-
* @param {Uint8Array} program
|
|
351
|
-
* @param {WitnessMap} witness_map
|
|
352
|
-
* @returns {WitnessMap}
|
|
353
|
-
*/
|
|
354
|
-
module.exports.getReturnWitness = function(program, witness_map) {
|
|
355
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
356
|
-
const len0 = WASM_VECTOR_LEN;
|
|
357
|
-
const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
|
|
358
|
-
if (ret[2]) {
|
|
359
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
360
|
-
}
|
|
361
|
-
return takeFromExternrefTable0(ret[0]);
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
366
|
-
*
|
|
367
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
368
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
369
|
-
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
370
|
-
* @param {Uint8Array} program
|
|
371
|
-
* @param {WitnessMap} solved_witness
|
|
372
|
-
* @returns {WitnessMap}
|
|
373
|
-
*/
|
|
374
|
-
module.exports.getPublicParametersWitness = function(program, solved_witness) {
|
|
375
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
376
|
-
const len0 = WASM_VECTOR_LEN;
|
|
377
|
-
const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
|
|
378
|
-
if (ret[2]) {
|
|
379
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
380
|
-
}
|
|
381
|
-
return takeFromExternrefTable0(ret[0]);
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
|
|
386
|
-
*
|
|
387
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
388
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
389
|
-
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
390
|
-
* @param {Uint8Array} program
|
|
391
|
-
* @param {WitnessMap} solved_witness
|
|
392
|
-
* @returns {WitnessMap}
|
|
393
|
-
*/
|
|
394
|
-
module.exports.getPublicWitness = function(program, solved_witness) {
|
|
395
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
396
|
-
const len0 = WASM_VECTOR_LEN;
|
|
397
|
-
const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
|
|
398
|
-
if (ret[2]) {
|
|
399
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
400
|
-
}
|
|
401
|
-
return takeFromExternrefTable0(ret[0]);
|
|
402
|
-
};
|
|
403
218
|
|
|
219
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
220
|
+
ptr = ptr >>> 0;
|
|
221
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
222
|
+
}
|
|
404
223
|
/**
|
|
405
224
|
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
406
225
|
*
|
|
@@ -417,6 +236,12 @@ module.exports.compressWitness = function(witness_map) {
|
|
|
417
236
|
return v1;
|
|
418
237
|
};
|
|
419
238
|
|
|
239
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
240
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
241
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
242
|
+
WASM_VECTOR_LEN = arg.length;
|
|
243
|
+
return ptr;
|
|
244
|
+
}
|
|
420
245
|
/**
|
|
421
246
|
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
|
|
422
247
|
* This should be used to only fetch the witness map for the main function.
|
|
@@ -526,6 +351,181 @@ module.exports.executeProgram = function(program, initial_witness, foreign_call_
|
|
|
526
351
|
return ret;
|
|
527
352
|
};
|
|
528
353
|
|
|
354
|
+
/**
|
|
355
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
356
|
+
*
|
|
357
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
358
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
359
|
+
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
360
|
+
* @param {Uint8Array} program
|
|
361
|
+
* @param {WitnessMap} witness_map
|
|
362
|
+
* @returns {WitnessMap}
|
|
363
|
+
*/
|
|
364
|
+
module.exports.getReturnWitness = function(program, witness_map) {
|
|
365
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
366
|
+
const len0 = WASM_VECTOR_LEN;
|
|
367
|
+
const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
|
|
368
|
+
if (ret[2]) {
|
|
369
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
370
|
+
}
|
|
371
|
+
return takeFromExternrefTable0(ret[0]);
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
376
|
+
*
|
|
377
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
378
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
379
|
+
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
380
|
+
* @param {Uint8Array} program
|
|
381
|
+
* @param {WitnessMap} solved_witness
|
|
382
|
+
* @returns {WitnessMap}
|
|
383
|
+
*/
|
|
384
|
+
module.exports.getPublicParametersWitness = function(program, solved_witness) {
|
|
385
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
386
|
+
const len0 = WASM_VECTOR_LEN;
|
|
387
|
+
const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
|
|
388
|
+
if (ret[2]) {
|
|
389
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
390
|
+
}
|
|
391
|
+
return takeFromExternrefTable0(ret[0]);
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
|
|
396
|
+
*
|
|
397
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
398
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
399
|
+
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
400
|
+
* @param {Uint8Array} program
|
|
401
|
+
* @param {WitnessMap} solved_witness
|
|
402
|
+
* @returns {WitnessMap}
|
|
403
|
+
*/
|
|
404
|
+
module.exports.getPublicWitness = function(program, solved_witness) {
|
|
405
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
406
|
+
const len0 = WASM_VECTOR_LEN;
|
|
407
|
+
const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
|
|
408
|
+
if (ret[2]) {
|
|
409
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
410
|
+
}
|
|
411
|
+
return takeFromExternrefTable0(ret[0]);
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
416
|
+
* @param {string} lhs
|
|
417
|
+
* @param {string} rhs
|
|
418
|
+
* @returns {string}
|
|
419
|
+
*/
|
|
420
|
+
module.exports.and = function(lhs, rhs) {
|
|
421
|
+
const ret = wasm.and(lhs, rhs);
|
|
422
|
+
return ret;
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
427
|
+
* @param {string} lhs
|
|
428
|
+
* @param {string} rhs
|
|
429
|
+
* @returns {string}
|
|
430
|
+
*/
|
|
431
|
+
module.exports.xor = function(lhs, rhs) {
|
|
432
|
+
const ret = wasm.xor(lhs, rhs);
|
|
433
|
+
return ret;
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
let cachedUint32ArrayMemory0 = null;
|
|
437
|
+
|
|
438
|
+
function getUint32ArrayMemory0() {
|
|
439
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
440
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
441
|
+
}
|
|
442
|
+
return cachedUint32ArrayMemory0;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
446
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
447
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
448
|
+
WASM_VECTOR_LEN = arg.length;
|
|
449
|
+
return ptr;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
453
|
+
ptr = ptr >>> 0;
|
|
454
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Sha256 compression function
|
|
458
|
+
* @param {Uint32Array} inputs
|
|
459
|
+
* @param {Uint32Array} state
|
|
460
|
+
* @returns {Uint32Array}
|
|
461
|
+
*/
|
|
462
|
+
module.exports.sha256_compression = function(inputs, state) {
|
|
463
|
+
const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
464
|
+
const len0 = WASM_VECTOR_LEN;
|
|
465
|
+
const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
|
|
466
|
+
const len1 = WASM_VECTOR_LEN;
|
|
467
|
+
const ret = wasm.sha256_compression(ptr0, len0, ptr1, len1);
|
|
468
|
+
var v3 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
469
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
470
|
+
return v3;
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
475
|
+
* @param {Uint8Array} inputs
|
|
476
|
+
* @returns {Uint8Array}
|
|
477
|
+
*/
|
|
478
|
+
module.exports.blake2s256 = function(inputs) {
|
|
479
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
480
|
+
const len0 = WASM_VECTOR_LEN;
|
|
481
|
+
const ret = wasm.blake2s256(ptr0, len0);
|
|
482
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
483
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
484
|
+
return v2;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
489
|
+
* @param {Uint8Array} hashed_msg
|
|
490
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
491
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
492
|
+
* @param {Uint8Array} signature
|
|
493
|
+
* @returns {boolean}
|
|
494
|
+
*/
|
|
495
|
+
module.exports.ecdsa_secp256k1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
496
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
497
|
+
const len0 = WASM_VECTOR_LEN;
|
|
498
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
499
|
+
const len1 = WASM_VECTOR_LEN;
|
|
500
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
501
|
+
const len2 = WASM_VECTOR_LEN;
|
|
502
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
503
|
+
const len3 = WASM_VECTOR_LEN;
|
|
504
|
+
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
505
|
+
return ret !== 0;
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
510
|
+
* @param {Uint8Array} hashed_msg
|
|
511
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
512
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
513
|
+
* @param {Uint8Array} signature
|
|
514
|
+
* @returns {boolean}
|
|
515
|
+
*/
|
|
516
|
+
module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
517
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
518
|
+
const len0 = WASM_VECTOR_LEN;
|
|
519
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
520
|
+
const len1 = WASM_VECTOR_LEN;
|
|
521
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
522
|
+
const len2 = WASM_VECTOR_LEN;
|
|
523
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
524
|
+
const len3 = WASM_VECTOR_LEN;
|
|
525
|
+
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
526
|
+
return ret !== 0;
|
|
527
|
+
};
|
|
528
|
+
|
|
529
529
|
function __wbg_adapter_30(arg0, arg1, arg2) {
|
|
530
530
|
wasm.closure255_externref_shim(arg0, arg1, arg2);
|
|
531
531
|
}
|
|
@@ -553,12 +553,12 @@ module.exports.__wbg_call_833bed5770ea2041 = function() { return handleError(fun
|
|
|
553
553
|
return ret;
|
|
554
554
|
}, arguments) };
|
|
555
555
|
|
|
556
|
-
module.exports.
|
|
556
|
+
module.exports.__wbg_constructor_6f67fe370a1d12e4 = function(arg0) {
|
|
557
557
|
const ret = new Error(arg0);
|
|
558
558
|
return ret;
|
|
559
559
|
};
|
|
560
560
|
|
|
561
|
-
module.exports.
|
|
561
|
+
module.exports.__wbg_constructor_e1ce7ec5d0c26936 = function(arg0) {
|
|
562
562
|
const ret = new Error(arg0);
|
|
563
563
|
return ret;
|
|
564
564
|
};
|
|
@@ -674,11 +674,6 @@ module.exports.__wbg_new_23a2665fac83c611 = function(arg0, arg1) {
|
|
|
674
674
|
}
|
|
675
675
|
};
|
|
676
676
|
|
|
677
|
-
module.exports.__wbg_new_3f4c5c451d69e970 = function() {
|
|
678
|
-
const ret = new Map();
|
|
679
|
-
return ret;
|
|
680
|
-
};
|
|
681
|
-
|
|
682
677
|
module.exports.__wbg_new_5e0be73521bc8c17 = function() {
|
|
683
678
|
const ret = new Map();
|
|
684
679
|
return ret;
|
|
@@ -694,11 +689,16 @@ module.exports.__wbg_new_8a6f238a6ece86ea = function() {
|
|
|
694
689
|
return ret;
|
|
695
690
|
};
|
|
696
691
|
|
|
697
|
-
module.exports.
|
|
692
|
+
module.exports.__wbg_new_afcb88b732711926 = function() {
|
|
698
693
|
const ret = new Array();
|
|
699
694
|
return ret;
|
|
700
695
|
};
|
|
701
696
|
|
|
697
|
+
module.exports.__wbg_new_c4d92c865672cdba = function() {
|
|
698
|
+
const ret = new Map();
|
|
699
|
+
return ret;
|
|
700
|
+
};
|
|
701
|
+
|
|
702
702
|
module.exports.__wbg_new_c68d7209be747379 = function(arg0, arg1) {
|
|
703
703
|
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
704
704
|
return ret;
|
|
@@ -813,7 +813,7 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
|
813
813
|
return ret;
|
|
814
814
|
};
|
|
815
815
|
|
|
816
|
-
module.exports.
|
|
816
|
+
module.exports.__wbindgen_closure_wrapper736 = function(arg0, arg1, arg2) {
|
|
817
817
|
const ret = makeMutClosure(arg0, arg1, 256, __wbg_adapter_30);
|
|
818
818
|
return ret;
|
|
819
819
|
};
|
package/nodejs/acvm_js_bg.wasm
CHANGED
|
Binary file
|
|
@@ -2,15 +2,6 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const buildInfo: () => any;
|
|
5
|
-
export const and: (a: any, b: any) => any;
|
|
6
|
-
export const xor: (a: any, b: any) => any;
|
|
7
|
-
export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
|
|
8
|
-
export const blake2s256: (a: number, b: number) => [number, number];
|
|
9
|
-
export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
10
|
-
export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
11
|
-
export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
12
|
-
export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
13
|
-
export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
14
5
|
export const compressWitness: (a: any) => [number, number, number, number];
|
|
15
6
|
export const decompressWitness: (a: number, b: number) => [number, number, number];
|
|
16
7
|
export const compressWitnessStack: (a: any) => [number, number, number, number];
|
|
@@ -19,6 +10,15 @@ export const initLogLevel: (a: number, b: number) => [number, number];
|
|
|
19
10
|
export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
|
|
20
11
|
export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
|
|
21
12
|
export const executeProgram: (a: number, b: number, c: any, d: any) => any;
|
|
13
|
+
export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
14
|
+
export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
15
|
+
export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
16
|
+
export const and: (a: any, b: any) => any;
|
|
17
|
+
export const xor: (a: any, b: any) => any;
|
|
18
|
+
export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
|
|
19
|
+
export const blake2s256: (a: number, b: number) => [number, number];
|
|
20
|
+
export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
21
|
+
export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
22
22
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
23
23
|
export const __externref_table_alloc: () => number;
|
|
24
24
|
export const __wbindgen_export_2: WebAssembly.Table;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/noir-acvm_js",
|
|
3
|
-
"version": "0.84.0-nightly.
|
|
3
|
+
"version": "0.84.0-nightly.20250412",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"@web/test-runner": "^0.18.1",
|
|
43
43
|
"@web/test-runner-playwright": "^0.11.0",
|
|
44
44
|
"chai": "^4.4.1",
|
|
45
|
-
"eslint": "^9.
|
|
46
|
-
"eslint-plugin-prettier": "^5.2.
|
|
45
|
+
"eslint": "^9.24.0",
|
|
46
|
+
"eslint-plugin-prettier": "^5.2.6",
|
|
47
47
|
"mocha": "^11.1.0",
|
|
48
48
|
"prettier": "3.5.3",
|
|
49
|
-
"ts-node": "^10.9.
|
|
50
|
-
"typescript": "^5.8.
|
|
49
|
+
"ts-node": "^10.9.2",
|
|
50
|
+
"typescript": "^5.8.3"
|
|
51
51
|
}
|
|
52
52
|
}
|
package/web/acvm_js.d.ts
CHANGED
|
@@ -5,54 +5,6 @@
|
|
|
5
5
|
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
6
6
|
*/
|
|
7
7
|
export function buildInfo(): BuildInfo;
|
|
8
|
-
/**
|
|
9
|
-
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
10
|
-
*/
|
|
11
|
-
export function and(lhs: string, rhs: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
14
|
-
*/
|
|
15
|
-
export function xor(lhs: string, rhs: string): string;
|
|
16
|
-
/**
|
|
17
|
-
* Sha256 compression function
|
|
18
|
-
*/
|
|
19
|
-
export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
|
|
20
|
-
/**
|
|
21
|
-
* Calculates the Blake2s256 hash of the input bytes
|
|
22
|
-
*/
|
|
23
|
-
export function blake2s256(inputs: Uint8Array): Uint8Array;
|
|
24
|
-
/**
|
|
25
|
-
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
26
|
-
*/
|
|
27
|
-
export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
30
|
-
*/
|
|
31
|
-
export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
34
|
-
*
|
|
35
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
36
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
37
|
-
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
38
|
-
*/
|
|
39
|
-
export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
|
|
40
|
-
/**
|
|
41
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
42
|
-
*
|
|
43
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
44
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
45
|
-
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
46
|
-
*/
|
|
47
|
-
export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
48
|
-
/**
|
|
49
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
|
|
50
|
-
*
|
|
51
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
52
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
53
|
-
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
54
|
-
*/
|
|
55
|
-
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
56
8
|
/**
|
|
57
9
|
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
58
10
|
*
|
|
@@ -116,6 +68,54 @@ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_wit
|
|
|
116
68
|
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
117
69
|
*/
|
|
118
70
|
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
|
|
71
|
+
/**
|
|
72
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
73
|
+
*
|
|
74
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
75
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
76
|
+
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
77
|
+
*/
|
|
78
|
+
export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
|
|
79
|
+
/**
|
|
80
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
81
|
+
*
|
|
82
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
83
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
84
|
+
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
85
|
+
*/
|
|
86
|
+
export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
87
|
+
/**
|
|
88
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
|
|
89
|
+
*
|
|
90
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
91
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
92
|
+
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
93
|
+
*/
|
|
94
|
+
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
95
|
+
/**
|
|
96
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
97
|
+
*/
|
|
98
|
+
export function and(lhs: string, rhs: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
101
|
+
*/
|
|
102
|
+
export function xor(lhs: string, rhs: string): string;
|
|
103
|
+
/**
|
|
104
|
+
* Sha256 compression function
|
|
105
|
+
*/
|
|
106
|
+
export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
|
|
107
|
+
/**
|
|
108
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
109
|
+
*/
|
|
110
|
+
export function blake2s256(inputs: Uint8Array): Uint8Array;
|
|
111
|
+
/**
|
|
112
|
+
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
113
|
+
*/
|
|
114
|
+
export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
117
|
+
*/
|
|
118
|
+
export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
121
|
* @typedef {Object} BuildInfo - Information about how the installed package was built
|
|
@@ -131,20 +131,6 @@ export type BuildInfo = {
|
|
|
131
131
|
|
|
132
132
|
|
|
133
133
|
|
|
134
|
-
export type ForeignCallInput = string[]
|
|
135
|
-
export type ForeignCallOutput = string | string[]
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* A callback which performs an foreign call and returns the response.
|
|
139
|
-
* @callback ForeignCallHandler
|
|
140
|
-
* @param {string} name - The identifier for the type of foreign call being performed.
|
|
141
|
-
* @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
|
|
142
|
-
* @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
|
|
143
|
-
*/
|
|
144
|
-
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
134
|
// Map from witness index to hex string value of witness.
|
|
149
135
|
export type WitnessMap = Map<number, string>;
|
|
150
136
|
|
|
@@ -173,6 +159,20 @@ export type ExecutionError = Error & {
|
|
|
173
159
|
|
|
174
160
|
|
|
175
161
|
|
|
162
|
+
export type ForeignCallInput = string[]
|
|
163
|
+
export type ForeignCallOutput = string | string[]
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* A callback which performs an foreign call and returns the response.
|
|
167
|
+
* @callback ForeignCallHandler
|
|
168
|
+
* @param {string} name - The identifier for the type of foreign call being performed.
|
|
169
|
+
* @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
|
|
170
|
+
* @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
|
|
171
|
+
*/
|
|
172
|
+
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
176
|
export type StackItem = {
|
|
177
177
|
index: number;
|
|
178
178
|
witness: WitnessMap;
|
|
@@ -187,15 +187,6 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
187
187
|
export interface InitOutput {
|
|
188
188
|
readonly memory: WebAssembly.Memory;
|
|
189
189
|
readonly buildInfo: () => any;
|
|
190
|
-
readonly and: (a: any, b: any) => any;
|
|
191
|
-
readonly xor: (a: any, b: any) => any;
|
|
192
|
-
readonly sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
|
|
193
|
-
readonly blake2s256: (a: number, b: number) => [number, number];
|
|
194
|
-
readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
195
|
-
readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
196
|
-
readonly getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
197
|
-
readonly getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
198
|
-
readonly getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
199
190
|
readonly compressWitness: (a: any) => [number, number, number, number];
|
|
200
191
|
readonly decompressWitness: (a: number, b: number) => [number, number, number];
|
|
201
192
|
readonly compressWitnessStack: (a: any) => [number, number, number, number];
|
|
@@ -204,6 +195,15 @@ export interface InitOutput {
|
|
|
204
195
|
readonly executeCircuit: (a: number, b: number, c: any, d: any) => any;
|
|
205
196
|
readonly executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
|
|
206
197
|
readonly executeProgram: (a: number, b: number, c: any, d: any) => any;
|
|
198
|
+
readonly getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
199
|
+
readonly getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
200
|
+
readonly getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
201
|
+
readonly and: (a: any, b: any) => any;
|
|
202
|
+
readonly xor: (a: any, b: any) => any;
|
|
203
|
+
readonly sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
|
|
204
|
+
readonly blake2s256: (a: number, b: number) => [number, number];
|
|
205
|
+
readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
206
|
+
readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
207
207
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
208
208
|
readonly __externref_table_alloc: () => number;
|
|
209
209
|
readonly __wbindgen_export_2: WebAssembly.Table;
|
package/web/acvm_js.js
CHANGED
|
@@ -206,197 +206,16 @@ export function buildInfo() {
|
|
|
206
206
|
return ret;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
/**
|
|
210
|
-
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
211
|
-
* @param {string} lhs
|
|
212
|
-
* @param {string} rhs
|
|
213
|
-
* @returns {string}
|
|
214
|
-
*/
|
|
215
|
-
export function and(lhs, rhs) {
|
|
216
|
-
const ret = wasm.and(lhs, rhs);
|
|
217
|
-
return ret;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
222
|
-
* @param {string} lhs
|
|
223
|
-
* @param {string} rhs
|
|
224
|
-
* @returns {string}
|
|
225
|
-
*/
|
|
226
|
-
export function xor(lhs, rhs) {
|
|
227
|
-
const ret = wasm.xor(lhs, rhs);
|
|
228
|
-
return ret;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
let cachedUint32ArrayMemory0 = null;
|
|
232
|
-
|
|
233
|
-
function getUint32ArrayMemory0() {
|
|
234
|
-
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
235
|
-
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
236
|
-
}
|
|
237
|
-
return cachedUint32ArrayMemory0;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function passArray32ToWasm0(arg, malloc) {
|
|
241
|
-
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
242
|
-
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
243
|
-
WASM_VECTOR_LEN = arg.length;
|
|
244
|
-
return ptr;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
function getArrayU32FromWasm0(ptr, len) {
|
|
248
|
-
ptr = ptr >>> 0;
|
|
249
|
-
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Sha256 compression function
|
|
253
|
-
* @param {Uint32Array} inputs
|
|
254
|
-
* @param {Uint32Array} state
|
|
255
|
-
* @returns {Uint32Array}
|
|
256
|
-
*/
|
|
257
|
-
export function sha256_compression(inputs, state) {
|
|
258
|
-
const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
259
|
-
const len0 = WASM_VECTOR_LEN;
|
|
260
|
-
const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
|
|
261
|
-
const len1 = WASM_VECTOR_LEN;
|
|
262
|
-
const ret = wasm.sha256_compression(ptr0, len0, ptr1, len1);
|
|
263
|
-
var v3 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
264
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
265
|
-
return v3;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
269
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
270
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
271
|
-
WASM_VECTOR_LEN = arg.length;
|
|
272
|
-
return ptr;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
276
|
-
ptr = ptr >>> 0;
|
|
277
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Calculates the Blake2s256 hash of the input bytes
|
|
281
|
-
* @param {Uint8Array} inputs
|
|
282
|
-
* @returns {Uint8Array}
|
|
283
|
-
*/
|
|
284
|
-
export function blake2s256(inputs) {
|
|
285
|
-
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
286
|
-
const len0 = WASM_VECTOR_LEN;
|
|
287
|
-
const ret = wasm.blake2s256(ptr0, len0);
|
|
288
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
289
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
290
|
-
return v2;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
295
|
-
* @param {Uint8Array} hashed_msg
|
|
296
|
-
* @param {Uint8Array} public_key_x_bytes
|
|
297
|
-
* @param {Uint8Array} public_key_y_bytes
|
|
298
|
-
* @param {Uint8Array} signature
|
|
299
|
-
* @returns {boolean}
|
|
300
|
-
*/
|
|
301
|
-
export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
302
|
-
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
303
|
-
const len0 = WASM_VECTOR_LEN;
|
|
304
|
-
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
305
|
-
const len1 = WASM_VECTOR_LEN;
|
|
306
|
-
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
307
|
-
const len2 = WASM_VECTOR_LEN;
|
|
308
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
309
|
-
const len3 = WASM_VECTOR_LEN;
|
|
310
|
-
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
311
|
-
return ret !== 0;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
316
|
-
* @param {Uint8Array} hashed_msg
|
|
317
|
-
* @param {Uint8Array} public_key_x_bytes
|
|
318
|
-
* @param {Uint8Array} public_key_y_bytes
|
|
319
|
-
* @param {Uint8Array} signature
|
|
320
|
-
* @returns {boolean}
|
|
321
|
-
*/
|
|
322
|
-
export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
323
|
-
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
324
|
-
const len0 = WASM_VECTOR_LEN;
|
|
325
|
-
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
326
|
-
const len1 = WASM_VECTOR_LEN;
|
|
327
|
-
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
328
|
-
const len2 = WASM_VECTOR_LEN;
|
|
329
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
330
|
-
const len3 = WASM_VECTOR_LEN;
|
|
331
|
-
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
332
|
-
return ret !== 0;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
209
|
function takeFromExternrefTable0(idx) {
|
|
336
210
|
const value = wasm.__wbindgen_export_2.get(idx);
|
|
337
211
|
wasm.__externref_table_dealloc(idx);
|
|
338
212
|
return value;
|
|
339
213
|
}
|
|
340
|
-
/**
|
|
341
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
342
|
-
*
|
|
343
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
344
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
345
|
-
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
346
|
-
* @param {Uint8Array} program
|
|
347
|
-
* @param {WitnessMap} witness_map
|
|
348
|
-
* @returns {WitnessMap}
|
|
349
|
-
*/
|
|
350
|
-
export function getReturnWitness(program, witness_map) {
|
|
351
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
352
|
-
const len0 = WASM_VECTOR_LEN;
|
|
353
|
-
const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
|
|
354
|
-
if (ret[2]) {
|
|
355
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
356
|
-
}
|
|
357
|
-
return takeFromExternrefTable0(ret[0]);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
362
|
-
*
|
|
363
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
364
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
365
|
-
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
366
|
-
* @param {Uint8Array} program
|
|
367
|
-
* @param {WitnessMap} solved_witness
|
|
368
|
-
* @returns {WitnessMap}
|
|
369
|
-
*/
|
|
370
|
-
export function getPublicParametersWitness(program, solved_witness) {
|
|
371
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
372
|
-
const len0 = WASM_VECTOR_LEN;
|
|
373
|
-
const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
|
|
374
|
-
if (ret[2]) {
|
|
375
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
376
|
-
}
|
|
377
|
-
return takeFromExternrefTable0(ret[0]);
|
|
378
|
-
}
|
|
379
214
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
384
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
385
|
-
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
386
|
-
* @param {Uint8Array} program
|
|
387
|
-
* @param {WitnessMap} solved_witness
|
|
388
|
-
* @returns {WitnessMap}
|
|
389
|
-
*/
|
|
390
|
-
export function getPublicWitness(program, solved_witness) {
|
|
391
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
392
|
-
const len0 = WASM_VECTOR_LEN;
|
|
393
|
-
const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
|
|
394
|
-
if (ret[2]) {
|
|
395
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
396
|
-
}
|
|
397
|
-
return takeFromExternrefTable0(ret[0]);
|
|
215
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
216
|
+
ptr = ptr >>> 0;
|
|
217
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
398
218
|
}
|
|
399
|
-
|
|
400
219
|
/**
|
|
401
220
|
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
402
221
|
*
|
|
@@ -413,6 +232,12 @@ export function compressWitness(witness_map) {
|
|
|
413
232
|
return v1;
|
|
414
233
|
}
|
|
415
234
|
|
|
235
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
236
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
237
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
238
|
+
WASM_VECTOR_LEN = arg.length;
|
|
239
|
+
return ptr;
|
|
240
|
+
}
|
|
416
241
|
/**
|
|
417
242
|
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
|
|
418
243
|
* This should be used to only fetch the witness map for the main function.
|
|
@@ -522,6 +347,181 @@ export function executeProgram(program, initial_witness, foreign_call_handler) {
|
|
|
522
347
|
return ret;
|
|
523
348
|
}
|
|
524
349
|
|
|
350
|
+
/**
|
|
351
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
352
|
+
*
|
|
353
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
354
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
355
|
+
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
356
|
+
* @param {Uint8Array} program
|
|
357
|
+
* @param {WitnessMap} witness_map
|
|
358
|
+
* @returns {WitnessMap}
|
|
359
|
+
*/
|
|
360
|
+
export function getReturnWitness(program, witness_map) {
|
|
361
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
362
|
+
const len0 = WASM_VECTOR_LEN;
|
|
363
|
+
const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
|
|
364
|
+
if (ret[2]) {
|
|
365
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
366
|
+
}
|
|
367
|
+
return takeFromExternrefTable0(ret[0]);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
372
|
+
*
|
|
373
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
374
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
375
|
+
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
376
|
+
* @param {Uint8Array} program
|
|
377
|
+
* @param {WitnessMap} solved_witness
|
|
378
|
+
* @returns {WitnessMap}
|
|
379
|
+
*/
|
|
380
|
+
export function getPublicParametersWitness(program, solved_witness) {
|
|
381
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
382
|
+
const len0 = WASM_VECTOR_LEN;
|
|
383
|
+
const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
|
|
384
|
+
if (ret[2]) {
|
|
385
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
386
|
+
}
|
|
387
|
+
return takeFromExternrefTable0(ret[0]);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
|
|
392
|
+
*
|
|
393
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
394
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
395
|
+
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
396
|
+
* @param {Uint8Array} program
|
|
397
|
+
* @param {WitnessMap} solved_witness
|
|
398
|
+
* @returns {WitnessMap}
|
|
399
|
+
*/
|
|
400
|
+
export function getPublicWitness(program, solved_witness) {
|
|
401
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
402
|
+
const len0 = WASM_VECTOR_LEN;
|
|
403
|
+
const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
|
|
404
|
+
if (ret[2]) {
|
|
405
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
406
|
+
}
|
|
407
|
+
return takeFromExternrefTable0(ret[0]);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
412
|
+
* @param {string} lhs
|
|
413
|
+
* @param {string} rhs
|
|
414
|
+
* @returns {string}
|
|
415
|
+
*/
|
|
416
|
+
export function and(lhs, rhs) {
|
|
417
|
+
const ret = wasm.and(lhs, rhs);
|
|
418
|
+
return ret;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
423
|
+
* @param {string} lhs
|
|
424
|
+
* @param {string} rhs
|
|
425
|
+
* @returns {string}
|
|
426
|
+
*/
|
|
427
|
+
export function xor(lhs, rhs) {
|
|
428
|
+
const ret = wasm.xor(lhs, rhs);
|
|
429
|
+
return ret;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
let cachedUint32ArrayMemory0 = null;
|
|
433
|
+
|
|
434
|
+
function getUint32ArrayMemory0() {
|
|
435
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
436
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
437
|
+
}
|
|
438
|
+
return cachedUint32ArrayMemory0;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
442
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
443
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
444
|
+
WASM_VECTOR_LEN = arg.length;
|
|
445
|
+
return ptr;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
449
|
+
ptr = ptr >>> 0;
|
|
450
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Sha256 compression function
|
|
454
|
+
* @param {Uint32Array} inputs
|
|
455
|
+
* @param {Uint32Array} state
|
|
456
|
+
* @returns {Uint32Array}
|
|
457
|
+
*/
|
|
458
|
+
export function sha256_compression(inputs, state) {
|
|
459
|
+
const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
460
|
+
const len0 = WASM_VECTOR_LEN;
|
|
461
|
+
const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
|
|
462
|
+
const len1 = WASM_VECTOR_LEN;
|
|
463
|
+
const ret = wasm.sha256_compression(ptr0, len0, ptr1, len1);
|
|
464
|
+
var v3 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
465
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
466
|
+
return v3;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
471
|
+
* @param {Uint8Array} inputs
|
|
472
|
+
* @returns {Uint8Array}
|
|
473
|
+
*/
|
|
474
|
+
export function blake2s256(inputs) {
|
|
475
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
476
|
+
const len0 = WASM_VECTOR_LEN;
|
|
477
|
+
const ret = wasm.blake2s256(ptr0, len0);
|
|
478
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
479
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
480
|
+
return v2;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
485
|
+
* @param {Uint8Array} hashed_msg
|
|
486
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
487
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
488
|
+
* @param {Uint8Array} signature
|
|
489
|
+
* @returns {boolean}
|
|
490
|
+
*/
|
|
491
|
+
export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
492
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
493
|
+
const len0 = WASM_VECTOR_LEN;
|
|
494
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
495
|
+
const len1 = WASM_VECTOR_LEN;
|
|
496
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
497
|
+
const len2 = WASM_VECTOR_LEN;
|
|
498
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
499
|
+
const len3 = WASM_VECTOR_LEN;
|
|
500
|
+
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
501
|
+
return ret !== 0;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
506
|
+
* @param {Uint8Array} hashed_msg
|
|
507
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
508
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
509
|
+
* @param {Uint8Array} signature
|
|
510
|
+
* @returns {boolean}
|
|
511
|
+
*/
|
|
512
|
+
export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
513
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
514
|
+
const len0 = WASM_VECTOR_LEN;
|
|
515
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
516
|
+
const len1 = WASM_VECTOR_LEN;
|
|
517
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
518
|
+
const len2 = WASM_VECTOR_LEN;
|
|
519
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
520
|
+
const len3 = WASM_VECTOR_LEN;
|
|
521
|
+
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
522
|
+
return ret !== 0;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
525
|
function __wbg_adapter_30(arg0, arg1, arg2) {
|
|
526
526
|
wasm.closure255_externref_shim(arg0, arg1, arg2);
|
|
527
527
|
}
|
|
@@ -580,11 +580,11 @@ function __wbg_get_imports() {
|
|
|
580
580
|
const ret = arg0.call(arg1, arg2, arg3);
|
|
581
581
|
return ret;
|
|
582
582
|
}, arguments) };
|
|
583
|
-
imports.wbg.
|
|
583
|
+
imports.wbg.__wbg_constructor_6f67fe370a1d12e4 = function(arg0) {
|
|
584
584
|
const ret = new Error(arg0);
|
|
585
585
|
return ret;
|
|
586
586
|
};
|
|
587
|
-
imports.wbg.
|
|
587
|
+
imports.wbg.__wbg_constructor_e1ce7ec5d0c26936 = function(arg0) {
|
|
588
588
|
const ret = new Error(arg0);
|
|
589
589
|
return ret;
|
|
590
590
|
};
|
|
@@ -685,10 +685,6 @@ function __wbg_get_imports() {
|
|
|
685
685
|
state0.a = state0.b = 0;
|
|
686
686
|
}
|
|
687
687
|
};
|
|
688
|
-
imports.wbg.__wbg_new_3f4c5c451d69e970 = function() {
|
|
689
|
-
const ret = new Map();
|
|
690
|
-
return ret;
|
|
691
|
-
};
|
|
692
688
|
imports.wbg.__wbg_new_5e0be73521bc8c17 = function() {
|
|
693
689
|
const ret = new Map();
|
|
694
690
|
return ret;
|
|
@@ -701,10 +697,14 @@ function __wbg_get_imports() {
|
|
|
701
697
|
const ret = new Error();
|
|
702
698
|
return ret;
|
|
703
699
|
};
|
|
704
|
-
imports.wbg.
|
|
700
|
+
imports.wbg.__wbg_new_afcb88b732711926 = function() {
|
|
705
701
|
const ret = new Array();
|
|
706
702
|
return ret;
|
|
707
703
|
};
|
|
704
|
+
imports.wbg.__wbg_new_c4d92c865672cdba = function() {
|
|
705
|
+
const ret = new Map();
|
|
706
|
+
return ret;
|
|
707
|
+
};
|
|
708
708
|
imports.wbg.__wbg_new_c68d7209be747379 = function(arg0, arg1) {
|
|
709
709
|
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
710
710
|
return ret;
|
|
@@ -797,7 +797,7 @@ function __wbg_get_imports() {
|
|
|
797
797
|
const ret = false;
|
|
798
798
|
return ret;
|
|
799
799
|
};
|
|
800
|
-
imports.wbg.
|
|
800
|
+
imports.wbg.__wbindgen_closure_wrapper736 = function(arg0, arg1, arg2) {
|
|
801
801
|
const ret = makeMutClosure(arg0, arg1, 256, __wbg_adapter_30);
|
|
802
802
|
return ret;
|
|
803
803
|
};
|
package/web/acvm_js_bg.wasm
CHANGED
|
Binary file
|
package/web/acvm_js_bg.wasm.d.ts
CHANGED
|
@@ -2,15 +2,6 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const buildInfo: () => any;
|
|
5
|
-
export const and: (a: any, b: any) => any;
|
|
6
|
-
export const xor: (a: any, b: any) => any;
|
|
7
|
-
export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
|
|
8
|
-
export const blake2s256: (a: number, b: number) => [number, number];
|
|
9
|
-
export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
10
|
-
export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
11
|
-
export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
12
|
-
export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
13
|
-
export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
14
5
|
export const compressWitness: (a: any) => [number, number, number, number];
|
|
15
6
|
export const decompressWitness: (a: number, b: number) => [number, number, number];
|
|
16
7
|
export const compressWitnessStack: (a: any) => [number, number, number, number];
|
|
@@ -19,6 +10,15 @@ export const initLogLevel: (a: number, b: number) => [number, number];
|
|
|
19
10
|
export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
|
|
20
11
|
export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
|
|
21
12
|
export const executeProgram: (a: number, b: number, c: any, d: any) => any;
|
|
13
|
+
export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
14
|
+
export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
15
|
+
export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
16
|
+
export const and: (a: any, b: any) => any;
|
|
17
|
+
export const xor: (a: any, b: any) => any;
|
|
18
|
+
export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
|
|
19
|
+
export const blake2s256: (a: number, b: number) => [number, number];
|
|
20
|
+
export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
21
|
+
export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
22
22
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
23
23
|
export const __externref_table_alloc: () => number;
|
|
24
24
|
export const __wbindgen_export_2: WebAssembly.Table;
|