@noir-lang/acvm_js 1.0.0-beta.9-b2713a9.nightly → 1.0.0-beta.9-20c37b2.nightly
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/nodejs/acvm_js.d.ts +52 -52
- package/nodejs/acvm_js.js +156 -157
- package/nodejs/acvm_js_bg.wasm +0 -0
- package/nodejs/acvm_js_bg.wasm.d.ts +12 -12
- package/package.json +1 -1
- package/web/acvm_js.d.ts +64 -64
- package/web/acvm_js.js +156 -157
- package/web/acvm_js_bg.wasm +0 -0
- package/web/acvm_js_bg.wasm.d.ts +12 -12
package/nodejs/acvm_js.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
7
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
8
|
-
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
4
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
9
5
|
*/
|
|
10
|
-
export function
|
|
6
|
+
export function and(lhs: string, rhs: string): string;
|
|
11
7
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
15
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
16
|
-
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
8
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
17
9
|
*/
|
|
18
|
-
export function
|
|
10
|
+
export function xor(lhs: string, rhs: string): string;
|
|
19
11
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
23
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
24
|
-
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
12
|
+
* Sha256 compression function
|
|
25
13
|
*/
|
|
26
|
-
export function
|
|
14
|
+
export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
|
|
15
|
+
/**
|
|
16
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
17
|
+
*/
|
|
18
|
+
export function blake2s256(inputs: Uint8Array): Uint8Array;
|
|
19
|
+
/**
|
|
20
|
+
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
21
|
+
*/
|
|
22
|
+
export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
25
|
+
*/
|
|
26
|
+
export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
27
27
|
/**
|
|
28
28
|
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
29
29
|
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
@@ -93,43 +93,37 @@ export function executeProgram(program: Uint8Array, initial_witness: WitnessMap,
|
|
|
93
93
|
*/
|
|
94
94
|
export function initLogLevel(filter: string): void;
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
*
|
|
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
|
|
96
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
97
|
+
*
|
|
98
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
99
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
100
|
+
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
109
101
|
*/
|
|
110
|
-
export function
|
|
102
|
+
export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
|
|
111
103
|
/**
|
|
112
|
-
*
|
|
104
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
105
|
+
*
|
|
106
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
107
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
108
|
+
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
113
109
|
*/
|
|
114
|
-
export function
|
|
110
|
+
export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
115
111
|
/**
|
|
116
|
-
*
|
|
112
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
|
|
113
|
+
*
|
|
114
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
115
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
116
|
+
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
117
117
|
*/
|
|
118
|
-
export function
|
|
119
|
-
|
|
120
|
-
// Map from witness index to hex string value of witness.
|
|
121
|
-
export type WitnessMap = Map<number, string>;
|
|
118
|
+
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
122
119
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
* 2. The return witness which contains the given public return values within the full witness.
|
|
127
|
-
*/
|
|
128
|
-
export type SolvedAndReturnWitness = {
|
|
129
|
-
solvedWitness: WitnessMap;
|
|
130
|
-
returnWitness: WitnessMap;
|
|
120
|
+
export type StackItem = {
|
|
121
|
+
index: number;
|
|
122
|
+
witness: WitnessMap;
|
|
131
123
|
}
|
|
132
124
|
|
|
125
|
+
export type WitnessStack = Array<StackItem>;
|
|
126
|
+
|
|
133
127
|
|
|
134
128
|
|
|
135
129
|
/**
|
|
@@ -174,11 +168,17 @@ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => P
|
|
|
174
168
|
|
|
175
169
|
|
|
176
170
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
witness: WitnessMap;
|
|
180
|
-
}
|
|
171
|
+
// Map from witness index to hex string value of witness.
|
|
172
|
+
export type WitnessMap = Map<number, string>;
|
|
181
173
|
|
|
182
|
-
|
|
174
|
+
/**
|
|
175
|
+
* An execution result containing two witnesses.
|
|
176
|
+
* 1. The full solved witness of the execution.
|
|
177
|
+
* 2. The return witness which contains the given public return values within the full witness.
|
|
178
|
+
*/
|
|
179
|
+
export type SolvedAndReturnWitness = {
|
|
180
|
+
solvedWitness: WitnessMap;
|
|
181
|
+
returnWitness: WitnessMap;
|
|
182
|
+
}
|
|
183
183
|
|
|
184
184
|
|
package/nodejs/acvm_js.js
CHANGED
|
@@ -201,6 +201,64 @@ function debugString(val) {
|
|
|
201
201
|
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
202
202
|
return className;
|
|
203
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
206
|
+
* @param {string} lhs
|
|
207
|
+
* @param {string} rhs
|
|
208
|
+
* @returns {string}
|
|
209
|
+
*/
|
|
210
|
+
module.exports.and = function(lhs, rhs) {
|
|
211
|
+
const ret = wasm.and(lhs, rhs);
|
|
212
|
+
return ret;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
217
|
+
* @param {string} lhs
|
|
218
|
+
* @param {string} rhs
|
|
219
|
+
* @returns {string}
|
|
220
|
+
*/
|
|
221
|
+
module.exports.xor = function(lhs, rhs) {
|
|
222
|
+
const ret = wasm.xor(lhs, rhs);
|
|
223
|
+
return ret;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
let cachedUint32ArrayMemory0 = null;
|
|
227
|
+
|
|
228
|
+
function getUint32ArrayMemory0() {
|
|
229
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
230
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
231
|
+
}
|
|
232
|
+
return cachedUint32ArrayMemory0;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
236
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
237
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
238
|
+
WASM_VECTOR_LEN = arg.length;
|
|
239
|
+
return ptr;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
243
|
+
ptr = ptr >>> 0;
|
|
244
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Sha256 compression function
|
|
248
|
+
* @param {Uint32Array} inputs
|
|
249
|
+
* @param {Uint32Array} state
|
|
250
|
+
* @returns {Uint32Array}
|
|
251
|
+
*/
|
|
252
|
+
module.exports.sha256_compression = function(inputs, state) {
|
|
253
|
+
const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
254
|
+
const len0 = WASM_VECTOR_LEN;
|
|
255
|
+
const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
|
|
256
|
+
const len1 = WASM_VECTOR_LEN;
|
|
257
|
+
const ret = wasm.sha256_compression(ptr0, len0, ptr1, len1);
|
|
258
|
+
var v3 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
259
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
260
|
+
return v3;
|
|
261
|
+
};
|
|
204
262
|
|
|
205
263
|
function passArray8ToWasm0(arg, malloc) {
|
|
206
264
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
@@ -209,69 +267,64 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
209
267
|
return ptr;
|
|
210
268
|
}
|
|
211
269
|
|
|
212
|
-
function
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return value;
|
|
270
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
271
|
+
ptr = ptr >>> 0;
|
|
272
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
216
273
|
}
|
|
217
274
|
/**
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
* @
|
|
221
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
222
|
-
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
223
|
-
* @param {Uint8Array} program
|
|
224
|
-
* @param {WitnessMap} witness_map
|
|
225
|
-
* @returns {WitnessMap}
|
|
275
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
276
|
+
* @param {Uint8Array} inputs
|
|
277
|
+
* @returns {Uint8Array}
|
|
226
278
|
*/
|
|
227
|
-
module.exports.
|
|
228
|
-
const ptr0 = passArray8ToWasm0(
|
|
279
|
+
module.exports.blake2s256 = function(inputs) {
|
|
280
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
229
281
|
const len0 = WASM_VECTOR_LEN;
|
|
230
|
-
const ret = wasm.
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
return takeFromExternrefTable0(ret[0]);
|
|
282
|
+
const ret = wasm.blake2s256(ptr0, len0);
|
|
283
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
284
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
285
|
+
return v2;
|
|
235
286
|
};
|
|
236
287
|
|
|
237
288
|
/**
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
* @param {Uint8Array}
|
|
241
|
-
* @param {
|
|
242
|
-
* @
|
|
243
|
-
* @
|
|
244
|
-
* @param {WitnessMap} solved_witness
|
|
245
|
-
* @returns {WitnessMap}
|
|
289
|
+
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
290
|
+
* @param {Uint8Array} hashed_msg
|
|
291
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
292
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
293
|
+
* @param {Uint8Array} signature
|
|
294
|
+
* @returns {boolean}
|
|
246
295
|
*/
|
|
247
|
-
module.exports.
|
|
248
|
-
const ptr0 = passArray8ToWasm0(
|
|
296
|
+
module.exports.ecdsa_secp256k1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
297
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
249
298
|
const len0 = WASM_VECTOR_LEN;
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
299
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
300
|
+
const len1 = WASM_VECTOR_LEN;
|
|
301
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
302
|
+
const len2 = WASM_VECTOR_LEN;
|
|
303
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
304
|
+
const len3 = WASM_VECTOR_LEN;
|
|
305
|
+
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
306
|
+
return ret !== 0;
|
|
255
307
|
};
|
|
256
308
|
|
|
257
309
|
/**
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
* @param {Uint8Array}
|
|
261
|
-
* @param {
|
|
262
|
-
* @
|
|
263
|
-
* @
|
|
264
|
-
* @param {WitnessMap} solved_witness
|
|
265
|
-
* @returns {WitnessMap}
|
|
310
|
+
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
311
|
+
* @param {Uint8Array} hashed_msg
|
|
312
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
313
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
314
|
+
* @param {Uint8Array} signature
|
|
315
|
+
* @returns {boolean}
|
|
266
316
|
*/
|
|
267
|
-
module.exports.
|
|
268
|
-
const ptr0 = passArray8ToWasm0(
|
|
317
|
+
module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
318
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
269
319
|
const len0 = WASM_VECTOR_LEN;
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
320
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
321
|
+
const len1 = WASM_VECTOR_LEN;
|
|
322
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
323
|
+
const len2 = WASM_VECTOR_LEN;
|
|
324
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
325
|
+
const len3 = WASM_VECTOR_LEN;
|
|
326
|
+
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
327
|
+
return ret !== 0;
|
|
275
328
|
};
|
|
276
329
|
|
|
277
330
|
/**
|
|
@@ -283,9 +336,10 @@ module.exports.buildInfo = function() {
|
|
|
283
336
|
return ret;
|
|
284
337
|
};
|
|
285
338
|
|
|
286
|
-
function
|
|
287
|
-
|
|
288
|
-
|
|
339
|
+
function takeFromExternrefTable0(idx) {
|
|
340
|
+
const value = wasm.__wbindgen_export_2.get(idx);
|
|
341
|
+
wasm.__externref_table_dealloc(idx);
|
|
342
|
+
return value;
|
|
289
343
|
}
|
|
290
344
|
/**
|
|
291
345
|
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
@@ -413,130 +467,75 @@ module.exports.initLogLevel = function(filter) {
|
|
|
413
467
|
};
|
|
414
468
|
|
|
415
469
|
/**
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
* @param {
|
|
419
|
-
* @
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
428
|
-
* @param {string} lhs
|
|
429
|
-
* @param {string} rhs
|
|
430
|
-
* @returns {string}
|
|
431
|
-
*/
|
|
432
|
-
module.exports.xor = function(lhs, rhs) {
|
|
433
|
-
const ret = wasm.xor(lhs, rhs);
|
|
434
|
-
return ret;
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
let cachedUint32ArrayMemory0 = null;
|
|
438
|
-
|
|
439
|
-
function getUint32ArrayMemory0() {
|
|
440
|
-
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
441
|
-
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
442
|
-
}
|
|
443
|
-
return cachedUint32ArrayMemory0;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
function passArray32ToWasm0(arg, malloc) {
|
|
447
|
-
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
448
|
-
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
449
|
-
WASM_VECTOR_LEN = arg.length;
|
|
450
|
-
return ptr;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
function getArrayU32FromWasm0(ptr, len) {
|
|
454
|
-
ptr = ptr >>> 0;
|
|
455
|
-
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* Sha256 compression function
|
|
459
|
-
* @param {Uint32Array} inputs
|
|
460
|
-
* @param {Uint32Array} state
|
|
461
|
-
* @returns {Uint32Array}
|
|
462
|
-
*/
|
|
463
|
-
module.exports.sha256_compression = function(inputs, state) {
|
|
464
|
-
const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
465
|
-
const len0 = WASM_VECTOR_LEN;
|
|
466
|
-
const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
|
|
467
|
-
const len1 = WASM_VECTOR_LEN;
|
|
468
|
-
const ret = wasm.sha256_compression(ptr0, len0, ptr1, len1);
|
|
469
|
-
var v3 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
470
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
471
|
-
return v3;
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* Calculates the Blake2s256 hash of the input bytes
|
|
476
|
-
* @param {Uint8Array} inputs
|
|
477
|
-
* @returns {Uint8Array}
|
|
470
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
471
|
+
*
|
|
472
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
473
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
474
|
+
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
475
|
+
* @param {Uint8Array} program
|
|
476
|
+
* @param {WitnessMap} witness_map
|
|
477
|
+
* @returns {WitnessMap}
|
|
478
478
|
*/
|
|
479
|
-
module.exports.
|
|
480
|
-
const ptr0 = passArray8ToWasm0(
|
|
479
|
+
module.exports.getReturnWitness = function(program, witness_map) {
|
|
480
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
481
481
|
const len0 = WASM_VECTOR_LEN;
|
|
482
|
-
const ret = wasm.
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
482
|
+
const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
|
|
483
|
+
if (ret[2]) {
|
|
484
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
485
|
+
}
|
|
486
|
+
return takeFromExternrefTable0(ret[0]);
|
|
486
487
|
};
|
|
487
488
|
|
|
488
489
|
/**
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
* @param {Uint8Array}
|
|
492
|
-
* @param {
|
|
493
|
-
* @
|
|
494
|
-
* @
|
|
490
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
491
|
+
*
|
|
492
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
493
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
494
|
+
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
495
|
+
* @param {Uint8Array} program
|
|
496
|
+
* @param {WitnessMap} solved_witness
|
|
497
|
+
* @returns {WitnessMap}
|
|
495
498
|
*/
|
|
496
|
-
module.exports.
|
|
497
|
-
const ptr0 = passArray8ToWasm0(
|
|
499
|
+
module.exports.getPublicParametersWitness = function(program, solved_witness) {
|
|
500
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
498
501
|
const len0 = WASM_VECTOR_LEN;
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
const len3 = WASM_VECTOR_LEN;
|
|
505
|
-
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
506
|
-
return ret !== 0;
|
|
502
|
+
const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
|
|
503
|
+
if (ret[2]) {
|
|
504
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
505
|
+
}
|
|
506
|
+
return takeFromExternrefTable0(ret[0]);
|
|
507
507
|
};
|
|
508
508
|
|
|
509
509
|
/**
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
* @param {Uint8Array}
|
|
513
|
-
* @param {
|
|
514
|
-
* @
|
|
515
|
-
* @
|
|
510
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
|
|
511
|
+
*
|
|
512
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
513
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
514
|
+
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
515
|
+
* @param {Uint8Array} program
|
|
516
|
+
* @param {WitnessMap} solved_witness
|
|
517
|
+
* @returns {WitnessMap}
|
|
516
518
|
*/
|
|
517
|
-
module.exports.
|
|
518
|
-
const ptr0 = passArray8ToWasm0(
|
|
519
|
+
module.exports.getPublicWitness = function(program, solved_witness) {
|
|
520
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
519
521
|
const len0 = WASM_VECTOR_LEN;
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
const len3 = WASM_VECTOR_LEN;
|
|
526
|
-
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
527
|
-
return ret !== 0;
|
|
522
|
+
const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
|
|
523
|
+
if (ret[2]) {
|
|
524
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
525
|
+
}
|
|
526
|
+
return takeFromExternrefTable0(ret[0]);
|
|
528
527
|
};
|
|
529
528
|
|
|
530
529
|
function __wbg_adapter_30(arg0, arg1, arg2) {
|
|
531
|
-
wasm.
|
|
530
|
+
wasm.closure644_externref_shim(arg0, arg1, arg2);
|
|
532
531
|
}
|
|
533
532
|
|
|
534
533
|
function __wbg_adapter_89(arg0, arg1, arg2, arg3, arg4) {
|
|
535
|
-
wasm.
|
|
534
|
+
wasm.closure1309_externref_shim(arg0, arg1, arg2, arg3, arg4);
|
|
536
535
|
}
|
|
537
536
|
|
|
538
537
|
function __wbg_adapter_110(arg0, arg1, arg2, arg3) {
|
|
539
|
-
wasm.
|
|
538
|
+
wasm.closure1313_externref_shim(arg0, arg1, arg2, arg3);
|
|
540
539
|
}
|
|
541
540
|
|
|
542
541
|
module.exports.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
|
|
@@ -814,8 +813,8 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
|
814
813
|
return ret;
|
|
815
814
|
};
|
|
816
815
|
|
|
817
|
-
module.exports.
|
|
818
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
816
|
+
module.exports.__wbindgen_closure_wrapper2144 = function(arg0, arg1, arg2) {
|
|
817
|
+
const ret = makeMutClosure(arg0, arg1, 645, __wbg_adapter_30);
|
|
819
818
|
return ret;
|
|
820
819
|
};
|
|
821
820
|
|
package/nodejs/acvm_js_bg.wasm
CHANGED
|
Binary file
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
4
|
+
export const and: (a: any, b: any) => any;
|
|
5
|
+
export const xor: (a: any, b: any) => any;
|
|
6
|
+
export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
|
|
7
|
+
export const blake2s256: (a: number, b: number) => [number, number];
|
|
8
|
+
export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
9
|
+
export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
7
10
|
export const buildInfo: () => any;
|
|
8
11
|
export const compressWitness: (a: any) => [number, number, number, number];
|
|
9
12
|
export const decompressWitness: (a: number, b: number) => [number, number, number];
|
|
@@ -13,12 +16,9 @@ export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
|
|
|
13
16
|
export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
|
|
14
17
|
export const executeProgram: (a: number, b: number, c: any, d: any) => any;
|
|
15
18
|
export const initLogLevel: (a: number, b: number) => [number, number];
|
|
16
|
-
export const
|
|
17
|
-
export const
|
|
18
|
-
export const
|
|
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;
|
|
19
|
+
export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
20
|
+
export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
21
|
+
export const getPublicWitness: (a: number, b: number, c: any) => [number, 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;
|
|
@@ -27,7 +27,7 @@ export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
|
27
27
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
28
28
|
export const __wbindgen_export_6: WebAssembly.Table;
|
|
29
29
|
export const __externref_table_dealloc: (a: number) => void;
|
|
30
|
-
export const
|
|
31
|
-
export const
|
|
32
|
-
export const
|
|
30
|
+
export const closure644_externref_shim: (a: number, b: number, c: any) => void;
|
|
31
|
+
export const closure1309_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
|
|
32
|
+
export const closure1313_externref_shim: (a: number, b: number, c: any, d: any) => void;
|
|
33
33
|
export const __wbindgen_start: () => void;
|
package/package.json
CHANGED
package/web/acvm_js.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
7
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
8
|
-
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
4
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
9
5
|
*/
|
|
10
|
-
export function
|
|
6
|
+
export function and(lhs: string, rhs: string): string;
|
|
11
7
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
15
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
16
|
-
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
8
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
17
9
|
*/
|
|
18
|
-
export function
|
|
10
|
+
export function xor(lhs: string, rhs: string): string;
|
|
19
11
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
23
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
24
|
-
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
12
|
+
* Sha256 compression function
|
|
25
13
|
*/
|
|
26
|
-
export function
|
|
14
|
+
export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
|
|
15
|
+
/**
|
|
16
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
17
|
+
*/
|
|
18
|
+
export function blake2s256(inputs: Uint8Array): Uint8Array;
|
|
19
|
+
/**
|
|
20
|
+
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
21
|
+
*/
|
|
22
|
+
export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
25
|
+
*/
|
|
26
|
+
export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
27
27
|
/**
|
|
28
28
|
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
29
29
|
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
@@ -93,43 +93,37 @@ export function executeProgram(program: Uint8Array, initial_witness: WitnessMap,
|
|
|
93
93
|
*/
|
|
94
94
|
export function initLogLevel(filter: string): void;
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
*
|
|
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
|
|
96
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
97
|
+
*
|
|
98
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
99
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
100
|
+
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
109
101
|
*/
|
|
110
|
-
export function
|
|
102
|
+
export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
|
|
111
103
|
/**
|
|
112
|
-
*
|
|
104
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
105
|
+
*
|
|
106
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
107
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
108
|
+
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
113
109
|
*/
|
|
114
|
-
export function
|
|
110
|
+
export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
115
111
|
/**
|
|
116
|
-
*
|
|
112
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
|
|
113
|
+
*
|
|
114
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
115
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
116
|
+
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
117
117
|
*/
|
|
118
|
-
export function
|
|
119
|
-
|
|
120
|
-
// Map from witness index to hex string value of witness.
|
|
121
|
-
export type WitnessMap = Map<number, string>;
|
|
118
|
+
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
122
119
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
* 2. The return witness which contains the given public return values within the full witness.
|
|
127
|
-
*/
|
|
128
|
-
export type SolvedAndReturnWitness = {
|
|
129
|
-
solvedWitness: WitnessMap;
|
|
130
|
-
returnWitness: WitnessMap;
|
|
120
|
+
export type StackItem = {
|
|
121
|
+
index: number;
|
|
122
|
+
witness: WitnessMap;
|
|
131
123
|
}
|
|
132
124
|
|
|
125
|
+
export type WitnessStack = Array<StackItem>;
|
|
126
|
+
|
|
133
127
|
|
|
134
128
|
|
|
135
129
|
/**
|
|
@@ -174,12 +168,18 @@ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => P
|
|
|
174
168
|
|
|
175
169
|
|
|
176
170
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
witness: WitnessMap;
|
|
180
|
-
}
|
|
171
|
+
// Map from witness index to hex string value of witness.
|
|
172
|
+
export type WitnessMap = Map<number, string>;
|
|
181
173
|
|
|
182
|
-
|
|
174
|
+
/**
|
|
175
|
+
* An execution result containing two witnesses.
|
|
176
|
+
* 1. The full solved witness of the execution.
|
|
177
|
+
* 2. The return witness which contains the given public return values within the full witness.
|
|
178
|
+
*/
|
|
179
|
+
export type SolvedAndReturnWitness = {
|
|
180
|
+
solvedWitness: WitnessMap;
|
|
181
|
+
returnWitness: WitnessMap;
|
|
182
|
+
}
|
|
183
183
|
|
|
184
184
|
|
|
185
185
|
|
|
@@ -187,9 +187,12 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
187
187
|
|
|
188
188
|
export interface InitOutput {
|
|
189
189
|
readonly memory: WebAssembly.Memory;
|
|
190
|
-
readonly
|
|
191
|
-
readonly
|
|
192
|
-
readonly
|
|
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;
|
|
193
196
|
readonly buildInfo: () => any;
|
|
194
197
|
readonly compressWitness: (a: any) => [number, number, number, number];
|
|
195
198
|
readonly decompressWitness: (a: number, b: number) => [number, number, number];
|
|
@@ -199,12 +202,9 @@ export interface InitOutput {
|
|
|
199
202
|
readonly executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
|
|
200
203
|
readonly executeProgram: (a: number, b: number, c: any, d: any) => any;
|
|
201
204
|
readonly initLogLevel: (a: number, b: number) => [number, number];
|
|
202
|
-
readonly
|
|
203
|
-
readonly
|
|
204
|
-
readonly
|
|
205
|
-
readonly blake2s256: (a: number, b: number) => [number, number];
|
|
206
|
-
readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
207
|
-
readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
205
|
+
readonly getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
206
|
+
readonly getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
207
|
+
readonly getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
208
208
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
209
209
|
readonly __externref_table_alloc: () => number;
|
|
210
210
|
readonly __wbindgen_export_2: WebAssembly.Table;
|
|
@@ -213,9 +213,9 @@ export interface InitOutput {
|
|
|
213
213
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
214
214
|
readonly __wbindgen_export_6: WebAssembly.Table;
|
|
215
215
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
216
|
-
readonly
|
|
217
|
-
readonly
|
|
218
|
-
readonly
|
|
216
|
+
readonly closure644_externref_shim: (a: number, b: number, c: any) => void;
|
|
217
|
+
readonly closure1309_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
|
|
218
|
+
readonly closure1313_externref_shim: (a: number, b: number, c: any, d: any) => void;
|
|
219
219
|
readonly __wbindgen_start: () => void;
|
|
220
220
|
}
|
|
221
221
|
|
package/web/acvm_js.js
CHANGED
|
@@ -197,6 +197,64 @@ function debugString(val) {
|
|
|
197
197
|
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
198
198
|
return className;
|
|
199
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
202
|
+
* @param {string} lhs
|
|
203
|
+
* @param {string} rhs
|
|
204
|
+
* @returns {string}
|
|
205
|
+
*/
|
|
206
|
+
export function and(lhs, rhs) {
|
|
207
|
+
const ret = wasm.and(lhs, rhs);
|
|
208
|
+
return ret;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
213
|
+
* @param {string} lhs
|
|
214
|
+
* @param {string} rhs
|
|
215
|
+
* @returns {string}
|
|
216
|
+
*/
|
|
217
|
+
export function xor(lhs, rhs) {
|
|
218
|
+
const ret = wasm.xor(lhs, rhs);
|
|
219
|
+
return ret;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
let cachedUint32ArrayMemory0 = null;
|
|
223
|
+
|
|
224
|
+
function getUint32ArrayMemory0() {
|
|
225
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
226
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
227
|
+
}
|
|
228
|
+
return cachedUint32ArrayMemory0;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
232
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
233
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
234
|
+
WASM_VECTOR_LEN = arg.length;
|
|
235
|
+
return ptr;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
239
|
+
ptr = ptr >>> 0;
|
|
240
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Sha256 compression function
|
|
244
|
+
* @param {Uint32Array} inputs
|
|
245
|
+
* @param {Uint32Array} state
|
|
246
|
+
* @returns {Uint32Array}
|
|
247
|
+
*/
|
|
248
|
+
export function sha256_compression(inputs, state) {
|
|
249
|
+
const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
250
|
+
const len0 = WASM_VECTOR_LEN;
|
|
251
|
+
const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
|
|
252
|
+
const len1 = WASM_VECTOR_LEN;
|
|
253
|
+
const ret = wasm.sha256_compression(ptr0, len0, ptr1, len1);
|
|
254
|
+
var v3 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
255
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
256
|
+
return v3;
|
|
257
|
+
}
|
|
200
258
|
|
|
201
259
|
function passArray8ToWasm0(arg, malloc) {
|
|
202
260
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
@@ -205,69 +263,64 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
205
263
|
return ptr;
|
|
206
264
|
}
|
|
207
265
|
|
|
208
|
-
function
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return value;
|
|
266
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
267
|
+
ptr = ptr >>> 0;
|
|
268
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
212
269
|
}
|
|
213
270
|
/**
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
* @
|
|
217
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
218
|
-
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
219
|
-
* @param {Uint8Array} program
|
|
220
|
-
* @param {WitnessMap} witness_map
|
|
221
|
-
* @returns {WitnessMap}
|
|
271
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
272
|
+
* @param {Uint8Array} inputs
|
|
273
|
+
* @returns {Uint8Array}
|
|
222
274
|
*/
|
|
223
|
-
export function
|
|
224
|
-
const ptr0 = passArray8ToWasm0(
|
|
275
|
+
export function blake2s256(inputs) {
|
|
276
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
225
277
|
const len0 = WASM_VECTOR_LEN;
|
|
226
|
-
const ret = wasm.
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
return takeFromExternrefTable0(ret[0]);
|
|
278
|
+
const ret = wasm.blake2s256(ptr0, len0);
|
|
279
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
280
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
281
|
+
return v2;
|
|
231
282
|
}
|
|
232
283
|
|
|
233
284
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
* @param {Uint8Array}
|
|
237
|
-
* @param {
|
|
238
|
-
* @
|
|
239
|
-
* @
|
|
240
|
-
* @param {WitnessMap} solved_witness
|
|
241
|
-
* @returns {WitnessMap}
|
|
285
|
+
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
286
|
+
* @param {Uint8Array} hashed_msg
|
|
287
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
288
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
289
|
+
* @param {Uint8Array} signature
|
|
290
|
+
* @returns {boolean}
|
|
242
291
|
*/
|
|
243
|
-
export function
|
|
244
|
-
const ptr0 = passArray8ToWasm0(
|
|
292
|
+
export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
293
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
245
294
|
const len0 = WASM_VECTOR_LEN;
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
295
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
296
|
+
const len1 = WASM_VECTOR_LEN;
|
|
297
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
298
|
+
const len2 = WASM_VECTOR_LEN;
|
|
299
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
300
|
+
const len3 = WASM_VECTOR_LEN;
|
|
301
|
+
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
302
|
+
return ret !== 0;
|
|
251
303
|
}
|
|
252
304
|
|
|
253
305
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
* @param {Uint8Array}
|
|
257
|
-
* @param {
|
|
258
|
-
* @
|
|
259
|
-
* @
|
|
260
|
-
* @param {WitnessMap} solved_witness
|
|
261
|
-
* @returns {WitnessMap}
|
|
306
|
+
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
307
|
+
* @param {Uint8Array} hashed_msg
|
|
308
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
309
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
310
|
+
* @param {Uint8Array} signature
|
|
311
|
+
* @returns {boolean}
|
|
262
312
|
*/
|
|
263
|
-
export function
|
|
264
|
-
const ptr0 = passArray8ToWasm0(
|
|
313
|
+
export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
314
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
265
315
|
const len0 = WASM_VECTOR_LEN;
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
316
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
317
|
+
const len1 = WASM_VECTOR_LEN;
|
|
318
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
319
|
+
const len2 = WASM_VECTOR_LEN;
|
|
320
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
321
|
+
const len3 = WASM_VECTOR_LEN;
|
|
322
|
+
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
323
|
+
return ret !== 0;
|
|
271
324
|
}
|
|
272
325
|
|
|
273
326
|
/**
|
|
@@ -279,9 +332,10 @@ export function buildInfo() {
|
|
|
279
332
|
return ret;
|
|
280
333
|
}
|
|
281
334
|
|
|
282
|
-
function
|
|
283
|
-
|
|
284
|
-
|
|
335
|
+
function takeFromExternrefTable0(idx) {
|
|
336
|
+
const value = wasm.__wbindgen_export_2.get(idx);
|
|
337
|
+
wasm.__externref_table_dealloc(idx);
|
|
338
|
+
return value;
|
|
285
339
|
}
|
|
286
340
|
/**
|
|
287
341
|
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
@@ -409,130 +463,75 @@ export function initLogLevel(filter) {
|
|
|
409
463
|
}
|
|
410
464
|
|
|
411
465
|
/**
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
* @param {
|
|
415
|
-
* @
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
424
|
-
* @param {string} lhs
|
|
425
|
-
* @param {string} rhs
|
|
426
|
-
* @returns {string}
|
|
427
|
-
*/
|
|
428
|
-
export function xor(lhs, rhs) {
|
|
429
|
-
const ret = wasm.xor(lhs, rhs);
|
|
430
|
-
return ret;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
let cachedUint32ArrayMemory0 = null;
|
|
434
|
-
|
|
435
|
-
function getUint32ArrayMemory0() {
|
|
436
|
-
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
437
|
-
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
438
|
-
}
|
|
439
|
-
return cachedUint32ArrayMemory0;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
function passArray32ToWasm0(arg, malloc) {
|
|
443
|
-
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
444
|
-
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
445
|
-
WASM_VECTOR_LEN = arg.length;
|
|
446
|
-
return ptr;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
function getArrayU32FromWasm0(ptr, len) {
|
|
450
|
-
ptr = ptr >>> 0;
|
|
451
|
-
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Sha256 compression function
|
|
455
|
-
* @param {Uint32Array} inputs
|
|
456
|
-
* @param {Uint32Array} state
|
|
457
|
-
* @returns {Uint32Array}
|
|
458
|
-
*/
|
|
459
|
-
export function sha256_compression(inputs, state) {
|
|
460
|
-
const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
461
|
-
const len0 = WASM_VECTOR_LEN;
|
|
462
|
-
const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
|
|
463
|
-
const len1 = WASM_VECTOR_LEN;
|
|
464
|
-
const ret = wasm.sha256_compression(ptr0, len0, ptr1, len1);
|
|
465
|
-
var v3 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
466
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
467
|
-
return v3;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* Calculates the Blake2s256 hash of the input bytes
|
|
472
|
-
* @param {Uint8Array} inputs
|
|
473
|
-
* @returns {Uint8Array}
|
|
466
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
467
|
+
*
|
|
468
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
469
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
470
|
+
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
471
|
+
* @param {Uint8Array} program
|
|
472
|
+
* @param {WitnessMap} witness_map
|
|
473
|
+
* @returns {WitnessMap}
|
|
474
474
|
*/
|
|
475
|
-
export function
|
|
476
|
-
const ptr0 = passArray8ToWasm0(
|
|
475
|
+
export function getReturnWitness(program, witness_map) {
|
|
476
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
477
477
|
const len0 = WASM_VECTOR_LEN;
|
|
478
|
-
const ret = wasm.
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
478
|
+
const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
|
|
479
|
+
if (ret[2]) {
|
|
480
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
481
|
+
}
|
|
482
|
+
return takeFromExternrefTable0(ret[0]);
|
|
482
483
|
}
|
|
483
484
|
|
|
484
485
|
/**
|
|
485
|
-
*
|
|
486
|
-
*
|
|
487
|
-
* @param {Uint8Array}
|
|
488
|
-
* @param {
|
|
489
|
-
* @
|
|
490
|
-
* @
|
|
486
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
487
|
+
*
|
|
488
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
489
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
490
|
+
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
491
|
+
* @param {Uint8Array} program
|
|
492
|
+
* @param {WitnessMap} solved_witness
|
|
493
|
+
* @returns {WitnessMap}
|
|
491
494
|
*/
|
|
492
|
-
export function
|
|
493
|
-
const ptr0 = passArray8ToWasm0(
|
|
495
|
+
export function getPublicParametersWitness(program, solved_witness) {
|
|
496
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
494
497
|
const len0 = WASM_VECTOR_LEN;
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
const len3 = WASM_VECTOR_LEN;
|
|
501
|
-
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
502
|
-
return ret !== 0;
|
|
498
|
+
const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
|
|
499
|
+
if (ret[2]) {
|
|
500
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
501
|
+
}
|
|
502
|
+
return takeFromExternrefTable0(ret[0]);
|
|
503
503
|
}
|
|
504
504
|
|
|
505
505
|
/**
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
* @param {Uint8Array}
|
|
509
|
-
* @param {
|
|
510
|
-
* @
|
|
511
|
-
* @
|
|
506
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
|
|
507
|
+
*
|
|
508
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
509
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
510
|
+
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
511
|
+
* @param {Uint8Array} program
|
|
512
|
+
* @param {WitnessMap} solved_witness
|
|
513
|
+
* @returns {WitnessMap}
|
|
512
514
|
*/
|
|
513
|
-
export function
|
|
514
|
-
const ptr0 = passArray8ToWasm0(
|
|
515
|
+
export function getPublicWitness(program, solved_witness) {
|
|
516
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
515
517
|
const len0 = WASM_VECTOR_LEN;
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
const len3 = WASM_VECTOR_LEN;
|
|
522
|
-
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
523
|
-
return ret !== 0;
|
|
518
|
+
const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
|
|
519
|
+
if (ret[2]) {
|
|
520
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
521
|
+
}
|
|
522
|
+
return takeFromExternrefTable0(ret[0]);
|
|
524
523
|
}
|
|
525
524
|
|
|
526
525
|
function __wbg_adapter_30(arg0, arg1, arg2) {
|
|
527
|
-
wasm.
|
|
526
|
+
wasm.closure644_externref_shim(arg0, arg1, arg2);
|
|
528
527
|
}
|
|
529
528
|
|
|
530
529
|
function __wbg_adapter_89(arg0, arg1, arg2, arg3, arg4) {
|
|
531
|
-
wasm.
|
|
530
|
+
wasm.closure1309_externref_shim(arg0, arg1, arg2, arg3, arg4);
|
|
532
531
|
}
|
|
533
532
|
|
|
534
533
|
function __wbg_adapter_110(arg0, arg1, arg2, arg3) {
|
|
535
|
-
wasm.
|
|
534
|
+
wasm.closure1313_externref_shim(arg0, arg1, arg2, arg3);
|
|
536
535
|
}
|
|
537
536
|
|
|
538
537
|
async function __wbg_load(module, imports) {
|
|
@@ -798,8 +797,8 @@ function __wbg_get_imports() {
|
|
|
798
797
|
const ret = false;
|
|
799
798
|
return ret;
|
|
800
799
|
};
|
|
801
|
-
imports.wbg.
|
|
802
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
800
|
+
imports.wbg.__wbindgen_closure_wrapper2144 = function(arg0, arg1, arg2) {
|
|
801
|
+
const ret = makeMutClosure(arg0, arg1, 645, __wbg_adapter_30);
|
|
803
802
|
return ret;
|
|
804
803
|
};
|
|
805
804
|
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
package/web/acvm_js_bg.wasm
CHANGED
|
Binary file
|
package/web/acvm_js_bg.wasm.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
4
|
+
export const and: (a: any, b: any) => any;
|
|
5
|
+
export const xor: (a: any, b: any) => any;
|
|
6
|
+
export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
|
|
7
|
+
export const blake2s256: (a: number, b: number) => [number, number];
|
|
8
|
+
export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
9
|
+
export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
7
10
|
export const buildInfo: () => any;
|
|
8
11
|
export const compressWitness: (a: any) => [number, number, number, number];
|
|
9
12
|
export const decompressWitness: (a: number, b: number) => [number, number, number];
|
|
@@ -13,12 +16,9 @@ export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
|
|
|
13
16
|
export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
|
|
14
17
|
export const executeProgram: (a: number, b: number, c: any, d: any) => any;
|
|
15
18
|
export const initLogLevel: (a: number, b: number) => [number, number];
|
|
16
|
-
export const
|
|
17
|
-
export const
|
|
18
|
-
export const
|
|
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;
|
|
19
|
+
export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
20
|
+
export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
21
|
+
export const getPublicWitness: (a: number, b: number, c: any) => [number, 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;
|
|
@@ -27,7 +27,7 @@ export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
|
27
27
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
28
28
|
export const __wbindgen_export_6: WebAssembly.Table;
|
|
29
29
|
export const __externref_table_dealloc: (a: number) => void;
|
|
30
|
-
export const
|
|
31
|
-
export const
|
|
32
|
-
export const
|
|
30
|
+
export const closure644_externref_shim: (a: number, b: number, c: any) => void;
|
|
31
|
+
export const closure1309_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
|
|
32
|
+
export const closure1313_externref_shim: (a: number, b: number, c: any, d: any) => void;
|
|
33
33
|
export const __wbindgen_start: () => void;
|