@noir-lang/acvm_js 1.0.0-beta.15-0ffef1c.nightly → 1.0.0-beta.15-87ab921.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.
@@ -28,30 +28,6 @@ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_wit
28
28
  * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
29
29
  */
30
30
  export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
31
- /**
32
- * Performs a bitwise AND operation between `lhs` and `rhs`
33
- */
34
- export function and(lhs: string, rhs: string): string;
35
- /**
36
- * Performs a bitwise XOR operation between `lhs` and `rhs`
37
- */
38
- export function xor(lhs: string, rhs: string): string;
39
- /**
40
- * Sha256 compression function
41
- */
42
- export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
43
- /**
44
- * Calculates the Blake2s256 hash of the input bytes
45
- */
46
- export function blake2s256(inputs: Uint8Array): Uint8Array;
47
- /**
48
- * Verifies a ECDSA signature over the secp256k1 curve.
49
- */
50
- export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
51
- /**
52
- * Verifies a ECDSA signature over the secp256r1 curve.
53
- */
54
- export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
55
31
  /**
56
32
  * Sets the package's logging level.
57
33
  *
@@ -116,27 +92,42 @@ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
116
92
  * @returns {WitnessStack} The decompressed witness stack.
117
93
  */
118
94
  export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
119
-
120
- export type ForeignCallInput = string[]
121
- export type ForeignCallOutput = string | string[]
122
-
123
95
  /**
124
- * A callback which performs an foreign call and returns the response.
125
- * @callback ForeignCallHandler
126
- * @param {string} name - The identifier for the type of foreign call being performed.
127
- * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
128
- * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
129
- */
130
- export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
131
-
132
-
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;
133
119
 
134
- export type StackItem = {
135
- index: number;
136
- witness: WitnessMap;
137
- }
120
+ export type RawAssertionPayload = {
121
+ selector: string;
122
+ data: string[];
123
+ };
138
124
 
139
- export type WitnessStack = Array<StackItem>;
125
+ export type ExecutionError = Error & {
126
+ callStack?: string[];
127
+ rawAssertionPayload?: RawAssertionPayload;
128
+ acirFunctionId?: number;
129
+ brilligFunctionId?: number;
130
+ };
140
131
 
141
132
 
142
133
 
@@ -155,20 +146,6 @@ export type SolvedAndReturnWitness = {
155
146
 
156
147
 
157
148
 
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
149
  /**
173
150
  * @typedef {Object} BuildInfo - Information about how the installed package was built
174
151
  * @property {string} gitHash - The hash of the git commit from which the package was built.
@@ -182,3 +159,26 @@ export type BuildInfo = {
182
159
  }
183
160
 
184
161
 
162
+
163
+ export type StackItem = {
164
+ index: number;
165
+ witness: WitnessMap;
166
+ }
167
+
168
+ export type WitnessStack = Array<StackItem>;
169
+
170
+
171
+
172
+ export type ForeignCallInput = string[]
173
+ export type ForeignCallOutput = string | string[]
174
+
175
+ /**
176
+ * A callback which performs an foreign call and returns the response.
177
+ * @callback ForeignCallHandler
178
+ * @param {string} name - The identifier for the type of foreign call being performed.
179
+ * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
180
+ * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
181
+ */
182
+ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
183
+
184
+
package/nodejs/acvm_js.js CHANGED
@@ -254,125 +254,6 @@ module.exports.executeProgram = function(program, initial_witness, foreign_call_
254
254
  return ret;
255
255
  };
256
256
 
257
- /**
258
- * Performs a bitwise AND operation between `lhs` and `rhs`
259
- * @param {string} lhs
260
- * @param {string} rhs
261
- * @returns {string}
262
- */
263
- module.exports.and = function(lhs, rhs) {
264
- const ret = wasm.and(lhs, rhs);
265
- return ret;
266
- };
267
-
268
- /**
269
- * Performs a bitwise XOR operation between `lhs` and `rhs`
270
- * @param {string} lhs
271
- * @param {string} rhs
272
- * @returns {string}
273
- */
274
- module.exports.xor = function(lhs, rhs) {
275
- const ret = wasm.xor(lhs, rhs);
276
- return ret;
277
- };
278
-
279
- let cachedUint32ArrayMemory0 = null;
280
-
281
- function getUint32ArrayMemory0() {
282
- if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
283
- cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
284
- }
285
- return cachedUint32ArrayMemory0;
286
- }
287
-
288
- function passArray32ToWasm0(arg, malloc) {
289
- const ptr = malloc(arg.length * 4, 4) >>> 0;
290
- getUint32ArrayMemory0().set(arg, ptr / 4);
291
- WASM_VECTOR_LEN = arg.length;
292
- return ptr;
293
- }
294
-
295
- function getArrayU32FromWasm0(ptr, len) {
296
- ptr = ptr >>> 0;
297
- return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
298
- }
299
- /**
300
- * Sha256 compression function
301
- * @param {Uint32Array} inputs
302
- * @param {Uint32Array} state
303
- * @returns {Uint32Array}
304
- */
305
- module.exports.sha256_compression = function(inputs, state) {
306
- const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
307
- const len0 = WASM_VECTOR_LEN;
308
- const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
309
- const len1 = WASM_VECTOR_LEN;
310
- const ret = wasm.sha256_compression(ptr0, len0, ptr1, len1);
311
- var v3 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
312
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
313
- return v3;
314
- };
315
-
316
- function getArrayU8FromWasm0(ptr, len) {
317
- ptr = ptr >>> 0;
318
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
319
- }
320
- /**
321
- * Calculates the Blake2s256 hash of the input bytes
322
- * @param {Uint8Array} inputs
323
- * @returns {Uint8Array}
324
- */
325
- module.exports.blake2s256 = function(inputs) {
326
- const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
327
- const len0 = WASM_VECTOR_LEN;
328
- const ret = wasm.blake2s256(ptr0, len0);
329
- var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
330
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
331
- return v2;
332
- };
333
-
334
- /**
335
- * Verifies a ECDSA signature over the secp256k1 curve.
336
- * @param {Uint8Array} hashed_msg
337
- * @param {Uint8Array} public_key_x_bytes
338
- * @param {Uint8Array} public_key_y_bytes
339
- * @param {Uint8Array} signature
340
- * @returns {boolean}
341
- */
342
- module.exports.ecdsa_secp256k1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
343
- const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
344
- const len0 = WASM_VECTOR_LEN;
345
- const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
346
- const len1 = WASM_VECTOR_LEN;
347
- const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
348
- const len2 = WASM_VECTOR_LEN;
349
- const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
350
- const len3 = WASM_VECTOR_LEN;
351
- const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
352
- return ret !== 0;
353
- };
354
-
355
- /**
356
- * Verifies a ECDSA signature over the secp256r1 curve.
357
- * @param {Uint8Array} hashed_msg
358
- * @param {Uint8Array} public_key_x_bytes
359
- * @param {Uint8Array} public_key_y_bytes
360
- * @param {Uint8Array} signature
361
- * @returns {boolean}
362
- */
363
- module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
364
- const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
365
- const len0 = WASM_VECTOR_LEN;
366
- const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
367
- const len1 = WASM_VECTOR_LEN;
368
- const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
369
- const len2 = WASM_VECTOR_LEN;
370
- const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
371
- const len3 = WASM_VECTOR_LEN;
372
- const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
373
- return ret !== 0;
374
- };
375
-
376
257
  function takeFromExternrefTable0(idx) {
377
258
  const value = wasm.__wbindgen_export_2.get(idx);
378
259
  wasm.__externref_table_dealloc(idx);
@@ -461,6 +342,10 @@ module.exports.buildInfo = function() {
461
342
  return ret;
462
343
  };
463
344
 
345
+ function getArrayU8FromWasm0(ptr, len) {
346
+ ptr = ptr >>> 0;
347
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
348
+ }
464
349
  /**
465
350
  * Compresses a `WitnessMap` into the binary format outputted by Nargo.
466
351
  *
@@ -526,6 +411,121 @@ module.exports.decompressWitnessStack = function(compressed_witness) {
526
411
  return takeFromExternrefTable0(ret[0]);
527
412
  };
528
413
 
414
+ /**
415
+ * Performs a bitwise AND operation between `lhs` and `rhs`
416
+ * @param {string} lhs
417
+ * @param {string} rhs
418
+ * @returns {string}
419
+ */
420
+ module.exports.and = function(lhs, rhs) {
421
+ const ret = wasm.and(lhs, rhs);
422
+ return ret;
423
+ };
424
+
425
+ /**
426
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
427
+ * @param {string} lhs
428
+ * @param {string} rhs
429
+ * @returns {string}
430
+ */
431
+ module.exports.xor = function(lhs, rhs) {
432
+ const ret = wasm.xor(lhs, rhs);
433
+ return ret;
434
+ };
435
+
436
+ let cachedUint32ArrayMemory0 = null;
437
+
438
+ function getUint32ArrayMemory0() {
439
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
440
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
441
+ }
442
+ return cachedUint32ArrayMemory0;
443
+ }
444
+
445
+ function passArray32ToWasm0(arg, malloc) {
446
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
447
+ getUint32ArrayMemory0().set(arg, ptr / 4);
448
+ WASM_VECTOR_LEN = arg.length;
449
+ return ptr;
450
+ }
451
+
452
+ function getArrayU32FromWasm0(ptr, len) {
453
+ ptr = ptr >>> 0;
454
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
455
+ }
456
+ /**
457
+ * Sha256 compression function
458
+ * @param {Uint32Array} inputs
459
+ * @param {Uint32Array} state
460
+ * @returns {Uint32Array}
461
+ */
462
+ module.exports.sha256_compression = function(inputs, state) {
463
+ const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
464
+ const len0 = WASM_VECTOR_LEN;
465
+ const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
466
+ const len1 = WASM_VECTOR_LEN;
467
+ const ret = wasm.sha256_compression(ptr0, len0, ptr1, len1);
468
+ var v3 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
469
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
470
+ return v3;
471
+ };
472
+
473
+ /**
474
+ * Calculates the Blake2s256 hash of the input bytes
475
+ * @param {Uint8Array} inputs
476
+ * @returns {Uint8Array}
477
+ */
478
+ module.exports.blake2s256 = function(inputs) {
479
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
480
+ const len0 = WASM_VECTOR_LEN;
481
+ const ret = wasm.blake2s256(ptr0, len0);
482
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
483
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
484
+ return v2;
485
+ };
486
+
487
+ /**
488
+ * Verifies a ECDSA signature over the secp256k1 curve.
489
+ * @param {Uint8Array} hashed_msg
490
+ * @param {Uint8Array} public_key_x_bytes
491
+ * @param {Uint8Array} public_key_y_bytes
492
+ * @param {Uint8Array} signature
493
+ * @returns {boolean}
494
+ */
495
+ module.exports.ecdsa_secp256k1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
496
+ const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
497
+ const len0 = WASM_VECTOR_LEN;
498
+ const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
499
+ const len1 = WASM_VECTOR_LEN;
500
+ const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
501
+ const len2 = WASM_VECTOR_LEN;
502
+ const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
503
+ const len3 = WASM_VECTOR_LEN;
504
+ const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
505
+ return ret !== 0;
506
+ };
507
+
508
+ /**
509
+ * Verifies a ECDSA signature over the secp256r1 curve.
510
+ * @param {Uint8Array} hashed_msg
511
+ * @param {Uint8Array} public_key_x_bytes
512
+ * @param {Uint8Array} public_key_y_bytes
513
+ * @param {Uint8Array} signature
514
+ * @returns {boolean}
515
+ */
516
+ module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
517
+ const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
518
+ const len0 = WASM_VECTOR_LEN;
519
+ const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
520
+ const len1 = WASM_VECTOR_LEN;
521
+ const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
522
+ const len2 = WASM_VECTOR_LEN;
523
+ const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
524
+ const len3 = WASM_VECTOR_LEN;
525
+ const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
526
+ return ret !== 0;
527
+ };
528
+
529
529
  function __wbg_adapter_30(arg0, arg1, arg2) {
530
530
  wasm.closure573_externref_shim(arg0, arg1, arg2);
531
531
  }
Binary file
@@ -4,12 +4,6 @@ export const memory: WebAssembly.Memory;
4
4
  export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
5
5
  export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
6
6
  export const executeProgram: (a: number, b: number, c: any, d: any) => any;
7
- export const and: (a: any, b: any) => any;
8
- export const xor: (a: any, b: any) => any;
9
- export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
10
- export const blake2s256: (a: number, b: number) => [number, number];
11
- export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
12
- export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
13
7
  export const initLogLevel: (a: number, b: number) => [number, number];
14
8
  export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
15
9
  export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
@@ -19,6 +13,12 @@ export const compressWitness: (a: any) => [number, number, number, number];
19
13
  export const decompressWitness: (a: number, b: number) => [number, number, number];
20
14
  export const compressWitnessStack: (a: any) => [number, number, number, number];
21
15
  export const decompressWitnessStack: (a: number, b: number) => [number, number, number];
16
+ export const and: (a: any, b: any) => any;
17
+ export const xor: (a: any, b: any) => any;
18
+ export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
19
+ export const blake2s256: (a: number, b: number) => [number, number];
20
+ export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
21
+ export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
22
22
  export const __wbindgen_exn_store: (a: number) => void;
23
23
  export const __externref_table_alloc: () => number;
24
24
  export const __wbindgen_export_2: WebAssembly.Table;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noir-lang/acvm_js",
3
- "version": "1.0.0-beta.15-0ffef1c.nightly",
3
+ "version": "1.0.0-beta.15-87ab921.nightly",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/web/acvm_js.d.ts CHANGED
@@ -28,30 +28,6 @@ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_wit
28
28
  * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
29
29
  */
30
30
  export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
31
- /**
32
- * Performs a bitwise AND operation between `lhs` and `rhs`
33
- */
34
- export function and(lhs: string, rhs: string): string;
35
- /**
36
- * Performs a bitwise XOR operation between `lhs` and `rhs`
37
- */
38
- export function xor(lhs: string, rhs: string): string;
39
- /**
40
- * Sha256 compression function
41
- */
42
- export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
43
- /**
44
- * Calculates the Blake2s256 hash of the input bytes
45
- */
46
- export function blake2s256(inputs: Uint8Array): Uint8Array;
47
- /**
48
- * Verifies a ECDSA signature over the secp256k1 curve.
49
- */
50
- export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
51
- /**
52
- * Verifies a ECDSA signature over the secp256r1 curve.
53
- */
54
- export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
55
31
  /**
56
32
  * Sets the package's logging level.
57
33
  *
@@ -116,27 +92,42 @@ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
116
92
  * @returns {WitnessStack} The decompressed witness stack.
117
93
  */
118
94
  export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
119
-
120
- export type ForeignCallInput = string[]
121
- export type ForeignCallOutput = string | string[]
122
-
123
95
  /**
124
- * A callback which performs an foreign call and returns the response.
125
- * @callback ForeignCallHandler
126
- * @param {string} name - The identifier for the type of foreign call being performed.
127
- * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
128
- * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
129
- */
130
- export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
131
-
132
-
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;
133
119
 
134
- export type StackItem = {
135
- index: number;
136
- witness: WitnessMap;
137
- }
120
+ export type RawAssertionPayload = {
121
+ selector: string;
122
+ data: string[];
123
+ };
138
124
 
139
- export type WitnessStack = Array<StackItem>;
125
+ export type ExecutionError = Error & {
126
+ callStack?: string[];
127
+ rawAssertionPayload?: RawAssertionPayload;
128
+ acirFunctionId?: number;
129
+ brilligFunctionId?: number;
130
+ };
140
131
 
141
132
 
142
133
 
@@ -155,20 +146,6 @@ export type SolvedAndReturnWitness = {
155
146
 
156
147
 
157
148
 
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
149
  /**
173
150
  * @typedef {Object} BuildInfo - Information about how the installed package was built
174
151
  * @property {string} gitHash - The hash of the git commit from which the package was built.
@@ -183,6 +160,29 @@ export type BuildInfo = {
183
160
 
184
161
 
185
162
 
163
+ export type StackItem = {
164
+ index: number;
165
+ witness: WitnessMap;
166
+ }
167
+
168
+ export type WitnessStack = Array<StackItem>;
169
+
170
+
171
+
172
+ export type ForeignCallInput = string[]
173
+ export type ForeignCallOutput = string | string[]
174
+
175
+ /**
176
+ * A callback which performs an foreign call and returns the response.
177
+ * @callback ForeignCallHandler
178
+ * @param {string} name - The identifier for the type of foreign call being performed.
179
+ * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
180
+ * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
181
+ */
182
+ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
183
+
184
+
185
+
186
186
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
187
187
 
188
188
  export interface InitOutput {
@@ -190,12 +190,6 @@ export interface InitOutput {
190
190
  readonly executeCircuit: (a: number, b: number, c: any, d: any) => any;
191
191
  readonly executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
192
192
  readonly executeProgram: (a: number, b: number, c: any, d: any) => any;
193
- readonly and: (a: any, b: any) => any;
194
- readonly xor: (a: any, b: any) => any;
195
- readonly sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
196
- readonly blake2s256: (a: number, b: number) => [number, number];
197
- readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
198
- readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
199
193
  readonly initLogLevel: (a: number, b: number) => [number, number];
200
194
  readonly getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
201
195
  readonly getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
@@ -205,6 +199,12 @@ export interface InitOutput {
205
199
  readonly decompressWitness: (a: number, b: number) => [number, number, number];
206
200
  readonly compressWitnessStack: (a: any) => [number, number, number, number];
207
201
  readonly decompressWitnessStack: (a: number, b: number) => [number, number, number];
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;
package/web/acvm_js.js CHANGED
@@ -250,125 +250,6 @@ export function executeProgram(program, initial_witness, foreign_call_handler) {
250
250
  return ret;
251
251
  }
252
252
 
253
- /**
254
- * Performs a bitwise AND operation between `lhs` and `rhs`
255
- * @param {string} lhs
256
- * @param {string} rhs
257
- * @returns {string}
258
- */
259
- export function and(lhs, rhs) {
260
- const ret = wasm.and(lhs, rhs);
261
- return ret;
262
- }
263
-
264
- /**
265
- * Performs a bitwise XOR operation between `lhs` and `rhs`
266
- * @param {string} lhs
267
- * @param {string} rhs
268
- * @returns {string}
269
- */
270
- export function xor(lhs, rhs) {
271
- const ret = wasm.xor(lhs, rhs);
272
- return ret;
273
- }
274
-
275
- let cachedUint32ArrayMemory0 = null;
276
-
277
- function getUint32ArrayMemory0() {
278
- if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
279
- cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
280
- }
281
- return cachedUint32ArrayMemory0;
282
- }
283
-
284
- function passArray32ToWasm0(arg, malloc) {
285
- const ptr = malloc(arg.length * 4, 4) >>> 0;
286
- getUint32ArrayMemory0().set(arg, ptr / 4);
287
- WASM_VECTOR_LEN = arg.length;
288
- return ptr;
289
- }
290
-
291
- function getArrayU32FromWasm0(ptr, len) {
292
- ptr = ptr >>> 0;
293
- return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
294
- }
295
- /**
296
- * Sha256 compression function
297
- * @param {Uint32Array} inputs
298
- * @param {Uint32Array} state
299
- * @returns {Uint32Array}
300
- */
301
- export function sha256_compression(inputs, state) {
302
- const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
303
- const len0 = WASM_VECTOR_LEN;
304
- const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
305
- const len1 = WASM_VECTOR_LEN;
306
- const ret = wasm.sha256_compression(ptr0, len0, ptr1, len1);
307
- var v3 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
308
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
309
- return v3;
310
- }
311
-
312
- function getArrayU8FromWasm0(ptr, len) {
313
- ptr = ptr >>> 0;
314
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
315
- }
316
- /**
317
- * Calculates the Blake2s256 hash of the input bytes
318
- * @param {Uint8Array} inputs
319
- * @returns {Uint8Array}
320
- */
321
- export function blake2s256(inputs) {
322
- const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
323
- const len0 = WASM_VECTOR_LEN;
324
- const ret = wasm.blake2s256(ptr0, len0);
325
- var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
326
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
327
- return v2;
328
- }
329
-
330
- /**
331
- * Verifies a ECDSA signature over the secp256k1 curve.
332
- * @param {Uint8Array} hashed_msg
333
- * @param {Uint8Array} public_key_x_bytes
334
- * @param {Uint8Array} public_key_y_bytes
335
- * @param {Uint8Array} signature
336
- * @returns {boolean}
337
- */
338
- export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
339
- const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
340
- const len0 = WASM_VECTOR_LEN;
341
- const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
342
- const len1 = WASM_VECTOR_LEN;
343
- const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
344
- const len2 = WASM_VECTOR_LEN;
345
- const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
346
- const len3 = WASM_VECTOR_LEN;
347
- const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
348
- return ret !== 0;
349
- }
350
-
351
- /**
352
- * Verifies a ECDSA signature over the secp256r1 curve.
353
- * @param {Uint8Array} hashed_msg
354
- * @param {Uint8Array} public_key_x_bytes
355
- * @param {Uint8Array} public_key_y_bytes
356
- * @param {Uint8Array} signature
357
- * @returns {boolean}
358
- */
359
- export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
360
- const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
361
- const len0 = WASM_VECTOR_LEN;
362
- const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
363
- const len1 = WASM_VECTOR_LEN;
364
- const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
365
- const len2 = WASM_VECTOR_LEN;
366
- const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
367
- const len3 = WASM_VECTOR_LEN;
368
- const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
369
- return ret !== 0;
370
- }
371
-
372
253
  function takeFromExternrefTable0(idx) {
373
254
  const value = wasm.__wbindgen_export_2.get(idx);
374
255
  wasm.__externref_table_dealloc(idx);
@@ -457,6 +338,10 @@ export function buildInfo() {
457
338
  return ret;
458
339
  }
459
340
 
341
+ function getArrayU8FromWasm0(ptr, len) {
342
+ ptr = ptr >>> 0;
343
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
344
+ }
460
345
  /**
461
346
  * Compresses a `WitnessMap` into the binary format outputted by Nargo.
462
347
  *
@@ -522,6 +407,121 @@ export function decompressWitnessStack(compressed_witness) {
522
407
  return takeFromExternrefTable0(ret[0]);
523
408
  }
524
409
 
410
+ /**
411
+ * Performs a bitwise AND operation between `lhs` and `rhs`
412
+ * @param {string} lhs
413
+ * @param {string} rhs
414
+ * @returns {string}
415
+ */
416
+ export function and(lhs, rhs) {
417
+ const ret = wasm.and(lhs, rhs);
418
+ return ret;
419
+ }
420
+
421
+ /**
422
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
423
+ * @param {string} lhs
424
+ * @param {string} rhs
425
+ * @returns {string}
426
+ */
427
+ export function xor(lhs, rhs) {
428
+ const ret = wasm.xor(lhs, rhs);
429
+ return ret;
430
+ }
431
+
432
+ let cachedUint32ArrayMemory0 = null;
433
+
434
+ function getUint32ArrayMemory0() {
435
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
436
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
437
+ }
438
+ return cachedUint32ArrayMemory0;
439
+ }
440
+
441
+ function passArray32ToWasm0(arg, malloc) {
442
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
443
+ getUint32ArrayMemory0().set(arg, ptr / 4);
444
+ WASM_VECTOR_LEN = arg.length;
445
+ return ptr;
446
+ }
447
+
448
+ function getArrayU32FromWasm0(ptr, len) {
449
+ ptr = ptr >>> 0;
450
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
451
+ }
452
+ /**
453
+ * Sha256 compression function
454
+ * @param {Uint32Array} inputs
455
+ * @param {Uint32Array} state
456
+ * @returns {Uint32Array}
457
+ */
458
+ export function sha256_compression(inputs, state) {
459
+ const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
460
+ const len0 = WASM_VECTOR_LEN;
461
+ const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
462
+ const len1 = WASM_VECTOR_LEN;
463
+ const ret = wasm.sha256_compression(ptr0, len0, ptr1, len1);
464
+ var v3 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
465
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
466
+ return v3;
467
+ }
468
+
469
+ /**
470
+ * Calculates the Blake2s256 hash of the input bytes
471
+ * @param {Uint8Array} inputs
472
+ * @returns {Uint8Array}
473
+ */
474
+ export function blake2s256(inputs) {
475
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
476
+ const len0 = WASM_VECTOR_LEN;
477
+ const ret = wasm.blake2s256(ptr0, len0);
478
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
479
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
480
+ return v2;
481
+ }
482
+
483
+ /**
484
+ * Verifies a ECDSA signature over the secp256k1 curve.
485
+ * @param {Uint8Array} hashed_msg
486
+ * @param {Uint8Array} public_key_x_bytes
487
+ * @param {Uint8Array} public_key_y_bytes
488
+ * @param {Uint8Array} signature
489
+ * @returns {boolean}
490
+ */
491
+ export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
492
+ const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
493
+ const len0 = WASM_VECTOR_LEN;
494
+ const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
495
+ const len1 = WASM_VECTOR_LEN;
496
+ const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
497
+ const len2 = WASM_VECTOR_LEN;
498
+ const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
499
+ const len3 = WASM_VECTOR_LEN;
500
+ const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
501
+ return ret !== 0;
502
+ }
503
+
504
+ /**
505
+ * Verifies a ECDSA signature over the secp256r1 curve.
506
+ * @param {Uint8Array} hashed_msg
507
+ * @param {Uint8Array} public_key_x_bytes
508
+ * @param {Uint8Array} public_key_y_bytes
509
+ * @param {Uint8Array} signature
510
+ * @returns {boolean}
511
+ */
512
+ export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
513
+ const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
514
+ const len0 = WASM_VECTOR_LEN;
515
+ const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
516
+ const len1 = WASM_VECTOR_LEN;
517
+ const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
518
+ const len2 = WASM_VECTOR_LEN;
519
+ const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
520
+ const len3 = WASM_VECTOR_LEN;
521
+ const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
522
+ return ret !== 0;
523
+ }
524
+
525
525
  function __wbg_adapter_30(arg0, arg1, arg2) {
526
526
  wasm.closure573_externref_shim(arg0, arg1, arg2);
527
527
  }
Binary file
@@ -4,12 +4,6 @@ export const memory: WebAssembly.Memory;
4
4
  export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
5
5
  export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
6
6
  export const executeProgram: (a: number, b: number, c: any, d: any) => any;
7
- export const and: (a: any, b: any) => any;
8
- export const xor: (a: any, b: any) => any;
9
- export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
10
- export const blake2s256: (a: number, b: number) => [number, number];
11
- export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
12
- export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
13
7
  export const initLogLevel: (a: number, b: number) => [number, number];
14
8
  export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
15
9
  export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
@@ -19,6 +13,12 @@ export const compressWitness: (a: any) => [number, number, number, number];
19
13
  export const decompressWitness: (a: number, b: number) => [number, number, number];
20
14
  export const compressWitnessStack: (a: any) => [number, number, number, number];
21
15
  export const decompressWitnessStack: (a: number, b: number) => [number, number, number];
16
+ export const and: (a: any, b: any) => any;
17
+ export const xor: (a: any, b: any) => any;
18
+ export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
19
+ export const blake2s256: (a: number, b: number) => [number, number];
20
+ export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
21
+ export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
22
22
  export const __wbindgen_exn_store: (a: number) => void;
23
23
  export const __externref_table_alloc: () => number;
24
24
  export const __wbindgen_export_2: WebAssembly.Table;