@aztec/noir-acvm_js 3.0.0-nightly.20251104 → 3.0.0-nightly.20251106
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 +58 -58
- package/nodejs/acvm_js.js +143 -144
- package/nodejs/acvm_js_bg.wasm +0 -0
- package/nodejs/acvm_js_bg.wasm.d.ts +10 -10
- package/package.json +1 -1
- package/web/acvm_js.d.ts +68 -68
- package/web/acvm_js.js +143 -144
- package/web/acvm_js_bg.wasm +0 -0
- package/web/acvm_js_bg.wasm.d.ts +10 -10
package/nodejs/acvm_js.d.ts
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
5
|
+
*/
|
|
6
|
+
export function and(lhs: string, rhs: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
9
|
+
*/
|
|
10
|
+
export function xor(lhs: string, rhs: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Sha256 compression function
|
|
13
|
+
*/
|
|
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;
|
|
3
27
|
/**
|
|
4
28
|
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
5
29
|
*
|
|
@@ -57,12 +81,6 @@ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_wit
|
|
|
57
81
|
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
58
82
|
*/
|
|
59
83
|
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
|
|
60
|
-
/**
|
|
61
|
-
* Sets the package's logging level.
|
|
62
|
-
*
|
|
63
|
-
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
64
|
-
*/
|
|
65
|
-
export function initLogLevel(filter: string): void;
|
|
66
84
|
/**
|
|
67
85
|
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
68
86
|
*
|
|
@@ -87,63 +105,17 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
|
|
|
87
105
|
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
88
106
|
*/
|
|
89
107
|
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
108
|
+
/**
|
|
109
|
+
* Sets the package's logging level.
|
|
110
|
+
*
|
|
111
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
112
|
+
*/
|
|
113
|
+
export function initLogLevel(filter: string): void;
|
|
90
114
|
/**
|
|
91
115
|
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
92
116
|
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
93
117
|
*/
|
|
94
118
|
export function buildInfo(): BuildInfo;
|
|
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
|
-
|
|
120
|
-
export type RawAssertionPayload = {
|
|
121
|
-
selector: string;
|
|
122
|
-
data: string[];
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export type ExecutionError = Error & {
|
|
126
|
-
callStack?: string[];
|
|
127
|
-
rawAssertionPayload?: RawAssertionPayload;
|
|
128
|
-
acirFunctionId?: number;
|
|
129
|
-
brilligFunctionId?: number;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
|
|
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
119
|
|
|
148
120
|
// Map from witness index to hex string value of witness.
|
|
149
121
|
export type WitnessMap = Map<number, string>;
|
|
@@ -169,6 +141,34 @@ export type WitnessStack = Array<StackItem>;
|
|
|
169
141
|
|
|
170
142
|
|
|
171
143
|
|
|
144
|
+
export type ForeignCallInput = string[]
|
|
145
|
+
export type ForeignCallOutput = string | string[]
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* A callback which performs an foreign call and returns the response.
|
|
149
|
+
* @callback ForeignCallHandler
|
|
150
|
+
* @param {string} name - The identifier for the type of foreign call being performed.
|
|
151
|
+
* @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
|
|
152
|
+
* @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
|
|
153
|
+
*/
|
|
154
|
+
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
export type RawAssertionPayload = {
|
|
159
|
+
selector: string;
|
|
160
|
+
data: string[];
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export type ExecutionError = Error & {
|
|
164
|
+
callStack?: string[];
|
|
165
|
+
rawAssertionPayload?: RawAssertionPayload;
|
|
166
|
+
acirFunctionId?: number;
|
|
167
|
+
brilligFunctionId?: number;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
172
|
/**
|
|
173
173
|
* @typedef {Object} BuildInfo - Information about how the installed package was built
|
|
174
174
|
* @property {string} gitHash - The hash of the git commit from which the package was built.
|
package/nodejs/acvm_js.js
CHANGED
|
@@ -201,17 +201,137 @@ 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
|
+
};
|
|
204
214
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
+
};
|
|
262
|
+
|
|
263
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
264
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
265
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
266
|
+
WASM_VECTOR_LEN = arg.length;
|
|
267
|
+
return ptr;
|
|
209
268
|
}
|
|
210
269
|
|
|
211
270
|
function getArrayU8FromWasm0(ptr, len) {
|
|
212
271
|
ptr = ptr >>> 0;
|
|
213
272
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
214
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
276
|
+
* @param {Uint8Array} inputs
|
|
277
|
+
* @returns {Uint8Array}
|
|
278
|
+
*/
|
|
279
|
+
module.exports.blake2s256 = function(inputs) {
|
|
280
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
281
|
+
const len0 = WASM_VECTOR_LEN;
|
|
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;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
/**
|
|
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}
|
|
295
|
+
*/
|
|
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);
|
|
298
|
+
const len0 = WASM_VECTOR_LEN;
|
|
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;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
/**
|
|
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}
|
|
316
|
+
*/
|
|
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);
|
|
319
|
+
const len0 = WASM_VECTOR_LEN;
|
|
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;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
function takeFromExternrefTable0(idx) {
|
|
331
|
+
const value = wasm.__wbindgen_export_2.get(idx);
|
|
332
|
+
wasm.__externref_table_dealloc(idx);
|
|
333
|
+
return value;
|
|
334
|
+
}
|
|
215
335
|
/**
|
|
216
336
|
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
217
337
|
*
|
|
@@ -228,12 +348,6 @@ module.exports.compressWitness = function(witness_map) {
|
|
|
228
348
|
return v1;
|
|
229
349
|
};
|
|
230
350
|
|
|
231
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
232
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
233
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
234
|
-
WASM_VECTOR_LEN = arg.length;
|
|
235
|
-
return ptr;
|
|
236
|
-
}
|
|
237
351
|
/**
|
|
238
352
|
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
|
|
239
353
|
* This should be used to only fetch the witness map for the main function.
|
|
@@ -329,20 +443,6 @@ module.exports.executeProgram = function(program, initial_witness, foreign_call_
|
|
|
329
443
|
return ret;
|
|
330
444
|
};
|
|
331
445
|
|
|
332
|
-
/**
|
|
333
|
-
* Sets the package's logging level.
|
|
334
|
-
*
|
|
335
|
-
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
336
|
-
*/
|
|
337
|
-
module.exports.initLogLevel = function(filter) {
|
|
338
|
-
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
339
|
-
const len0 = WASM_VECTOR_LEN;
|
|
340
|
-
const ret = wasm.initLogLevel(ptr0, len0);
|
|
341
|
-
if (ret[1]) {
|
|
342
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
|
|
346
446
|
/**
|
|
347
447
|
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
348
448
|
*
|
|
@@ -404,139 +504,38 @@ module.exports.getPublicWitness = function(program, solved_witness) {
|
|
|
404
504
|
};
|
|
405
505
|
|
|
406
506
|
/**
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
|
|
410
|
-
module.exports.buildInfo = function() {
|
|
411
|
-
const ret = wasm.buildInfo();
|
|
412
|
-
return ret;
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
417
|
-
* @param {string} lhs
|
|
418
|
-
* @param {string} rhs
|
|
419
|
-
* @returns {string}
|
|
420
|
-
*/
|
|
421
|
-
module.exports.and = function(lhs, rhs) {
|
|
422
|
-
const ret = wasm.and(lhs, rhs);
|
|
423
|
-
return ret;
|
|
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}
|
|
478
|
-
*/
|
|
479
|
-
module.exports.blake2s256 = function(inputs) {
|
|
480
|
-
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
481
|
-
const len0 = WASM_VECTOR_LEN;
|
|
482
|
-
const ret = wasm.blake2s256(ptr0, len0);
|
|
483
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
484
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
485
|
-
return v2;
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
490
|
-
* @param {Uint8Array} hashed_msg
|
|
491
|
-
* @param {Uint8Array} public_key_x_bytes
|
|
492
|
-
* @param {Uint8Array} public_key_y_bytes
|
|
493
|
-
* @param {Uint8Array} signature
|
|
494
|
-
* @returns {boolean}
|
|
507
|
+
* Sets the package's logging level.
|
|
508
|
+
*
|
|
509
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
495
510
|
*/
|
|
496
|
-
module.exports.
|
|
497
|
-
const ptr0 =
|
|
511
|
+
module.exports.initLogLevel = function(filter) {
|
|
512
|
+
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
498
513
|
const len0 = WASM_VECTOR_LEN;
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
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;
|
|
514
|
+
const ret = wasm.initLogLevel(ptr0, len0);
|
|
515
|
+
if (ret[1]) {
|
|
516
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
517
|
+
}
|
|
507
518
|
};
|
|
508
519
|
|
|
509
520
|
/**
|
|
510
|
-
*
|
|
511
|
-
* @
|
|
512
|
-
* @param {Uint8Array} public_key_x_bytes
|
|
513
|
-
* @param {Uint8Array} public_key_y_bytes
|
|
514
|
-
* @param {Uint8Array} signature
|
|
515
|
-
* @returns {boolean}
|
|
521
|
+
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
522
|
+
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
516
523
|
*/
|
|
517
|
-
module.exports.
|
|
518
|
-
const
|
|
519
|
-
|
|
520
|
-
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
521
|
-
const len1 = WASM_VECTOR_LEN;
|
|
522
|
-
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
523
|
-
const len2 = WASM_VECTOR_LEN;
|
|
524
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
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;
|
|
524
|
+
module.exports.buildInfo = function() {
|
|
525
|
+
const ret = wasm.buildInfo();
|
|
526
|
+
return ret;
|
|
528
527
|
};
|
|
529
528
|
|
|
530
529
|
function __wbg_adapter_30(arg0, arg1, arg2) {
|
|
531
|
-
wasm.
|
|
530
|
+
wasm.closure580_externref_shim(arg0, arg1, arg2);
|
|
532
531
|
}
|
|
533
532
|
|
|
534
533
|
function __wbg_adapter_89(arg0, arg1, arg2, arg3, arg4) {
|
|
535
|
-
wasm.
|
|
534
|
+
wasm.closure1175_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.closure1179_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_wrapper1960 = function(arg0, arg1, arg2) {
|
|
817
|
+
const ret = makeMutClosure(arg0, arg1, 581, __wbg_adapter_30);
|
|
819
818
|
return ret;
|
|
820
819
|
};
|
|
821
820
|
|
package/nodejs/acvm_js_bg.wasm
CHANGED
|
Binary file
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
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;
|
|
4
10
|
export const compressWitness: (a: any) => [number, number, number, number];
|
|
5
11
|
export const decompressWitness: (a: number, b: number) => [number, number, number];
|
|
6
12
|
export const compressWitnessStack: (a: any) => [number, number, number, number];
|
|
@@ -8,17 +14,11 @@ export const decompressWitnessStack: (a: number, b: number) => [number, number,
|
|
|
8
14
|
export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
|
|
9
15
|
export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
|
|
10
16
|
export const executeProgram: (a: number, b: number, c: any, d: any) => any;
|
|
11
|
-
export const initLogLevel: (a: number, b: number) => [number, number];
|
|
12
17
|
export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
13
18
|
export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
14
19
|
export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
20
|
+
export const initLogLevel: (a: number, b: number) => [number, number];
|
|
15
21
|
export const buildInfo: () => any;
|
|
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;
|
|
@@ -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 closure580_externref_shim: (a: number, b: number, c: any) => void;
|
|
31
|
+
export const closure1175_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
|
|
32
|
+
export const closure1179_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,5 +1,29 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
5
|
+
*/
|
|
6
|
+
export function and(lhs: string, rhs: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
9
|
+
*/
|
|
10
|
+
export function xor(lhs: string, rhs: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Sha256 compression function
|
|
13
|
+
*/
|
|
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;
|
|
3
27
|
/**
|
|
4
28
|
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
5
29
|
*
|
|
@@ -57,12 +81,6 @@ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_wit
|
|
|
57
81
|
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
58
82
|
*/
|
|
59
83
|
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
|
|
60
|
-
/**
|
|
61
|
-
* Sets the package's logging level.
|
|
62
|
-
*
|
|
63
|
-
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
64
|
-
*/
|
|
65
|
-
export function initLogLevel(filter: string): void;
|
|
66
84
|
/**
|
|
67
85
|
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
68
86
|
*
|
|
@@ -87,63 +105,17 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
|
|
|
87
105
|
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
88
106
|
*/
|
|
89
107
|
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
108
|
+
/**
|
|
109
|
+
* Sets the package's logging level.
|
|
110
|
+
*
|
|
111
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
112
|
+
*/
|
|
113
|
+
export function initLogLevel(filter: string): void;
|
|
90
114
|
/**
|
|
91
115
|
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
92
116
|
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
93
117
|
*/
|
|
94
118
|
export function buildInfo(): BuildInfo;
|
|
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
|
-
|
|
120
|
-
export type RawAssertionPayload = {
|
|
121
|
-
selector: string;
|
|
122
|
-
data: string[];
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export type ExecutionError = Error & {
|
|
126
|
-
callStack?: string[];
|
|
127
|
-
rawAssertionPayload?: RawAssertionPayload;
|
|
128
|
-
acirFunctionId?: number;
|
|
129
|
-
brilligFunctionId?: number;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
|
|
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
119
|
|
|
148
120
|
// Map from witness index to hex string value of witness.
|
|
149
121
|
export type WitnessMap = Map<number, string>;
|
|
@@ -169,6 +141,34 @@ export type WitnessStack = Array<StackItem>;
|
|
|
169
141
|
|
|
170
142
|
|
|
171
143
|
|
|
144
|
+
export type ForeignCallInput = string[]
|
|
145
|
+
export type ForeignCallOutput = string | string[]
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* A callback which performs an foreign call and returns the response.
|
|
149
|
+
* @callback ForeignCallHandler
|
|
150
|
+
* @param {string} name - The identifier for the type of foreign call being performed.
|
|
151
|
+
* @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
|
|
152
|
+
* @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
|
|
153
|
+
*/
|
|
154
|
+
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
export type RawAssertionPayload = {
|
|
159
|
+
selector: string;
|
|
160
|
+
data: string[];
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export type ExecutionError = Error & {
|
|
164
|
+
callStack?: string[];
|
|
165
|
+
rawAssertionPayload?: RawAssertionPayload;
|
|
166
|
+
acirFunctionId?: number;
|
|
167
|
+
brilligFunctionId?: number;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
172
|
/**
|
|
173
173
|
* @typedef {Object} BuildInfo - Information about how the installed package was built
|
|
174
174
|
* @property {string} gitHash - The hash of the git commit from which the package was built.
|
|
@@ -187,6 +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 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;
|
|
190
196
|
readonly compressWitness: (a: any) => [number, number, number, number];
|
|
191
197
|
readonly decompressWitness: (a: number, b: number) => [number, number, number];
|
|
192
198
|
readonly compressWitnessStack: (a: any) => [number, number, number, number];
|
|
@@ -194,17 +200,11 @@ export interface InitOutput {
|
|
|
194
200
|
readonly executeCircuit: (a: number, b: number, c: any, d: any) => any;
|
|
195
201
|
readonly executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
|
|
196
202
|
readonly executeProgram: (a: number, b: number, c: any, d: any) => any;
|
|
197
|
-
readonly initLogLevel: (a: number, b: number) => [number, number];
|
|
198
203
|
readonly getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
199
204
|
readonly getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
200
205
|
readonly getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
206
|
+
readonly initLogLevel: (a: number, b: number) => [number, number];
|
|
201
207
|
readonly buildInfo: () => any;
|
|
202
|
-
readonly and: (a: any, b: any) => any;
|
|
203
|
-
readonly xor: (a: any, b: any) => any;
|
|
204
|
-
readonly sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
|
|
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;
|
|
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 closure580_externref_shim: (a: number, b: number, c: any) => void;
|
|
217
|
+
readonly closure1175_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
|
|
218
|
+
readonly closure1179_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,17 +197,137 @@ 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
|
+
}
|
|
200
210
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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
|
+
}
|
|
258
|
+
|
|
259
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
260
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
261
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
262
|
+
WASM_VECTOR_LEN = arg.length;
|
|
263
|
+
return ptr;
|
|
205
264
|
}
|
|
206
265
|
|
|
207
266
|
function getArrayU8FromWasm0(ptr, len) {
|
|
208
267
|
ptr = ptr >>> 0;
|
|
209
268
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
210
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
272
|
+
* @param {Uint8Array} inputs
|
|
273
|
+
* @returns {Uint8Array}
|
|
274
|
+
*/
|
|
275
|
+
export function blake2s256(inputs) {
|
|
276
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
277
|
+
const len0 = WASM_VECTOR_LEN;
|
|
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;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
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}
|
|
291
|
+
*/
|
|
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);
|
|
294
|
+
const len0 = WASM_VECTOR_LEN;
|
|
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;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
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}
|
|
312
|
+
*/
|
|
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);
|
|
315
|
+
const len0 = WASM_VECTOR_LEN;
|
|
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;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function takeFromExternrefTable0(idx) {
|
|
327
|
+
const value = wasm.__wbindgen_export_2.get(idx);
|
|
328
|
+
wasm.__externref_table_dealloc(idx);
|
|
329
|
+
return value;
|
|
330
|
+
}
|
|
211
331
|
/**
|
|
212
332
|
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
213
333
|
*
|
|
@@ -224,12 +344,6 @@ export function compressWitness(witness_map) {
|
|
|
224
344
|
return v1;
|
|
225
345
|
}
|
|
226
346
|
|
|
227
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
228
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
229
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
230
|
-
WASM_VECTOR_LEN = arg.length;
|
|
231
|
-
return ptr;
|
|
232
|
-
}
|
|
233
347
|
/**
|
|
234
348
|
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
|
|
235
349
|
* This should be used to only fetch the witness map for the main function.
|
|
@@ -325,20 +439,6 @@ export function executeProgram(program, initial_witness, foreign_call_handler) {
|
|
|
325
439
|
return ret;
|
|
326
440
|
}
|
|
327
441
|
|
|
328
|
-
/**
|
|
329
|
-
* Sets the package's logging level.
|
|
330
|
-
*
|
|
331
|
-
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
332
|
-
*/
|
|
333
|
-
export function initLogLevel(filter) {
|
|
334
|
-
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
335
|
-
const len0 = WASM_VECTOR_LEN;
|
|
336
|
-
const ret = wasm.initLogLevel(ptr0, len0);
|
|
337
|
-
if (ret[1]) {
|
|
338
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
442
|
/**
|
|
343
443
|
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
344
444
|
*
|
|
@@ -400,139 +500,38 @@ export function getPublicWitness(program, solved_witness) {
|
|
|
400
500
|
}
|
|
401
501
|
|
|
402
502
|
/**
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
|
|
406
|
-
export function buildInfo() {
|
|
407
|
-
const ret = wasm.buildInfo();
|
|
408
|
-
return ret;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
413
|
-
* @param {string} lhs
|
|
414
|
-
* @param {string} rhs
|
|
415
|
-
* @returns {string}
|
|
416
|
-
*/
|
|
417
|
-
export function and(lhs, rhs) {
|
|
418
|
-
const ret = wasm.and(lhs, rhs);
|
|
419
|
-
return ret;
|
|
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}
|
|
474
|
-
*/
|
|
475
|
-
export function blake2s256(inputs) {
|
|
476
|
-
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
477
|
-
const len0 = WASM_VECTOR_LEN;
|
|
478
|
-
const ret = wasm.blake2s256(ptr0, len0);
|
|
479
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
480
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
481
|
-
return v2;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
486
|
-
* @param {Uint8Array} hashed_msg
|
|
487
|
-
* @param {Uint8Array} public_key_x_bytes
|
|
488
|
-
* @param {Uint8Array} public_key_y_bytes
|
|
489
|
-
* @param {Uint8Array} signature
|
|
490
|
-
* @returns {boolean}
|
|
503
|
+
* Sets the package's logging level.
|
|
504
|
+
*
|
|
505
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
491
506
|
*/
|
|
492
|
-
export function
|
|
493
|
-
const ptr0 =
|
|
507
|
+
export function initLogLevel(filter) {
|
|
508
|
+
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
494
509
|
const len0 = WASM_VECTOR_LEN;
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
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;
|
|
510
|
+
const ret = wasm.initLogLevel(ptr0, len0);
|
|
511
|
+
if (ret[1]) {
|
|
512
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
513
|
+
}
|
|
503
514
|
}
|
|
504
515
|
|
|
505
516
|
/**
|
|
506
|
-
*
|
|
507
|
-
* @
|
|
508
|
-
* @param {Uint8Array} public_key_x_bytes
|
|
509
|
-
* @param {Uint8Array} public_key_y_bytes
|
|
510
|
-
* @param {Uint8Array} signature
|
|
511
|
-
* @returns {boolean}
|
|
517
|
+
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
518
|
+
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
512
519
|
*/
|
|
513
|
-
export function
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
517
|
-
const len1 = WASM_VECTOR_LEN;
|
|
518
|
-
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
519
|
-
const len2 = WASM_VECTOR_LEN;
|
|
520
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
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;
|
|
520
|
+
export function buildInfo() {
|
|
521
|
+
const ret = wasm.buildInfo();
|
|
522
|
+
return ret;
|
|
524
523
|
}
|
|
525
524
|
|
|
526
525
|
function __wbg_adapter_30(arg0, arg1, arg2) {
|
|
527
|
-
wasm.
|
|
526
|
+
wasm.closure580_externref_shim(arg0, arg1, arg2);
|
|
528
527
|
}
|
|
529
528
|
|
|
530
529
|
function __wbg_adapter_89(arg0, arg1, arg2, arg3, arg4) {
|
|
531
|
-
wasm.
|
|
530
|
+
wasm.closure1175_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.closure1179_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_wrapper1960 = function(arg0, arg1, arg2) {
|
|
801
|
+
const ret = makeMutClosure(arg0, arg1, 581, __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,6 +1,12 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
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;
|
|
4
10
|
export const compressWitness: (a: any) => [number, number, number, number];
|
|
5
11
|
export const decompressWitness: (a: number, b: number) => [number, number, number];
|
|
6
12
|
export const compressWitnessStack: (a: any) => [number, number, number, number];
|
|
@@ -8,17 +14,11 @@ export const decompressWitnessStack: (a: number, b: number) => [number, number,
|
|
|
8
14
|
export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
|
|
9
15
|
export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
|
|
10
16
|
export const executeProgram: (a: number, b: number, c: any, d: any) => any;
|
|
11
|
-
export const initLogLevel: (a: number, b: number) => [number, number];
|
|
12
17
|
export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
13
18
|
export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
14
19
|
export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
20
|
+
export const initLogLevel: (a: number, b: number) => [number, number];
|
|
15
21
|
export const buildInfo: () => any;
|
|
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;
|
|
@@ -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 closure580_externref_shim: (a: number, b: number, c: any) => void;
|
|
31
|
+
export const closure1175_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
|
|
32
|
+
export const closure1179_externref_shim: (a: number, b: number, c: any, d: any) => void;
|
|
33
33
|
export const __wbindgen_start: () => void;
|