From ea66d2fe3169afc513fa501bf742d92770a96f56 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:09:25 +0000 Subject: [PATCH 01/37] add base64 decode method --- tooling/noir_js/src/base64_decode.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tooling/noir_js/src/base64_decode.ts diff --git a/tooling/noir_js/src/base64_decode.ts b/tooling/noir_js/src/base64_decode.ts new file mode 100644 index 00000000000..d53aed187c7 --- /dev/null +++ b/tooling/noir_js/src/base64_decode.ts @@ -0,0 +1,13 @@ +// Since this is a simple function, we can use feature detection to +// see if we are in the nodeJs environment or the browser environment. +export function base64Decode(input: string): Uint8Array { + if (typeof Buffer !== 'undefined') { + // Node.js environment + return Buffer.from(input, 'base64'); + } else if (typeof atob === 'function') { + // Browser environment + return Uint8Array.from(atob(input), (c) => c.charCodeAt(0)); + } else { + throw new Error('No implementation found for base64 decoding.'); + } +} From 723028f29afc21783dd6906b88440d7c4953a1e5 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:10:05 +0000 Subject: [PATCH 02/37] add wip version of input validation --- tooling/noir_js/src/input_validation.ts | 55 +++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tooling/noir_js/src/input_validation.ts diff --git a/tooling/noir_js/src/input_validation.ts b/tooling/noir_js/src/input_validation.ts new file mode 100644 index 00000000000..56fe6fcdb23 --- /dev/null +++ b/tooling/noir_js/src/input_validation.ts @@ -0,0 +1,55 @@ +// Check if all of the input values are correct according to the ABI +export function validateInputs(inputs: any, abi: any) { + for (const param of abi.parameters) { + const inputValue = inputs[param.name]; + if (inputValue === undefined) { + // This is checked by noirc_abi, so we could likely remove this check + return { isValid: false, error: `Input for ${param.name} is missing` }; + } + if (!checkType(inputValue, param.type)) { + return { + isValid: false, + error: `Input for ${param.name} is the wrong type, expected ${type_to_string( + param.type, + )}, got \"${inputValue}\"`, + }; + } + } + return { isValid: true, error: null }; +} + +// Checks that value is of type "type" +// Where type is taken from the abi +function checkType(value: any, type: any) { + switch (type.kind) { + case 'integer': + if (type.sign === 'unsigned') { + return isUnsignedInteger(value, type.width); + } + // Other integer sign checks can be added here + break; + // Other type.kind checks can be added here + } + return false; +} + +function type_to_string(type: any) { + switch (type.kind) { + case 'integer': + if (type.sign === 'unsigned') { + return `uint${type.width}`; + } + break; + } + return false; +} + +// Returns true if `value` is an unsigned integer that is less than 2^{width} +function isUnsignedInteger(value: any, width: any) { + try { + const bigIntValue = BigInt(value); + return bigIntValue >= 0 && bigIntValue <= BigInt(2) ** BigInt(width) - 1n; + } catch (e) { + return false; // Not a valid integer + } +} From 56dc4c154383ec22aa3580f0f5b094f5cd6388ca Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:10:41 +0000 Subject: [PATCH 03/37] add initial witness generation method - does not handle return values --- tooling/noir_js/src/witness_generation.ts | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tooling/noir_js/src/witness_generation.ts diff --git a/tooling/noir_js/src/witness_generation.ts b/tooling/noir_js/src/witness_generation.ts new file mode 100644 index 00000000000..6d460932494 --- /dev/null +++ b/tooling/noir_js/src/witness_generation.ts @@ -0,0 +1,24 @@ +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'; + +// Generates the witnesses needed to feed into the chosen proving system +export async function generateWitness(compiledProgram: any, inputs: any): Promise { + // Validate inputs + const { isValid, error } = validateInputs(inputs, compiledProgram.abi); + if (!isValid) { + throw new Error(error?.toString()); + } + const witnessMap = abiEncode(compiledProgram.abi, inputs, null); + + // Execute the circuit to generate the rest of the witnesses + try { + const solvedWitness = await executeCircuit(base64Decode(compiledProgram.bytecode), witnessMap, () => { + throw Error('unexpected oracle during execution'); + }); + return solvedWitness; + } catch (err) { + throw new Error(`Circuit execution failed: ${err}`); + } +} From 581758f1c4b6d355d09617e679439b7857317045 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:11:06 +0000 Subject: [PATCH 04/37] add serialize method to abstract away the discrepancies with serialization --- tooling/noir_js/src/serialize.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tooling/noir_js/src/serialize.ts diff --git a/tooling/noir_js/src/serialize.ts b/tooling/noir_js/src/serialize.ts new file mode 100644 index 00000000000..170db735429 --- /dev/null +++ b/tooling/noir_js/src/serialize.ts @@ -0,0 +1,17 @@ +import { WitnessMap, compressWitness } from '@noir-lang/acvm_js'; +import { decompressSync as gunzip } from 'fflate'; +import { base64Decode } from './base64_decode.js'; + +// After solving the witness, to pass it a backend, we need to serialize it to a Uint8Array +export function witnessMapToUint8Array(solvedWitness: WitnessMap): Uint8Array { + // TODO: We just want to serialize, but this will zip up the witness + // TODO so its not ideal + const compressedWitness = compressWitness(solvedWitness); + return gunzip(compressedWitness); +} + +// Converts an bytecode to a Uint8Array +export function acirToUint8Array(base64EncodedBytecode: any): Uint8Array { + const compressedByteCode = base64Decode(base64EncodedBytecode); + return gunzip(compressedByteCode); +} From 752535d3bb326869379481158b3c48b979146fd2 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:11:34 +0000 Subject: [PATCH 05/37] export new methods --- tooling/noir_js/src/index.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tooling/noir_js/src/index.ts b/tooling/noir_js/src/index.ts index 2b3bf593d0c..4125affae6d 100644 --- a/tooling/noir_js/src/index.ts +++ b/tooling/noir_js/src/index.ts @@ -1,3 +1,8 @@ -import * as acvm from "@noir-lang/acvm_js"; -import * as noirc from "@noir-lang/noirc_abi"; -export { acvm, noirc } \ No newline at end of file +import * as acvm from '@noir-lang/acvm_js'; +import * as abi from '@noir-lang/noirc_abi'; + +export { acvm, abi }; + +import { generateWitness } from './witness_generation.js'; +import { acirToUint8Array, witnessMapToUint8Array } from './serialize.js'; +export { acirToUint8Array, witnessMapToUint8Array, generateWitness }; From e94f00b725286ce7ae26bfcc1ec6519e37716fad Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:13:22 +0000 Subject: [PATCH 06/37] add mocha, prettier and add `type: module` for node --- tooling/noir_js/.mocharc.json | 8 ++++++++ tooling/noir_js/.prettierrc | 6 ++++++ tooling/noir_js/package.json | 19 +++++++++++++++++-- tooling/noir_js/tsconfig.json | 3 ++- 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 tooling/noir_js/.mocharc.json create mode 100644 tooling/noir_js/.prettierrc diff --git a/tooling/noir_js/.mocharc.json b/tooling/noir_js/.mocharc.json new file mode 100644 index 00000000000..9e1a6acc542 --- /dev/null +++ b/tooling/noir_js/.mocharc.json @@ -0,0 +1,8 @@ +{ + "require": "ts-node/register", + "loader": "ts-node/esm", + "extensions": ["ts"], + "spec": [ + "test/node/**/*.test.ts*" + ] +} \ No newline at end of file diff --git a/tooling/noir_js/.prettierrc b/tooling/noir_js/.prettierrc new file mode 100644 index 00000000000..ef937f9697a --- /dev/null +++ b/tooling/noir_js/.prettierrc @@ -0,0 +1,6 @@ +{ + "parser": "typescript", + "printWidth": 120, + "singleQuote": true, + "trailingComma": "all" +} \ No newline at end of file diff --git a/tooling/noir_js/package.json b/tooling/noir_js/package.json index 5fc7bbcb62f..98c224a7d49 100644 --- a/tooling/noir_js/package.json +++ b/tooling/noir_js/package.json @@ -6,9 +6,11 @@ "version": "0.12.0", "packageManager": "yarn@3.5.1", "license": "(MIT OR Apache-2.0)", + "type": "module", "dependencies": { "@noir-lang/acvm_js": "0.26.1", - "@noir-lang/noirc_abi": "workspace:*" + "@noir-lang/noirc_abi": "workspace:*", + "fflate": "^0.8.0" }, "files": [ "lib", @@ -17,9 +19,22 @@ "main": "lib/index.js", "types": "lib/index.d.ts", "scripts": { - "build": "tsc" + "dev": "tsc --watch", + "build": "tsc", + "test:node": "mocha --timeout 5000", + "prettier": "prettier 'src/**/*.ts'", + "prettier:fix": "prettier --write 'src/**/*.ts' 'test/**/*.ts'" }, "devDependencies": { + "@aztec/bb.js": "0.7.2", + "@types/chai": "^4", + "@types/mocha": "^10.0.1", + "@types/node": "^20.6.2", + "@types/prettier": "^3", + "chai": "^4.3.8", + "mocha": "^10.2.0", + "prettier": "3.0.3", + "ts-node": "^10.9.1", "typescript": "^5.2.2" } } diff --git a/tooling/noir_js/tsconfig.json b/tooling/noir_js/tsconfig.json index 45c1f060a57..41e6dbaf77e 100644 --- a/tooling/noir_js/tsconfig.json +++ b/tooling/noir_js/tsconfig.json @@ -7,7 +7,8 @@ "moduleResolution": "node", "outDir": "./lib", "esModuleInterop": true, - "strict": true + "resolveJsonModule": true, + "strict": true, }, "include": ["src/**/*.ts"], "exclude": ["node_modules"] From c45fc8fb68bd2f0e6895360277f4ee3c7a68428e Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:14:20 +0000 Subject: [PATCH 07/37] add compiled_examples folder for noir tests --- .../noir_js/test/noir_compiled_examples/1_mul/Nargo.toml | 7 +++++++ .../test/noir_compiled_examples/1_mul/src/main.nr | 9 +++++++++ .../test/noir_compiled_examples/assert_lt/Nargo.toml | 7 +++++++ .../test/noir_compiled_examples/assert_lt/src/main.nr | 3 +++ tooling/noir_js/test/noir_compiled_examples/readme.md | 3 +++ 5 files changed, 29 insertions(+) create mode 100644 tooling/noir_js/test/noir_compiled_examples/1_mul/Nargo.toml create mode 100644 tooling/noir_js/test/noir_compiled_examples/1_mul/src/main.nr create mode 100644 tooling/noir_js/test/noir_compiled_examples/assert_lt/Nargo.toml create mode 100644 tooling/noir_js/test/noir_compiled_examples/assert_lt/src/main.nr create mode 100644 tooling/noir_js/test/noir_compiled_examples/readme.md diff --git a/tooling/noir_js/test/noir_compiled_examples/1_mul/Nargo.toml b/tooling/noir_js/test/noir_compiled_examples/1_mul/Nargo.toml new file mode 100644 index 00000000000..29053e36f7c --- /dev/null +++ b/tooling/noir_js/test/noir_compiled_examples/1_mul/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "1_mul" +type = "bin" +authors = [""] +compiler_version = "0.1" + +[dependencies] diff --git a/tooling/noir_js/test/noir_compiled_examples/1_mul/src/main.nr b/tooling/noir_js/test/noir_compiled_examples/1_mul/src/main.nr new file mode 100644 index 00000000000..4587b4b5947 --- /dev/null +++ b/tooling/noir_js/test/noir_compiled_examples/1_mul/src/main.nr @@ -0,0 +1,9 @@ +// Test unsafe integer multiplication with overflow: 12^8 = 429 981 696 +// The circuit should handle properly the growth of the bit size +fn main(mut x: u32, y: u32, z: u32) { + x *= y; + x *= x; //144 + x *= x; //20736 + x *= x; //429 981 696 + assert(x == z); +} diff --git a/tooling/noir_js/test/noir_compiled_examples/assert_lt/Nargo.toml b/tooling/noir_js/test/noir_compiled_examples/assert_lt/Nargo.toml new file mode 100644 index 00000000000..742f100681f --- /dev/null +++ b/tooling/noir_js/test/noir_compiled_examples/assert_lt/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "assert_lt" +type = "bin" +authors = [""] +compiler_version = "0.1" + +[dependencies] diff --git a/tooling/noir_js/test/noir_compiled_examples/assert_lt/src/main.nr b/tooling/noir_js/test/noir_compiled_examples/assert_lt/src/main.nr new file mode 100644 index 00000000000..7f3767f4a48 --- /dev/null +++ b/tooling/noir_js/test/noir_compiled_examples/assert_lt/src/main.nr @@ -0,0 +1,3 @@ +fn main(x : u64, y : pub u64) { + assert(x < y); +} \ No newline at end of file diff --git a/tooling/noir_js/test/noir_compiled_examples/readme.md b/tooling/noir_js/test/noir_compiled_examples/readme.md new file mode 100644 index 00000000000..26c571850ae --- /dev/null +++ b/tooling/noir_js/test/noir_compiled_examples/readme.md @@ -0,0 +1,3 @@ +## Why + +While we do not automatically pull the .json files from .artifacts, we have these hard-coded versions of examples. From bcbc0ce9b561c736d262578278910ab81b1dbfbe Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:15:27 +0000 Subject: [PATCH 08/37] do not ignore the target folders --- tooling/noir_js/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 tooling/noir_js/.gitignore diff --git a/tooling/noir_js/.gitignore b/tooling/noir_js/.gitignore new file mode 100644 index 00000000000..9d26861cc3c --- /dev/null +++ b/tooling/noir_js/.gitignore @@ -0,0 +1 @@ +!test/noir_compiled_examples/*/target \ No newline at end of file From 6664b7208632905968845fa93fdef8321c212e7d Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:15:43 +0000 Subject: [PATCH 09/37] commit .json files for noir_compiled examples --- .../noir_js/test/noir_compiled_examples/1_mul/target/1_mul.json | 1 + .../test/noir_compiled_examples/assert_lt/target/assert_lt.json | 1 + 2 files changed, 2 insertions(+) create mode 100644 tooling/noir_js/test/noir_compiled_examples/1_mul/target/1_mul.json create mode 100644 tooling/noir_js/test/noir_compiled_examples/assert_lt/target/assert_lt.json diff --git a/tooling/noir_js/test/noir_compiled_examples/1_mul/target/1_mul.json b/tooling/noir_js/test/noir_compiled_examples/1_mul/target/1_mul.json new file mode 100644 index 00000000000..b98559b1a12 --- /dev/null +++ b/tooling/noir_js/test/noir_compiled_examples/1_mul/target/1_mul.json @@ -0,0 +1 @@ +{"backend":"acvm-backend-barretenberg","abi":{"parameters":[{"name":"x","type":{"kind":"integer","sign":"unsigned","width":32},"visibility":"private"},{"name":"y","type":{"kind":"integer","sign":"unsigned","width":32},"visibility":"private"},{"name":"z","type":{"kind":"integer","sign":"unsigned","width":32},"visibility":"private"}],"param_witnesses":{"x":[1],"y":[2],"z":[3]},"return_type":null,"return_witnesses":[]},"bytecode":"H4sIAAAAAAAA/23LywkAAAgCUPsM0v5TFlQQkiDyDjoAQ0eqOhvHSrYx/9ZfEgkgcMloAAAA"} \ No newline at end of file diff --git a/tooling/noir_js/test/noir_compiled_examples/assert_lt/target/assert_lt.json b/tooling/noir_js/test/noir_compiled_examples/assert_lt/target/assert_lt.json new file mode 100644 index 00000000000..fdf25a4743d --- /dev/null +++ b/tooling/noir_js/test/noir_compiled_examples/assert_lt/target/assert_lt.json @@ -0,0 +1 @@ +{"backend":"acvm-backend-barretenberg","abi":{"parameters":[{"name":"x","type":{"kind":"integer","sign":"unsigned","width":64},"visibility":"private"},{"name":"y","type":{"kind":"integer","sign":"unsigned","width":64},"visibility":"public"}],"param_witnesses":{"x":[1],"y":[2]},"return_type":null,"return_witnesses":[]},"bytecode":"H4sIAAAAAAAA/81WXW7DIAw20BJl0noWE6CBt6k3WbT0/kfYooJm0bQPxZZqKXKw4PPPB5Y/AOATbqL+Pl30F1nrsqaiiq52j+cQ1nlanXffOOUlRQxxOSeXXEzxZ0rerymkOS95xuyCX901Zn/Fm5jXsbDBcobE9yxm7BNn+LCQxnvY+dfEZoq2AjlB46et42nHxupcgqSDAO4R+C6/VN5Hfo6QQIrWFDvFwP9DoaKZY1aM90C/HpdrDTupvyP2nS/a6GzRA7GNhEfd7Nu4qJxvb/5CzimiFcG4kDN7e9QDnJHY6vkTiQX4aoICjR5FG3mdHCwp5rYe4H6SMAK+Kxbng+zFGkGmCbf1652eLGPOAyOvHfV72sC4J1nLyPOjptXKL8ADXjPGCwAA"} \ No newline at end of file From 8bd188ca52135f7472d9e6fa7edebd9bc75eeecc Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:24:28 +0000 Subject: [PATCH 10/37] add bb test backend code --- tooling/noir_js/test/backend/barretenberg.ts | 118 +++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 tooling/noir_js/test/backend/barretenberg.ts diff --git a/tooling/noir_js/test/backend/barretenberg.ts b/tooling/noir_js/test/backend/barretenberg.ts new file mode 100644 index 00000000000..61a673f0856 --- /dev/null +++ b/tooling/noir_js/test/backend/barretenberg.ts @@ -0,0 +1,118 @@ +// @ts-ignore +import { Barretenberg, Crs, RawBuffer } from '@aztec/bb.js'; +// TODO: This should be re-exported from @aztec/bb-js +import { Ptr } from '@aztec/bb.js/dest/browser/types'; +import { acirToUint8Array } from '../../src/index.js'; + +export class Backend { + api = {} as Barretenberg; + acirComposer = {} as Ptr; + acirUncompressedBytecode: Uint8Array; + + constructor(acirBytecodeBase64: string) { + this.acirUncompressedBytecode = acirToUint8Array(acirBytecodeBase64); + } + async init() { + const numThreads = 4; + + const { api, composer } = await this.initBarretenberg(numThreads, this.acirUncompressedBytecode); + + this.api = api; + this.acirComposer = composer; + } + + async initBarretenberg(numThreads: number, acirUncompressedBytecode: Uint8Array) { + const api = await Barretenberg.new(numThreads); + + const [exact, total, subgroupSize] = await api.acirGetCircuitSizes(acirUncompressedBytecode); + const crs = await Crs.new(subgroupSize + 1); + await api.commonInitSlabAllocator(subgroupSize); + await api.srsInitSrs(new RawBuffer(crs.getG1Data()), crs.numPoints, new RawBuffer(crs.getG2Data())); + + const acirComposer = await api.acirNewAcirComposer(subgroupSize); + return { api: api, composer: acirComposer }; + } + + // Generate an outer proof. This is the proof for the circuit which will verify + // inner proofs and or can be seen as the proof created for regular circuits. + // + // 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) { + const makeEasyToVerifyInCircuit = false; + return this.generateProof(decompressedWitness, makeEasyToVerifyInCircuit); + } + + // Generates an inner proof. This is the proof that will be verified + // in another circuit. + // + // This is sometimes referred to as a recursive proof. + // We avoid this terminology as the only property of this proof + // that matters, is the fact that it is easy to verify in another + // circuit. We _could_ choose to verify this proof in the CLI. + // + // 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) { + const makeEasyToVerifyInCircuit = true; + return this.generateProof(witness, makeEasyToVerifyInCircuit); + } + + async generateProof(decompressedWitness: Uint8Array, makeEasyToVerifyInCircuit: boolean) { + const proof = await this.api.acirCreateProof( + this.acirComposer, + this.acirUncompressedBytecode, + decompressedWitness, + makeEasyToVerifyInCircuit, + ); + + return proof; + } + + // Generates artifacts that will be passed to a circuit that will verify this proof. + // + // Instead of passing the proof and verification key as a byte array, we pass them + // as fields which makes it cheaper to verify in a circuit. + // + // The proof that is passed here will have been created using the `generateInnerProof` + // method. + // + // The number of public inputs denotes how many public inputs are in the inner proof. + async generateInnerProofArtifacts(proof: Uint8Array, numOfPublicInputs: number = 0) { + const proofAsFields = await this.api.acirSerializeProofIntoFields(this.acirComposer, proof, numOfPublicInputs); + + // TODO: perhaps we should put this in the init function. Need to benchmark + // TODO how long it takes. + await this.api.acirInitVerificationKey(this.acirComposer); + + // Note: If you don't init verification key, `acirSerializeVerificationKeyIntoFields`` will just hang on serialization + const vk = await this.api.acirSerializeVerificationKeyIntoFields(this.acirComposer); + + return { + proofAsFields: proofAsFields.map((p: any) => p.toString()), + vkAsFields: vk[0].map((vk: any) => vk.toString()), + vkHash: vk[1].toString(), + }; + } + + async verifyOuterProof(proof: Uint8Array) { + const makeEasyToVerifyInCircuit = false; + const verified = await this.verifyProof(proof, makeEasyToVerifyInCircuit); + return verified; + } + + async verifyInnerProof(proof: Uint8Array) { + const makeEasyToVerifyInCircuit = true; + return this.verifyProof(proof, makeEasyToVerifyInCircuit); + } + + async verifyProof(proof: Uint8Array, makeEasyToVerifyInCircuit: boolean) { + await this.api.acirInitVerificationKey(this.acirComposer); + return await this.api.acirVerifyProof(this.acirComposer, proof, makeEasyToVerifyInCircuit); + } + + async destroy() { + await this.api.destroy(); + } +} From f431c72fb9a25957decbf6377f8b28d59b1481c1 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:25:03 +0000 Subject: [PATCH 11/37] add comment to explain why we are doing type assertions --- tooling/noir_js/test/backend/barretenberg.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tooling/noir_js/test/backend/barretenberg.ts b/tooling/noir_js/test/backend/barretenberg.ts index 61a673f0856..0ec269286b0 100644 --- a/tooling/noir_js/test/backend/barretenberg.ts +++ b/tooling/noir_js/test/backend/barretenberg.ts @@ -5,6 +5,10 @@ import { Ptr } from '@aztec/bb.js/dest/browser/types'; import { acirToUint8Array } from '../../src/index.js'; export class Backend { + // These type assertions are used so that we don't + // have to initialize `api` and `acirComposer` in the constructor. + // These are initialized asynchronously in the `init` function, + // constructors cannot be asynchronous which is why we do this. api = {} as Barretenberg; acirComposer = {} as Ptr; acirUncompressedBytecode: Uint8Array; From ec3cc28f9b39edba04843477797d5bfc51a4feba Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:25:24 +0000 Subject: [PATCH 12/37] add some smoke tests --- tooling/noir_js/test/node/smoke.test.ts | 72 +++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 tooling/noir_js/test/node/smoke.test.ts diff --git a/tooling/noir_js/test/node/smoke.test.ts b/tooling/noir_js/test/node/smoke.test.ts new file mode 100644 index 00000000000..ad839d5058c --- /dev/null +++ b/tooling/noir_js/test/node/smoke.test.ts @@ -0,0 +1,72 @@ +import { expect } from 'chai'; +import assert_lt_json from '../noir_compiled_examples/assert_lt/target/assert_lt.json' assert { type: 'json' }; +import { generateWitness } from '../../src/index.js'; + +it('generates witnesses successfully', async () => { + const inputs = { + x: '2', + y: '3', + }; + const solvedWitness = await 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 generateWitness(assert_lt_json, inputsString); + const solvedWitnessNumber = await generateWitness(assert_lt_json, inputsNumber); + 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 generateWitness(assert_lt_json, inputsString); + const solvedWitnessNumber = await generateWitness(assert_lt_json, inputsNumber); + expect(solvedWitnessString).to.deep.equal(solvedWitnessNumber); +}); + +it('0x prefixed string input for inputs will throw', async () => { + const inputsHexPrefix = { + x: '0x2', + y: '0x3', + }; + + try { + await generateWitness(assert_lt_json, inputsHexPrefix); + 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 generateWitness(assert_lt_json, inputs); + expect.fail('Expected generatedWitness to throw, due to x not being convertible to a uint64'); + } catch (error) { + const knownError = error as Error; + expect(knownError.message).to.equal('Input for x is the wrong type, expected uint64, got "foo"'); + } + }); +}); From 153a72f8263b880c3365c8e80fbd84a9f9a1faea Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:26:21 +0000 Subject: [PATCH 13/37] add bb.js test to show how it may interact with noir.js --- tooling/noir_js/test/node/e2e.test.ts | 65 +++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tooling/noir_js/test/node/e2e.test.ts diff --git a/tooling/noir_js/test/node/e2e.test.ts b/tooling/noir_js/test/node/e2e.test.ts new file mode 100644 index 00000000000..60fcc5b5cb7 --- /dev/null +++ b/tooling/noir_js/test/node/e2e.test.ts @@ -0,0 +1,65 @@ +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 { Backend } from '../backend/barretenberg.js'; + +it('end-to-end proof creation and verification', async () => { + // Noir.Js part + const inputs = { + x: '2', + y: '3', + }; + const solvedWitness = 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 + const isValid = await prover.verifyOuterProof(proof); + expect(isValid).to.be.true; +}); + +// The "real" workflow will involve a prover and a verifier on different systems. +// +// We cannot do this in our tests because they will panic with: +// `RuntimeError: null function or function signature mismatch` +// +// This happens when we we create a proof with one barretenberg instance and +// try to verify it with another. +// +// If this bug is fixed, we can remove this test and split barretenberg into +// a prover and verifier class to more accurately reflect what happens in production. +// +// If its not fixable, we can leave it in as documentation of this behavior. +it('[BUG] -- bb.js null function or function signature mismatch ', async () => { + // Noir.Js part + const inputs = { + x: '2', + y: '3', + }; + const solvedWitness = 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 { + const verifier = new Backend(assert_lt_json.bytecode); + await verifier.init(); + await verifier.verifyOuterProof(proof); + expect.fail( + 'bb.js currently returns a bug when we try to verify a proof with a different Barretenberg instance that created it.', + ); + } catch (error) { + const knownError = error as Error; + expect(knownError.message).to.contain('null function or function signature mismatch'); + } +}); From 98bfa9fd7b96f66e4b8dc54f82eb61b46f47401c Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:46:09 +0000 Subject: [PATCH 14/37] increase timeout --- tooling/noir_js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tooling/noir_js/package.json b/tooling/noir_js/package.json index 98c224a7d49..a8436fa5da0 100644 --- a/tooling/noir_js/package.json +++ b/tooling/noir_js/package.json @@ -21,7 +21,7 @@ "scripts": { "dev": "tsc --watch", "build": "tsc", - "test:node": "mocha --timeout 5000", + "test:node": "mocha --timeout 10000", "prettier": "prettier 'src/**/*.ts'", "prettier:fix": "prettier --write 'src/**/*.ts' 'test/**/*.ts'" }, From 6386400f77b8db5d0c885b3eec9ac76ea3ce01de Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:46:39 +0000 Subject: [PATCH 15/37] add another instance of null function --- tooling/noir_js/test/node/e2e.test.ts | 48 ++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/tooling/noir_js/test/node/e2e.test.ts b/tooling/noir_js/test/node/e2e.test.ts index 60fcc5b5cb7..2fbd92e64d3 100644 --- a/tooling/noir_js/test/node/e2e.test.ts +++ b/tooling/noir_js/test/node/e2e.test.ts @@ -36,7 +36,7 @@ it('end-to-end proof creation and verification', async () => { // a prover and verifier class to more accurately reflect what happens in production. // // If its not fixable, we can leave it in as documentation of this behavior. -it('[BUG] -- bb.js null function or function signature mismatch ', async () => { +it('[BUG] -- bb.js null function or function signature mismatch (different instance) ', async () => { // Noir.Js part const inputs = { x: '2', @@ -63,3 +63,49 @@ it('[BUG] -- bb.js null function or function signature mismatch ', async () => { expect(knownError.message).to.contain('null function or function signature mismatch'); } }); + +// This bug occurs when we use the same backend to create an inner proof and then an outer proof +// and then try to verify either one of them. +// +// The panic occurs when we try to verify the outer/inner proof that was created. +// If we only create one type of proof, then this works as expected. +// +// If we do not create an inner proof, then this will work as expected. +it.only('[BUG] -- bb.js null function or function signature mismatch (outer-inner) ', async () => { + + // Noir.Js part + const inputs = { + x: '2', + y: '3', + }; + const solvedWitness = 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); + // 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); + + // Proof verification + // + try { + + const isValidOuter = await prover.verifyOuterProof(proofOuter); + expect(isValidOuter).to.be.true; + // We can also try verifying an inner proof and it will fail. + // const isValidInner = await prover.verifyInnerProof(proofInner); + // expect(isValidInner).to.be.true; + expect.fail( + 'bb.js currently returns a bug when we try to verify an inner and outer proof with the same backend', + ); + } catch (error) { + const knownError = error as Error; + expect(knownError.message).to.contain('null function or function signature mismatch'); + } +}); \ No newline at end of file From e479c9c23068146b8377d05f5fb237bd8edd74a4 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:46:59 +0000 Subject: [PATCH 16/37] update yarn.lock --- yarn.lock | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6d8c11a8eb7..20ac012106a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,6 +22,20 @@ __metadata: languageName: node linkType: hard +"@aztec/bb.js@npm:0.7.2": + version: 0.7.2 + resolution: "@aztec/bb.js@npm:0.7.2" + dependencies: + comlink: ^4.4.1 + commander: ^10.0.1 + debug: ^4.3.4 + tslib: ^2.4.0 + bin: + bb.js: dest/node/main.js + checksum: 68299e5b0ef9583d78d1aaeb4e6a80cf5e049d45e48fb02798a41a2dfda0e68d729e8fbc1d23ab692914ce3857c729b48da9200fca49b838416b7988e5516d0b + languageName: node + linkType: hard + "@aztec/bb.js@npm:^0.5.1": version: 0.5.1 resolution: "@aztec/bb.js@npm:0.5.1" @@ -403,8 +417,18 @@ __metadata: version: 0.0.0-use.local resolution: "@noir-lang/noir_js@workspace:tooling/noir_js" dependencies: + "@aztec/bb.js": 0.7.2 "@noir-lang/acvm_js": 0.26.1 "@noir-lang/noirc_abi": "workspace:*" + "@types/chai": ^4 + "@types/mocha": ^10.0.1 + "@types/node": ^20.6.2 + "@types/prettier": ^3 + chai: ^4.3.8 + fflate: ^0.8.0 + mocha: ^10.2.0 + prettier: 3.0.3 + ts-node: ^10.9.1 typescript: ^5.2.2 languageName: unknown linkType: soft @@ -655,7 +679,7 @@ __metadata: languageName: node linkType: hard -"@types/chai@npm:^4.2.12": +"@types/chai@npm:^4, @types/chai@npm:^4.2.12": version: 4.3.6 resolution: "@types/chai@npm:4.3.6" checksum: 32a6c18bf53fb3dbd89d1bfcadb1c6fd45cc0007c34e436393cc37a0a5a556f9e6a21d1e8dd71674c40cc36589d2f30bf4d9369d7787021e54d6e997b0d7300a @@ -867,6 +891,13 @@ __metadata: languageName: node linkType: hard +"@types/mocha@npm:^10.0.1": + version: 10.0.1 + resolution: "@types/mocha@npm:10.0.1" + checksum: 224ea9fce7b1734ccdb9aa99a622d902a538ce1847bca7fd22c5fb38adcf3ed536f50f48f587085db988a4bb3c2eb68f4b98e1cd6a38bc5547bd3bbbedc54495 + languageName: node + linkType: hard + "@types/mocha@npm:^8.2.0": version: 8.2.3 resolution: "@types/mocha@npm:8.2.3" @@ -888,6 +919,13 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^20.6.2": + version: 20.6.2 + resolution: "@types/node@npm:20.6.2" + checksum: 96fe5303872640a173f3fd43e289a451776ed5b8f0090094447c6790b43f23fb607eea8268af0829cef4d132e5afa0bfa4cd871aa7412e9042a414a698e9e971 + languageName: node + linkType: hard + "@types/normalize-package-data@npm:^2.4.1": version: 2.4.1 resolution: "@types/normalize-package-data@npm:2.4.1" @@ -902,6 +940,15 @@ __metadata: languageName: node linkType: hard +"@types/prettier@npm:^3": + version: 3.0.0 + resolution: "@types/prettier@npm:3.0.0" + dependencies: + prettier: "*" + checksum: a2a512d304e5bcf78f38089dc88ad19215e6ab871d435a17aef3ce538a63b07c0e359c18db23989dc1ed9fff96d99eee1f680416080184df5c7e0e3bf767e165 + languageName: node + linkType: hard + "@types/ps-tree@npm:^1.1.2": version: 1.1.2 resolution: "@types/ps-tree@npm:1.1.2" @@ -2145,7 +2192,7 @@ __metadata: languageName: node linkType: hard -"chai@npm:^4.3.7": +"chai@npm:^4.3.7, chai@npm:^4.3.8": version: 4.3.8 resolution: "chai@npm:4.3.8" dependencies: @@ -5914,6 +5961,15 @@ __metadata: languageName: node linkType: hard +"prettier@npm:*, prettier@npm:3.0.3": + version: 3.0.3 + resolution: "prettier@npm:3.0.3" + bin: + prettier: bin/prettier.cjs + checksum: e10b9af02b281f6c617362ebd2571b1d7fc9fb8a3bd17e371754428cda992e5e8d8b7a046e8f7d3e2da1dcd21aa001e2e3c797402ebb6111b5cd19609dd228e0 + languageName: node + linkType: hard + "prettier@npm:^2.8.8": version: 2.8.8 resolution: "prettier@npm:2.8.8" From 4cdeeae6ef6dc5f9cc1d8d56d8a70250ce22429e Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:51:56 +0000 Subject: [PATCH 17/37] add `yarn test` --- tooling/noir_js/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tooling/noir_js/package.json b/tooling/noir_js/package.json index 3500894e480..113c8bb7610 100644 --- a/tooling/noir_js/package.json +++ b/tooling/noir_js/package.json @@ -21,6 +21,7 @@ "scripts": { "dev": "tsc --watch", "build": "tsc", + "test": "yarn test:node", "test:node": "mocha --timeout 10000", "prettier": "prettier 'src/**/*.ts'", "prettier:fix": "prettier --write 'src/**/*.ts' 'test/**/*.ts'", From dd6b837ec2e50377d2fbe0ca17f672ad47ba379c Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 21:52:06 +0000 Subject: [PATCH 18/37] remove .only --- tooling/noir_js/test/node/e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tooling/noir_js/test/node/e2e.test.ts b/tooling/noir_js/test/node/e2e.test.ts index 2fbd92e64d3..2891ae2d647 100644 --- a/tooling/noir_js/test/node/e2e.test.ts +++ b/tooling/noir_js/test/node/e2e.test.ts @@ -71,7 +71,7 @@ it('[BUG] -- bb.js null function or function signature mismatch (different insta // If we only create one type of proof, then this works as expected. // // If we do not create an inner proof, then this will work as expected. -it.only('[BUG] -- bb.js null function or function signature mismatch (outer-inner) ', async () => { +it('[BUG] -- bb.js null function or function signature mismatch (outer-inner) ', async () => { // Noir.Js part const inputs = { From de1f7efe763e045c229b676d8cd97b3f22995891 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 22:00:49 +0000 Subject: [PATCH 19/37] no test is using 1_mul so we can remove it --- .../noir_js/test/noir_compiled_examples/1_mul/Nargo.toml | 7 ------- .../test/noir_compiled_examples/1_mul/src/main.nr | 9 --------- .../test/noir_compiled_examples/1_mul/target/1_mul.json | 1 - 3 files changed, 17 deletions(-) delete mode 100644 tooling/noir_js/test/noir_compiled_examples/1_mul/Nargo.toml delete mode 100644 tooling/noir_js/test/noir_compiled_examples/1_mul/src/main.nr delete mode 100644 tooling/noir_js/test/noir_compiled_examples/1_mul/target/1_mul.json diff --git a/tooling/noir_js/test/noir_compiled_examples/1_mul/Nargo.toml b/tooling/noir_js/test/noir_compiled_examples/1_mul/Nargo.toml deleted file mode 100644 index 29053e36f7c..00000000000 --- a/tooling/noir_js/test/noir_compiled_examples/1_mul/Nargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "1_mul" -type = "bin" -authors = [""] -compiler_version = "0.1" - -[dependencies] diff --git a/tooling/noir_js/test/noir_compiled_examples/1_mul/src/main.nr b/tooling/noir_js/test/noir_compiled_examples/1_mul/src/main.nr deleted file mode 100644 index 4587b4b5947..00000000000 --- a/tooling/noir_js/test/noir_compiled_examples/1_mul/src/main.nr +++ /dev/null @@ -1,9 +0,0 @@ -// Test unsafe integer multiplication with overflow: 12^8 = 429 981 696 -// The circuit should handle properly the growth of the bit size -fn main(mut x: u32, y: u32, z: u32) { - x *= y; - x *= x; //144 - x *= x; //20736 - x *= x; //429 981 696 - assert(x == z); -} diff --git a/tooling/noir_js/test/noir_compiled_examples/1_mul/target/1_mul.json b/tooling/noir_js/test/noir_compiled_examples/1_mul/target/1_mul.json deleted file mode 100644 index b98559b1a12..00000000000 --- a/tooling/noir_js/test/noir_compiled_examples/1_mul/target/1_mul.json +++ /dev/null @@ -1 +0,0 @@ -{"backend":"acvm-backend-barretenberg","abi":{"parameters":[{"name":"x","type":{"kind":"integer","sign":"unsigned","width":32},"visibility":"private"},{"name":"y","type":{"kind":"integer","sign":"unsigned","width":32},"visibility":"private"},{"name":"z","type":{"kind":"integer","sign":"unsigned","width":32},"visibility":"private"}],"param_witnesses":{"x":[1],"y":[2],"z":[3]},"return_type":null,"return_witnesses":[]},"bytecode":"H4sIAAAAAAAA/23LywkAAAgCUPsM0v5TFlQQkiDyDjoAQ0eqOhvHSrYx/9ZfEgkgcMloAAAA"} \ No newline at end of file From 1fb56d0852dd11a63a4c846c6db86e0e0881d27d Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 22:19:43 +0000 Subject: [PATCH 20/37] add separate inner proof -- this quickly verifies that inner proof creation is not broken --- tooling/noir_js/test/node/e2e.test.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tooling/noir_js/test/node/e2e.test.ts b/tooling/noir_js/test/node/e2e.test.ts index 2891ae2d647..4f6db02e9ea 100644 --- a/tooling/noir_js/test/node/e2e.test.ts +++ b/tooling/noir_js/test/node/e2e.test.ts @@ -3,7 +3,7 @@ import assert_lt_json from '../noir_compiled_examples/assert_lt/target/assert_lt import { generateWitness, witnessMapToUint8Array } from '../../src/index.js'; import { Backend } from '../backend/barretenberg.js'; -it('end-to-end proof creation and verification', async () => { +it('end-to-end proof creation and verification (outer)', async () => { // Noir.Js part const inputs = { x: '2', @@ -24,6 +24,27 @@ it('end-to-end proof creation and verification', async () => { expect(isValid).to.be.true; }); +it('end-to-end proof creation and verification (inner)', async () => { + // Noir.Js part + const inputs = { + x: '2', + y: '3', + }; + const solvedWitness = 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 + const isValid = await prover.verifyInnerProof(proof); + expect(isValid).to.be.true; +}); + // The "real" workflow will involve a prover and a verifier on different systems. // // We cannot do this in our tests because they will panic with: From 3666b5a3cdace2cc75d8fe49057d35d0bf7aa83f Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 16 Sep 2023 22:41:41 +0000 Subject: [PATCH 21/37] add bug-doc test that creates and verifies an inner and outer proof using two _different_ instances. --- tooling/noir_js/test/node/e2e.test.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tooling/noir_js/test/node/e2e.test.ts b/tooling/noir_js/test/node/e2e.test.ts index 4f6db02e9ea..3f5d2006ad7 100644 --- a/tooling/noir_js/test/node/e2e.test.ts +++ b/tooling/noir_js/test/node/e2e.test.ts @@ -129,4 +129,28 @@ it('[BUG] -- bb.js null function or function signature mismatch (outer-inner) ', const knownError = error as Error; expect(knownError.message).to.contain('null function or function signature mismatch'); } +}); + +// This is being added to further document the above test marked as bugs. +it.only('create and verify proof inner and outer proof with two different backends ', async () => { + + // Noir.Js part + const inputs = { + x: '2', + y: '3', + }; + const solvedWitness = await generateWitness(assert_lt_json, inputs); + + let backend = new Backend(assert_lt_json.bytecode); + await backend.init(); + const serializedWitness = witnessMapToUint8Array(solvedWitness); + const proofInner = await backend.generateInnerProof(serializedWitness); + const isValidInner = await backend.verifyInnerProof(proofInner); + expect(isValidInner).to.be.true; + + backend = new Backend(assert_lt_json.bytecode); + await backend.init(); + const proofOuter = await backend.generateOuterProof(serializedWitness); + const isValidOuter = await backend.verifyOuterProof(proofOuter); + expect(isValidOuter).to.be.true; }); \ No newline at end of file From f4060335e184d6086edcdfaf11c0010b1953a02a Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sun, 17 Sep 2023 12:26:47 +0000 Subject: [PATCH 22/37] update yarn.lock --- yarn.lock | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/yarn.lock b/yarn.lock index 25abc9fc747..9712133e550 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,6 +22,20 @@ __metadata: languageName: node linkType: hard +"@aztec/bb.js@npm:0.7.2": + version: 0.7.2 + resolution: "@aztec/bb.js@npm:0.7.2" + dependencies: + comlink: ^4.4.1 + commander: ^10.0.1 + debug: ^4.3.4 + tslib: ^2.4.0 + bin: + bb.js: dest/node/main.js + checksum: 68299e5b0ef9583d78d1aaeb4e6a80cf5e049d45e48fb02798a41a2dfda0e68d729e8fbc1d23ab692914ce3857c729b48da9200fca49b838416b7988e5516d0b + languageName: node + linkType: hard + "@aztec/bb.js@npm:^0.6.7": version: 0.6.7 resolution: "@aztec/bb.js@npm:0.6.7" From c7146ddd5376af94fd3019fbb59f99adfd38f4e1 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 18 Sep 2023 10:17:03 +0000 Subject: [PATCH 23/37] add correct eslint and prettier --- tooling/noir_js/package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tooling/noir_js/package.json b/tooling/noir_js/package.json index 113c8bb7610..f4127f14fd7 100644 --- a/tooling/noir_js/package.json +++ b/tooling/noir_js/package.json @@ -22,7 +22,7 @@ "dev": "tsc --watch", "build": "tsc", "test": "yarn test:node", - "test:node": "mocha --timeout 10000", + "test:node": "mocha --timeout 25000", "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" @@ -34,6 +34,8 @@ "@types/node": "^20.6.2", "@types/prettier": "^3", "chai": "^4.3.8", + "eslint": "^8.40.0", + "eslint-plugin-prettier": "^5.0.0", "mocha": "^10.2.0", "prettier": "3.0.3", "ts-node": "^10.9.1", From 97ad1fc556cc8c0a0d3c4016d6bca7407beedd00 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 18 Sep 2023 10:18:21 +0000 Subject: [PATCH 24/37] change file to .cjs since we have instructed typescript to treat node as esm --- tooling/noir_js/{.eslintrc.js => .eslintrc.cjs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tooling/noir_js/{.eslintrc.js => .eslintrc.cjs} (100%) diff --git a/tooling/noir_js/.eslintrc.js b/tooling/noir_js/.eslintrc.cjs similarity index 100% rename from tooling/noir_js/.eslintrc.js rename to tooling/noir_js/.eslintrc.cjs From b01a21552c3d145dca1aa0d93a3cada615a604e9 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 18 Sep 2023 10:18:37 +0000 Subject: [PATCH 25/37] update yarn.lock --- yarn.lock | 276 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 270 insertions(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index 9712133e550..9a92be42a67 100644 --- a/yarn.lock +++ b/yarn.lock @@ -418,6 +418,8 @@ __metadata: "@types/node": ^20.6.2 "@types/prettier": ^3 chai: ^4.3.8 + eslint: ^8.40.0 + eslint-plugin-prettier: ^5.0.0 fflate: ^0.8.0 mocha: ^10.2.0 prettier: 3.0.3 @@ -497,6 +499,20 @@ __metadata: languageName: node linkType: hard +"@pkgr/utils@npm:^2.3.1": + version: 2.4.2 + resolution: "@pkgr/utils@npm:2.4.2" + dependencies: + cross-spawn: ^7.0.3 + fast-glob: ^3.3.0 + is-glob: ^4.0.3 + open: ^9.1.0 + picocolors: ^1.0.0 + tslib: ^2.6.0 + checksum: 24e04c121269317d259614cd32beea3af38277151c4002df5883c4be920b8e3490bb897748e844f9d46bf68230f86dabd4e8f093773130e7e60529a769a132fc + languageName: node + linkType: hard + "@puppeteer/browsers@npm:0.5.0": version: 0.5.0 resolution: "@puppeteer/browsers@npm:0.5.0" @@ -1964,7 +1980,7 @@ __metadata: languageName: node linkType: hard -"big-integer@npm:^1.6.17": +"big-integer@npm:^1.6.17, big-integer@npm:^1.6.44": version: 1.6.51 resolution: "big-integer@npm:1.6.51" checksum: 3d444173d1b2e20747e2c175568bedeebd8315b0637ea95d75fd27830d3b8e8ba36c6af40374f36bdaea7b5de376dcada1b07587cb2a79a928fccdb6e6e3c518 @@ -2013,6 +2029,15 @@ __metadata: languageName: node linkType: hard +"bplist-parser@npm:^0.2.0": + version: 0.2.0 + resolution: "bplist-parser@npm:0.2.0" + dependencies: + big-integer: ^1.6.44 + checksum: d5339dd16afc51de6c88f88f58a45b72ed6a06aa31f5557d09877575f220b7c1d3fbe375da0b62e6a10d4b8ed80523567e351f24014f5bc886ad523758142cdd + languageName: node + linkType: hard + "brace-expansion@npm:^1.1.7": version: 1.1.11 resolution: "brace-expansion@npm:1.1.11" @@ -2086,6 +2111,15 @@ __metadata: languageName: node linkType: hard +"bundle-name@npm:^3.0.0": + version: 3.0.0 + resolution: "bundle-name@npm:3.0.0" + dependencies: + run-applescript: ^5.0.0 + checksum: edf2b1fbe6096ed32e7566947ace2ea937ee427391744d7510a2880c4b9a5b3543d3f6c551236a29e5c87d3195f8e2912516290e638c15bcbede7b37cc375615 + languageName: node + linkType: hard + "bytes@npm:3.1.2": version: 3.1.2 resolution: "bytes@npm:3.1.2" @@ -2675,7 +2709,7 @@ __metadata: languageName: node linkType: hard -"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.2": +"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3": version: 7.0.3 resolution: "cross-spawn@npm:7.0.3" dependencies: @@ -2829,6 +2863,28 @@ __metadata: languageName: node linkType: hard +"default-browser-id@npm:^3.0.0": + version: 3.0.0 + resolution: "default-browser-id@npm:3.0.0" + dependencies: + bplist-parser: ^0.2.0 + untildify: ^4.0.0 + checksum: 279c7ad492542e5556336b6c254a4eaf31b2c63a5433265655ae6e47301197b6cfb15c595a6fdc6463b2ff8e1a1a1ed3cba56038a60e1527ba4ab1628c6b9941 + languageName: node + linkType: hard + +"default-browser@npm:^4.0.0": + version: 4.0.0 + resolution: "default-browser@npm:4.0.0" + dependencies: + bundle-name: ^3.0.0 + default-browser-id: ^3.0.0 + execa: ^7.1.1 + titleize: ^3.0.0 + checksum: 40c5af984799042b140300be5639c9742599bda76dc9eba5ac9ad5943c83dd36cebc4471eafcfddf8e0ec817166d5ba89d56f08e66a126c7c7908a179cead1a7 + languageName: node + linkType: hard + "defer-to-connect@npm:^2.0.1": version: 2.0.1 resolution: "defer-to-connect@npm:2.0.1" @@ -2843,6 +2899,13 @@ __metadata: languageName: node linkType: hard +"define-lazy-prop@npm:^3.0.0": + version: 3.0.0 + resolution: "define-lazy-prop@npm:3.0.0" + checksum: 54884f94caac0791bf6395a3ec530ce901cf71c47b0196b8754f3fd17edb6c0e80149c1214429d851873bb0d689dbe08dcedbb2306dc45c8534a5934723851b6 + languageName: node + linkType: hard + "degenerator@npm:^5.0.0": version: 5.0.1 resolution: "degenerator@npm:5.0.1" @@ -3247,6 +3310,25 @@ __metadata: languageName: node linkType: hard +"eslint-plugin-prettier@npm:^5.0.0": + version: 5.0.0 + resolution: "eslint-plugin-prettier@npm:5.0.0" + dependencies: + prettier-linter-helpers: ^1.0.0 + synckit: ^0.8.5 + peerDependencies: + "@types/eslint": ">=8.0.0" + eslint: ">=8.0.0" + prettier: ">=3.0.0" + peerDependenciesMeta: + "@types/eslint": + optional: true + eslint-config-prettier: + optional: true + checksum: 84e88744b9050f2d5ef31b94e85294dda16f3a53c2449f9d33eac8ae6264889b459bf35a68e438fb6b329c2a1d6491aac4bfa00d86317e7009de3dad0311bec6 + languageName: node + linkType: hard + "eslint-scope@npm:^5.1.1": version: 5.1.1 resolution: "eslint-scope@npm:5.1.1" @@ -3410,6 +3492,40 @@ __metadata: languageName: node linkType: hard +"execa@npm:^5.0.0": + version: 5.1.1 + resolution: "execa@npm:5.1.1" + dependencies: + cross-spawn: ^7.0.3 + get-stream: ^6.0.0 + human-signals: ^2.1.0 + is-stream: ^2.0.0 + merge-stream: ^2.0.0 + npm-run-path: ^4.0.1 + onetime: ^5.1.2 + signal-exit: ^3.0.3 + strip-final-newline: ^2.0.0 + checksum: fba9022c8c8c15ed862847e94c252b3d946036d7547af310e344a527e59021fd8b6bb0723883ea87044dc4f0201f949046993124a42ccb0855cae5bf8c786343 + languageName: node + linkType: hard + +"execa@npm:^7.1.1": + version: 7.2.0 + resolution: "execa@npm:7.2.0" + dependencies: + cross-spawn: ^7.0.3 + get-stream: ^6.0.1 + human-signals: ^4.3.0 + is-stream: ^3.0.0 + merge-stream: ^2.0.0 + npm-run-path: ^5.1.0 + onetime: ^6.0.0 + signal-exit: ^3.0.7 + strip-final-newline: ^3.0.0 + checksum: 14fd17ba0ca8c87b277584d93b1d9fc24f2a65e5152b31d5eb159a3b814854283eaae5f51efa9525e304447e2f757c691877f7adff8fde5746aae67eb1edd1cc + languageName: node + linkType: hard + "exponential-backoff@npm:^3.1.1": version: 3.1.1 resolution: "exponential-backoff@npm:3.1.1" @@ -4207,6 +4323,20 @@ __metadata: languageName: node linkType: hard +"human-signals@npm:^2.1.0": + version: 2.1.0 + resolution: "human-signals@npm:2.1.0" + checksum: b87fd89fce72391625271454e70f67fe405277415b48bcc0117ca73d31fa23a4241787afdc8d67f5a116cf37258c052f59ea82daffa72364d61351423848e3b8 + languageName: node + linkType: hard + +"human-signals@npm:^4.3.0": + version: 4.3.1 + resolution: "human-signals@npm:4.3.1" + checksum: 6f12958df3f21b6fdaf02d90896c271df00636a31e2bbea05bddf817a35c66b38a6fdac5863e2df85bd52f34958997f1f50350ff97249e1dff8452865d5235d1 + languageName: node + linkType: hard + "humanize-ms@npm:^1.2.1": version: 1.2.1 resolution: "humanize-ms@npm:1.2.1" @@ -4405,6 +4535,15 @@ __metadata: languageName: node linkType: hard +"is-docker@npm:^3.0.0": + version: 3.0.0 + resolution: "is-docker@npm:3.0.0" + bin: + is-docker: cli.js + checksum: b698118f04feb7eaf3338922bd79cba064ea54a1c3db6ec8c0c8d8ee7613e7e5854d802d3ef646812a8a3ace81182a085dfa0a71cc68b06f3fa794b9783b3c90 + languageName: node + linkType: hard + "is-error@npm:^2.2.2": version: 2.2.2 resolution: "is-error@npm:2.2.2" @@ -4451,6 +4590,17 @@ __metadata: languageName: node linkType: hard +"is-inside-container@npm:^1.0.0": + version: 1.0.0 + resolution: "is-inside-container@npm:1.0.0" + dependencies: + is-docker: ^3.0.0 + bin: + is-inside-container: cli.js + checksum: c50b75a2ab66ab3e8b92b3bc534e1ea72ca25766832c0623ac22d134116a98bcf012197d1caabe1d1c4bd5f84363d4aa5c36bb4b585fbcaf57be172cd10a1a03 + languageName: node + linkType: hard + "is-lambda@npm:^1.0.1": version: 1.0.1 resolution: "is-lambda@npm:1.0.1" @@ -4514,6 +4664,13 @@ __metadata: languageName: node linkType: hard +"is-stream@npm:^3.0.0": + version: 3.0.0 + resolution: "is-stream@npm:3.0.0" + checksum: 172093fe99119ffd07611ab6d1bcccfe8bc4aa80d864b15f43e63e54b7abc71e779acd69afdb854c4e2a67fdc16ae710e370eda40088d1cfc956a50ed82d8f16 + languageName: node + linkType: hard + "is-unicode-supported@npm:^0.1.0": version: 0.1.0 resolution: "is-unicode-supported@npm:0.1.0" @@ -5106,6 +5263,13 @@ __metadata: languageName: node linkType: hard +"merge-stream@npm:^2.0.0": + version: 2.0.0 + resolution: "merge-stream@npm:2.0.0" + checksum: 6fa4dcc8d86629705cea944a4b88ef4cb0e07656ebf223fa287443256414283dd25d91c1cd84c77987f2aec5927af1a9db6085757cb43d90eb170ebf4b47f4f4 + languageName: node + linkType: hard + "merge2@npm:^1.3.0, merge2@npm:^1.4.1": version: 1.4.1 resolution: "merge2@npm:1.4.1" @@ -5570,6 +5734,24 @@ __metadata: languageName: node linkType: hard +"npm-run-path@npm:^4.0.1": + version: 4.0.1 + resolution: "npm-run-path@npm:4.0.1" + dependencies: + path-key: ^3.0.0 + checksum: 5374c0cea4b0bbfdfae62da7bbdf1e1558d338335f4cacf2515c282ff358ff27b2ecb91ffa5330a8b14390ac66a1e146e10700440c1ab868208430f56b5f4d23 + languageName: node + linkType: hard + +"npm-run-path@npm:^5.1.0": + version: 5.1.0 + resolution: "npm-run-path@npm:5.1.0" + dependencies: + path-key: ^4.0.0 + checksum: dc184eb5ec239d6a2b990b43236845332ef12f4e0beaa9701de724aa797fe40b6bbd0157fb7639d24d3ab13f5d5cf22d223a19c6300846b8126f335f788bee66 + languageName: node + linkType: hard + "npmlog@npm:^6.0.0": version: 6.0.2 resolution: "npmlog@npm:6.0.2" @@ -5607,7 +5789,7 @@ __metadata: languageName: node linkType: hard -"onetime@npm:^5.1.0": +"onetime@npm:^5.1.0, onetime@npm:^5.1.2": version: 5.1.2 resolution: "onetime@npm:5.1.2" dependencies: @@ -5616,6 +5798,15 @@ __metadata: languageName: node linkType: hard +"onetime@npm:^6.0.0": + version: 6.0.0 + resolution: "onetime@npm:6.0.0" + dependencies: + mimic-fn: ^4.0.0 + checksum: 0846ce78e440841335d4e9182ef69d5762e9f38aa7499b19f42ea1c4cd40f0b4446094c455c713f9adac3f4ae86f613bb5e30c99e52652764d06a89f709b3788 + languageName: node + linkType: hard + "only@npm:~0.0.2": version: 0.0.2 resolution: "only@npm:0.0.2" @@ -5634,6 +5825,18 @@ __metadata: languageName: node linkType: hard +"open@npm:^9.1.0": + version: 9.1.0 + resolution: "open@npm:9.1.0" + dependencies: + default-browser: ^4.0.0 + define-lazy-prop: ^3.0.0 + is-inside-container: ^1.0.0 + is-wsl: ^2.2.0 + checksum: 3993c0f61d51fed8ac290e99c9c3cf45d3b6cfb3e2aa2b74cafd312c3486c22fd81df16ac8f3ab91dd8a4e3e729a16fc2480cfc406c4833416cf908acf1ae7c9 + languageName: node + linkType: hard + "optionator@npm:^0.9.3": version: 0.9.3 resolution: "optionator@npm:0.9.3" @@ -5823,13 +6026,20 @@ __metadata: languageName: node linkType: hard -"path-key@npm:^3.1.0": +"path-key@npm:^3.0.0, path-key@npm:^3.1.0": version: 3.1.1 resolution: "path-key@npm:3.1.1" checksum: 55cd7a9dd4b343412a8386a743f9c746ef196e57c823d90ca3ab917f90ab9f13dd0ded27252ba49dbdfcab2b091d998bc446f6220cd3cea65db407502a740020 languageName: node linkType: hard +"path-key@npm:^4.0.0": + version: 4.0.0 + resolution: "path-key@npm:4.0.0" + checksum: 8e6c314ae6d16b83e93032c61020129f6f4484590a777eed709c4a01b50e498822b00f76ceaf94bc64dbd90b327df56ceadce27da3d83393790f1219e07721d7 + languageName: node + linkType: hard + "path-parse@npm:^1.0.7": version: 1.0.7 resolution: "path-parse@npm:1.0.7" @@ -5877,6 +6087,13 @@ __metadata: languageName: node linkType: hard +"picocolors@npm:^1.0.0": + version: 1.0.0 + resolution: "picocolors@npm:1.0.0" + checksum: a2e8092dd86c8396bdba9f2b5481032848525b3dc295ce9b57896f931e63fc16f79805144321f72976383fc249584672a75cc18d6777c6b757603f372f745981 + languageName: node + linkType: hard + "picomatch@npm:^2.0.4, picomatch@npm:^2.2.1, picomatch@npm:^2.2.2, picomatch@npm:^2.3.1": version: 2.3.1 resolution: "picomatch@npm:2.3.1" @@ -6407,6 +6624,15 @@ __metadata: languageName: node linkType: hard +"run-applescript@npm:^5.0.0": + version: 5.0.0 + resolution: "run-applescript@npm:5.0.0" + dependencies: + execa: ^5.0.0 + checksum: d00c2dbfa5b2d774de7451194b8b125f40f65fc183de7d9dcae97f57f59433586d3c39b9001e111c38bfa24c3436c99df1bb4066a2a0c90d39a8c4cd6889af77 + languageName: node + linkType: hard + "run-parallel@npm:^1.1.9": version: 1.2.0 resolution: "run-parallel@npm:1.2.0" @@ -6546,7 +6772,7 @@ __metadata: languageName: node linkType: hard -"signal-exit@npm:^3.0.2, signal-exit@npm:^3.0.7": +"signal-exit@npm:^3.0.2, signal-exit@npm:^3.0.3, signal-exit@npm:^3.0.7": version: 3.0.7 resolution: "signal-exit@npm:3.0.7" checksum: a2f098f247adc367dffc27845853e9959b9e88b01cb301658cfe4194352d8d2bb32e18467c786a7fe15f1d44b233ea35633d076d5e737870b7139949d1ab6318 @@ -6821,6 +7047,20 @@ __metadata: languageName: node linkType: hard +"strip-final-newline@npm:^2.0.0": + version: 2.0.0 + resolution: "strip-final-newline@npm:2.0.0" + checksum: 69412b5e25731e1938184b5d489c32e340605bb611d6140344abc3421b7f3c6f9984b21dff296dfcf056681b82caa3bb4cc996a965ce37bcfad663e92eae9c64 + languageName: node + linkType: hard + +"strip-final-newline@npm:^3.0.0": + version: 3.0.0 + resolution: "strip-final-newline@npm:3.0.0" + checksum: 23ee263adfa2070cd0f23d1ac14e2ed2f000c9b44229aec9c799f1367ec001478469560abefd00c5c99ee6f0b31c137d53ec6029c53e9f32a93804e18c201050 + languageName: node + linkType: hard + "strip-json-comments@npm:3.1.1, strip-json-comments@npm:^3.1.1": version: 3.1.1 resolution: "strip-json-comments@npm:3.1.1" @@ -6874,6 +7114,16 @@ __metadata: languageName: node linkType: hard +"synckit@npm:^0.8.5": + version: 0.8.5 + resolution: "synckit@npm:0.8.5" + dependencies: + "@pkgr/utils": ^2.3.1 + tslib: ^2.5.0 + checksum: 8a9560e5d8f3d94dc3cf5f7b9c83490ffa30d320093560a37b88f59483040771fd1750e76b9939abfbb1b5a23fd6dfbae77f6b338abffe7cae7329cd9b9bb86b + languageName: node + linkType: hard + "table-layout@npm:^3.0.0": version: 3.0.2 resolution: "table-layout@npm:3.0.2" @@ -6980,6 +7230,13 @@ __metadata: languageName: node linkType: hard +"titleize@npm:^3.0.0": + version: 3.0.0 + resolution: "titleize@npm:3.0.0" + checksum: 71fbbeabbfb36ccd840559f67f21e356e1d03da2915b32d2ae1a60ddcc13a124be2739f696d2feb884983441d159a18649e8d956648d591bdad35c430a6b6d28 + languageName: node + linkType: hard + "to-regex-range@npm:^5.0.1": version: 5.0.1 resolution: "to-regex-range@npm:5.0.1" @@ -7064,7 +7321,7 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^2.0.1, tslib@npm:^2.4.0": +"tslib@npm:^2.0.1, tslib@npm:^2.4.0, tslib@npm:^2.5.0, tslib@npm:^2.6.0": version: 2.6.2 resolution: "tslib@npm:2.6.2" checksum: 329ea56123005922f39642318e3d1f0f8265d1e7fcb92c633e0809521da75eeaca28d2cf96d7248229deb40e5c19adf408259f4b9640afd20d13aecc1430f3ad @@ -7274,6 +7531,13 @@ __metadata: languageName: node linkType: hard +"untildify@npm:^4.0.0": + version: 4.0.0 + resolution: "untildify@npm:4.0.0" + checksum: 39ced9c418a74f73f0a56e1ba4634b4d959422dff61f4c72a8e39f60b99380c1b45ed776fbaa0a4101b157e4310d873ad7d114e8534ca02609b4916bb4187fb9 + languageName: node + linkType: hard + "unzipper@npm:^0.10.14": version: 0.10.14 resolution: "unzipper@npm:0.10.14" From f2fd224b3421d0cdc830df741c2dea0edfe3f5c9 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 18 Sep 2023 10:21:36 +0000 Subject: [PATCH 26/37] commit recursive --- tooling/noir_js/test/backend/barretenberg.ts | 107 +++++++++++++++++- tooling/noir_js/test/node/e2e.test.ts | 35 ++++-- .../double_verify_proof/Nargo.toml | 7 ++ .../double_verify_proof/Prover.toml | 6 + .../double_verify_proof/src/main.nr | 32 ++++++ .../target/double_verify_proof.json | 1 + 6 files changed, 173 insertions(+), 15 deletions(-) create mode 100644 tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Nargo.toml create mode 100644 tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Prover.toml create mode 100644 tooling/noir_js/test/noir_compiled_examples/double_verify_proof/src/main.nr create mode 100644 tooling/noir_js/test/noir_compiled_examples/double_verify_proof/target/double_verify_proof.json diff --git a/tooling/noir_js/test/backend/barretenberg.ts b/tooling/noir_js/test/backend/barretenberg.ts index 0ec269286b0..8c30acf6b2e 100644 --- a/tooling/noir_js/test/backend/barretenberg.ts +++ b/tooling/noir_js/test/backend/barretenberg.ts @@ -2,10 +2,13 @@ import { Barretenberg, Crs, RawBuffer } from '@aztec/bb.js'; // TODO: This should be re-exported from @aztec/bb-js import { Ptr } from '@aztec/bb.js/dest/browser/types'; -import { acirToUint8Array } from '../../src/index.js'; +import { acirToUint8Array, acvm, generateWitness, witnessMapToUint8Array } from '../../src/index.js'; +import { WitnessMap, getPublicParametersWitness } from '@noir-lang/acvm_js'; +import { base64Decode } from '../../src/base64_decode.js'; +import double_verify_json from '../noir_compiled_examples/double_verify_proof/target/double_verify_proof.json' assert { type: 'json' }; export class Backend { - // These type assertions are used so that we don't + // These type assertions are used so that we don't // have to initialize `api` and `acirComposer` in the constructor. // These are initialized asynchronously in the `init` function, // constructors cannot be asynchronous which is why we do this. @@ -83,7 +86,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: number = 0) { + async generateInnerProofArtifacts(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 @@ -120,3 +123,101 @@ export class Backend { await this.api.destroy(); } } + +// This uses a 2 to 1 recursive backend. +// We assume all the circuits on the base layer are homogenous +// for simplicity, but we can change it, it will just require a lot more +// memory. +// TODO: Note that this API is vastly different from the one in the backend +// TODO my only concern is the usage of compiledProgram and bytecode not being consistent +// +// TODO: This API will change depending on whether we can aggregate different +// TODO circuits. If not, then API is fine. If so, then we cannot just save the proof +// TODO because each proof could be associated with a different circuit. +export class RecursiveBackend { + backend: Backend; + innerProofs: any[] = []; + acirCompressedBytecode: Uint8Array; + // + compiledProgram: any; + + constructor(compiledProgram: any) { + const acirBytecodeBase64 = compiledProgram.bytecode as string; + this.backend = new Backend(acirBytecodeBase64); + this.compiledProgram = compiledProgram; + + // TODO: This is needed because acvm reads in compressed bytecode + // TODO: while backends read in uncompressed bytecode. + // TODO: We should fix up the API to get rid of this discrepancy. + // + // Its only the raw barretenberg API that requires the uncompressed bytecode + // The acir tests for example use the compressed bytecode. + // We could: + // - change the barretenberg raw API to use compressed bytecode + // - make acvm take in uncompressed bytecode + // - create an API over the raw barretenberg API that takes in compressed bytecode + // I'm leaning towards modifying the acvm api to use uncompressed bytecode + this.acirCompressedBytecode = base64Decode(acirBytecodeBase64); + } + + async init() { + await this.backend.init(); + } + + // Creates a new inner proof, given just the inputs + // + // This is a nice APi, though it requires the abi being known + // by this class. This is the reason that the constructor takes in + // a compiledProgram. + async newInnerProof(inputs: any) { + const solvedWitness = await generateWitness(this.compiledProgram, inputs); + await this.newInnerProofFromSolvedWitness(solvedWitness); + } + + private async newInnerProofFromSolvedWitness(solvedWitness: WitnessMap) { + const serializedWitness = witnessMapToUint8Array(solvedWitness); + const proof = await this.backend.generateInnerProof(serializedWitness); + const numPublicParameters = getPublicParametersWitness(this.acirCompressedBytecode, solvedWitness).size; + const innerProofArtifacts = await this.backend.generateInnerProofArtifacts(proof, numPublicParameters); + this.innerProofs.push({ proofArtifacts: innerProofArtifacts, numPublicParameters: numPublicParameters }); + } + + // Recursively verifies a list of inner proofs. + // + // + async finalize(): Promise { + if (this.innerProofs.length == 0) { + throw new Error('No inner proofs have been created'); + } + if (this.innerProofs.length == 1) { + throw new Error('Currently we do not support the edge case of 1 proof being created. Fix would be to pad.'); + } + + // TODO(Maxim): I this should be fixed in ACVM and barretenberg. + if (this.innerProofs.length > 2) { + throw new Error( + 'Currently we only support recursively verifying 2 proofs, where each proof must not contain a recursive verification opcode. Barretenberg API does not support this.', + ); + } + + // Assuming we have the same circuit. + const proofA = this.innerProofs[0]; + const proofB = this.innerProofs[1]; + + this.backend = new Backend(double_verify_json.bytecode); + await this.backend.init(); + await generateWitness(double_verify_json, { verification_key: proofA.proofArtifacts.vkAsFields, y: '3' }); + + return new Uint8Array(); + + // This is sort of broken at the moment because barretenberg does not accept proofs + // which themselves have aggregation objects. So we can only have a tree which has two leaves. + // So doing a tree style recursive aggregation does not really work. + // + // Need to discuss further what the API should look like. + // + // If it was not broken, one use-case is we would push all proofs into a queue and verify + // each pair of proofs using an inner double-verify proof, until we get to the last layer. + throw new Error('Its not clear if we should do a tree based recursion algorithm or something closer to IVF'); + } +} diff --git a/tooling/noir_js/test/node/e2e.test.ts b/tooling/noir_js/test/node/e2e.test.ts index 3f5d2006ad7..9dbe6544d59 100644 --- a/tooling/noir_js/test/node/e2e.test.ts +++ b/tooling/noir_js/test/node/e2e.test.ts @@ -1,7 +1,7 @@ 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 { Backend } from '../backend/barretenberg.js'; +import { Backend, RecursiveBackend } from '../backend/barretenberg.js'; it('end-to-end proof creation and verification (outer)', async () => { // Noir.Js part @@ -93,7 +93,6 @@ it('[BUG] -- bb.js null function or function signature mismatch (different insta // // If we do not create an inner proof, then this will work as expected. it('[BUG] -- bb.js null function or function signature mismatch (outer-inner) ', async () => { - // Noir.Js part const inputs = { x: '2', @@ -108,23 +107,20 @@ 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 + // 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); - + // Proof verification // try { - const isValidOuter = await prover.verifyOuterProof(proofOuter); expect(isValidOuter).to.be.true; // We can also try verifying an inner proof and it will fail. // const isValidInner = await prover.verifyInnerProof(proofInner); // expect(isValidInner).to.be.true; - expect.fail( - 'bb.js currently returns a bug when we try to verify an inner and outer proof with the same backend', - ); + expect.fail('bb.js currently returns a bug when we try to verify an inner and outer proof with the same backend'); } catch (error) { const knownError = error as Error; expect(knownError.message).to.contain('null function or function signature mismatch'); @@ -132,8 +128,7 @@ it('[BUG] -- bb.js null function or function signature mismatch (outer-inner) ', }); // This is being added to further document the above test marked as bugs. -it.only('create and verify proof inner and outer proof with two different backends ', async () => { - +it('create and verify proof inner and outer proof with two different backends ', async () => { // Noir.Js part const inputs = { x: '2', @@ -147,10 +142,26 @@ it.only('create and verify proof inner and outer proof with two different backen const proofInner = await backend.generateInnerProof(serializedWitness); const isValidInner = await backend.verifyInnerProof(proofInner); expect(isValidInner).to.be.true; - + backend = new Backend(assert_lt_json.bytecode); await backend.init(); const proofOuter = await backend.generateOuterProof(serializedWitness); const isValidOuter = await backend.verifyOuterProof(proofOuter); expect(isValidOuter).to.be.true; -}); \ No newline at end of file +}); + +it.only('end-to-end proof recursive proof creation and verification', async () => { + // Noir.Js part + const inputs = { + x: '2', + y: '3', + }; + + const recursiveBackend = new RecursiveBackend(assert_lt_json); + await recursiveBackend.init(); + await recursiveBackend.newInnerProof({ x: '2', y: '3' }); + await recursiveBackend.newInnerProof({ x: '1', y: '3' }); + await recursiveBackend.newInnerProof({ x: '5', y: '6' }); + + const outerProof = await recursiveBackend.finalize(); +}); diff --git a/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Nargo.toml b/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Nargo.toml new file mode 100644 index 00000000000..61aaabfcf5b --- /dev/null +++ b/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "double_verify_proof" +type = "bin" +authors = [""] +compiler_version = "0.6.0" + +[dependencies] diff --git a/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Prover.toml b/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Prover.toml new file mode 100644 index 00000000000..3b4ca3c198f --- /dev/null +++ b/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Prover.toml @@ -0,0 +1,6 @@ +input_aggregation_object = ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"] +key_hash = "0x284158f92a5305f662f78fc36a397fb8eb44d229fd22152e2dc085cad142c3c2" +proof = ["0x000000000000000000000000000000000000000000000000000000000000000a","0x0000000000000000000000000000005e77a294b0829c1233b25f34cbd1e36ca5","0x00000000000000000000000000000000001efb564c6d131a2005503e7bc96dfd","0x0000000000000000000000000000003a2960d64558302ab11263ac1d4e99c792","0x000000000000000000000000000000000027934be1b834b8444d8974e4c1c9bb","0x000000000000000000000000000000a5e281184b833e3567ce8e285c80bd7dfc","0x00000000000000000000000000000000002ef660bd670bea9dc8e18192cb71fa","0x00000000000000000000000000000075b29302806ec08bb2c7af1b5463fc34fa","0x00000000000000000000000000000000001138c220233f7b40034a4f49a23ae6","0x000000000000000000000000000000c24fb0b91d6ea29b55a925f221c5b285d8","0x000000000000000000000000000000000013ff3e12b86654ca896bfd6bbedd69","0x0000000000000000000000000000005709282fede94015f85bce4c39d859e34a","0x00000000000000000000000000000000000fb8a86b7540bfdc1c2784d7943400","0x00000000000000000000000000000020bf9ff7ac6ddadf43c1f9128f13f66481","0x000000000000000000000000000000000012f42d353e8a008c1c65650aea9720","0x0000000000000000000000000000009b8c079fcd0a17aecbda82b255ac26131b","0x000000000000000000000000000000000027fe6ea46f3898befbae77137e493e","0x0000000000000000000000000000002a66a58be32207d7ac2e318e6d3235edac","0x00000000000000000000000000000000000fa3dfdf2bbf7c51f39b861dc44be6","0x0000000000000000000000000000003746eb9ded01fcafcc65c5d87f49141ee5","0x00000000000000000000000000000000001e65f8c6b1af063d4103022b38cd3e","0x00000000000000000000000000000046c520b61b4608d1bc2c98ca800765ebd7","0x000000000000000000000000000000000020434f43987d0f71d0a1aa2ed8f270","0x000000000000000000000000000000827b6b7c3b2a9c71a45a253a2a298c47f4","0x000000000000000000000000000000000009e45e0d42b0e22cbde0f4667e6288","0x000000000000000000000000000000c8150ed84dd7b794ce5427fe99040bcd3d","0x00000000000000000000000000000000002696a5d48bf45b5a80619ef91013d4","0x0000000000000000000000000000003a1caa16acc8da5032b2e836770312009d","0x0000000000000000000000000000000000237a8423952c1c64e1e7c75da9d7cf","0x0000000000000000000000000000000d8eb5fa6490a4cd67943b646d05bd0859","0x0000000000000000000000000000000000159ebdb4a5c764c0346287984ed47d","0x000000000000000000000000000000e862c821c535a49e93959d08dc9f2645b5","0x00000000000000000000000000000000000c440edae454a8865dc27c8de51090","0x000000000000000000000000000000a6973dd133a0e974b564e76d185a4b06b0","0x000000000000000000000000000000000016248ed7566da68af6f2bc248763b4","0x000000000000000000000000000000a568fd8430c974e995915c9265ac74617d","0x000000000000000000000000000000000006e205349a7913be4af0af8778a0fd","0x00000000000000000000000000000009fd63b6ca1767490d4ce191e7332fbdd6","0x00000000000000000000000000000000000f95d28c7e720dc455fd46a532731e","0x00000000000000000000000000000008d1b9d51b2425ddf4a15bc5307ea911b4","0x000000000000000000000000000000000001131845742cefc926b7d2b7dc4b9c","0x0000000000000000000000000000008dbc181365f1a3db87a66d527ca9d81ca5","0x00000000000000000000000000000000000a6f78cdcd1e2177580e6c89c23235","0x0000000000000000000000000000004723acbe295108f00ff760c0671d2d4bbf","0x000000000000000000000000000000000006058d93abb1d596501ee4c3f62971","0x08bacf9fdaba383e584559b8cd64ae8c04e670d9203f90c6b49efac7f00f5003","0x18541473055ebbcaefe15759125b820ed1c6b932af2659c5280bdf70bd5c09cc","0x161e0a0cb1aa6028cabb8ccb98646a9b0976618cad99bb1145c4d25cecef50be","0x0d353ffc0833fd6e1947133f5391544ed7dde0fbfa0109ec7a54baafb117b1ca","0x1a5209fd1dcf2705b7081b4e3bf7b2c33dd00ac4b2becfdf8ee7927703ea0357","0x1d247635110c48df6f62387026c5823f0eb9d843848fe7b8e1a9a96b1c6ad763","0x1cc4a7a8be5edc32432191b0ee2a9051d3b6384313c6b9e5efe8cd8712c872f2","0x2c8b6fa617041faeb2e814b39c288ff607ac03d746f3c0e622860720dfb24b83","0x1ecc99a77fda5d79a6426b18049876b36ad1a1aba693518b1b976360630c2f55","0x2f75dc15bb6fdd3d9762fe74485c5ead7a5476c11cd44ed9f43324028cd2dd68","0x0e20add7931c78604ef7986fe7b286ab582842a23b4c09e8ec03d8d88a31969c","0x2467bb747466b69b6b4deeaac4a82e32ca7585194cd838912a65d12f912b5c6c","0x23edab06b87cf9fd4a5f0161287283d97a9bcdbdd68779e08cad3e763420bd20","0x2817c054ad1ac5454f58ff525196ed920ba54fbb4d86820a5a414aaa61d7d1b1","0x12d63d1f6ed0a080694a209534ee08e4758b0382f9bab7e13aafcbcb62ecc8d0","0x153104c35caab490767364a7db8bca01043c63f358f20edd6205c544cf4a61ea","0x178bcc674a84c8a0839ca8ba82298b1d92edc463b82965d9895bbebe3ba7fb04","0x1224834d4b8a36290e11b8b153d81062ba503c36d6e7ef41916b647517a6e632","0x13112373ea4e5bf7e041a7312167b4f82653ead2f5e5e3d4d07bafd79ca690b6","0x26b7669e3463c6d162363b2cd0e8f6720aa97f9cdb04a8340fce7ead2421af56","0x120d09593529a665d992bf009fc6268a9088c95f401784f939d5ed1649a4e779","0x1c415baf2638f0c09def30dfcf650d56b0508544769813d1d807b1b114632d38","0x1e9c2353141304d0ab1874f27602ce733f01e5b4d5cf6acdff5dab2a80c0c652","0x20f6eaf701ed18e0b841b9051ca08f8fcdb346253506c1ca26b3a4a3ed1e5f6c","0x2351b29aefc72cf0c56afd17c33e50ac5c64a695943e18c64e099e1d597bf886","0x19e6940b385edcb090c5eccd28c74c3a219f24d41760bcd5b0b1b837a805941e","0x2cd7e4b967101d6ee0f2a33521762cace8ffe35930bc210554e8307df664c899","0x041f06de46e4862d5d59c363c119a79629261d6aa18aa737c288ac7f4bfb4153","0x2dc39620da58c2822418179ba6f61de6d31ee938c79a5ca15c473aef7ca1e824","0x00000000000000000000000000000000ffbd168649f4e00f0baef4ec3a08615f","0x18fbeff26a87cb38f373584bbd02d016fed78aefc6462811a23006679509b3a9","0x1888e78ad37d146406e710ae2dbd244877263b133875d090f7615a1e9c0ac083","0x2196fbe28ce9ce0e0e202bbf1268cabdcd0a2c03588e118765ba1ee1a16f2dc7","0x0137bc731354b1531dbdcbfc83802605035f69f937f9a7311a57e6d7126368ba","0x19f38da8f0717fe78812addd655ef59411805d70eb731d5da309ad111698e8d0","0x155452e2824d5bd4fd8f8e5feaa4bd7abe783613d6b78cf88377a48e9f7e70c2","0x2396966b07a6e535a9ae30883a97e854ff2425c6dcfa34bda164394ba919191f","0x09374f47b862065ac0ac49ceb02b5cc0d925af1980ab2bd5f4d9df555e8c4c91","0x26366e50b5c7244ffc3ecdf50a65180742b1c53092659bd1db852bdd726d52f3","0x12d13ee6d1faa21b7f810c64e31d7af08409f2ff2a669b3c7e4e82d1964e5954","0x2fd05defcf5fc010bb13908b3d573636ed9609163c210b3864f9cf59aa2f5fb6","0x00000000000000000000000000000046955fdfd58ca9013b39025ae688416131","0x00000000000000000000000000000000001d335d2fb9857cbc49e72cf34e86a5","0x0000000000000000000000000000000c6a8930092b36c72dbd0a7f4b65533c19","0x00000000000000000000000000000000000d099ff72ffae0f73756528d629a5e","0x0000000000000000000000000000008c8d80c3f2886519cb37a563f88f166cb8","0x00000000000000000000000000000000000393e9f6fdc31492e4b3da33fa5fe4","0x000000000000000000000000000000417fb818a6933554bf3ff602f1f450728d","0x00000000000000000000000000000000002074eb75888a752047676f72f5343f"] +public_inputs = ["0x000000000000000000000000000000000000000000000000000000000000000a"] +verification_key = ["0x21082ca216cbbf4e1c6e4f4594dd508c996dfbe1174efb98b11509c6e306460b","0x0000000000000000000000000000000000000000000000000000000000000010","0x0000000000000000000000000000000000000000000000000000000000000005","0x0000000000000000000000000000000000000000000000000000000000000010","0x0000000000000000000000000000000000000000000000000000000000000001","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000004cf4015c3a5297f556c3b72581f2dca64d","0x00000000000000000000000000000000000a67b44462aa65528a3e3b181e0bcd","0x00000000000000000000000000000091507f347e13f13eec9d9f327ac25ada11","0x00000000000000000000000000000000001993946f40247aa93aedba75857f3e","0x0000000000000000000000000000005d340a5ecb1a33c0b7055734ef91200c97","0x00000000000000000000000000000000001eebbe1207643a8bd1669b999e8226","0x0000000000000000000000000000006b27d5d1ffba12754d0718481e1a9a419a","0x00000000000000000000000000000000002f08a6a07ed616c588bcf4e3555c00","0x0000000000000000000000000000003cbc8e573c1299e8ba491bd2218a413bd7","0x0000000000000000000000000000000000192b586ec6fb3b1b6d063a00a86c65","0x000000000000000000000000000000c4516b3cffabe3dcdd074d74f595c81c04","0x000000000000000000000000000000000021142418da600cf97a5248cbd45524","0x000000000000000000000000000000c292117b1a17fefe9de0bfd9edf1a84bf9","0x000000000000000000000000000000000002d6fd9e84dbe74b7531e1801405a1","0x000000000000000000000000000000459a3b2a0b768da45ac7af7f2aec40fc42","0x0000000000000000000000000000000000293c6ab3c06a0669af13393a82c60a","0x0000000000000000000000000000006c845044cca9a2d9dbf94039a11d999aaa","0x00000000000000000000000000000000000efe5ad29f99fce939416b6638dff2","0x000000000000000000000000000000587f768022c11ac8e37cd9dce243d01ef2","0x00000000000000000000000000000000000a44bf49517a4b66ae6b51eee6ac68","0x00000000000000000000000000000059d49ef10107e88711fc0919e244e17a08","0x0000000000000000000000000000000000132d159fdf1907b0619b9809904594","0x00000000000000000000000000000016d9bd1186bcef7a31846ce703eb4cb5b2","0x0000000000000000000000000000000000291c00ed4a7689fec327330104b85c","0x0000000000000000000000000000004b6c55389300451eb2a2deddf244129e7a","0x000000000000000000000000000000000018c3e78f81e83b52719158e4ac4c2f","0x0000000000000000000000000000008d7beb75f905a5894e18d27c42c62fd797","0x00000000000000000000000000000000000002e9c902fe5cd49b64563cadf3bb","0x0000000000000000000000000000000d9e28aa6d00e046852781a5f20816645c","0x00000000000000000000000000000000002cbce7beee3076b78dace04943d69d","0x000000000000000000000000000000fd915d11bfedbdc0e59de09e5b28952080","0x00000000000000000000000000000000002bc27ec2e1612ea284b08bcc55b6f2","0x000000000000000000000000000000be6ed4f4d252a79059e505f9abc1bdf3ed","0x00000000000000000000000000000000000ad34b5e8db72a5acf4427546c7294","0x00000000000000000000000000000090a049f42a3852acd45e6f521f24b4900e","0x00000000000000000000000000000000001e5b26790a26eb340217dd9ad28dbf","0x000000000000000000000000000000ac27e570ae50bc180509764eb3fef94815","0x0000000000000000000000000000000000155a0f51fec78c33ffceb7364d69d7","0x000000000000000000000000000000b644999713a8d3c66e9054aa5726324c76","0x00000000000000000000000000000000001c1c4720bed44a591d97cbc72b6e44","0x000000000000000000000000000000058cc5ad51753faec2a5908155d472e429","0x00000000000000000000000000000000000f7261cf55a71f4d0d7b961dda9ddb","0x0000000000000000000000000000004a36df78f0d50144437ef26f8bbfe69ac1","0x00000000000000000000000000000000001b7b1a10c1e638ce11d8c84b831aca","0x000000000000000000000000000000826ba5b1d1ddd8d6bb960f01cd1321a169","0x0000000000000000000000000000000000163a9c8b67447afccc64e9ccba9d9e","0x0000000000000000000000000000007653a773088aba5c6b1337f435188d72c4","0x000000000000000000000000000000000019256311d43dbc795f746c63b20966","0x000000000000000000000000000000df58a7bad9afe3651be67bc6c298092e11","0x00000000000000000000000000000000001fa51a0d75363b3af4e259e0dbb2c5","0x000000000000000000000000000000c8b5836b29551d41dbc04bdb1fcf1a1868","0x000000000000000000000000000000000021915198840ad9c3666122b2837aea","0x0000000000000000000000000000005df0e69d7efdbc7898b3762f0a0ed976ad","0x00000000000000000000000000000000000cee6b75dcf02a07c50939e8ca3cf3","0x00000000000000000000000000000066a493be1ea69d2b335152719acd54d735","0x000000000000000000000000000000000027e49262bd388ce2d0f193988f3b8f","0x000000000000000000000000000000dd783bff1a1cfc999bb29859cfb16c46fc","0x000000000000000000000000000000000002c397073c8abce6d4140c9b961209","0x000000000000000000000000000000750599be670db593af86e1923fe8a1bb18","0x00000000000000000000000000000000002b7bba2d1efffce0d033f596b4d030","0x0000000000000000000000000000008ffb571a4b3cf83533f3f71b99a04f6e6b","0x00000000000000000000000000000000002c71c58b66498f903b3bbbda3d05ce","0x0000000000000000000000000000002afaefbcbd080c84dcea90b54f4e0a858f","0x0000000000000000000000000000000000039dce37f94d1bbd97ccea32a224fe","0x00000000000000000000000000000075783c73cfe56847d848fd93b63bf32083","0x000000000000000000000000000000000027dc44977efe6b3746a290706f4f72","0x000000000000000000000000000000de0cbf2edc8f085b16d73652b15eced8f5","0x00000000000000000000000000000000000a5366266dd7b71a10b356030226a2","0x00000000000000000000000000000000a7588ec4d6809c90bb451005a3de3077","0x0000000000000000000000000000000000136097d79e1b0ae373255e8760c499","0x000000000000000000000000000000f2595d77bdf72e4acdb0b0b43969860d98","0x000000000000000000000000000000000013dd7515ccac4095302d204f06f0bf","0x000000000000000000000000000000057fe211dad1b706e49a3b55920fac20ec","0x000000000000000000000000000000000016ff3501369121d410b445929239ba","0x000000000000000000000000000000eb8007673c1ed10b834a695adf0068522a","0x00000000000000000000000000000000001e190987ebd9cf480f608b82134a00","0x0000000000000000000000000000000944f94301aa6da3016a226de04de52f4c","0x00000000000000000000000000000000001e44194e60f0ab4ee0f77adc50f422","0x0000000000000000000000000000006c2c7bea37dfbd20be6bed19efd743397a","0x00000000000000000000000000000000002a017d0d9f40d0aeb5c8152ffddec5","0x0000000000000000000000000000007f43efe5631bf48c872c317bed3b8bf12b","0x000000000000000000000000000000000027579be0883627093cf8bdec0b72e7","0x000000000000000000000000000000cef6108b89e89b35679431d113f3be7dff","0x00000000000000000000000000000000000ddb2d01ec88ed69144177a4af3850","0x0000000000000000000000000000000083e7ab1f26781948b36d131759f7c8c9","0x00000000000000000000000000000000000a7fe830f1cb7a5d49d71877dd226a","0x0000000000000000000000000000001834ecd1ce1e8e80812bdd95f960a45e57","0x00000000000000000000000000000000002db7a5185064e6501ef61e989895a0","0x000000000000000000000000000000363f0c994e91cecad25835338edee2294f","0x00000000000000000000000000000000002eea648c8732596b1314fe2a4d2f05","0x000000000000000000000000000000b2671d2ae51d31c1210433c3972bb64578","0x00000000000000000000000000000000000ab49886c2b94bd0bd3f6ed1dbbe2c"] +proof_b = ["0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000000000522e2d3071a75aa35d1e477d9e0ad3c0c2","0x000000000000000000000000000000000027bd4377f2ede7bc0133dde7d3b79d","0x000000000000000000000000000000df15ed61667d6fc6b99b97daafc3f7eddb","0x000000000000000000000000000000000003572ca7295a3ee92dc2ddafed48cd","0x000000000000000000000000000000b5dfb839be2c47c3d0e289df3c482bf286","0x00000000000000000000000000000000002471c02fbda062e36bcc7fbdf42dce","0x000000000000000000000000000000e3cbbbc33fb43fb006bd9f8e02dfd4cf9b","0x00000000000000000000000000000000000b3eb6b7a756351688c2561977d618","0x00000000000000000000000000000058d410d526cbd3adbee65868596758007f","0x0000000000000000000000000000000000289c7fe794a87811176d6b8a3973b3","0x000000000000000000000000000000deebf1d6b009435d734b2399d3558eb3f7","0x000000000000000000000000000000000023b6573225d811337c37b16691b872","0x000000000000000000000000000000c29b8cb5048472631403ee526a725ac163","0x0000000000000000000000000000000000206bff7bf596fde59255e7b85f9c7a","0x000000000000000000000000000000d8907ebb05228e706b57826cfc8207af57","0x0000000000000000000000000000000000305f614425315c05fc891c9a92a743","0x000000000000000000000000000000f183e5285136ab6c87d28dcfb65a99b02c","0x00000000000000000000000000000000000383ca0c47e2c56d39f5b58b9726a4","0x000000000000000000000000000000cc11844c28848bcdb1575af5bbae6eafa5","0x000000000000000000000000000000000018b1f820411130433f38ede2bd9158","0x000000000000000000000000000000821bd5681fdbbc82311485f9750ecda390","0x0000000000000000000000000000000000064257d786e839c16aa159b3672cc8","0x0000000000000000000000000000000e5205d207323e06ea8a18111dff8354af","0x00000000000000000000000000000000001254044ff7e569e4002f38956d2762","0x0000000000000000000000000000004591d851f6226ffe1a8a63456ee13411f7","0x00000000000000000000000000000000002b118f2b6639c3f776ed6847f98863","0x000000000000000000000000000000a0a0f63e73dd651c139b2fc3f45e9f4a94","0x00000000000000000000000000000000002669baf309d743d8c94871745bb19a","0x0000000000000000000000000000004cafdee2031bda8c4a2be55862c864524e","0x000000000000000000000000000000000002e68b1c1d2454113f78a184434cf2","0x000000000000000000000000000000899c0497e76b6b345776d9990c8eee4160","0x00000000000000000000000000000000000ec802d07823d277acf631b5c451f3","0x000000000000000000000000000000d5f1fa88434b81dd239ca62a3d168ff20e","0x000000000000000000000000000000000028511b798a4e506da8219fefcfe462","0x000000000000000000000000000000597adcfba2064c09a9e57b37d6a50fe775","0x00000000000000000000000000000000001f691d6d4cbed7b749f55e9af17403","0x00000000000000000000000000000071c78d719253bf3165591474d0a27a50ac","0x000000000000000000000000000000000024858bf4aff0e08df3c03fae341fc0","0x000000000000000000000000000000d0e80eafe0f0d2c1f760bd98087a069da0","0x0000000000000000000000000000000000266239c233e34815ca720e2e378f21","0x000000000000000000000000000000ad6462e3eca1c9a94e4dd30f3cecba48ad","0x0000000000000000000000000000000000147e1bff29ff6979f76ab6d840ded4","0x00000000000000000000000000000047cd629558a91f9db60c63944fa3835cdb","0x00000000000000000000000000000000002531925eaa902131ef11542fb5b20a","0x198e99c9dbc6f3ca902d080fdafb51410ee129edf20015c8337964f3f92b0376","0x2f04d8358d5740b6fa3aca9893cac185d641f2a00089b2bc428401ac21343d2c","0x2d5e2a67dee4e227ca84367a7d7ecd4860b1586a0d1eb799a41ee1042857e46a","0x2651bde5af62489c373d5fa812d6140b60df4569c6184d0d38f6f55dd49ec439","0x10e9e9d0cb817c09034cf3a4dbc9a44ed7a2618fd0281bf0d07a30b12facc6ea","0x11256980eccf0e654c61db759c8d71b04cd9a7c74d44165beaca2978aae075a9","0x2360ce983c2edb38f60b84a7f5ade89eed1fdb65363227e737dffbb8acba96e6","0x06c2d6ce83f1dc608f2cd267b351faa80bae0f688b3e2c6689235365ac05d614","0x1954b4ab315a061b176b67c8adb73d8ef4cc795951c506549ee17f0db90cca9a","0x1a738a34c81c0875d1fe2c68fb111bb55194edcf6c879e9ec99b4c93c5bac76b","0x012434d4aa45c5fb67f138a86116447befa784435b50fc1e67c74f07223480ef","0x1da9f41af8143f464c89dfae2b802ab73f0e64bcd71e5a18574bb4afa391a80f","0x1c41b34f51bf6cfddc0572770164eadcbf2fc4e7959f0fc7a4f19dc11780380a","0x0a6692e54ad790aa12bd9e225e116bfe1d068459dcd66eeac3ff646c672a0372","0x01859bc6385d07f9dfec4b8b2c1db0a53f8a05af246bfad33509beb42d9b5694","0x19e876787001790df811f7d7d26212e87b953a8945d632763d9bf154ab4ec167","0x01e702b7c67449f857e75e6df7251cce8f6c871aed86f988024c2e6139022c39","0x008b6178e573502eac46923d9df263b57cafa83bb14e7b91080370cf82750f75","0x2ea063d2aad0c7bcadf7fd7493e0cb8352c308a4e4101f128a7c4eb6dd80b118","0x099650fcf5f0c4f8f75189d335f9f176f8d1355ac6a31274782c21345d1f9c2a","0x1b8b6888ec0de5154a5ec2b3ebd4ace865dc035253532ebed5abf575a9e89763","0x024869a9548b8bf6cfe27150c22c88f7df4f0886b6a1f83ccf8e9e0e446901de","0x1aab445b8c2ffd0ae8081d9d6870eb3b1b5a3d60d80c2fdfd820d0aec21c6cb1","0x02a9d09ae2a2cdf547dd84338d33f5212f3189f27fbcf6f19cd10dbb4fcfd783","0x1b0cab4d1a473f0960033080337857646b3cbecca1272e94a563405bcd834256","0x1a49dd69fe18bb0c700d0aba9d697f11cb77bbf50ef1312b0ade6101b6b5970c","0x17a899e0aaba06df5f640dee973615b2a1c2b1a302c36432c0e496c0e1fc12d4","0x29416ace9513e527f7896ed30c14f92cbab613f3eebe6c87f810369c846023f3","0x13aca814f98cc1ba1c8818827876a6b782a579ab0494e03e190ebf6bd448e005","0x00000000000000000000000000000000d00591628e7f3bc935d0615c0808e684","0x0e1e573fd4e227709e85770ce6b1ec54c62a4563a360a85cafa285ef0de23f65","0x0df2626fd4c3b1352933f185d2ea12e6bfafced47ecea438cade894cc6e2db56","0x024a1e3b18a149a7643d0a7413a9f9a859534acb1075a49d79f80ab4b54d2a54","0x1ddc4265b93c17d06fa34332906e26b193c22fca27979dfe1dc7a3481ca26368","0x162ace72663cfa6de2e9f04e51dc9b391a9842df5c390ea45c830cb9ffe41170","0x0495b2a1fdf4505e043a1f14d28d3183875c756190b4f3d573ddcca45271c578","0x108711fd3a535631ffedab15afa2b45462d0109de6a5ce207b728da7fb0cc861","0x12f61ffde0a5cdd06d99615a9a13e9c35c9acf021c34d945a43911d6b5bc7357","0x1892fe8746226c4ff0c22f46b1b5af461256b39da8b35f6ce23b5274ee36d249","0x1e2fdd10ab9f0acf73eafd32c95774c8c81298393531e594203d931326b1313b","0x23ccbb9a111ba94ef713cb1ee0f93a4b7dce7cd4c1b06bbb5e3fd3b15f2b902d","0x00000000000000000000000000000012c0034de11daf4073d7347808aeaa15c3","0x00000000000000000000000000000000002467b5b5f10cf216361cdc1e6ec924","0x00000000000000000000000000000009d0e5bd1b7ed299b7150dd860562b575f","0x00000000000000000000000000000000000121e299f7c5b7b9a264a0237ba9c0","0x000000000000000000000000000000e52730fdae3a174391fede8b22ca59d266","0x000000000000000000000000000000000011e9a259a74f701d565dfbc05db520","0x000000000000000000000000000000e7574bc9af75e9f84a887d120d72b60507","0x000000000000000000000000000000000006f7685fea564d498d183eb56236b0"] \ No newline at end of file diff --git a/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/src/main.nr b/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/src/main.nr new file mode 100644 index 00000000000..39b8c142ace --- /dev/null +++ b/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/src/main.nr @@ -0,0 +1,32 @@ +use dep::std; + +fn main( + verification_key : [Field; 114], + proof : [Field; 94], + public_inputs : [Field; 1], + key_hash : Field, + input_aggregation_object : [Field; 16], + proof_b : [Field; 94], +) -> pub [Field; 16] { + let output_aggregation_object_a = std::verify_proof( + verification_key.as_slice(), + proof.as_slice(), + public_inputs.as_slice(), + key_hash, + input_aggregation_object + ); + + let output_aggregation_object = std::verify_proof( + verification_key.as_slice(), + proof_b.as_slice(), + public_inputs.as_slice(), + key_hash, + output_aggregation_object_a + ); + + let mut output = [0; 16]; + for i in 0..16 { + output[i] = output_aggregation_object[i]; + } + output +} diff --git a/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/target/double_verify_proof.json b/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/target/double_verify_proof.json new file mode 100644 index 00000000000..c873a25551a --- /dev/null +++ b/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/target/double_verify_proof.json @@ -0,0 +1 @@ +{"backend":"acvm-backend-barretenberg","abi":{"parameters":[{"name":"verification_key","type":{"kind":"array","length":114,"type":{"kind":"field"}},"visibility":"private"},{"name":"proof","type":{"kind":"array","length":94,"type":{"kind":"field"}},"visibility":"private"},{"name":"public_inputs","type":{"kind":"array","length":1,"type":{"kind":"field"}},"visibility":"private"},{"name":"key_hash","type":{"kind":"field"},"visibility":"private"},{"name":"input_aggregation_object","type":{"kind":"array","length":16,"type":{"kind":"field"}},"visibility":"private"},{"name":"proof_b","type":{"kind":"array","length":94,"type":{"kind":"field"}},"visibility":"private"}],"param_witnesses":{"input_aggregation_object":[211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226],"key_hash":[210],"proof":[115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208],"proof_b":[227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320],"public_inputs":[209],"verification_key":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114]},"return_type":{"kind":"array","length":16,"type":{"kind":"field"}},"return_witnesses":[337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352]},"bytecode":"H4sIAAAAAAAA/+3YZWxcRwAAYTuJw+AwJw4zMzvMzJyUmZkbZmZmZmZmLjOGmTl1Oqcbt1H/NlJaySt9Gr07++ns9e2et2toSEiCkOAIs69ZngqJhdiI4/NxEQ/xQ4LflxCJkBhJkBTJEI7kSIGUSIXUSIO0SIf0yICMyITMyIKsiEA2ZEcO5EQu5EYe5EU+5EcBFEQhFEYRFEUxFEcJlEQplEYZlEU5lEcFVEQlVEYVRKIqqqE6aqAmaqE26qAu6qE+GqAhGqExmqApmqE5WqAlWqE12qAt2qE9OqAjOqEzuqArHsPjeAJP4ik8jWfwLJ7D83gBL+IlvIxX8KpzGeZcdnJeX8cbeBNv4W28g3fxHt7HB/gQH+FjfIJP0Q3d0QM90Qu90Qd90Q/9MQADMQiDMQRDMQzDMQIjMQqjMQZjMQ7jMQETMQmTMQVTMQ3TMQMzMQuzMQdzMQ/zsQALsQiLsQRLsQzLsQIrsQqrsQZrsQ7rsQEbsQmbsQVbsQ3bsQM7sQu7sQd7sQ/7cQAHcQiHccR5iOVcBMZnPhZ4f4X72Bf4El/ha3yDb/EdvscP+BE/4Wf8gl/xG373foH3avRcH8UxHMcJnMQpnMYZnMU5nMcFXMQlXMYVXMU1XMcN3MQt3MYd3MU9/IEo3A8J/oChiIXYiIMwxEU8xA+sOUiIREiMJEiKZAhHcqRASqRCaqRBWqRDemRARmRCZmRBVkQgG7IjB3IiF3IjD/IiH/KjAAqiEAqjCIqiGIqjBEqiFEqjDMqiHMqjAiqiEiqjCiJDg3McWA8fXEujnP8o5zzKuYpy3gKNa+PZ+DaBTWgT2cQ2iU1qk9lwm9ymsCltKpvaprFpbTqb3mawGW0mm9lmsVlthM1ms9scNqfNZXPbPDavzWfz2wK2oC1kC9sitqgtZovbErakLWVL2zK2rC1ny9sKtqKtZCvbKjbSVrXVbHVbw9a0tWxtW8fWtfVsfdvANrSNbGPbxDa1zWxz28K2tK1sa9vGtrXtbHvbwXa0nWxn28V2tY/Zx+0T9kn7lH3aPmOftc/Z5+0L9kX7kn3ZvmJfta898DoD43Wv37Bv2rfs2/Yd+659z75vP7Af2o/sx/YT+6ntZrvbHran7WV72z62r+1n+9sBdqAdZAfbIXaoHWaH2xF2pB1lR9sxdqwdZ8fbCXainWQn2yl2qp1mp9sZdqadZWfbOXaunWfn2wV2oV1kF9sldqldZpfbFXalXWVX2zV2rV1n19sNdqPdZDfbLXar3Wa32x12p91ld9s9dq/dZ/fbA/agPWQP2yP2wc8egevP7V8fQKryFdVQHTVQE7VQG3VQF/VQHw3QEI3QGE1CgxtZ2EO8X8xGGmyEjdlIg43ZSIP9r2ykR70+Zo/bE/akPWVP2zP2rD1nz9sL9qK9ZC/bK/aqvWav2xv2pr1lb9s79q69Z6P/oYl23wYWoEBDbSwb28axYTaujWfj2wQ2oU1kE9skNqlNZsNtcpvCprSpbGqbxqa16Wx6m8FmtJlsZpvFZrURNpvNbnPYnDaXzW3z2Lw2n81vC9iCtpAtbIvYoraYLW5L2JK2lC1ty9iytpwtbyvYiraSrWyr2Mjo+Q8Jjn9upKEPbnyBB6rZ6raGrWlr2dq2jq1r69n6toFtaBvZxrZJ9B+Kr6Mp183QHC3QEq3QGm3QFu3QHh3QEZ3QGV1C/z71e1j3i/Q3F0jM6eL//3Qx5jTx0ZwmBhaewKLzb08MY04IH80JYfR4WOtq9PgTMelQ69IZAAA="} \ No newline at end of file From 13304e7154738291999d45a4afc81b4e7c61c0e6 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 18 Sep 2023 10:23:33 +0000 Subject: [PATCH 27/37] remove recursive --- tooling/noir_js/test/backend/barretenberg.ts | 105 +----------------- tooling/noir_js/test/node/e2e.test.ts | 41 +------ .../double_verify_proof/Nargo.toml | 7 -- .../double_verify_proof/Prover.toml | 6 - .../double_verify_proof/src/main.nr | 32 ------ .../target/double_verify_proof.json | 1 - 6 files changed, 3 insertions(+), 189 deletions(-) delete mode 100644 tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Nargo.toml delete mode 100644 tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Prover.toml delete mode 100644 tooling/noir_js/test/noir_compiled_examples/double_verify_proof/src/main.nr delete mode 100644 tooling/noir_js/test/noir_compiled_examples/double_verify_proof/target/double_verify_proof.json diff --git a/tooling/noir_js/test/backend/barretenberg.ts b/tooling/noir_js/test/backend/barretenberg.ts index 8c30acf6b2e..5124d6e2517 100644 --- a/tooling/noir_js/test/backend/barretenberg.ts +++ b/tooling/noir_js/test/backend/barretenberg.ts @@ -2,10 +2,7 @@ import { Barretenberg, Crs, RawBuffer } from '@aztec/bb.js'; // TODO: This should be re-exported from @aztec/bb-js import { Ptr } from '@aztec/bb.js/dest/browser/types'; -import { acirToUint8Array, acvm, generateWitness, witnessMapToUint8Array } from '../../src/index.js'; -import { WitnessMap, getPublicParametersWitness } from '@noir-lang/acvm_js'; -import { base64Decode } from '../../src/base64_decode.js'; -import double_verify_json from '../noir_compiled_examples/double_verify_proof/target/double_verify_proof.json' assert { type: 'json' }; +import { acirToUint8Array } from '../../src/index.js'; export class Backend { // These type assertions are used so that we don't @@ -122,102 +119,4 @@ export class Backend { async destroy() { await this.api.destroy(); } -} - -// This uses a 2 to 1 recursive backend. -// We assume all the circuits on the base layer are homogenous -// for simplicity, but we can change it, it will just require a lot more -// memory. -// TODO: Note that this API is vastly different from the one in the backend -// TODO my only concern is the usage of compiledProgram and bytecode not being consistent -// -// TODO: This API will change depending on whether we can aggregate different -// TODO circuits. If not, then API is fine. If so, then we cannot just save the proof -// TODO because each proof could be associated with a different circuit. -export class RecursiveBackend { - backend: Backend; - innerProofs: any[] = []; - acirCompressedBytecode: Uint8Array; - // - compiledProgram: any; - - constructor(compiledProgram: any) { - const acirBytecodeBase64 = compiledProgram.bytecode as string; - this.backend = new Backend(acirBytecodeBase64); - this.compiledProgram = compiledProgram; - - // TODO: This is needed because acvm reads in compressed bytecode - // TODO: while backends read in uncompressed bytecode. - // TODO: We should fix up the API to get rid of this discrepancy. - // - // Its only the raw barretenberg API that requires the uncompressed bytecode - // The acir tests for example use the compressed bytecode. - // We could: - // - change the barretenberg raw API to use compressed bytecode - // - make acvm take in uncompressed bytecode - // - create an API over the raw barretenberg API that takes in compressed bytecode - // I'm leaning towards modifying the acvm api to use uncompressed bytecode - this.acirCompressedBytecode = base64Decode(acirBytecodeBase64); - } - - async init() { - await this.backend.init(); - } - - // Creates a new inner proof, given just the inputs - // - // This is a nice APi, though it requires the abi being known - // by this class. This is the reason that the constructor takes in - // a compiledProgram. - async newInnerProof(inputs: any) { - const solvedWitness = await generateWitness(this.compiledProgram, inputs); - await this.newInnerProofFromSolvedWitness(solvedWitness); - } - - private async newInnerProofFromSolvedWitness(solvedWitness: WitnessMap) { - const serializedWitness = witnessMapToUint8Array(solvedWitness); - const proof = await this.backend.generateInnerProof(serializedWitness); - const numPublicParameters = getPublicParametersWitness(this.acirCompressedBytecode, solvedWitness).size; - const innerProofArtifacts = await this.backend.generateInnerProofArtifacts(proof, numPublicParameters); - this.innerProofs.push({ proofArtifacts: innerProofArtifacts, numPublicParameters: numPublicParameters }); - } - - // Recursively verifies a list of inner proofs. - // - // - async finalize(): Promise { - if (this.innerProofs.length == 0) { - throw new Error('No inner proofs have been created'); - } - if (this.innerProofs.length == 1) { - throw new Error('Currently we do not support the edge case of 1 proof being created. Fix would be to pad.'); - } - - // TODO(Maxim): I this should be fixed in ACVM and barretenberg. - if (this.innerProofs.length > 2) { - throw new Error( - 'Currently we only support recursively verifying 2 proofs, where each proof must not contain a recursive verification opcode. Barretenberg API does not support this.', - ); - } - - // Assuming we have the same circuit. - const proofA = this.innerProofs[0]; - const proofB = this.innerProofs[1]; - - this.backend = new Backend(double_verify_json.bytecode); - await this.backend.init(); - await generateWitness(double_verify_json, { verification_key: proofA.proofArtifacts.vkAsFields, y: '3' }); - - return new Uint8Array(); - - // This is sort of broken at the moment because barretenberg does not accept proofs - // which themselves have aggregation objects. So we can only have a tree which has two leaves. - // So doing a tree style recursive aggregation does not really work. - // - // Need to discuss further what the API should look like. - // - // If it was not broken, one use-case is we would push all proofs into a queue and verify - // each pair of proofs using an inner double-verify proof, until we get to the last layer. - throw new Error('Its not clear if we should do a tree based recursion algorithm or something closer to IVF'); - } -} +} \ No newline at end of file diff --git a/tooling/noir_js/test/node/e2e.test.ts b/tooling/noir_js/test/node/e2e.test.ts index 9dbe6544d59..e4ae25956c7 100644 --- a/tooling/noir_js/test/node/e2e.test.ts +++ b/tooling/noir_js/test/node/e2e.test.ts @@ -1,7 +1,7 @@ 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 { Backend, RecursiveBackend } from '../backend/barretenberg.js'; +import { Backend } from '../backend/barretenberg.js'; it('end-to-end proof creation and verification (outer)', async () => { // Noir.Js part @@ -126,42 +126,3 @@ it('[BUG] -- bb.js null function or function signature mismatch (outer-inner) ', expect(knownError.message).to.contain('null function or function signature mismatch'); } }); - -// This is being added to further document the above test marked as bugs. -it('create and verify proof inner and outer proof with two different backends ', async () => { - // Noir.Js part - const inputs = { - x: '2', - y: '3', - }; - const solvedWitness = await generateWitness(assert_lt_json, inputs); - - let backend = new Backend(assert_lt_json.bytecode); - await backend.init(); - const serializedWitness = witnessMapToUint8Array(solvedWitness); - const proofInner = await backend.generateInnerProof(serializedWitness); - const isValidInner = await backend.verifyInnerProof(proofInner); - expect(isValidInner).to.be.true; - - backend = new Backend(assert_lt_json.bytecode); - await backend.init(); - const proofOuter = await backend.generateOuterProof(serializedWitness); - const isValidOuter = await backend.verifyOuterProof(proofOuter); - expect(isValidOuter).to.be.true; -}); - -it.only('end-to-end proof recursive proof creation and verification', async () => { - // Noir.Js part - const inputs = { - x: '2', - y: '3', - }; - - const recursiveBackend = new RecursiveBackend(assert_lt_json); - await recursiveBackend.init(); - await recursiveBackend.newInnerProof({ x: '2', y: '3' }); - await recursiveBackend.newInnerProof({ x: '1', y: '3' }); - await recursiveBackend.newInnerProof({ x: '5', y: '6' }); - - const outerProof = await recursiveBackend.finalize(); -}); diff --git a/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Nargo.toml b/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Nargo.toml deleted file mode 100644 index 61aaabfcf5b..00000000000 --- a/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Nargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "double_verify_proof" -type = "bin" -authors = [""] -compiler_version = "0.6.0" - -[dependencies] diff --git a/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Prover.toml b/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Prover.toml deleted file mode 100644 index 3b4ca3c198f..00000000000 --- a/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/Prover.toml +++ /dev/null @@ -1,6 +0,0 @@ -input_aggregation_object = ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"] -key_hash = "0x284158f92a5305f662f78fc36a397fb8eb44d229fd22152e2dc085cad142c3c2" -proof = ["0x000000000000000000000000000000000000000000000000000000000000000a","0x0000000000000000000000000000005e77a294b0829c1233b25f34cbd1e36ca5","0x00000000000000000000000000000000001efb564c6d131a2005503e7bc96dfd","0x0000000000000000000000000000003a2960d64558302ab11263ac1d4e99c792","0x000000000000000000000000000000000027934be1b834b8444d8974e4c1c9bb","0x000000000000000000000000000000a5e281184b833e3567ce8e285c80bd7dfc","0x00000000000000000000000000000000002ef660bd670bea9dc8e18192cb71fa","0x00000000000000000000000000000075b29302806ec08bb2c7af1b5463fc34fa","0x00000000000000000000000000000000001138c220233f7b40034a4f49a23ae6","0x000000000000000000000000000000c24fb0b91d6ea29b55a925f221c5b285d8","0x000000000000000000000000000000000013ff3e12b86654ca896bfd6bbedd69","0x0000000000000000000000000000005709282fede94015f85bce4c39d859e34a","0x00000000000000000000000000000000000fb8a86b7540bfdc1c2784d7943400","0x00000000000000000000000000000020bf9ff7ac6ddadf43c1f9128f13f66481","0x000000000000000000000000000000000012f42d353e8a008c1c65650aea9720","0x0000000000000000000000000000009b8c079fcd0a17aecbda82b255ac26131b","0x000000000000000000000000000000000027fe6ea46f3898befbae77137e493e","0x0000000000000000000000000000002a66a58be32207d7ac2e318e6d3235edac","0x00000000000000000000000000000000000fa3dfdf2bbf7c51f39b861dc44be6","0x0000000000000000000000000000003746eb9ded01fcafcc65c5d87f49141ee5","0x00000000000000000000000000000000001e65f8c6b1af063d4103022b38cd3e","0x00000000000000000000000000000046c520b61b4608d1bc2c98ca800765ebd7","0x000000000000000000000000000000000020434f43987d0f71d0a1aa2ed8f270","0x000000000000000000000000000000827b6b7c3b2a9c71a45a253a2a298c47f4","0x000000000000000000000000000000000009e45e0d42b0e22cbde0f4667e6288","0x000000000000000000000000000000c8150ed84dd7b794ce5427fe99040bcd3d","0x00000000000000000000000000000000002696a5d48bf45b5a80619ef91013d4","0x0000000000000000000000000000003a1caa16acc8da5032b2e836770312009d","0x0000000000000000000000000000000000237a8423952c1c64e1e7c75da9d7cf","0x0000000000000000000000000000000d8eb5fa6490a4cd67943b646d05bd0859","0x0000000000000000000000000000000000159ebdb4a5c764c0346287984ed47d","0x000000000000000000000000000000e862c821c535a49e93959d08dc9f2645b5","0x00000000000000000000000000000000000c440edae454a8865dc27c8de51090","0x000000000000000000000000000000a6973dd133a0e974b564e76d185a4b06b0","0x000000000000000000000000000000000016248ed7566da68af6f2bc248763b4","0x000000000000000000000000000000a568fd8430c974e995915c9265ac74617d","0x000000000000000000000000000000000006e205349a7913be4af0af8778a0fd","0x00000000000000000000000000000009fd63b6ca1767490d4ce191e7332fbdd6","0x00000000000000000000000000000000000f95d28c7e720dc455fd46a532731e","0x00000000000000000000000000000008d1b9d51b2425ddf4a15bc5307ea911b4","0x000000000000000000000000000000000001131845742cefc926b7d2b7dc4b9c","0x0000000000000000000000000000008dbc181365f1a3db87a66d527ca9d81ca5","0x00000000000000000000000000000000000a6f78cdcd1e2177580e6c89c23235","0x0000000000000000000000000000004723acbe295108f00ff760c0671d2d4bbf","0x000000000000000000000000000000000006058d93abb1d596501ee4c3f62971","0x08bacf9fdaba383e584559b8cd64ae8c04e670d9203f90c6b49efac7f00f5003","0x18541473055ebbcaefe15759125b820ed1c6b932af2659c5280bdf70bd5c09cc","0x161e0a0cb1aa6028cabb8ccb98646a9b0976618cad99bb1145c4d25cecef50be","0x0d353ffc0833fd6e1947133f5391544ed7dde0fbfa0109ec7a54baafb117b1ca","0x1a5209fd1dcf2705b7081b4e3bf7b2c33dd00ac4b2becfdf8ee7927703ea0357","0x1d247635110c48df6f62387026c5823f0eb9d843848fe7b8e1a9a96b1c6ad763","0x1cc4a7a8be5edc32432191b0ee2a9051d3b6384313c6b9e5efe8cd8712c872f2","0x2c8b6fa617041faeb2e814b39c288ff607ac03d746f3c0e622860720dfb24b83","0x1ecc99a77fda5d79a6426b18049876b36ad1a1aba693518b1b976360630c2f55","0x2f75dc15bb6fdd3d9762fe74485c5ead7a5476c11cd44ed9f43324028cd2dd68","0x0e20add7931c78604ef7986fe7b286ab582842a23b4c09e8ec03d8d88a31969c","0x2467bb747466b69b6b4deeaac4a82e32ca7585194cd838912a65d12f912b5c6c","0x23edab06b87cf9fd4a5f0161287283d97a9bcdbdd68779e08cad3e763420bd20","0x2817c054ad1ac5454f58ff525196ed920ba54fbb4d86820a5a414aaa61d7d1b1","0x12d63d1f6ed0a080694a209534ee08e4758b0382f9bab7e13aafcbcb62ecc8d0","0x153104c35caab490767364a7db8bca01043c63f358f20edd6205c544cf4a61ea","0x178bcc674a84c8a0839ca8ba82298b1d92edc463b82965d9895bbebe3ba7fb04","0x1224834d4b8a36290e11b8b153d81062ba503c36d6e7ef41916b647517a6e632","0x13112373ea4e5bf7e041a7312167b4f82653ead2f5e5e3d4d07bafd79ca690b6","0x26b7669e3463c6d162363b2cd0e8f6720aa97f9cdb04a8340fce7ead2421af56","0x120d09593529a665d992bf009fc6268a9088c95f401784f939d5ed1649a4e779","0x1c415baf2638f0c09def30dfcf650d56b0508544769813d1d807b1b114632d38","0x1e9c2353141304d0ab1874f27602ce733f01e5b4d5cf6acdff5dab2a80c0c652","0x20f6eaf701ed18e0b841b9051ca08f8fcdb346253506c1ca26b3a4a3ed1e5f6c","0x2351b29aefc72cf0c56afd17c33e50ac5c64a695943e18c64e099e1d597bf886","0x19e6940b385edcb090c5eccd28c74c3a219f24d41760bcd5b0b1b837a805941e","0x2cd7e4b967101d6ee0f2a33521762cace8ffe35930bc210554e8307df664c899","0x041f06de46e4862d5d59c363c119a79629261d6aa18aa737c288ac7f4bfb4153","0x2dc39620da58c2822418179ba6f61de6d31ee938c79a5ca15c473aef7ca1e824","0x00000000000000000000000000000000ffbd168649f4e00f0baef4ec3a08615f","0x18fbeff26a87cb38f373584bbd02d016fed78aefc6462811a23006679509b3a9","0x1888e78ad37d146406e710ae2dbd244877263b133875d090f7615a1e9c0ac083","0x2196fbe28ce9ce0e0e202bbf1268cabdcd0a2c03588e118765ba1ee1a16f2dc7","0x0137bc731354b1531dbdcbfc83802605035f69f937f9a7311a57e6d7126368ba","0x19f38da8f0717fe78812addd655ef59411805d70eb731d5da309ad111698e8d0","0x155452e2824d5bd4fd8f8e5feaa4bd7abe783613d6b78cf88377a48e9f7e70c2","0x2396966b07a6e535a9ae30883a97e854ff2425c6dcfa34bda164394ba919191f","0x09374f47b862065ac0ac49ceb02b5cc0d925af1980ab2bd5f4d9df555e8c4c91","0x26366e50b5c7244ffc3ecdf50a65180742b1c53092659bd1db852bdd726d52f3","0x12d13ee6d1faa21b7f810c64e31d7af08409f2ff2a669b3c7e4e82d1964e5954","0x2fd05defcf5fc010bb13908b3d573636ed9609163c210b3864f9cf59aa2f5fb6","0x00000000000000000000000000000046955fdfd58ca9013b39025ae688416131","0x00000000000000000000000000000000001d335d2fb9857cbc49e72cf34e86a5","0x0000000000000000000000000000000c6a8930092b36c72dbd0a7f4b65533c19","0x00000000000000000000000000000000000d099ff72ffae0f73756528d629a5e","0x0000000000000000000000000000008c8d80c3f2886519cb37a563f88f166cb8","0x00000000000000000000000000000000000393e9f6fdc31492e4b3da33fa5fe4","0x000000000000000000000000000000417fb818a6933554bf3ff602f1f450728d","0x00000000000000000000000000000000002074eb75888a752047676f72f5343f"] -public_inputs = ["0x000000000000000000000000000000000000000000000000000000000000000a"] -verification_key = ["0x21082ca216cbbf4e1c6e4f4594dd508c996dfbe1174efb98b11509c6e306460b","0x0000000000000000000000000000000000000000000000000000000000000010","0x0000000000000000000000000000000000000000000000000000000000000005","0x0000000000000000000000000000000000000000000000000000000000000010","0x0000000000000000000000000000000000000000000000000000000000000001","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000004cf4015c3a5297f556c3b72581f2dca64d","0x00000000000000000000000000000000000a67b44462aa65528a3e3b181e0bcd","0x00000000000000000000000000000091507f347e13f13eec9d9f327ac25ada11","0x00000000000000000000000000000000001993946f40247aa93aedba75857f3e","0x0000000000000000000000000000005d340a5ecb1a33c0b7055734ef91200c97","0x00000000000000000000000000000000001eebbe1207643a8bd1669b999e8226","0x0000000000000000000000000000006b27d5d1ffba12754d0718481e1a9a419a","0x00000000000000000000000000000000002f08a6a07ed616c588bcf4e3555c00","0x0000000000000000000000000000003cbc8e573c1299e8ba491bd2218a413bd7","0x0000000000000000000000000000000000192b586ec6fb3b1b6d063a00a86c65","0x000000000000000000000000000000c4516b3cffabe3dcdd074d74f595c81c04","0x000000000000000000000000000000000021142418da600cf97a5248cbd45524","0x000000000000000000000000000000c292117b1a17fefe9de0bfd9edf1a84bf9","0x000000000000000000000000000000000002d6fd9e84dbe74b7531e1801405a1","0x000000000000000000000000000000459a3b2a0b768da45ac7af7f2aec40fc42","0x0000000000000000000000000000000000293c6ab3c06a0669af13393a82c60a","0x0000000000000000000000000000006c845044cca9a2d9dbf94039a11d999aaa","0x00000000000000000000000000000000000efe5ad29f99fce939416b6638dff2","0x000000000000000000000000000000587f768022c11ac8e37cd9dce243d01ef2","0x00000000000000000000000000000000000a44bf49517a4b66ae6b51eee6ac68","0x00000000000000000000000000000059d49ef10107e88711fc0919e244e17a08","0x0000000000000000000000000000000000132d159fdf1907b0619b9809904594","0x00000000000000000000000000000016d9bd1186bcef7a31846ce703eb4cb5b2","0x0000000000000000000000000000000000291c00ed4a7689fec327330104b85c","0x0000000000000000000000000000004b6c55389300451eb2a2deddf244129e7a","0x000000000000000000000000000000000018c3e78f81e83b52719158e4ac4c2f","0x0000000000000000000000000000008d7beb75f905a5894e18d27c42c62fd797","0x00000000000000000000000000000000000002e9c902fe5cd49b64563cadf3bb","0x0000000000000000000000000000000d9e28aa6d00e046852781a5f20816645c","0x00000000000000000000000000000000002cbce7beee3076b78dace04943d69d","0x000000000000000000000000000000fd915d11bfedbdc0e59de09e5b28952080","0x00000000000000000000000000000000002bc27ec2e1612ea284b08bcc55b6f2","0x000000000000000000000000000000be6ed4f4d252a79059e505f9abc1bdf3ed","0x00000000000000000000000000000000000ad34b5e8db72a5acf4427546c7294","0x00000000000000000000000000000090a049f42a3852acd45e6f521f24b4900e","0x00000000000000000000000000000000001e5b26790a26eb340217dd9ad28dbf","0x000000000000000000000000000000ac27e570ae50bc180509764eb3fef94815","0x0000000000000000000000000000000000155a0f51fec78c33ffceb7364d69d7","0x000000000000000000000000000000b644999713a8d3c66e9054aa5726324c76","0x00000000000000000000000000000000001c1c4720bed44a591d97cbc72b6e44","0x000000000000000000000000000000058cc5ad51753faec2a5908155d472e429","0x00000000000000000000000000000000000f7261cf55a71f4d0d7b961dda9ddb","0x0000000000000000000000000000004a36df78f0d50144437ef26f8bbfe69ac1","0x00000000000000000000000000000000001b7b1a10c1e638ce11d8c84b831aca","0x000000000000000000000000000000826ba5b1d1ddd8d6bb960f01cd1321a169","0x0000000000000000000000000000000000163a9c8b67447afccc64e9ccba9d9e","0x0000000000000000000000000000007653a773088aba5c6b1337f435188d72c4","0x000000000000000000000000000000000019256311d43dbc795f746c63b20966","0x000000000000000000000000000000df58a7bad9afe3651be67bc6c298092e11","0x00000000000000000000000000000000001fa51a0d75363b3af4e259e0dbb2c5","0x000000000000000000000000000000c8b5836b29551d41dbc04bdb1fcf1a1868","0x000000000000000000000000000000000021915198840ad9c3666122b2837aea","0x0000000000000000000000000000005df0e69d7efdbc7898b3762f0a0ed976ad","0x00000000000000000000000000000000000cee6b75dcf02a07c50939e8ca3cf3","0x00000000000000000000000000000066a493be1ea69d2b335152719acd54d735","0x000000000000000000000000000000000027e49262bd388ce2d0f193988f3b8f","0x000000000000000000000000000000dd783bff1a1cfc999bb29859cfb16c46fc","0x000000000000000000000000000000000002c397073c8abce6d4140c9b961209","0x000000000000000000000000000000750599be670db593af86e1923fe8a1bb18","0x00000000000000000000000000000000002b7bba2d1efffce0d033f596b4d030","0x0000000000000000000000000000008ffb571a4b3cf83533f3f71b99a04f6e6b","0x00000000000000000000000000000000002c71c58b66498f903b3bbbda3d05ce","0x0000000000000000000000000000002afaefbcbd080c84dcea90b54f4e0a858f","0x0000000000000000000000000000000000039dce37f94d1bbd97ccea32a224fe","0x00000000000000000000000000000075783c73cfe56847d848fd93b63bf32083","0x000000000000000000000000000000000027dc44977efe6b3746a290706f4f72","0x000000000000000000000000000000de0cbf2edc8f085b16d73652b15eced8f5","0x00000000000000000000000000000000000a5366266dd7b71a10b356030226a2","0x00000000000000000000000000000000a7588ec4d6809c90bb451005a3de3077","0x0000000000000000000000000000000000136097d79e1b0ae373255e8760c499","0x000000000000000000000000000000f2595d77bdf72e4acdb0b0b43969860d98","0x000000000000000000000000000000000013dd7515ccac4095302d204f06f0bf","0x000000000000000000000000000000057fe211dad1b706e49a3b55920fac20ec","0x000000000000000000000000000000000016ff3501369121d410b445929239ba","0x000000000000000000000000000000eb8007673c1ed10b834a695adf0068522a","0x00000000000000000000000000000000001e190987ebd9cf480f608b82134a00","0x0000000000000000000000000000000944f94301aa6da3016a226de04de52f4c","0x00000000000000000000000000000000001e44194e60f0ab4ee0f77adc50f422","0x0000000000000000000000000000006c2c7bea37dfbd20be6bed19efd743397a","0x00000000000000000000000000000000002a017d0d9f40d0aeb5c8152ffddec5","0x0000000000000000000000000000007f43efe5631bf48c872c317bed3b8bf12b","0x000000000000000000000000000000000027579be0883627093cf8bdec0b72e7","0x000000000000000000000000000000cef6108b89e89b35679431d113f3be7dff","0x00000000000000000000000000000000000ddb2d01ec88ed69144177a4af3850","0x0000000000000000000000000000000083e7ab1f26781948b36d131759f7c8c9","0x00000000000000000000000000000000000a7fe830f1cb7a5d49d71877dd226a","0x0000000000000000000000000000001834ecd1ce1e8e80812bdd95f960a45e57","0x00000000000000000000000000000000002db7a5185064e6501ef61e989895a0","0x000000000000000000000000000000363f0c994e91cecad25835338edee2294f","0x00000000000000000000000000000000002eea648c8732596b1314fe2a4d2f05","0x000000000000000000000000000000b2671d2ae51d31c1210433c3972bb64578","0x00000000000000000000000000000000000ab49886c2b94bd0bd3f6ed1dbbe2c"] -proof_b = ["0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000000000522e2d3071a75aa35d1e477d9e0ad3c0c2","0x000000000000000000000000000000000027bd4377f2ede7bc0133dde7d3b79d","0x000000000000000000000000000000df15ed61667d6fc6b99b97daafc3f7eddb","0x000000000000000000000000000000000003572ca7295a3ee92dc2ddafed48cd","0x000000000000000000000000000000b5dfb839be2c47c3d0e289df3c482bf286","0x00000000000000000000000000000000002471c02fbda062e36bcc7fbdf42dce","0x000000000000000000000000000000e3cbbbc33fb43fb006bd9f8e02dfd4cf9b","0x00000000000000000000000000000000000b3eb6b7a756351688c2561977d618","0x00000000000000000000000000000058d410d526cbd3adbee65868596758007f","0x0000000000000000000000000000000000289c7fe794a87811176d6b8a3973b3","0x000000000000000000000000000000deebf1d6b009435d734b2399d3558eb3f7","0x000000000000000000000000000000000023b6573225d811337c37b16691b872","0x000000000000000000000000000000c29b8cb5048472631403ee526a725ac163","0x0000000000000000000000000000000000206bff7bf596fde59255e7b85f9c7a","0x000000000000000000000000000000d8907ebb05228e706b57826cfc8207af57","0x0000000000000000000000000000000000305f614425315c05fc891c9a92a743","0x000000000000000000000000000000f183e5285136ab6c87d28dcfb65a99b02c","0x00000000000000000000000000000000000383ca0c47e2c56d39f5b58b9726a4","0x000000000000000000000000000000cc11844c28848bcdb1575af5bbae6eafa5","0x000000000000000000000000000000000018b1f820411130433f38ede2bd9158","0x000000000000000000000000000000821bd5681fdbbc82311485f9750ecda390","0x0000000000000000000000000000000000064257d786e839c16aa159b3672cc8","0x0000000000000000000000000000000e5205d207323e06ea8a18111dff8354af","0x00000000000000000000000000000000001254044ff7e569e4002f38956d2762","0x0000000000000000000000000000004591d851f6226ffe1a8a63456ee13411f7","0x00000000000000000000000000000000002b118f2b6639c3f776ed6847f98863","0x000000000000000000000000000000a0a0f63e73dd651c139b2fc3f45e9f4a94","0x00000000000000000000000000000000002669baf309d743d8c94871745bb19a","0x0000000000000000000000000000004cafdee2031bda8c4a2be55862c864524e","0x000000000000000000000000000000000002e68b1c1d2454113f78a184434cf2","0x000000000000000000000000000000899c0497e76b6b345776d9990c8eee4160","0x00000000000000000000000000000000000ec802d07823d277acf631b5c451f3","0x000000000000000000000000000000d5f1fa88434b81dd239ca62a3d168ff20e","0x000000000000000000000000000000000028511b798a4e506da8219fefcfe462","0x000000000000000000000000000000597adcfba2064c09a9e57b37d6a50fe775","0x00000000000000000000000000000000001f691d6d4cbed7b749f55e9af17403","0x00000000000000000000000000000071c78d719253bf3165591474d0a27a50ac","0x000000000000000000000000000000000024858bf4aff0e08df3c03fae341fc0","0x000000000000000000000000000000d0e80eafe0f0d2c1f760bd98087a069da0","0x0000000000000000000000000000000000266239c233e34815ca720e2e378f21","0x000000000000000000000000000000ad6462e3eca1c9a94e4dd30f3cecba48ad","0x0000000000000000000000000000000000147e1bff29ff6979f76ab6d840ded4","0x00000000000000000000000000000047cd629558a91f9db60c63944fa3835cdb","0x00000000000000000000000000000000002531925eaa902131ef11542fb5b20a","0x198e99c9dbc6f3ca902d080fdafb51410ee129edf20015c8337964f3f92b0376","0x2f04d8358d5740b6fa3aca9893cac185d641f2a00089b2bc428401ac21343d2c","0x2d5e2a67dee4e227ca84367a7d7ecd4860b1586a0d1eb799a41ee1042857e46a","0x2651bde5af62489c373d5fa812d6140b60df4569c6184d0d38f6f55dd49ec439","0x10e9e9d0cb817c09034cf3a4dbc9a44ed7a2618fd0281bf0d07a30b12facc6ea","0x11256980eccf0e654c61db759c8d71b04cd9a7c74d44165beaca2978aae075a9","0x2360ce983c2edb38f60b84a7f5ade89eed1fdb65363227e737dffbb8acba96e6","0x06c2d6ce83f1dc608f2cd267b351faa80bae0f688b3e2c6689235365ac05d614","0x1954b4ab315a061b176b67c8adb73d8ef4cc795951c506549ee17f0db90cca9a","0x1a738a34c81c0875d1fe2c68fb111bb55194edcf6c879e9ec99b4c93c5bac76b","0x012434d4aa45c5fb67f138a86116447befa784435b50fc1e67c74f07223480ef","0x1da9f41af8143f464c89dfae2b802ab73f0e64bcd71e5a18574bb4afa391a80f","0x1c41b34f51bf6cfddc0572770164eadcbf2fc4e7959f0fc7a4f19dc11780380a","0x0a6692e54ad790aa12bd9e225e116bfe1d068459dcd66eeac3ff646c672a0372","0x01859bc6385d07f9dfec4b8b2c1db0a53f8a05af246bfad33509beb42d9b5694","0x19e876787001790df811f7d7d26212e87b953a8945d632763d9bf154ab4ec167","0x01e702b7c67449f857e75e6df7251cce8f6c871aed86f988024c2e6139022c39","0x008b6178e573502eac46923d9df263b57cafa83bb14e7b91080370cf82750f75","0x2ea063d2aad0c7bcadf7fd7493e0cb8352c308a4e4101f128a7c4eb6dd80b118","0x099650fcf5f0c4f8f75189d335f9f176f8d1355ac6a31274782c21345d1f9c2a","0x1b8b6888ec0de5154a5ec2b3ebd4ace865dc035253532ebed5abf575a9e89763","0x024869a9548b8bf6cfe27150c22c88f7df4f0886b6a1f83ccf8e9e0e446901de","0x1aab445b8c2ffd0ae8081d9d6870eb3b1b5a3d60d80c2fdfd820d0aec21c6cb1","0x02a9d09ae2a2cdf547dd84338d33f5212f3189f27fbcf6f19cd10dbb4fcfd783","0x1b0cab4d1a473f0960033080337857646b3cbecca1272e94a563405bcd834256","0x1a49dd69fe18bb0c700d0aba9d697f11cb77bbf50ef1312b0ade6101b6b5970c","0x17a899e0aaba06df5f640dee973615b2a1c2b1a302c36432c0e496c0e1fc12d4","0x29416ace9513e527f7896ed30c14f92cbab613f3eebe6c87f810369c846023f3","0x13aca814f98cc1ba1c8818827876a6b782a579ab0494e03e190ebf6bd448e005","0x00000000000000000000000000000000d00591628e7f3bc935d0615c0808e684","0x0e1e573fd4e227709e85770ce6b1ec54c62a4563a360a85cafa285ef0de23f65","0x0df2626fd4c3b1352933f185d2ea12e6bfafced47ecea438cade894cc6e2db56","0x024a1e3b18a149a7643d0a7413a9f9a859534acb1075a49d79f80ab4b54d2a54","0x1ddc4265b93c17d06fa34332906e26b193c22fca27979dfe1dc7a3481ca26368","0x162ace72663cfa6de2e9f04e51dc9b391a9842df5c390ea45c830cb9ffe41170","0x0495b2a1fdf4505e043a1f14d28d3183875c756190b4f3d573ddcca45271c578","0x108711fd3a535631ffedab15afa2b45462d0109de6a5ce207b728da7fb0cc861","0x12f61ffde0a5cdd06d99615a9a13e9c35c9acf021c34d945a43911d6b5bc7357","0x1892fe8746226c4ff0c22f46b1b5af461256b39da8b35f6ce23b5274ee36d249","0x1e2fdd10ab9f0acf73eafd32c95774c8c81298393531e594203d931326b1313b","0x23ccbb9a111ba94ef713cb1ee0f93a4b7dce7cd4c1b06bbb5e3fd3b15f2b902d","0x00000000000000000000000000000012c0034de11daf4073d7347808aeaa15c3","0x00000000000000000000000000000000002467b5b5f10cf216361cdc1e6ec924","0x00000000000000000000000000000009d0e5bd1b7ed299b7150dd860562b575f","0x00000000000000000000000000000000000121e299f7c5b7b9a264a0237ba9c0","0x000000000000000000000000000000e52730fdae3a174391fede8b22ca59d266","0x000000000000000000000000000000000011e9a259a74f701d565dfbc05db520","0x000000000000000000000000000000e7574bc9af75e9f84a887d120d72b60507","0x000000000000000000000000000000000006f7685fea564d498d183eb56236b0"] \ No newline at end of file diff --git a/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/src/main.nr b/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/src/main.nr deleted file mode 100644 index 39b8c142ace..00000000000 --- a/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/src/main.nr +++ /dev/null @@ -1,32 +0,0 @@ -use dep::std; - -fn main( - verification_key : [Field; 114], - proof : [Field; 94], - public_inputs : [Field; 1], - key_hash : Field, - input_aggregation_object : [Field; 16], - proof_b : [Field; 94], -) -> pub [Field; 16] { - let output_aggregation_object_a = std::verify_proof( - verification_key.as_slice(), - proof.as_slice(), - public_inputs.as_slice(), - key_hash, - input_aggregation_object - ); - - let output_aggregation_object = std::verify_proof( - verification_key.as_slice(), - proof_b.as_slice(), - public_inputs.as_slice(), - key_hash, - output_aggregation_object_a - ); - - let mut output = [0; 16]; - for i in 0..16 { - output[i] = output_aggregation_object[i]; - } - output -} diff --git a/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/target/double_verify_proof.json b/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/target/double_verify_proof.json deleted file mode 100644 index c873a25551a..00000000000 --- a/tooling/noir_js/test/noir_compiled_examples/double_verify_proof/target/double_verify_proof.json +++ /dev/null @@ -1 +0,0 @@ -{"backend":"acvm-backend-barretenberg","abi":{"parameters":[{"name":"verification_key","type":{"kind":"array","length":114,"type":{"kind":"field"}},"visibility":"private"},{"name":"proof","type":{"kind":"array","length":94,"type":{"kind":"field"}},"visibility":"private"},{"name":"public_inputs","type":{"kind":"array","length":1,"type":{"kind":"field"}},"visibility":"private"},{"name":"key_hash","type":{"kind":"field"},"visibility":"private"},{"name":"input_aggregation_object","type":{"kind":"array","length":16,"type":{"kind":"field"}},"visibility":"private"},{"name":"proof_b","type":{"kind":"array","length":94,"type":{"kind":"field"}},"visibility":"private"}],"param_witnesses":{"input_aggregation_object":[211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226],"key_hash":[210],"proof":[115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208],"proof_b":[227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320],"public_inputs":[209],"verification_key":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114]},"return_type":{"kind":"array","length":16,"type":{"kind":"field"}},"return_witnesses":[337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352]},"bytecode":"H4sIAAAAAAAA/+3YZWxcRwAAYTuJw+AwJw4zMzvMzJyUmZkbZmZmZmZmLjOGmTl1Oqcbt1H/NlJaySt9Gr07++ns9e2et2toSEiCkOAIs69ZngqJhdiI4/NxEQ/xQ4LflxCJkBhJkBTJEI7kSIGUSIXUSIO0SIf0yICMyITMyIKsiEA2ZEcO5EQu5EYe5EU+5EcBFEQhFEYRFEUxFEcJlEQplEYZlEU5lEcFVEQlVEYVRKIqqqE6aqAmaqE26qAu6qE+GqAhGqExmqApmqE5WqAlWqE12qAt2qE9OqAjOqEzuqArHsPjeAJP4ik8jWfwLJ7D83gBL+IlvIxX8KpzGeZcdnJeX8cbeBNv4W28g3fxHt7HB/gQH+FjfIJP0Q3d0QM90Qu90Qd90Q/9MQADMQiDMQRDMQzDMQIjMQqjMQZjMQ7jMQETMQmTMQVTMQ3TMQMzMQuzMQdzMQ/zsQALsQiLsQRLsQzLsQIrsQqrsQZrsQ7rsQEbsQmbsQVbsQ3bsQM7sQu7sQd7sQ/7cQAHcQiHccR5iOVcBMZnPhZ4f4X72Bf4El/ha3yDb/EdvscP+BE/4Wf8gl/xG373foH3avRcH8UxHMcJnMQpnMYZnMU5nMcFXMQlXMYVXMU1XMcN3MQt3MYd3MU9/IEo3A8J/oChiIXYiIMwxEU8xA+sOUiIREiMJEiKZAhHcqRASqRCaqRBWqRDemRARmRCZmRBVkQgG7IjB3IiF3IjD/IiH/KjAAqiEAqjCIqiGIqjBEqiFEqjDMqiHMqjAiqiEiqjCiJDg3McWA8fXEujnP8o5zzKuYpy3gKNa+PZ+DaBTWgT2cQ2iU1qk9lwm9ymsCltKpvaprFpbTqb3mawGW0mm9lmsVlthM1ms9scNqfNZXPbPDavzWfz2wK2oC1kC9sitqgtZovbErakLWVL2zK2rC1ny9sKtqKtZCvbKjbSVrXVbHVbw9a0tWxtW8fWtfVsfdvANrSNbGPbxDa1zWxz28K2tK1sa9vGtrXtbHvbwXa0nWxn28V2tY/Zx+0T9kn7lH3aPmOftc/Z5+0L9kX7kn3ZvmJfta898DoD43Wv37Bv2rfs2/Yd+659z75vP7Af2o/sx/YT+6ntZrvbHran7WV72z62r+1n+9sBdqAdZAfbIXaoHWaH2xF2pB1lR9sxdqwdZ8fbCXainWQn2yl2qp1mp9sZdqadZWfbOXaunWfn2wV2oV1kF9sldqldZpfbFXalXWVX2zV2rV1n19sNdqPdZDfbLXar3Wa32x12p91ld9s9dq/dZ/fbA/agPWQP2yP2wc8egevP7V8fQKryFdVQHTVQE7VQG3VQF/VQHw3QEI3QGE1CgxtZ2EO8X8xGGmyEjdlIg43ZSIP9r2ykR70+Zo/bE/akPWVP2zP2rD1nz9sL9qK9ZC/bK/aqvWav2xv2pr1lb9s79q69Z6P/oYl23wYWoEBDbSwb28axYTaujWfj2wQ2oU1kE9skNqlNZsNtcpvCprSpbGqbxqa16Wx6m8FmtJlsZpvFZrURNpvNbnPYnDaXzW3z2Lw2n81vC9iCtpAtbIvYoraYLW5L2JK2lC1ty9iytpwtbyvYiraSrWyr2Mjo+Q8Jjn9upKEPbnyBB6rZ6raGrWlr2dq2jq1r69n6toFtaBvZxrZJ9B+Kr6Mp183QHC3QEq3QGm3QFu3QHh3QEZ3QGV1C/z71e1j3i/Q3F0jM6eL//3Qx5jTx0ZwmBhaewKLzb08MY04IH80JYfR4WOtq9PgTMelQ69IZAAA="} \ No newline at end of file From 5562e21df1ad71494c576bab5d68aa9f08697c7d Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 18 Sep 2023 10:31:45 +0000 Subject: [PATCH 28/37] add array case to type_to_string --- tooling/noir_js/src/input_validation.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tooling/noir_js/src/input_validation.ts b/tooling/noir_js/src/input_validation.ts index 56fe6fcdb23..675de120be5 100644 --- a/tooling/noir_js/src/input_validation.ts +++ b/tooling/noir_js/src/input_validation.ts @@ -33,15 +33,17 @@ function checkType(value: any, type: any) { return false; } -function type_to_string(type: any) { +function type_to_string(type: any):string { switch (type.kind) { case 'integer': if (type.sign === 'unsigned') { return `uint${type.width}`; } break; + case 'array': + return `${type_to_string(type.element)}[${type.length}]`; } - return false; + return "unknown type"; } // Returns true if `value` is an unsigned integer that is less than 2^{width} From 5b3f24d4b60f01ce3e2bb2aed6faea4eaccb6755 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 18 Sep 2023 10:36:30 +0000 Subject: [PATCH 29/37] lint --- tooling/noir_js/src/input_validation.ts | 8 +++----- tooling/noir_js/test/backend/barretenberg.ts | 4 ++-- tooling/noir_js/test/node/e2e.test.ts | 4 ++-- tooling/noir_js/test/node/smoke.test.ts | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tooling/noir_js/src/input_validation.ts b/tooling/noir_js/src/input_validation.ts index 675de120be5..7d2fdaba9cf 100644 --- a/tooling/noir_js/src/input_validation.ts +++ b/tooling/noir_js/src/input_validation.ts @@ -9,9 +9,7 @@ export function validateInputs(inputs: any, abi: any) { if (!checkType(inputValue, param.type)) { return { isValid: false, - error: `Input for ${param.name} is the wrong type, expected ${type_to_string( - param.type, - )}, got \"${inputValue}\"`, + error: `Input for ${param.name} is the wrong type, expected ${type_to_string(param.type)}, got "${inputValue}"`, }; } } @@ -33,7 +31,7 @@ function checkType(value: any, type: any) { return false; } -function type_to_string(type: any):string { +function type_to_string(type: any): string { switch (type.kind) { case 'integer': if (type.sign === 'unsigned') { @@ -43,7 +41,7 @@ function type_to_string(type: any):string { case 'array': return `${type_to_string(type.element)}[${type.length}]`; } - return "unknown type"; + return 'unknown type'; } // Returns true if `value` is an unsigned integer that is less than 2^{width} diff --git a/tooling/noir_js/test/backend/barretenberg.ts b/tooling/noir_js/test/backend/barretenberg.ts index 5124d6e2517..3fad57b6918 100644 --- a/tooling/noir_js/test/backend/barretenberg.ts +++ b/tooling/noir_js/test/backend/barretenberg.ts @@ -28,7 +28,7 @@ export class Backend { async initBarretenberg(numThreads: number, acirUncompressedBytecode: Uint8Array) { const api = await Barretenberg.new(numThreads); - const [exact, total, subgroupSize] = await api.acirGetCircuitSizes(acirUncompressedBytecode); + const [_exact, _total, subgroupSize] = await api.acirGetCircuitSizes(acirUncompressedBytecode); const crs = await Crs.new(subgroupSize + 1); await api.commonInitSlabAllocator(subgroupSize); await api.srsInitSrs(new RawBuffer(crs.getG1Data()), crs.numPoints, new RawBuffer(crs.getG2Data())); @@ -119,4 +119,4 @@ export class Backend { async destroy() { await this.api.destroy(); } -} \ No newline at end of file +} diff --git a/tooling/noir_js/test/node/e2e.test.ts b/tooling/noir_js/test/node/e2e.test.ts index e4ae25956c7..ddd91cca834 100644 --- a/tooling/noir_js/test/node/e2e.test.ts +++ b/tooling/noir_js/test/node/e2e.test.ts @@ -110,7 +110,7 @@ it('[BUG] -- bb.js null function or function signature mismatch (outer-inner) ', // 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 _proofInner = await prover.generateInnerProof(serializedWitness); // Proof verification // @@ -118,7 +118,7 @@ it('[BUG] -- bb.js null function or function signature mismatch (outer-inner) ', const isValidOuter = await prover.verifyOuterProof(proofOuter); expect(isValidOuter).to.be.true; // We can also try verifying an inner proof and it will fail. - // const isValidInner = await prover.verifyInnerProof(proofInner); + // const isValidInner = await prover.verifyInnerProof(_proofInner); // expect(isValidInner).to.be.true; expect.fail('bb.js currently returns a bug when we try to verify an inner and outer proof with the same backend'); } catch (error) { diff --git a/tooling/noir_js/test/node/smoke.test.ts b/tooling/noir_js/test/node/smoke.test.ts index ad839d5058c..179246745fe 100644 --- a/tooling/noir_js/test/node/smoke.test.ts +++ b/tooling/noir_js/test/node/smoke.test.ts @@ -7,7 +7,7 @@ it('generates witnesses successfully', async () => { x: '2', y: '3', }; - const solvedWitness = await generateWitness(assert_lt_json, inputs); + const _solvedWitness = await generateWitness(assert_lt_json, inputs); }); it('string input and number input are the same', async () => { From edcb749a90ce3aa9cb2cc2596b947100b29eef57 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 18 Sep 2023 10:40:30 +0000 Subject: [PATCH 30/37] explicit any --- tooling/noir_js/src/input_validation.ts | 8 ++++---- tooling/noir_js/src/serialize.ts | 2 +- tooling/noir_js/src/witness_generation.ts | 2 +- tooling/noir_js/test/backend/barretenberg.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tooling/noir_js/src/input_validation.ts b/tooling/noir_js/src/input_validation.ts index 7d2fdaba9cf..9a19528a0cf 100644 --- a/tooling/noir_js/src/input_validation.ts +++ b/tooling/noir_js/src/input_validation.ts @@ -1,5 +1,5 @@ // Check if all of the input values are correct according to the ABI -export function validateInputs(inputs: any, abi: any) { +export function validateInputs(inputs, abi) { for (const param of abi.parameters) { const inputValue = inputs[param.name]; if (inputValue === undefined) { @@ -18,7 +18,7 @@ export function validateInputs(inputs: any, abi: any) { // Checks that value is of type "type" // Where type is taken from the abi -function checkType(value: any, type: any) { +function checkType(value, type) { switch (type.kind) { case 'integer': if (type.sign === 'unsigned') { @@ -31,7 +31,7 @@ function checkType(value: any, type: any) { return false; } -function type_to_string(type: any): string { +function type_to_string(type): string { switch (type.kind) { case 'integer': if (type.sign === 'unsigned') { @@ -45,7 +45,7 @@ function type_to_string(type: any): string { } // Returns true if `value` is an unsigned integer that is less than 2^{width} -function isUnsignedInteger(value: any, width: any) { +function isUnsignedInteger(value: bigint, width: bigint) { try { const bigIntValue = BigInt(value); return bigIntValue >= 0 && bigIntValue <= BigInt(2) ** BigInt(width) - 1n; diff --git a/tooling/noir_js/src/serialize.ts b/tooling/noir_js/src/serialize.ts index 170db735429..df01769c06e 100644 --- a/tooling/noir_js/src/serialize.ts +++ b/tooling/noir_js/src/serialize.ts @@ -11,7 +11,7 @@ export function witnessMapToUint8Array(solvedWitness: WitnessMap): Uint8Array { } // Converts an bytecode to a Uint8Array -export function acirToUint8Array(base64EncodedBytecode: any): Uint8Array { +export function acirToUint8Array(base64EncodedBytecode): Uint8Array { const compressedByteCode = base64Decode(base64EncodedBytecode); return gunzip(compressedByteCode); } diff --git a/tooling/noir_js/src/witness_generation.ts b/tooling/noir_js/src/witness_generation.ts index 6d460932494..d72033b275a 100644 --- a/tooling/noir_js/src/witness_generation.ts +++ b/tooling/noir_js/src/witness_generation.ts @@ -4,7 +4,7 @@ import { base64Decode } from './base64_decode.js'; import { WitnessMap, executeCircuit } from '@noir-lang/acvm_js'; // Generates the witnesses needed to feed into the chosen proving system -export async function generateWitness(compiledProgram: any, inputs: any): Promise { +export async function generateWitness(compiledProgram, inputs): Promise { // Validate inputs const { isValid, error } = validateInputs(inputs, compiledProgram.abi); if (!isValid) { diff --git a/tooling/noir_js/test/backend/barretenberg.ts b/tooling/noir_js/test/backend/barretenberg.ts index 3fad57b6918..6a770cde2f2 100644 --- a/tooling/noir_js/test/backend/barretenberg.ts +++ b/tooling/noir_js/test/backend/barretenberg.ts @@ -94,8 +94,8 @@ export class Backend { const vk = await this.api.acirSerializeVerificationKeyIntoFields(this.acirComposer); return { - proofAsFields: proofAsFields.map((p: any) => p.toString()), - vkAsFields: vk[0].map((vk: any) => vk.toString()), + proofAsFields: proofAsFields.map((p) => p.toString()), + vkAsFields: vk[0].map((vk) => vk.toString()), vkHash: vk[1].toString(), }; } From ed6369ca95c81b90875666055b59a55e09d72d57 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 18 Sep 2023 10:44:31 +0000 Subject: [PATCH 31/37] hack around linting -> I think any should be explicit --- tooling/noir_js/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tooling/noir_js/tsconfig.json b/tooling/noir_js/tsconfig.json index 41e6dbaf77e..0fd439990a6 100644 --- a/tooling/noir_js/tsconfig.json +++ b/tooling/noir_js/tsconfig.json @@ -9,6 +9,7 @@ "esModuleInterop": true, "resolveJsonModule": true, "strict": true, + "noImplicitAny": false, }, "include": ["src/**/*.ts"], "exclude": ["node_modules"] From ae9a6fa4ee6acc3de02994ec651d7dbe27812504 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 18 Sep 2023 12:47:06 +0000 Subject: [PATCH 32/37] cannot remove ts-ignore unfortunately, or it will not compile --- tooling/noir_js/.eslintignore | 1 + 1 file changed, 1 insertion(+) diff --git a/tooling/noir_js/.eslintignore b/tooling/noir_js/.eslintignore index 3c3629e647f..fcbc654a839 100644 --- a/tooling/noir_js/.eslintignore +++ b/tooling/noir_js/.eslintignore @@ -1 +1,2 @@ node_modules +test/backend/barretenberg.ts \ No newline at end of file From be7e09ba6f5fc25d77d60e8460ef4f1581d25d32 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 18 Sep 2023 17:55:05 +0000 Subject: [PATCH 33/37] update dependencies --- package.json | 4 ++-- yarn.lock | 28 ++-------------------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index abfa7f270ba..718bd757042 100644 --- a/package.json +++ b/package.json @@ -21,9 +21,9 @@ "@typescript-eslint/parser": "^5.59.5", "chai": "^4.3.7", "eslint": "^8.40.0", - "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-prettier": "^5.0.0", "mocha": "^10.2.0", - "prettier": "^2.8.8", + "prettier": "3.0.3", "ts-node": "^10.9.1", "typescript": "^5.0.4" }, diff --git a/yarn.lock b/yarn.lock index 9a92be42a67..51e107692ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -465,9 +465,9 @@ __metadata: "@typescript-eslint/parser": ^5.59.5 chai: ^4.3.7 eslint: ^8.40.0 - eslint-plugin-prettier: ^4.2.1 + eslint-plugin-prettier: ^5.0.0 mocha: ^10.2.0 - prettier: ^2.8.8 + prettier: 3.0.3 ts-node: ^10.9.1 typescript: ^5.0.4 languageName: unknown @@ -3295,21 +3295,6 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-prettier@npm:^4.2.1": - version: 4.2.1 - resolution: "eslint-plugin-prettier@npm:4.2.1" - dependencies: - prettier-linter-helpers: ^1.0.0 - peerDependencies: - eslint: ">=7.28.0" - prettier: ">=2.0.0" - peerDependenciesMeta: - eslint-config-prettier: - optional: true - checksum: b9e839d2334ad8ec7a5589c5cb0f219bded260839a857d7a486997f9870e95106aa59b8756ff3f37202085ebab658de382b0267cae44c3a7f0eb0bcc03a4f6d6 - languageName: node - linkType: hard - "eslint-plugin-prettier@npm:^5.0.0": version: 5.0.0 resolution: "eslint-plugin-prettier@npm:5.0.0" @@ -6180,15 +6165,6 @@ __metadata: languageName: node linkType: hard -"prettier@npm:^2.8.8": - version: 2.8.8 - resolution: "prettier@npm:2.8.8" - bin: - prettier: bin-prettier.js - checksum: b49e409431bf129dd89238d64299ba80717b57ff5a6d1c1a8b1a28b590d998a34e083fa13573bc732bb8d2305becb4c9a4407f8486c81fa7d55100eb08263cf8 - languageName: node - linkType: hard - "pretty-ms@npm:^8.0.0": version: 8.0.0 resolution: "pretty-ms@npm:8.0.0" From 403d9b5b0c3ebdce620d78fb61fac9e0b19ef71e Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 18 Sep 2023 17:59:11 +0000 Subject: [PATCH 34/37] linter --- .../browser/compile_prove_verify.test.ts | 16 ++++++++-------- compiler/source-resolver/src/index.ts | 10 +++++----- compiler/source-resolver/types/index.d.ts | 2 +- compiler/wasm/test/node/index.test.ts | 2 +- .../test/browser/abi_encode.test.ts | 4 ++-- .../noirc_abi_wasm/test/node/abi_encode.test.ts | 4 ++-- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts index 1388923506c..28b07d67877 100644 --- a/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts +++ b/compiler/integration-tests/test/integration/browser/compile_prove_verify.test.ts @@ -57,11 +57,11 @@ test_cases.forEach((testInfo) => { const noir_source_url = new URL( `${base_relative_path}/${test_case}/src/main.nr`, - import.meta.url + import.meta.url, ); const prover_toml_url = new URL( `${base_relative_path}/${test_case}/Prover.toml`, - import.meta.url + import.meta.url, ); const noir_source = await getFile(noir_source_url); @@ -102,7 +102,7 @@ test_cases.forEach((testInfo) => { try { compressedByteCode = Uint8Array.from( atob(compile_output.circuit), - (c) => c.charCodeAt(0) + (c) => c.charCodeAt(0), ); solvedWitness = await executeCircuit( @@ -110,7 +110,7 @@ test_cases.forEach((testInfo) => { witnessMap, () => { throw Error("unexpected oracle"); - } + }, ); } catch (e) { expect(e, "Abi Encoding Step").to.not.be.an("error"); @@ -131,7 +131,7 @@ test_cases.forEach((testInfo) => { await api.srsInitSrs( new RawBuffer(crs.getG1Data()), crs.numPoints, - new RawBuffer(crs.getG2Data()) + new RawBuffer(crs.getG2Data()), ); const acirComposer = await api.acirNewAcirComposer(CIRCUIT_SIZE); @@ -141,14 +141,14 @@ test_cases.forEach((testInfo) => { acirComposer, acirUint8Array, witnessUint8Array, - isRecursive + isRecursive, ); // And this took ~5 minutes! const verified = await api.acirVerifyProof( acirComposer, proof, - isRecursive + isRecursive, ); expect(verified).to.be.true; @@ -156,7 +156,7 @@ test_cases.forEach((testInfo) => { expect(e, "Proving and Verifying").to.not.be.an("error"); throw e; } - } + }, ); suite.addTest(mochaTest); diff --git a/compiler/source-resolver/src/index.ts b/compiler/source-resolver/src/index.ts index e7e1db64b75..66ff1e947aa 100644 --- a/compiler/source-resolver/src/index.ts +++ b/compiler/source-resolver/src/index.ts @@ -8,30 +8,30 @@ export const read_file = function (source_id: string): string { return result; } else { throw new Error( - "Noir source resolver function MUST return String synchronously. Are you trying to return anything else, eg. `Promise`?" + "Noir source resolver function MUST return String synchronously. Are you trying to return anything else, eg. `Promise`?", ); } } else { throw new Error( - "Not yet initialized. Use initializeResolver(() => string)" + "Not yet initialized. Use initializeResolver(() => string)", ); } }; function initialize( - noir_resolver: (source_id: string) => string + noir_resolver: (source_id: string) => string, ): (source_id: string) => string { if (typeof noir_resolver === "function") { return noir_resolver; } else { throw new Error( - "Provided Noir Resolver is not a function, hint: use function(module_id) => NoirSource as second parameter" + "Provided Noir Resolver is not a function, hint: use function(module_id) => NoirSource as second parameter", ); } } export function initializeResolver( - resolver: (source_id: string) => string + resolver: (source_id: string) => string, ): void { resolveFunction = initialize(resolver); } diff --git a/compiler/source-resolver/types/index.d.ts b/compiler/source-resolver/types/index.d.ts index ef4e98c87e1..bf144c3928f 100644 --- a/compiler/source-resolver/types/index.d.ts +++ b/compiler/source-resolver/types/index.d.ts @@ -1,4 +1,4 @@ export declare const read_file: (source_id: string) => string; export declare function initializeResolver( - resolver: (source_id: string) => string + resolver: (source_id: string) => string, ): void; diff --git a/compiler/wasm/test/node/index.test.ts b/compiler/wasm/test/node/index.test.ts index c180fd6db39..f823db35944 100644 --- a/compiler/wasm/test/node/index.test.ts +++ b/compiler/wasm/test/node/index.test.ts @@ -34,7 +34,7 @@ describe("noir wasm compilation", () => { console.log( "Compilation is a match? ", - wasmCircuitBase64 === cliCircuitBase64 + wasmCircuitBase64 === cliCircuitBase64, ); expect(wasmCircuitBase64).to.equal(cliCircuitBase64); diff --git a/tooling/noirc_abi_wasm/test/browser/abi_encode.test.ts b/tooling/noirc_abi_wasm/test/browser/abi_encode.test.ts index 2ca45d78f5c..8cdf19c43a7 100644 --- a/tooling/noirc_abi_wasm/test/browser/abi_encode.test.ts +++ b/tooling/noirc_abi_wasm/test/browser/abi_encode.test.ts @@ -18,10 +18,10 @@ it("recovers original inputs when abi encoding and decoding", async () => { expect(BigInt(decoded_inputs.inputs.foo)).to.be.equal(BigInt(inputs.foo)); expect(BigInt(decoded_inputs.inputs.bar[0])).to.be.equal( - BigInt(inputs.bar[0]) + BigInt(inputs.bar[0]), ); expect(BigInt(decoded_inputs.inputs.bar[1])).to.be.equal( - BigInt(inputs.bar[1]) + BigInt(inputs.bar[1]), ); expect(decoded_inputs.return_value).to.be.null; }); diff --git a/tooling/noirc_abi_wasm/test/node/abi_encode.test.ts b/tooling/noirc_abi_wasm/test/node/abi_encode.test.ts index 8a3b6fe9ffc..b84d84fdd77 100644 --- a/tooling/noirc_abi_wasm/test/node/abi_encode.test.ts +++ b/tooling/noirc_abi_wasm/test/node/abi_encode.test.ts @@ -10,10 +10,10 @@ it("recovers original inputs when abi encoding and decoding", async () => { expect(BigInt(decoded_inputs.inputs.foo)).to.be.equal(BigInt(inputs.foo)); expect(BigInt(decoded_inputs.inputs.bar[0])).to.be.equal( - BigInt(inputs.bar[0]) + BigInt(inputs.bar[0]), ); expect(BigInt(decoded_inputs.inputs.bar[1])).to.be.equal( - BigInt(inputs.bar[1]) + BigInt(inputs.bar[1]), ); expect(decoded_inputs.return_value).to.be.null; }); From 75c226d62c9f7e65884c24c16899e8011262f029 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Tue, 19 Sep 2023 16:14:43 +0000 Subject: [PATCH 35/37] chore: update integration test glob --- .github/workflows/test-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 662b024d6b7..3680a1661d8 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: pull_request: paths: - - ./compiler/integration-tests + - ./compiler/integration-tests/** schedule: - cron: "0 2 * * *" # Run nightly at 2 AM UTC From f8ad3766095da6653dfa8f189a08441f4df6b459 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Thu, 21 Sep 2023 00:11:14 +0000 Subject: [PATCH 36/37] fix package.json --- tooling/noir_js/package.json | 4 +- yarn.lock | 171 ++++++++++++++++++----------------- 2 files changed, 88 insertions(+), 87 deletions(-) diff --git a/tooling/noir_js/package.json b/tooling/noir_js/package.json index 52721cfdf0b..5fd66672f0f 100644 --- a/tooling/noir_js/package.json +++ b/tooling/noir_js/package.json @@ -8,9 +8,9 @@ "license": "(MIT OR Apache-2.0)", "type": "module", "dependencies": { - "fflate": "^0.8.0" "@noir-lang/acvm_js": "0.27.0", - "@noir-lang/noirc_abi": "workspace:*" + "@noir-lang/noirc_abi": "workspace:*", + "fflate": "^0.8.0" }, "files": [ "lib", diff --git a/yarn.lock b/yarn.lock index b8409e18e9b..6ce7d6ae1bf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -60,21 +60,21 @@ __metadata: languageName: node linkType: hard -"@babel/helper-validator-identifier@npm:^7.22.5": - version: 7.22.19 - resolution: "@babel/helper-validator-identifier@npm:7.22.19" - checksum: cf1f94d35cdb2d0f519b31954d1c54929fb31cf8af70fed12b3a1e777c296fabe747e56d9ae3d181c1c96f33ac66aff9501189542554b6fe0508748a38c1c17f +"@babel/helper-validator-identifier@npm:^7.22.20": + version: 7.22.20 + resolution: "@babel/helper-validator-identifier@npm:7.22.20" + checksum: 136412784d9428266bcdd4d91c32bcf9ff0e8d25534a9d94b044f77fe76bc50f941a90319b05aafd1ec04f7d127cd57a179a3716009ff7f3412ef835ada95bdc languageName: node linkType: hard "@babel/highlight@npm:^7.22.13": - version: 7.22.13 - resolution: "@babel/highlight@npm:7.22.13" + version: 7.22.20 + resolution: "@babel/highlight@npm:7.22.20" dependencies: - "@babel/helper-validator-identifier": ^7.22.5 + "@babel/helper-validator-identifier": ^7.22.20 chalk: ^2.4.2 js-tokens: ^4.0.0 - checksum: 7266d2bff8aa8fc78eb65b6e92a8211e12897a731126a282d2f9bb50d8fcaa4c1b02af2284f990ac7e3ab8d892d448a2cab8f5ed0ea8a90bce2c025b11ebe802 + checksum: 84bd034dca309a5e680083cd827a766780ca63cef37308404f17653d32366ea76262bd2364b2d38776232f2d01b649f26721417d507e8b4b6da3e4e739f6d134 languageName: node linkType: hard @@ -672,19 +672,19 @@ __metadata: linkType: hard "@types/babel__code-frame@npm:^7.0.2": - version: 7.0.3 - resolution: "@types/babel__code-frame@npm:7.0.3" - checksum: 543bd933e5ffdfbf75dfee0a36461c8a9d9283d5a95ceae0e021b2aef7fe774f1f251ea56f507faedf9d3574894b4774636f2b125f5cc5f6759503e1e56feb93 + version: 7.0.4 + resolution: "@types/babel__code-frame@npm:7.0.4" + checksum: eb4adb0a79c5cbf2d88ad087b2694a1e38749dc0056693e6125c17a3967fc8d4cc1eb33eab26d3dcaaa8995236cba4a088965cc3a115967545f2a01ee430c87f languageName: node linkType: hard "@types/body-parser@npm:*": - version: 1.19.2 - resolution: "@types/body-parser@npm:1.19.2" + version: 1.19.3 + resolution: "@types/body-parser@npm:1.19.3" dependencies: "@types/connect": "*" "@types/node": "*" - checksum: e17840c7d747a549f00aebe72c89313d09fbc4b632b949b2470c5cb3b1cb73863901ae84d9335b567a79ec5efcfb8a28ff8e3f36bc8748a9686756b6d5681f40 + checksum: 932fa71437c275023799123680ef26ffd90efd37f51a1abe405e6ae6e5b4ad9511b7a3a8f5a12877ed1444a02b6286c0a137a98e914b3c61932390c83643cc2c languageName: node linkType: hard @@ -802,16 +802,16 @@ __metadata: linkType: hard "@types/http-cache-semantics@npm:^4.0.1": - version: 4.0.1 - resolution: "@types/http-cache-semantics@npm:4.0.1" - checksum: 1048aacf627829f0d5f00184e16548205cd9f964bf0841c29b36bc504509230c40bc57c39778703a1c965a6f5b416ae2cbf4c1d4589c889d2838dd9dbfccf6e9 + version: 4.0.2 + resolution: "@types/http-cache-semantics@npm:4.0.2" + checksum: 513429786a45d8124f93cc7ea1454b692008190ef743e9fec75a6a3c998309782d216f1e67d7d497ffece9c9212310ae05a8c56e8955492ee400eacdd7620e61 languageName: node linkType: hard "@types/http-errors@npm:*": - version: 2.0.1 - resolution: "@types/http-errors@npm:2.0.1" - checksum: 3bb0c50b0a652e679a84c30cd0340d696c32ef6558518268c238840346c077f899315daaf1c26c09c57ddd5dc80510f2a7f46acd52bf949e339e35ed3ee9654f + version: 2.0.2 + resolution: "@types/http-errors@npm:2.0.2" + checksum: d7f14045240ac4b563725130942b8e5c8080bfabc724c8ff3f166ea928ff7ae02c5194763bc8f6aaf21897e8a44049b0492493b9de3e058247e58fdfe0f86692 languageName: node linkType: hard @@ -841,9 +841,9 @@ __metadata: linkType: hard "@types/json-schema@npm:^7.0.9": - version: 7.0.12 - resolution: "@types/json-schema@npm:7.0.12" - checksum: 00239e97234eeb5ceefb0c1875d98ade6e922bfec39dd365ec6bd360b5c2f825e612ac4f6e5f1d13601b8b30f378f15e6faa805a3a732f4a1bbe61915163d293 + version: 7.0.13 + resolution: "@types/json-schema@npm:7.0.13" + checksum: 345df21a678fa72fb389f35f33de77833d09d4a142bb2bcb27c18690efa4cf70fc2876e43843cefb3fbdb9fcb12cd3e970a90936df30f53bbee899865ff605ab languageName: node linkType: hard @@ -914,24 +914,17 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:*, @types/node@npm:^20.1.0, @types/node@npm:^20.5.7": - version: 20.6.1 - resolution: "@types/node@npm:20.6.1" - checksum: f9848617221b513d558071c804b006750d1ee1734c5ffea3ada9a0edd1642334ad0812222d6b99b7b8c0e1a5f1e557946ae99444c2705e9afc125abdf9fa36c2 +"@types/node@npm:*, @types/node@npm:^20.1.0, @types/node@npm:^20.5.7, @types/node@npm:^20.6.2": + version: 20.6.3 + resolution: "@types/node@npm:20.6.3" + checksum: 444a6f1f41cfa8d3e20ce0108e6e43960fb2ae0e481f233bb1c14d6252aa63a92e021de561cd317d9fdb411688f871065f40175a1f18763282dee2613a08f8a3 languageName: node linkType: hard "@types/node@npm:^18.7.20": - version: 18.17.16 - resolution: "@types/node@npm:18.17.16" - checksum: 8f9dbaf4a67a14110e2a0d805f9b57f3a5cda774dbcb7b1e7973efe31d5eeea358482dbe36a5bfadb0dde99f065f1ae0531f25a032f015871aa0b2896eb3c4ae - languageName: node - linkType: hard - -"@types/node@npm:^20.6.2": - version: 20.6.2 - resolution: "@types/node@npm:20.6.2" - checksum: 96fe5303872640a173f3fd43e289a451776ed5b8f0090094447c6790b43f23fb607eea8268af0829cef4d132e5afa0bfa4cd871aa7412e9042a414a698e9e971 + version: 18.17.18 + resolution: "@types/node@npm:18.17.18" + checksum: 59cbd906363d37017fe9ba0c08c1446e440d4d977459609c5f90b8fb7eb41f273ce8af30c5a5b5d599d7de934c1b3702bc9fc27caf8d2270e5cdb659c5232991 languageName: node linkType: hard @@ -1171,19 +1164,19 @@ __metadata: languageName: node linkType: hard -"@wdio/config@npm:8.16.7": - version: 8.16.7 - resolution: "@wdio/config@npm:8.16.7" +"@wdio/config@npm:8.16.11": + version: 8.16.11 + resolution: "@wdio/config@npm:8.16.11" dependencies: "@wdio/logger": 8.11.0 "@wdio/types": 8.16.7 - "@wdio/utils": 8.16.7 + "@wdio/utils": 8.16.11 decamelize: ^6.0.0 deepmerge-ts: ^5.0.0 glob: ^10.2.2 import-meta-resolve: ^3.0.0 read-pkg-up: ^10.0.0 - checksum: 3eeaccfb8876c54101ad6d3c122e07d4e60dd3c69a9596b3b24333804835af60103bfa660c0d784dd1444263771a003879787eba3030f1179433b5330697a0a3 + checksum: 3e7aa863307f847fe9cd559878a61f9927fe7c389514b2281c120b81a7753a16fb329be224099daf8385d5a3e01c84cc012c4e37d943ba275fa46b7380546a64 languageName: node linkType: hard @@ -1224,9 +1217,9 @@ __metadata: languageName: node linkType: hard -"@wdio/utils@npm:8.16.7": - version: 8.16.7 - resolution: "@wdio/utils@npm:8.16.7" +"@wdio/utils@npm:8.16.11": + version: 8.16.11 + resolution: "@wdio/utils@npm:8.16.11" dependencies: "@puppeteer/browsers": ^1.6.0 "@wdio/logger": 8.11.0 @@ -1240,8 +1233,9 @@ __metadata: import-meta-resolve: ^3.0.0 locate-app: ^2.1.0 safaridriver: ^0.1.0 + split2: ^4.2.0 wait-port: ^1.0.4 - checksum: 0d064f85f4b436728751574f1993cc541f0c395c583cd6d90dd24f3410c66ed120a69b073b344de96bfaf4203109e1c6abbc9fe1f57a19f6fc7e297cc3cc6fb7 + checksum: d044cd135c02fc3d2d605a3607a60c2c318658649fbb8679e400fe33c7d5d2ef07e5e8730599bec3b42c04abbc880dfd3a22cf0e074ed5a78308ba8eaac37f9f languageName: node linkType: hard @@ -3619,9 +3613,9 @@ __metadata: linkType: hard "fflate@npm:^0.8.0": - version: 0.8.0 - resolution: "fflate@npm:0.8.0" - checksum: 6215f95ee01d620a41e459247a7de7e7117dd23e78ef017c26b64c26f2a880a90eedc77675918bbf816d18cc990f6505cd71be933c67cc48cc1e7ebbff1589ea + version: 0.8.1 + resolution: "fflate@npm:0.8.1" + checksum: 7207e2d333243724485d2488095256b776184bd4545aa9967b655feaee5dc18e9525ed9b6d75f94cfd71d98fb285336f4902641683472f1d0c19a99137084cec languageName: node linkType: hard @@ -3703,9 +3697,9 @@ __metadata: linkType: hard "flatted@npm:^3.2.7": - version: 3.2.7 - resolution: "flatted@npm:3.2.7" - checksum: 427633049d55bdb80201c68f7eb1cbd533e03eac541f97d3aecab8c5526f12a20ccecaeede08b57503e772c769e7f8680b37e8d482d1e5f8d7e2194687f9ea35 + version: 3.2.9 + resolution: "flatted@npm:3.2.9" + checksum: f14167fbe26a9d20f6fca8d998e8f1f41df72c8e81f9f2c9d61ed2bea058248f5e1cbd05e7f88c0e5087a6a0b822a1e5e2b446e879f3cfbe0b07ba2d7f80b026 languageName: node linkType: hard @@ -3988,8 +3982,8 @@ __metadata: linkType: hard "glob@npm:^10.2.2": - version: 10.3.4 - resolution: "glob@npm:10.3.4" + version: 10.3.5 + resolution: "glob@npm:10.3.5" dependencies: foreground-child: ^3.1.0 jackspeak: ^2.0.3 @@ -3998,7 +3992,7 @@ __metadata: path-scurry: ^1.10.1 bin: glob: dist/cjs/src/bin.js - checksum: 176b97c124414401cb51329a93d2ba112cef8814adbed10348481916b9521b677773eee2691cb6b24d66632d8c8bb8913533f5ac4bfb2d0ef5454a1856082361 + checksum: 564f4799cae48c0bcc841c88a20b539b5701c27ed5596f8623f588b3c523262d3fc20eb1ea89cab9c75b0912faf40ca5501fc835f982225d0d0599282b09e97a languageName: node linkType: hard @@ -4030,11 +4024,11 @@ __metadata: linkType: hard "globals@npm:^13.19.0": - version: 13.21.0 - resolution: "globals@npm:13.21.0" + version: 13.22.0 + resolution: "globals@npm:13.22.0" dependencies: type-fest: ^0.20.2 - checksum: 86c92ca8a04efd864c10852cd9abb1ebe6d447dcc72936783e66eaba1087d7dba5c9c3421a48d6ca722c319378754dbcc3f3f732dbe47592d7de908edf58a773 + checksum: 64af5a09565341432770444085f7aa98b54331c3b69732e0de411003921fa2dd060222ae7b50bec0b98f29c4d00b4f49bf434049ba9f7c36ca4ee1773f60458c languageName: node linkType: hard @@ -6489,28 +6483,28 @@ __metadata: linkType: hard "resolve@npm:^1.19.0": - version: 1.22.5 - resolution: "resolve@npm:1.22.5" + version: 1.22.6 + resolution: "resolve@npm:1.22.6" dependencies: is-core-module: ^2.13.0 path-parse: ^1.0.7 supports-preserve-symlinks-flag: ^1.0.0 bin: resolve: bin/resolve - checksum: 6d8c8e414c0727341bc5b78d3806aa6730975d6c633ff266e90f3502ae1c10353d3535c9810aa94187a32ea192b9b3722afecac67487e27f44e60d89cca45cda + checksum: d13bf66d4e2ee30d291491f16f2fa44edd4e0cefb85d53249dd6f93e70b2b8c20ec62f01b18662e3cd40e50a7528f18c4087a99490048992a3bb954cf3201a5b languageName: node linkType: hard "resolve@patch:resolve@^1.19.0#~builtin": - version: 1.22.5 - resolution: "resolve@patch:resolve@npm%3A1.22.5#~builtin::version=1.22.5&hash=c3c19d" + version: 1.22.6 + resolution: "resolve@patch:resolve@npm%3A1.22.6#~builtin::version=1.22.6&hash=c3c19d" dependencies: is-core-module: ^2.13.0 path-parse: ^1.0.7 supports-preserve-symlinks-flag: ^1.0.0 bin: resolve: bin/resolve - checksum: 8478df3911a3420450038b87aab4a6c66b91461035d901cd794076b46adfbf157fcfc8e83e3d0ef41a5956ce72ae166c33bd78432d6b41d43ee473b05c51cb32 + checksum: 9d3b3c67aefd12cecbe5f10ca4d1f51ea190891096497c43f301b086883b426466918c3a64f1bbf1788fabb52b579d58809614006c5d0b49186702b3b8fb746a languageName: node linkType: hard @@ -6884,9 +6878,16 @@ __metadata: linkType: hard "spdx-license-ids@npm:^3.0.0": - version: 3.0.13 - resolution: "spdx-license-ids@npm:3.0.13" - checksum: 3469d85c65f3245a279fa11afc250c3dca96e9e847f2f79d57f466940c5bb8495da08a542646086d499b7f24a74b8d0b42f3fc0f95d50ff99af1f599f6360ad7 + version: 3.0.15 + resolution: "spdx-license-ids@npm:3.0.15" + checksum: 99d567875b50504e1a7359f6da7d03e28db2b855b412ced18310679d091565a44f61ffd2585f19ea53a1192c35f2156c143507b12339dda26ef928547df32002 + languageName: node + linkType: hard + +"split2@npm:^4.2.0": + version: 4.2.0 + resolution: "split2@npm:4.2.0" + checksum: 05d54102546549fe4d2455900699056580cca006c0275c334611420f854da30ac999230857a85fdd9914dc2109ae50f80fda43d2a445f2aa86eccdc1dfce779d languageName: node linkType: hard @@ -7604,15 +7605,15 @@ __metadata: linkType: hard "wait-port@npm:^1.0.4": - version: 1.0.4 - resolution: "wait-port@npm:1.0.4" + version: 1.1.0 + resolution: "wait-port@npm:1.1.0" dependencies: chalk: ^4.1.2 commander: ^9.3.0 debug: ^4.3.4 bin: wait-port: bin/wait-port.js - checksum: 062aa830be38d16e0d004cb6b770cc1ce0b529e4e5cc2bca4c2e670c123bac1a1e692db938e9ce3db5199766a55fd02b1af5f4fee574b1b07ec65f373bbae324 + checksum: bf7c2cd566449530e2599a00cdf4b5a8a6e8c55d370bcd4045db6eacdc7040fdf3d83ff8773bbb036ac614e0d677ade28724a4d259cd3cc555cf9b4995647bab languageName: node linkType: hard @@ -7623,36 +7624,36 @@ __metadata: languageName: node linkType: hard -"webdriver@npm:8.16.7": - version: 8.16.7 - resolution: "webdriver@npm:8.16.7" +"webdriver@npm:8.16.11": + version: 8.16.11 + resolution: "webdriver@npm:8.16.11" dependencies: "@types/node": ^20.1.0 "@types/ws": ^8.5.3 - "@wdio/config": 8.16.7 + "@wdio/config": 8.16.11 "@wdio/logger": 8.11.0 "@wdio/protocols": 8.16.5 "@wdio/types": 8.16.7 - "@wdio/utils": 8.16.7 + "@wdio/utils": 8.16.11 deepmerge-ts: ^5.1.0 got: ^ 12.6.1 ky: ^0.33.0 ws: ^8.8.0 - checksum: e53546c5d330e93b21dfa1f970aed858d9c05408a2abab94196b6d51e9bbe2c3bcccd4f8e7e758cbec13148e31aabe4dd28050881d7aa09a336332d00610ab82 + checksum: 809331016bb04c303252f84a0b4d965dc716f18a798829dc35601cf7ed1fbfbf3f49d35a01ffe5573bdb3175121cbec36d18492f107fe47ecde8a4bffae0af88 languageName: node linkType: hard "webdriverio@npm:^8.8.6": - version: 8.16.7 - resolution: "webdriverio@npm:8.16.7" + version: 8.16.11 + resolution: "webdriverio@npm:8.16.11" dependencies: "@types/node": ^20.1.0 - "@wdio/config": 8.16.7 + "@wdio/config": 8.16.11 "@wdio/logger": 8.11.0 "@wdio/protocols": 8.16.5 "@wdio/repl": 8.10.1 "@wdio/types": 8.16.7 - "@wdio/utils": 8.16.7 + "@wdio/utils": 8.16.11 archiver: ^6.0.0 aria-query: ^5.0.0 css-shorthand-properties: ^1.1.1 @@ -7669,13 +7670,13 @@ __metadata: resq: ^1.9.1 rgb2hex: 0.2.5 serialize-error: ^11.0.1 - webdriver: 8.16.7 + webdriver: 8.16.11 peerDependencies: devtools: ^8.14.0 peerDependenciesMeta: devtools: optional: true - checksum: 6be1952f7ce4a87bf95ef2624f674a9f3d0f1483f91bf6bcec47f2766d496ba670aa564fad547695913439ffccc36b9a702e2922538cb0d128fa9ee4a39d5929 + checksum: 74199a7900ee81f1ccdf0e9096ab5a7ee6c9c1ec53a82293e64d5f06123f041155b3d9b594ac7e78e9fea4abb7f3c961f03d2f18fd2ca1ce50748c19b00a1a82 languageName: node linkType: hard @@ -7846,8 +7847,8 @@ __metadata: linkType: hard "ws@npm:^8.8.0": - version: 8.14.1 - resolution: "ws@npm:8.14.1" + version: 8.14.2 + resolution: "ws@npm:8.14.2" peerDependencies: bufferutil: ^4.0.1 utf-8-validate: ">=5.0.2" @@ -7856,7 +7857,7 @@ __metadata: optional: true utf-8-validate: optional: true - checksum: 9e310be2b0ff69e1f87d8c6d093ecd17a1ed4c37f281d17c35e8c30e2bd116401775b3d503249651374e6e0e1e9905db62fff096b694371c77561aee06bc3466 + checksum: 3ca0dad26e8cc6515ff392b622a1467430814c463b3368b0258e33696b1d4bed7510bc7030f7b72838b9fdeb8dbd8839cbf808367d6aae2e1d668ce741d4308b languageName: node linkType: hard From 6d5d9605a76034bf24d50dcc249eb16ba919c92c Mon Sep 17 00:00:00 2001 From: kevaundray Date: Thu, 21 Sep 2023 00:27:31 +0000 Subject: [PATCH 37/37] cargo fmt --- compiler/noirc_frontend/src/hir/resolution/resolver.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/noirc_frontend/src/hir/resolution/resolver.rs b/compiler/noirc_frontend/src/hir/resolution/resolver.rs index 0ac60ce099b..4231e493457 100644 --- a/compiler/noirc_frontend/src/hir/resolution/resolver.rs +++ b/compiler/noirc_frontend/src/hir/resolution/resolver.rs @@ -18,8 +18,8 @@ use crate::hir_def::expr::{ HirMemberAccess, HirMethodCallExpression, HirPrefixExpression, }; -use crate::token::FunctionAttribute; use crate::hir_def::traits::{Trait, TraitConstraint}; +use crate::token::FunctionAttribute; use regex::Regex; use std::collections::{BTreeMap, HashSet}; use std::rc::Rc;