@noir-lang/noir_js 0.22.0 → 0.23.0-2e32845.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.
@@ -4,6 +4,13 @@ exports.generateWitness = void 0;
4
4
  const noirc_abi_1 = require("@noir-lang/noirc_abi");
5
5
  const base64_decode_js_1 = require("./base64_decode.cjs");
6
6
  const acvm_js_1 = require("@noir-lang/acvm_js");
7
+ let solver;
8
+ const getSolver = () => {
9
+ if (!solver) {
10
+ solver = (0, acvm_js_1.createBlackBoxSolver)();
11
+ }
12
+ return solver;
13
+ };
7
14
  const defaultForeignCallHandler = async (name, args) => {
8
15
  if (name == 'print') {
9
16
  // By default we do not print anything for `print` foreign calls due to a need for formatting,
@@ -12,6 +19,13 @@ const defaultForeignCallHandler = async (name, args) => {
12
19
  // If a user needs to print values then they should provide a custom foreign call handler.
13
20
  return [];
14
21
  }
22
+ else if (name == 'assert_message') {
23
+ // By default we do not do anything for `assert_message` foreign calls due to a need for formatting,
24
+ // however we provide an empty response in order to not halt execution.
25
+ //
26
+ // If a user needs to use dynamic assertion messages then they should provide a custom foreign call handler.
27
+ return [];
28
+ }
15
29
  throw Error(`Unexpected oracle during execution: ${name}(${args.join(', ')})`);
16
30
  };
17
31
  // Generates the witnesses needed to feed into the chosen proving system
@@ -21,7 +35,7 @@ async function generateWitness(compiledProgram, inputs, foreignCallHandler = def
21
35
  // Execute the circuit to generate the rest of the witnesses and serialize
22
36
  // them into a Uint8Array.
23
37
  try {
24
- const solvedWitness = await (0, acvm_js_1.executeCircuit)((0, base64_decode_js_1.base64Decode)(compiledProgram.bytecode), witnessMap, foreignCallHandler);
38
+ const solvedWitness = await (0, acvm_js_1.executeCircuitWithBlackBoxSolver)(await getSolver(), (0, base64_decode_js_1.base64Decode)(compiledProgram.bytecode), witnessMap, foreignCallHandler);
25
39
  return solvedWitness;
26
40
  }
27
41
  catch (err) {
@@ -1,6 +1,13 @@
1
1
  import { abiEncode } from '@noir-lang/noirc_abi';
2
2
  import { base64Decode } from "./base64_decode.mjs";
3
- import { executeCircuit } from '@noir-lang/acvm_js';
3
+ import { createBlackBoxSolver, executeCircuitWithBlackBoxSolver, } from '@noir-lang/acvm_js';
4
+ let solver;
5
+ const getSolver = () => {
6
+ if (!solver) {
7
+ solver = createBlackBoxSolver();
8
+ }
9
+ return solver;
10
+ };
4
11
  const defaultForeignCallHandler = async (name, args) => {
5
12
  if (name == 'print') {
6
13
  // By default we do not print anything for `print` foreign calls due to a need for formatting,
@@ -9,6 +16,13 @@ const defaultForeignCallHandler = async (name, args) => {
9
16
  // If a user needs to print values then they should provide a custom foreign call handler.
10
17
  return [];
11
18
  }
19
+ else if (name == 'assert_message') {
20
+ // By default we do not do anything for `assert_message` foreign calls due to a need for formatting,
21
+ // however we provide an empty response in order to not halt execution.
22
+ //
23
+ // If a user needs to use dynamic assertion messages then they should provide a custom foreign call handler.
24
+ return [];
25
+ }
12
26
  throw Error(`Unexpected oracle during execution: ${name}(${args.join(', ')})`);
13
27
  };
14
28
  // Generates the witnesses needed to feed into the chosen proving system
@@ -18,7 +32,7 @@ export async function generateWitness(compiledProgram, inputs, foreignCallHandle
18
32
  // Execute the circuit to generate the rest of the witnesses and serialize
19
33
  // them into a Uint8Array.
20
34
  try {
21
- const solvedWitness = await executeCircuit(base64Decode(compiledProgram.bytecode), witnessMap, foreignCallHandler);
35
+ const solvedWitness = await executeCircuitWithBlackBoxSolver(await getSolver(), base64Decode(compiledProgram.bytecode), witnessMap, foreignCallHandler);
22
36
  return solvedWitness;
23
37
  }
24
38
  catch (err) {
package/package.json CHANGED
@@ -1,16 +1,25 @@
1
1
  {
2
2
  "name": "@noir-lang/noir_js",
3
- "collaborators": [
3
+ "contributors": [
4
4
  "The Noir Team <team@noir-lang.org>"
5
5
  ],
6
- "version": "0.22.0",
6
+ "version": "0.23.0-2e32845.nightly",
7
7
  "packageManager": "yarn@3.5.1",
8
8
  "license": "(MIT OR Apache-2.0)",
9
9
  "type": "module",
10
+ "homepage": "https://noir-lang.org/",
11
+ "repository": {
12
+ "url": "https://github.com/noir-lang/noir.git",
13
+ "directory": "tooling/noir_js",
14
+ "type": "git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/noir-lang/noir/issues"
18
+ },
10
19
  "dependencies": {
11
- "@noir-lang/acvm_js": "0.38.0",
12
- "@noir-lang/noirc_abi": "0.22.0",
13
- "@noir-lang/types": "0.22.0"
20
+ "@noir-lang/acvm_js": "0.39.0-2e32845.nightly",
21
+ "@noir-lang/noirc_abi": "0.23.0-2e32845.nightly",
22
+ "@noir-lang/types": "0.23.0-2e32845.nightly"
14
23
  },
15
24
  "files": [
16
25
  "lib",
@@ -28,7 +37,8 @@
28
37
  "scripts": {
29
38
  "dev": "tsc-multi --watch",
30
39
  "build": "tsc-multi",
31
- "test": "yarn test:node:esm && yarn test:node:cjs",
40
+ "test": "yarn test:compile_program && yarn test:node:esm && yarn test:node:cjs",
41
+ "test:compile_program": "./scripts/compile_test_programs.sh",
32
42
  "test:node:esm": "mocha --timeout 25000 --exit --config ./.mocharc.json",
33
43
  "test:node:cjs": "mocha --timeout 25000 --exit --config ./.mocharc.cjs.json",
34
44
  "prettier": "prettier 'src/**/*.ts'",