From 76ab555c7cec0d469844a5214086887a0a59530b Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Tue, 26 Sep 2023 11:43:10 +0100 Subject: [PATCH 1/7] chore: fix `acvm_js` linting and tests (#2834) --- .github/workflows/acvm-test-acvm-js.yml | 14 +----- acvm-repo/acvm_js/.eslintrc.js | 18 +------- .../test/browser/execute_circuit.test.ts | 22 +++++----- .../acvm_js/test/node/execute_circuit.test.ts | 24 +++++----- .../acvm_js/test/shared/schnorr_verify.ts | 2 +- acvm/acvm_js/Cargo.toml | 44 ------------------- 6 files changed, 27 insertions(+), 97 deletions(-) delete mode 100644 acvm/acvm_js/Cargo.toml diff --git a/.github/workflows/acvm-test-acvm-js.yml b/.github/workflows/acvm-test-acvm-js.yml index 1ba2369f780..d5a9dc07239 100644 --- a/.github/workflows/acvm-test-acvm-js.yml +++ b/.github/workflows/acvm-test-acvm-js.yml @@ -55,14 +55,9 @@ jobs: - name: Set up test environment uses: ./.github/actions/setup - with: - working-directory: ./acvm-repo/acvm_js - name: Run node tests - working-directory: ./acvm-repo/acvm_js - run: | - yarn - yarn test + run: yarn workspace @noir-lang/acvm_js test test-acvm_js-browser: needs: [build-acvm-js-package] @@ -81,17 +76,12 @@ jobs: - name: Set up test environment uses: ./.github/actions/setup - with: - working-directory: ./acvm-repo/acvm_js - name: Install playwright deps - working-directory: ./acvm-repo/acvm_js run: | npx playwright install npx playwright install-deps - name: Run browser tests working-directory: ./acvm-repo/acvm_js - run: | - yarn - yarn test:browser \ No newline at end of file + run: yarn workspace @noir-lang/acvm_js test:browser diff --git a/acvm-repo/acvm_js/.eslintrc.js b/acvm-repo/acvm_js/.eslintrc.js index b1346a8792f..33335c2a877 100644 --- a/acvm-repo/acvm_js/.eslintrc.js +++ b/acvm-repo/acvm_js/.eslintrc.js @@ -1,19 +1,3 @@ module.exports = { - root: true, - parser: "@typescript-eslint/parser", - plugins: ["@typescript-eslint", "prettier"], - extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"], - rules: { - "comma-spacing": ["error", { before: false, after: true }], - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": [ - "warn", // or "error" - { - argsIgnorePattern: "^_", - varsIgnorePattern: "^_", - caughtErrorsIgnorePattern: "^_", - }, - ], - "prettier/prettier": "error", - }, + extends: ["../../.eslintrc.js"], }; diff --git a/acvm-repo/acvm_js/test/browser/execute_circuit.test.ts b/acvm-repo/acvm_js/test/browser/execute_circuit.test.ts index 407aa830c65..280b08abed3 100644 --- a/acvm-repo/acvm_js/test/browser/execute_circuit.test.ts +++ b/acvm-repo/acvm_js/test/browser/execute_circuit.test.ts @@ -24,7 +24,7 @@ it("successfully executes circuit and extracts return value", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); // Solved witness should be consistent with initial witness @@ -50,7 +50,7 @@ it("successfully processes simple brillig foreign call opcodes", async () => { let observedInputs: string[][] = []; const foreignCallHandler: ForeignCallHandler = async ( name: string, - inputs: string[][] + inputs: string[][], ) => { // Throwing inside the oracle callback causes a timeout so we log the observed values // and defer the check against expected values until after the execution is complete. @@ -63,7 +63,7 @@ it("successfully processes simple brillig foreign call opcodes", async () => { const solved_witness: WitnessMap = await executeCircuit( bytecode, initialWitnessMap, - foreignCallHandler + foreignCallHandler, ); // Check that expected values were passed to oracle callback. @@ -89,7 +89,7 @@ it("successfully processes complex brillig foreign call opcodes", async () => { let observedInputs: string[][] = []; const foreignCallHandler: ForeignCallHandler = async ( name: string, - inputs: string[][] + inputs: string[][], ) => { // Throwing inside the oracle callback causes a timeout so we log the observed values // and defer the check against expected values until after the execution is complete. @@ -102,7 +102,7 @@ it("successfully processes complex brillig foreign call opcodes", async () => { const solved_witness: WitnessMap = await executeCircuit( bytecode, initialWitnessMap, - foreignCallHandler + foreignCallHandler, ); // Check that expected values were passed to oracle callback. @@ -124,7 +124,7 @@ it("successfully executes a Pedersen opcode", async function () { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -140,7 +140,7 @@ it("successfully executes a FixedBaseScalarMul opcode", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -156,7 +156,7 @@ it("successfully executes a SchnorrVerify opcode", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -172,7 +172,7 @@ it("successfully executes a MemoryOp opcode", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -194,7 +194,7 @@ it("successfully executes two circuits with same backend", async function () { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness0).to.be.deep.eq(expectedWitnessMap); @@ -205,7 +205,7 @@ it("successfully executes two circuits with same backend", async function () { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness1).to.be.deep.eq(expectedWitnessMap); }); diff --git a/acvm-repo/acvm_js/test/node/execute_circuit.test.ts b/acvm-repo/acvm_js/test/node/execute_circuit.test.ts index dac93b9f10c..0523d01b9ca 100644 --- a/acvm-repo/acvm_js/test/node/execute_circuit.test.ts +++ b/acvm-repo/acvm_js/test/node/execute_circuit.test.ts @@ -17,7 +17,7 @@ it("successfully executes circuit and extracts return value", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); // Solved witness should be consistent with initial witness @@ -43,7 +43,7 @@ it("successfully processes simple brillig foreign call opcodes", async () => { let observedInputs: string[][] = []; const foreignCallHandler: ForeignCallHandler = async ( name: string, - inputs: string[][] + inputs: string[][], ) => { // Throwing inside the oracle callback causes a timeout so we log the observed values // and defer the check against expected values until after the execution is complete. @@ -56,7 +56,7 @@ it("successfully processes simple brillig foreign call opcodes", async () => { const solved_witness: WitnessMap = await executeCircuit( bytecode, initialWitnessMap, - foreignCallHandler + foreignCallHandler, ); // Check that expected values were passed to oracle callback. @@ -82,7 +82,7 @@ it("successfully processes complex brillig foreign call opcodes", async () => { let observedInputs: string[][] = []; const foreignCallHandler: ForeignCallHandler = async ( name: string, - inputs: string[][] + inputs: string[][], ) => { // Throwing inside the oracle callback causes a timeout so we log the observed values // and defer the check against expected values until after the execution is complete. @@ -95,7 +95,7 @@ it("successfully processes complex brillig foreign call opcodes", async () => { const solved_witness: WitnessMap = await executeCircuit( bytecode, initialWitnessMap, - foreignCallHandler + foreignCallHandler, ); // Check that expected values were passed to oracle callback. @@ -118,7 +118,7 @@ it("successfully executes a Pedersen opcode", async function () { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -134,7 +134,7 @@ it("successfully executes a FixedBaseScalarMul opcode", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -150,7 +150,7 @@ it("successfully executes a SchnorrVerify opcode", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -166,7 +166,7 @@ it("successfully executes a MemoryOp opcode", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -190,7 +190,7 @@ it("successfully executes two circuits with same backend", async function () { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); const solvedWitness1 = await executeCircuitWithBlackBoxSolver( @@ -199,7 +199,7 @@ it("successfully executes two circuits with same backend", async function () { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness0).to.be.deep.eq(expectedWitnessMap); @@ -225,7 +225,7 @@ it("successfully executes 500 circuits with same backend", async function () { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); diff --git a/acvm-repo/acvm_js/test/shared/schnorr_verify.ts b/acvm-repo/acvm_js/test/shared/schnorr_verify.ts index fa91713474e..de9e61e757c 100644 --- a/acvm-repo/acvm_js/test/shared/schnorr_verify.ts +++ b/acvm-repo/acvm_js/test/shared/schnorr_verify.ts @@ -101,5 +101,5 @@ export const initialWitnessMap = new Map([ export const expectedWitnessMap = new Map(initialWitnessMap).set( 77, - "0x0000000000000000000000000000000000000000000000000000000000000001" + "0x0000000000000000000000000000000000000000000000000000000000000001", ); diff --git a/acvm/acvm_js/Cargo.toml b/acvm/acvm_js/Cargo.toml deleted file mode 100644 index 09f47b18edb..00000000000 --- a/acvm/acvm_js/Cargo.toml +++ /dev/null @@ -1,44 +0,0 @@ -[package] -name = "acvm_js" -description = "Typescript wrapper around the ACVM allowing execution of ACIR code" -# x-release-please-start-version -version = "0.27.0" -# x-release-please-end -authors.workspace = true -edition.workspace = true -license.workspace = true -rust-version.workspace = true -repository.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -crate-type = ["cdylib"] - -[dependencies] -cfg-if = "1.0.0" - -[target.'cfg(target_arch = "wasm32")'.dependencies] -acvm = { path = "../acvm", default-features = false } -barretenberg_blackbox_solver = { path = "../barretenberg_blackbox_solver", default-features = false } -wasm-bindgen = { version = "0.2.86", features = ["serde-serialize"] } -wasm-bindgen-futures = "0.4.36" -serde = { version = "1.0.136", features = ["derive"] } -log = "0.4.17" -wasm-logger = "0.2.0" -console_error_panic_hook = "0.1.7" -gloo-utils = { version = "0.1", features = ["serde"] } -js-sys = "0.3.62" -const-str = "0.5.5" - -[build-dependencies] -build-data = "0.1.3" -pkg-config = "0.3" - -[dev-dependencies] -wasm-bindgen-test = "0.3.36" - -[features] -default = ["bn254"] -bn254 = ["acvm/bn254", "barretenberg_blackbox_solver/bn254"] -bls12_381 = ["acvm/bls12_381", "barretenberg_blackbox_solver/bls12_381"] From 57d3f376d9ceadb75caf37a2bfc0e9394f76bfe6 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Tue, 26 Sep 2023 12:28:57 +0100 Subject: [PATCH 2/7] chore!: `generateWitness` now returns a serialized witness file (#2842) --- tooling/noir_js/src/witness_generation.ts | 6 ++++-- tooling/noir_js/test/node/e2e.test.ts | 14 +++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tooling/noir_js/src/witness_generation.ts b/tooling/noir_js/src/witness_generation.ts index d72033b275a..bce95ba0c5c 100644 --- a/tooling/noir_js/src/witness_generation.ts +++ b/tooling/noir_js/src/witness_generation.ts @@ -2,6 +2,7 @@ import { abiEncode } from '@noir-lang/noirc_abi'; import { validateInputs } from './input_validation.js'; import { base64Decode } from './base64_decode.js'; import { WitnessMap, executeCircuit } from '@noir-lang/acvm_js'; +import { witnessMapToUint8Array } from './serialize.js'; // Generates the witnesses needed to feed into the chosen proving system export async function generateWitness(compiledProgram, inputs): Promise { @@ -12,12 +13,13 @@ export async function generateWitness(compiledProgram, inputs): Promise { throw Error('unexpected oracle during execution'); }); - return solvedWitness; + return witnessMapToUint8Array(solvedWitness); } catch (err) { throw new Error(`Circuit execution failed: ${err}`); } diff --git a/tooling/noir_js/test/node/e2e.test.ts b/tooling/noir_js/test/node/e2e.test.ts index ddd91cca834..18413074871 100644 --- a/tooling/noir_js/test/node/e2e.test.ts +++ b/tooling/noir_js/test/node/e2e.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import assert_lt_json from '../noir_compiled_examples/assert_lt/target/assert_lt.json' assert { type: 'json' }; -import { generateWitness, witnessMapToUint8Array } from '../../src/index.js'; +import { generateWitness } from '../../src/index.js'; import { Backend } from '../backend/barretenberg.js'; it('end-to-end proof creation and verification (outer)', async () => { @@ -9,14 +9,13 @@ it('end-to-end proof creation and verification (outer)', async () => { x: '2', y: '3', }; - const solvedWitness = await generateWitness(assert_lt_json, inputs); + const serializedWitness = await generateWitness(assert_lt_json, inputs); // bb.js part // // Proof creation const prover = new Backend(assert_lt_json.bytecode); await prover.init(); - const serializedWitness = witnessMapToUint8Array(solvedWitness); const proof = await prover.generateOuterProof(serializedWitness); // Proof verification @@ -30,14 +29,13 @@ it('end-to-end proof creation and verification (inner)', async () => { x: '2', y: '3', }; - const solvedWitness = await generateWitness(assert_lt_json, inputs); + const serializedWitness = await generateWitness(assert_lt_json, inputs); // bb.js part // // Proof creation const prover = new Backend(assert_lt_json.bytecode); await prover.init(); - const serializedWitness = witnessMapToUint8Array(solvedWitness); const proof = await prover.generateInnerProof(serializedWitness); // Proof verification @@ -63,13 +61,12 @@ it('[BUG] -- bb.js null function or function signature mismatch (different insta x: '2', y: '3', }; - const solvedWitness = await generateWitness(assert_lt_json, inputs); + const serializedWitness = await generateWitness(assert_lt_json, inputs); // bb.js part const prover = new Backend(assert_lt_json.bytecode); await prover.init(); - const serializedWitness = witnessMapToUint8Array(solvedWitness); const proof = await prover.generateOuterProof(serializedWitness); try { @@ -98,7 +95,7 @@ it('[BUG] -- bb.js null function or function signature mismatch (outer-inner) ', x: '2', y: '3', }; - const solvedWitness = await generateWitness(assert_lt_json, inputs); + const serializedWitness = await generateWitness(assert_lt_json, inputs); // bb.js part // @@ -106,7 +103,6 @@ it('[BUG] -- bb.js null function or function signature mismatch (outer-inner) ', // const prover = new Backend(assert_lt_json.bytecode); await prover.init(); - const serializedWitness = witnessMapToUint8Array(solvedWitness); // Create a proof using both proving systems, the majority of the time // one would only use outer proofs. const proofOuter = await prover.generateOuterProof(serializedWitness); From 7006a83662986ad7b406bf882210b52ee5e5f20f Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Tue, 26 Sep 2023 13:03:30 +0100 Subject: [PATCH 3/7] chore: delete unnecessary nix files (#2840) --- acvm-repo/.envrc | 20 ---- acvm-repo/.gitignore | 1 - acvm-repo/flake.lock | 132 ------------------------- acvm-repo/flake.nix | 231 ------------------------------------------- 4 files changed, 384 deletions(-) delete mode 100644 acvm-repo/.envrc delete mode 100644 acvm-repo/flake.lock delete mode 100644 acvm-repo/flake.nix diff --git a/acvm-repo/.envrc b/acvm-repo/.envrc deleted file mode 100644 index 494e7adf16c..00000000000 --- a/acvm-repo/.envrc +++ /dev/null @@ -1,20 +0,0 @@ -# Based on https://github.com/direnv/direnv-vscode/blob/158e8302c2594cc0eaa5f8b4f0cafedd4e1c0315/.envrc - -# You can define your system-specific logic (like Git settings or GH tokens) in .envrc.local -# If that logic is usable by other people and might improve development environment, consider -# contributing it to this file! - -source_env_if_exists .envrc.local - -if [[ -z "${SKIP_NIX:-}" ]] && has nix; then - - if nix flake metadata &>/dev/null && has use_flake; then - # use flakes if possible - use flake - - else - # Otherwise fall back to pure nix - use nix - fi - -fi \ No newline at end of file diff --git a/acvm-repo/.gitignore b/acvm-repo/.gitignore index 54178440f50..e6cd42a8496 100644 --- a/acvm-repo/.gitignore +++ b/acvm-repo/.gitignore @@ -4,4 +4,3 @@ # Cargo.lock result outputs/ -.direnv \ No newline at end of file diff --git a/acvm-repo/flake.lock b/acvm-repo/flake.lock deleted file mode 100644 index 84fbe2e9edf..00000000000 --- a/acvm-repo/flake.lock +++ /dev/null @@ -1,132 +0,0 @@ -{ - "nodes": { - "crane": { - "inputs": { - "flake-compat": [ - "flake-compat" - ], - "flake-utils": [ - "flake-utils" - ], - "nixpkgs": [ - "nixpkgs" - ], - "rust-overlay": [ - "rust-overlay" - ] - }, - "locked": { - "lastModified": 1688772518, - "narHash": "sha256-ol7gZxwvgLnxNSZwFTDJJ49xVY5teaSvF7lzlo3YQfM=", - "owner": "ipetkov", - "repo": "crane", - "rev": "8b08e96c9af8c6e3a2b69af5a7fa168750fcf88e", - "type": "github" - }, - "original": { - "owner": "ipetkov", - "repo": "crane", - "type": "github" - } - }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1689068808, - "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1688392541, - "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-22.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "crane": "crane", - "flake-compat": "flake-compat", - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" - } - }, - "rust-overlay": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1690338181, - "narHash": "sha256-Sz2oQ9aNS3MVncnCMndr0302G26UrFUfPynoH2iLjsg=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "b7f0b7b58b3c6f14a1377ec31a3d78b23ab843ec", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/acvm-repo/flake.nix b/acvm-repo/flake.nix deleted file mode 100644 index 0491d855a43..00000000000 --- a/acvm-repo/flake.nix +++ /dev/null @@ -1,231 +0,0 @@ -{ - description = "Javascript bindings for the ACVM"; - - inputs = { - nixpkgs = { - url = "github:NixOS/nixpkgs/nixos-22.11"; - }; - - flake-utils = { - url = "github:numtide/flake-utils"; - }; - - flake-compat = { - url = "github:edolstra/flake-compat"; - flake = false; - }; - - rust-overlay = { - url = "github:oxalica/rust-overlay"; - # All of these inputs (a.k.a. dependencies) need to align with inputs we - # use so they use the `inputs.*.follows` syntax to reference our inputs - inputs = { - nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; - }; - }; - - crane = { - url = "github:ipetkov/crane"; - # All of these inputs (a.k.a. dependencies) need to align with inputs we - # use so they use the `inputs.*.follows` syntax to reference our inputs - inputs = { - nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; - flake-compat.follows = "flake-compat"; - rust-overlay.follows = "rust-overlay"; - }; - }; - }; - - outputs = - { self, nixpkgs, crane, flake-utils, rust-overlay, ... }: #, barretenberg - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { - inherit system; - overlays = [ - rust-overlay.overlays.default - ]; - }; - - rustToolchain = pkgs.rust-bin.stable."1.66.0".default.override { - # We include rust-src to ensure rust-analyzer works. - # See https://discourse.nixos.org/t/rust-src-not-found-and-other-misadventures-of-developing-rust-on-nixos/11570/4 - extensions = [ "rust-src" ]; - targets = [ "wasm32-unknown-unknown" ] - ++ pkgs.lib.optional (pkgs.hostPlatform.isx86_64 && pkgs.hostPlatform.isLinux) "x86_64-unknown-linux-gnu" - ++ pkgs.lib.optional (pkgs.hostPlatform.isAarch64 && pkgs.hostPlatform.isLinux) "aarch64-unknown-linux-gnu" - ++ pkgs.lib.optional (pkgs.hostPlatform.isx86_64 && pkgs.hostPlatform.isDarwin) "x86_64-apple-darwin" - ++ pkgs.lib.optional (pkgs.hostPlatform.isAarch64 && pkgs.hostPlatform.isDarwin) "aarch64-apple-darwin"; - }; - - craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; - - crateACVMJSDefinitions = craneLib.crateNameFromCargoToml { - cargoToml = ./acvm_js/Cargo.toml; - }; - - crateACVMDefinitions = craneLib.crateNameFromCargoToml { - cargoToml = ./acvm/Cargo.toml; - }; - - - sharedEnvironment = { - # Barretenberg fails if tests are run on multiple threads, so we set the test thread - # count to 1 throughout the entire project - # - # Note: Setting this allows for consistent behavior across build and shells, but is mostly - # hidden from the developer - i.e. when they see the command being run via `nix flake check` - # RUST_TEST_THREADS = "1"; - BARRETENBERG_ARCHIVE = builtins.fetchurl { - url = "https://github.com/AztecProtocol/barretenberg/releases/download/barretenberg-v0.4.5/acvm_backend.wasm.tar.gz"; - sha256 = "sha256:0z24yhvxc0dr13xj7y4xs9p42lzxwpazrmsrdpcgynfajkk6vqy4"; - }; - }; - - wasmEnvironment = sharedEnvironment // { }; - - sourceFilter = path: type: - (craneLib.filterCargoSources path type); - - # The `self.rev` property is only available when the working tree is not dirty - GIT_COMMIT = if (self ? rev) then self.rev else "unknown"; - GIT_DIRTY = if (self ? rev) then "false" else "true"; - - extraBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [ - # Need libiconv and apple Security on Darwin. See https://github.com/ipetkov/crane/issues/156 - pkgs.libiconv - pkgs.darwin.apple_sdk.frameworks.Security - ]; - - commonArgs = { - inherit (crateACVMDefinitions) pname version; - src = pkgs.lib.cleanSourceWith { - src = craneLib.path { - path = ./.; - }; - filter = sourceFilter; - }; - - cargoClippyExtraArgs = "--package acvm_js --all-targets -- -D warnings"; - cargoTestExtraArgs = "--workspace"; - - # We don't want to run checks or tests when just building the project - doCheck = false; - }; - - # Combine the environment and other configuration needed for crane to build with the wasm feature - acvmjsWasmArgs = wasmEnvironment // commonArgs // { - - inherit (crateACVMJSDefinitions) pname version; - - cargoExtraArgs = "--package acvm_js --target=wasm32-unknown-unknown"; - - cargoVendorDir = craneLib.vendorCargoDeps { - src = ./.; - }; - - buildInputs = [ ] ++ extraBuildInputs; - - }; - - # Build *just* the cargo dependencies, so we can reuse all of that work between runs - cargo-artifacts = craneLib.buildDepsOnly commonArgs; - - wasm-bindgen-cli = pkgs.callPackage ./acvm_js/nix/wasm-bindgen-cli/default.nix { - rustPlatform = pkgs.makeRustPlatform { - rustc = rustToolchain; - cargo = rustToolchain; - }; - }; - - in - rec { - checks = { - - cargo-clippy = craneLib.cargoClippy (commonArgs // sharedEnvironment // { - inherit GIT_COMMIT GIT_DIRTY; - - cargoArtifacts = cargo-artifacts; - doCheck = true; - }); - - cargo-test = craneLib.cargoTest (commonArgs // sharedEnvironment // { - inherit GIT_COMMIT GIT_DIRTY; - - cargoArtifacts = cargo-artifacts; - doCheck = true; - }); - - cargo-fmt = craneLib.cargoFmt (commonArgs // sharedEnvironment // { - inherit GIT_COMMIT GIT_DIRTY; - - cargoArtifacts = cargo-artifacts; - doCheck = true; - }); - - }; - - packages = { - default = craneLib.mkCargoDerivation (acvmjsWasmArgs // rec { - - cargoArtifacts = cargo-artifacts; - - inherit GIT_COMMIT; - inherit GIT_DIRTY; - - COMMIT_SHORT = builtins.substring 0 7 GIT_COMMIT; - VERSION_APPENDIX = if GIT_DIRTY == "true" then "-dirty" else ""; - - src = ./.; #craneLib.cleanCargoSource (craneLib.path ./.); - - nativeBuildInputs = with pkgs; [ - binaryen - which - git - jq - rustToolchain - wasm-bindgen-cli - ]; - - CARGO_TARGET_DIR = "./target"; - - buildPhaseCargoCommand = '' - bash ./acvm_js/buildPhaseCargoCommand.sh - ''; - - installPhase = '' - bash ./acvm_js/installPhase.sh - ''; - - }); - inherit cargo-artifacts; - }; - - # Setup the environment to match the stdenv from `nix build` & `nix flake check`, and - # combine it with the environment settings, the inputs from our checks derivations, - # and extra tooling via `nativeBuildInputs` - devShells.default = pkgs.mkShell (wasmEnvironment // { - # inputsFrom = builtins.attrValues checks; - - nativeBuildInputs = with pkgs; [ - starship - nil - nixpkgs-fmt - which - git - jq - toml2json - rustToolchain - wasm-bindgen-cli - nodejs - yarn - ]; - - shellHook = '' - eval "$(starship init bash)" - ''; - }); - }); -} From adc2d597536b52c690dceb14ea5f8e30a493452c Mon Sep 17 00:00:00 2001 From: Koby Hall <102518238+kobyhallx@users.noreply.github.com> Date: Tue, 26 Sep 2023 15:23:12 +0200 Subject: [PATCH 4/7] fix: lack of cjs package version (#2848) Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com> --- tooling/noir_js/.mocharc.cjs.json | 6 ++ tooling/noir_js/.mocharc.json | 2 +- tooling/noir_js/package.json | 19 +++++-- tooling/noir_js/test/node/cjs.test.cjs | 76 ++++++++++++++++++++++++++ tooling/noir_js/tsc-multi.json | 7 +++ yarn.lock | 59 +++++++++++++++++++- 6 files changed, 161 insertions(+), 8 deletions(-) create mode 100644 tooling/noir_js/.mocharc.cjs.json create mode 100644 tooling/noir_js/test/node/cjs.test.cjs create mode 100644 tooling/noir_js/tsc-multi.json diff --git a/tooling/noir_js/.mocharc.cjs.json b/tooling/noir_js/.mocharc.cjs.json new file mode 100644 index 00000000000..c1c37373f18 --- /dev/null +++ b/tooling/noir_js/.mocharc.cjs.json @@ -0,0 +1,6 @@ +{ + "extensions": ["cjs"], + "spec": [ + "test/node/**/*.test.cjs" + ] +} \ No newline at end of file diff --git a/tooling/noir_js/.mocharc.json b/tooling/noir_js/.mocharc.json index 9e1a6acc542..c2e70b73d0f 100644 --- a/tooling/noir_js/.mocharc.json +++ b/tooling/noir_js/.mocharc.json @@ -1,7 +1,7 @@ { "require": "ts-node/register", "loader": "ts-node/esm", - "extensions": ["ts"], + "extensions": ["ts", "cjs"], "spec": [ "test/node/**/*.test.ts*" ] diff --git a/tooling/noir_js/package.json b/tooling/noir_js/package.json index b66c4dd8e60..dbb6dccaf75 100644 --- a/tooling/noir_js/package.json +++ b/tooling/noir_js/package.json @@ -16,13 +16,21 @@ "lib", "package.json" ], - "main": "lib/index.js", + "source": "src/index.ts", + "main": "lib/index.cjs", + "module": "lib/index.js", + "exports": { + "require": "./lib/index.cjs", + "default": "./lib/index.js", + "types": "./lib/index.d.ts" + }, "types": "lib/index.d.ts", "scripts": { - "dev": "tsc --watch", - "build": "tsc", - "test": "yarn test:node", - "test:node": "mocha --timeout 25000", + "dev": "tsc-multi --watch", + "build": "tsc-multi", + "test": "yarn test:node:esm && yarn test:node:cjs", + "test:node:esm": "mocha --timeout 25000 --config ./.mocharc.json", + "test:node:cjs": "mocha --timeout 25000 --config ./.mocharc.cjs.json", "prettier": "prettier 'src/**/*.ts'", "prettier:fix": "prettier --write 'src/**/*.ts' 'test/**/*.ts'", "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0" @@ -39,6 +47,7 @@ "mocha": "^10.2.0", "prettier": "3.0.3", "ts-node": "^10.9.1", + "tsc-multi": "^1.1.0", "typescript": "^5.2.2" } } diff --git a/tooling/noir_js/test/node/cjs.test.cjs b/tooling/noir_js/test/node/cjs.test.cjs new file mode 100644 index 00000000000..0eddb3cc4af --- /dev/null +++ b/tooling/noir_js/test/node/cjs.test.cjs @@ -0,0 +1,76 @@ +/* eslint-disable no-undef */ +/* eslint-disable @typescript-eslint/no-var-requires */ +const chai = require('chai'); +const assert_lt_json = require('../noir_compiled_examples/assert_lt/target/assert_lt.json'); +const noirjs = require('@noir-lang/noir_js'); + +it('generates witnesses successfully', async () => { + const inputs = { + x: '2', + y: '3', + }; + const _solvedWitness = await noirjs.generateWitness(assert_lt_json, inputs); +}); + +it('string input and number input are the same', async () => { + const inputsString = { + x: '2', + y: '3', + }; + const inputsNumber = { + x: 2, + y: 3, + }; + const solvedWitnessString = await noirjs.generateWitness(assert_lt_json, inputsString); + const solvedWitnessNumber = await noirjs.generateWitness(assert_lt_json, inputsNumber); + chai.expect(solvedWitnessString).to.deep.equal(solvedWitnessNumber); +}); + +it('string input and number input are the same', async () => { + const inputsString = { + x: '2', + y: '3', + }; + const inputsNumber = { + x: 2, + y: 3, + }; + + const solvedWitnessString = await noirjs.generateWitness(assert_lt_json, inputsString); + const solvedWitnessNumber = await noirjs.generateWitness(assert_lt_json, inputsNumber); + chai.expect(solvedWitnessString).to.deep.equal(solvedWitnessNumber); +}); + +it('0x prefixed string input for inputs will throw', async () => { + const inputsHexPrefix = { + x: '0x2', + y: '0x3', + }; + + try { + await noirjs.generateWitness(assert_lt_json, inputsHexPrefix); + chai.expect.fail( + 'Expected generatedWitness to throw, due to inputs being prefixed with 0x. Currently not supported', + ); + } catch (error) { + // Successfully errored due to 0x not being supported. Update this test once/if we choose + // to support 0x prefixed inputs. + } +}); + +describe('input validation', () => { + it('x should be a uint64 not a string', async () => { + const inputs = { + x: 'foo', + y: '3', + }; + + try { + await noirjs.generateWitness(assert_lt_json, inputs); + chai.expect.fail('Expected generatedWitness to throw, due to x not being convertible to a uint64'); + } catch (error) { + const knownError = error; + chai.expect(knownError.message).to.equal('Input for x is the wrong type, expected uint64, got "foo"'); + } + }); +}); diff --git a/tooling/noir_js/tsc-multi.json b/tooling/noir_js/tsc-multi.json new file mode 100644 index 00000000000..af26d1e4aa6 --- /dev/null +++ b/tooling/noir_js/tsc-multi.json @@ -0,0 +1,7 @@ +{ + "targets": [ + { "extname": ".cjs", "module": "commonjs" }, + { "extname": ".mjs", "module": "esnext" } + ], + "projects": ["packages/*/tsconfig.json"] +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 1c33b723fa8..b91264ec860 100644 --- a/yarn.lock +++ b/yarn.lock @@ -423,6 +423,7 @@ __metadata: mocha: ^10.2.0 prettier: 3.0.3 ts-node: ^10.9.1 + tsc-multi: ^1.1.0 typescript: ^5.2.2 languageName: unknown linkType: soft @@ -3557,7 +3558,7 @@ __metadata: languageName: node linkType: hard -"fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.0": +"fast-glob@npm:^3.2.12, fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.0": version: 3.3.1 resolution: "fast-glob@npm:3.3.1" dependencies: @@ -3921,6 +3922,13 @@ __metadata: languageName: node linkType: hard +"get-stdin@npm:^8.0.0": + version: 8.0.0 + resolution: "get-stdin@npm:8.0.0" + checksum: 40128b6cd25781ddbd233344f1a1e4006d4284906191ed0a7d55ec2c1a3e44d650f280b2c9eeab79c03ac3037da80257476c0e4e5af38ddfb902d6ff06282d77 + languageName: node + linkType: hard + "get-stream@npm:^5.1.0": version: 5.2.0 resolution: "get-stream@npm:5.2.0" @@ -5830,6 +5838,15 @@ __metadata: languageName: node linkType: hard +"p-all@npm:^3.0.0": + version: 3.0.0 + resolution: "p-all@npm:3.0.0" + dependencies: + p-map: ^4.0.0 + checksum: 267a620c2330b14246b92008f4be8758debe74e1454c8fb5808544f51fd038ac4597dbeeaa1542f237794e613cd42e4f1a58c01e5a0a6a6b21340fef616257df + languageName: node + linkType: hard + "p-cancelable@npm:^3.0.0": version: 3.0.0 resolution: "p-cancelable@npm:3.0.0" @@ -6966,6 +6983,15 @@ __metadata: languageName: node linkType: hard +"string-to-stream@npm:^3.0.1": + version: 3.0.1 + resolution: "string-to-stream@npm:3.0.1" + dependencies: + readable-stream: ^3.4.0 + checksum: e8ac7f7497f8f101196e39dd529e98bb97165c532cc4cae5003083a420db62f46ffd67ddff7112b45f9f8d0f9ff1cc6cda9b06362236d43fa6b1685e8b0d446e + languageName: node + linkType: hard + "string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.3": version: 4.2.3 resolution: "string-width@npm:4.2.3" @@ -7045,6 +7071,13 @@ __metadata: languageName: node linkType: hard +"superstruct@npm:^1.0.3": + version: 1.0.3 + resolution: "superstruct@npm:1.0.3" + checksum: 761790bb111e6e21ddd608299c252f3be35df543263a7ebbc004e840d01fcf8046794c274bcb351bdf3eae4600f79d317d085cdbb19ca05803a4361840cc9bb1 + languageName: node + linkType: hard + "supertap@npm:^3.0.1": version: 3.0.1 resolution: "supertap@npm:3.0.1" @@ -7291,6 +7324,28 @@ __metadata: languageName: node linkType: hard +"tsc-multi@npm:^1.1.0": + version: 1.1.0 + resolution: "tsc-multi@npm:1.1.0" + dependencies: + debug: ^4.3.4 + fast-glob: ^3.2.12 + get-stdin: ^8.0.0 + p-all: ^3.0.0 + picocolors: ^1.0.0 + signal-exit: ^3.0.7 + string-to-stream: ^3.0.1 + superstruct: ^1.0.3 + tslib: ^2.5.0 + yargs: ^17.7.1 + peerDependencies: + typescript: ">=4.3.0" + bin: + tsc-multi: bin/tsc-multi.js + checksum: a82c0358611ac15667aa148ade33b6ad64cc0a94299fb9afc01e3e6224a994dff8812960a43643f25e4c0dac8419707027c3096d0e60bff3522591c06d5f4eeb + languageName: node + linkType: hard + "tslib@npm:^1.8.1": version: 1.14.1 resolution: "tslib@npm:1.14.1" @@ -7953,7 +8008,7 @@ __metadata: languageName: node linkType: hard -"yargs@npm:^17.7.2": +"yargs@npm:^17.7.1, yargs@npm:^17.7.2": version: 17.7.2 resolution: "yargs@npm:17.7.2" dependencies: From 63da875a85a2ad4ad3038443ba52eb28ea44ad10 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Tue, 26 Sep 2023 14:29:37 +0100 Subject: [PATCH 5/7] fix: Conditionally run the "Create or Update PR" step in acir artifacts rebuild workflow (#2849) --- .github/workflows/auto-pr-rebuild-script.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/auto-pr-rebuild-script.yml b/.github/workflows/auto-pr-rebuild-script.yml index 5d6fd218c48..ac8b5beaa3b 100644 --- a/.github/workflows/auto-pr-rebuild-script.yml +++ b/.github/workflows/auto-pr-rebuild-script.yml @@ -70,11 +70,14 @@ jobs: run: | chmod +x ./rebuild.sh ./rebuild.sh - - - name: Discard changes in nargo directory - run: git restore --source=HEAD --staged --worktree -- nargo/ - + + - name: Check for changes in acir_artifacts directory + id: check_changes + run: | + git diff --quiet tooling/nargo_cli/tests/acir_artifacts/ || echo "::set-output name=changes::true" + - name: Create or Update PR + if: steps.check_changes.outputs.changes == 'true' uses: peter-evans/create-pull-request@v3 with: token: ${{ secrets.NOIR_REPO_TOKEN }} From 1f470e52c6fb32cafbf10a19838af6b77d87cc97 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Tue, 26 Sep 2023 15:11:07 +0100 Subject: [PATCH 6/7] chore: remove unnecessary `AcirValue`s (#2823) --- .../src/ssa/acir_gen/acir_ir/acir_variable.rs | 16 +++------- .../noirc_evaluator/src/ssa/acir_gen/mod.rs | 32 +++++-------------- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs b/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs index 61ad747421a..0567118b419 100644 --- a/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs +++ b/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs @@ -285,13 +285,12 @@ impl AcirContext { // Compute the inverse with brillig code let inverse_code = brillig_directive::directive_invert(); - let field_type = AcirType::NumericType(NumericType::NativeField); let results = self.brillig( predicate, inverse_code, - vec![AcirValue::Var(var, field_type.clone())], - vec![field_type], + vec![AcirValue::Var(var, AcirType::field())], + vec![AcirType::field()], )?; let inverted_var = Self::expect_one_var(results); @@ -917,17 +916,10 @@ impl AcirContext { AcirValue::DynamicArray(AcirDynamicArray { block_id, len }) => { for i in 0..len { // We generate witnesses corresponding to the array values - let index = AcirValue::Var( - self.add_constant(FieldElement::from(i as u128)), - AcirType::NumericType(NumericType::NativeField), - ); - let index_var = index.into_var()?; + let index_var = self.add_constant(FieldElement::from(i as u128)); let value_read_var = self.read_from_memory(block_id, &index_var)?; - let value_read = AcirValue::Var( - value_read_var, - AcirType::NumericType(NumericType::NativeField), - ); + let value_read = AcirValue::Var(value_read_var, AcirType::field()); self.brillig_array_input(var_expressions, value_read)?; } diff --git a/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs b/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs index 0f238bd2858..d16985eb31c 100644 --- a/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs @@ -400,11 +400,8 @@ impl Context { let mut read_dynamic_array_index = |block_id: BlockId, array_index: usize| -> Result { - let index = AcirValue::Var( - self.acir_context.add_constant(FieldElement::from(array_index as u128)), - AcirType::NumericType(NumericType::NativeField), - ); - let index_var = index.into_var()?; + let index_var = + self.acir_context.add_constant(FieldElement::from(array_index as u128)); self.acir_context.read_from_memory(block_id, &index_var) }; @@ -896,16 +893,10 @@ impl Context { // Initialize the new array with the values from the old array result_block_id = self.block_id(result_id); let init_values = try_vecmap(0..array_len, |i| { - let index = AcirValue::Var( - self.acir_context.add_constant(FieldElement::from(i as u128)), - AcirType::NumericType(NumericType::NativeField), - ); - let var = index.into_var()?; - let read = self.acir_context.read_from_memory(block_id, &var)?; - Ok::(AcirValue::Var( - read, - AcirType::NumericType(NumericType::NativeField), - )) + let index_var = self.acir_context.add_constant(FieldElement::from(i as u128)); + + let read = self.acir_context.read_from_memory(block_id, &index_var)?; + Ok::(AcirValue::Var(read, AcirType::field())) })?; self.initialize_array( result_block_id, @@ -1609,18 +1600,11 @@ impl Context { AcirValue::DynamicArray(AcirDynamicArray { block_id, len }) => { for i in 0..len { // We generate witnesses corresponding to the array values - let index = AcirValue::Var( - self.acir_context.add_constant(FieldElement::from(i as u128)), - AcirType::NumericType(NumericType::NativeField), - ); + let index_var = self.acir_context.add_constant(FieldElement::from(i as u128)); - let index_var = index.into_var()?; let value_read_var = self.acir_context.read_from_memory(block_id, &index_var)?; - let value_read = AcirValue::Var( - value_read_var, - AcirType::NumericType(NumericType::NativeField), - ); + let value_read = AcirValue::Var(value_read_var, AcirType::field()); old_slice.push_back(value_read); } From 71dbbb863a6f262da4804c17965ace627bf3a278 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Tue, 26 Sep 2023 15:38:30 +0100 Subject: [PATCH 7/7] chore(noir_js)!: Rename inner and outer proof methods (#2845) --- tooling/noir_js/test/backend/barretenberg.ts | 10 +++++----- tooling/noir_js/test/node/e2e.test.ts | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tooling/noir_js/test/backend/barretenberg.ts b/tooling/noir_js/test/backend/barretenberg.ts index 6a770cde2f2..cc812084f87 100644 --- a/tooling/noir_js/test/backend/barretenberg.ts +++ b/tooling/noir_js/test/backend/barretenberg.ts @@ -42,7 +42,7 @@ export class Backend { // // The settings for this proof are the same as the settings for a "normal" proof // ie one that is not in the recursive setting. - async generateOuterProof(decompressedWitness: Uint8Array) { + async generateFinalProof(decompressedWitness: Uint8Array) { const makeEasyToVerifyInCircuit = false; return this.generateProof(decompressedWitness, makeEasyToVerifyInCircuit); } @@ -58,7 +58,7 @@ export class Backend { // We set `makeEasyToVerifyInCircuit` to true, which will tell the backend to // generate the proof using components that will make the proof // easier to verify in a circuit. - async generateInnerProof(witness: Uint8Array) { + async generateIntermediateProof(witness: Uint8Array) { const makeEasyToVerifyInCircuit = true; return this.generateProof(witness, makeEasyToVerifyInCircuit); } @@ -83,7 +83,7 @@ export class Backend { // method. // // The number of public inputs denotes how many public inputs are in the inner proof. - async generateInnerProofArtifacts(proof: Uint8Array, numOfPublicInputs = 0) { + async generateIntermediateProofArtifacts(proof: Uint8Array, numOfPublicInputs = 0) { const proofAsFields = await this.api.acirSerializeProofIntoFields(this.acirComposer, proof, numOfPublicInputs); // TODO: perhaps we should put this in the init function. Need to benchmark @@ -100,13 +100,13 @@ export class Backend { }; } - async verifyOuterProof(proof: Uint8Array) { + async verifyFinalProof(proof: Uint8Array) { const makeEasyToVerifyInCircuit = false; const verified = await this.verifyProof(proof, makeEasyToVerifyInCircuit); return verified; } - async verifyInnerProof(proof: Uint8Array) { + async verifyIntermediateProof(proof: Uint8Array) { const makeEasyToVerifyInCircuit = true; return this.verifyProof(proof, makeEasyToVerifyInCircuit); } diff --git a/tooling/noir_js/test/node/e2e.test.ts b/tooling/noir_js/test/node/e2e.test.ts index 18413074871..bbb936ea6e5 100644 --- a/tooling/noir_js/test/node/e2e.test.ts +++ b/tooling/noir_js/test/node/e2e.test.ts @@ -16,10 +16,10 @@ it('end-to-end proof creation and verification (outer)', async () => { // Proof creation const prover = new Backend(assert_lt_json.bytecode); await prover.init(); - const proof = await prover.generateOuterProof(serializedWitness); + const proof = await prover.generateFinalProof(serializedWitness); // Proof verification - const isValid = await prover.verifyOuterProof(proof); + const isValid = await prover.verifyFinalProof(proof); expect(isValid).to.be.true; }); @@ -36,10 +36,10 @@ it('end-to-end proof creation and verification (inner)', async () => { // Proof creation const prover = new Backend(assert_lt_json.bytecode); await prover.init(); - const proof = await prover.generateInnerProof(serializedWitness); + const proof = await prover.generateIntermediateProof(serializedWitness); // Proof verification - const isValid = await prover.verifyInnerProof(proof); + const isValid = await prover.verifyIntermediateProof(proof); expect(isValid).to.be.true; }); @@ -67,12 +67,12 @@ it('[BUG] -- bb.js null function or function signature mismatch (different insta const prover = new Backend(assert_lt_json.bytecode); await prover.init(); - const proof = await prover.generateOuterProof(serializedWitness); + const proof = await prover.generateFinalProof(serializedWitness); try { const verifier = new Backend(assert_lt_json.bytecode); await verifier.init(); - await verifier.verifyOuterProof(proof); + await verifier.verifyFinalProof(proof); expect.fail( 'bb.js currently returns a bug when we try to verify a proof with a different Barretenberg instance that created it.', ); @@ -105,13 +105,13 @@ it('[BUG] -- bb.js null function or function signature mismatch (outer-inner) ', await prover.init(); // Create a proof using both proving systems, the majority of the time // one would only use outer proofs. - const proofOuter = await prover.generateOuterProof(serializedWitness); - const _proofInner = await prover.generateInnerProof(serializedWitness); + const proofOuter = await prover.generateFinalProof(serializedWitness); + const _proofInner = await prover.generateIntermediateProof(serializedWitness); // Proof verification // try { - const isValidOuter = await prover.verifyOuterProof(proofOuter); + const isValidOuter = await prover.verifyFinalProof(proofOuter); expect(isValidOuter).to.be.true; // We can also try verifying an inner proof and it will fail. // const isValidInner = await prover.verifyInnerProof(_proofInner);