diff --git a/avm-transpiler/Cargo.lock b/avm-transpiler/Cargo.lock index 43287fcb588..8cc69462e76 100644 --- a/avm-transpiler/Cargo.lock +++ b/avm-transpiler/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "acir" -version = "0.40.0" +version = "0.41.0" dependencies = [ "acir_field", "base64 0.21.7", @@ -17,7 +17,7 @@ dependencies = [ [[package]] name = "acir_field" -version = "0.40.0" +version = "0.41.0" dependencies = [ "ark-bn254", "ark-ff", @@ -30,7 +30,7 @@ dependencies = [ [[package]] name = "acvm" -version = "0.40.0" +version = "0.41.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -43,7 +43,7 @@ dependencies = [ [[package]] name = "acvm_blackbox_solver" -version = "0.40.0" +version = "0.41.0" dependencies = [ "acir", "blake2", @@ -159,7 +159,7 @@ dependencies = [ [[package]] name = "arena" -version = "0.24.0" +version = "0.25.0" [[package]] name = "ark-bn254" @@ -312,7 +312,7 @@ dependencies = [ [[package]] name = "aztec_macros" -version = "0.24.0" +version = "0.25.0" dependencies = [ "convert_case", "iter-extended", @@ -395,7 +395,7 @@ dependencies = [ [[package]] name = "brillig" -version = "0.40.0" +version = "0.41.0" dependencies = [ "acir_field", "serde", @@ -403,7 +403,7 @@ dependencies = [ [[package]] name = "brillig_vm" -version = "0.40.0" +version = "0.41.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -776,7 +776,7 @@ dependencies = [ [[package]] name = "fm" -version = "0.24.0" +version = "0.25.0" dependencies = [ "codespan-reporting", "serde", @@ -954,7 +954,7 @@ dependencies = [ [[package]] name = "iter-extended" -version = "0.24.0" +version = "0.25.0" [[package]] name = "itertools" @@ -1053,7 +1053,7 @@ dependencies = [ [[package]] name = "noirc_abi" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "iter-extended", @@ -1068,7 +1068,7 @@ dependencies = [ [[package]] name = "noirc_driver" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "aztec_macros", @@ -1081,7 +1081,6 @@ dependencies = [ "noirc_errors", "noirc_evaluator", "noirc_frontend", - "noirc_macros", "rust-embed", "serde", "thiserror", @@ -1090,7 +1089,7 @@ dependencies = [ [[package]] name = "noirc_errors" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "base64 0.21.7", @@ -1108,7 +1107,7 @@ dependencies = [ [[package]] name = "noirc_evaluator" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "fxhash", @@ -1124,7 +1123,7 @@ dependencies = [ [[package]] name = "noirc_frontend" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "arena", @@ -1144,17 +1143,9 @@ dependencies = [ "tracing", ] -[[package]] -name = "noirc_macros" -version = "0.24.0" -dependencies = [ - "iter-extended", - "noirc_frontend", -] - [[package]] name = "noirc_printable_type" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "iter-extended", diff --git a/noir/noir-repo/.github/JS_PUBLISH_FAILED.md b/noir/noir-repo/.github/JS_PUBLISH_FAILED.md index 5b9f79aac1f..9adba2776c8 100644 --- a/noir/noir-repo/.github/JS_PUBLISH_FAILED.md +++ b/noir/noir-repo/.github/JS_PUBLISH_FAILED.md @@ -1,6 +1,6 @@ --- title: "JS packages failed to publish" -assignees: TomAFrench kevaundray savio-sou +assignees: TomAFrench kevaundray Savio-Sou labels: js --- diff --git a/noir/noir-repo/.github/workflows/publish-es-packages.yml b/noir/noir-repo/.github/workflows/publish-es-packages.yml index f72a97b2684..470db3b78f7 100644 --- a/noir/noir-repo/.github/workflows/publish-es-packages.yml +++ b/noir/noir-repo/.github/workflows/publish-es-packages.yml @@ -20,7 +20,9 @@ jobs: steps: - name: Checkout Noir repo uses: actions/checkout@v4 - + with: + ref: ${{ inputs.noir-ref }} + - name: Setup toolchain uses: dtolnay/rust-toolchain@1.73.0 @@ -87,6 +89,8 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v4 + with: + ref: ${{ inputs.noir-ref }} - name: Setup toolchain uses: dtolnay/rust-toolchain@1.73.0 @@ -164,4 +168,4 @@ jobs: WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} with: update_existing: true - filename: .github/JS_PUBLISH_FAILED.md \ No newline at end of file + filename: .github/JS_PUBLISH_FAILED.md diff --git a/noir/noir-repo/.release-please-manifest.json b/noir/noir-repo/.release-please-manifest.json index 8916585d7f1..b38234ca0b9 100644 --- a/noir/noir-repo/.release-please-manifest.json +++ b/noir/noir-repo/.release-please-manifest.json @@ -1,4 +1,4 @@ { - ".": "0.24.0", - "acvm-repo": "0.40.0" + ".": "0.25.0", + "acvm-repo": "0.41.0" } \ No newline at end of file diff --git a/noir/noir-repo/CHANGELOG.md b/noir/noir-repo/CHANGELOG.md index e9b2dfb48a5..cdbccf768ca 100644 --- a/noir/noir-repo/CHANGELOG.md +++ b/noir/noir-repo/CHANGELOG.md @@ -1,5 +1,82 @@ # Changelog +## [0.25.0](https://github.com/noir-lang/noir/compare/v0.24.0...v0.25.0) (2024-03-11) + + +### ⚠ BREAKING CHANGES + +* Internal as a macro (https://github.com/AztecProtocol/aztec-packages/pull/4898) +* reserve `unchecked` keyword ([#4432](https://github.com/noir-lang/noir/issues/4432)) +* Remove empty value from bounded vec ([#4431](https://github.com/noir-lang/noir/issues/4431)) +* Ban Fields in for loop indices and bitwise ops ([#4376](https://github.com/noir-lang/noir/issues/4376)) +* bump msrv to 1.73.0 ([#4406](https://github.com/noir-lang/noir/issues/4406)) +* **ci:** Bump MSRV to 1.72.1 and enforce that ACVM can be published using updated lockfile ([#4385](https://github.com/noir-lang/noir/issues/4385)) +* Restrict bit sizes ([#4235](https://github.com/noir-lang/noir/issues/4235)) +* move noir out of yarn-project (https://github.com/AztecProtocol/aztec-packages/pull/4479) +* note type ids (https://github.com/AztecProtocol/aztec-packages/pull/4500) + +### Features + +* Add eddsa_poseidon_to_pub function to stdlib with test + docs ([#4473](https://github.com/noir-lang/noir/issues/4473)) ([00d2c32](https://github.com/noir-lang/noir/commit/00d2c32e58176cc5de3574c8435a54d415c4a5fa)) +* Add HashMap to the stdlib ([#4242](https://github.com/noir-lang/noir/issues/4242)) ([650ffc5](https://github.com/noir-lang/noir/commit/650ffc5053cdca4b6ad2e027fa1f4fd90ef64871)) +* Add option to set max memory for bb.js ([#4227](https://github.com/noir-lang/noir/issues/4227)) ([8a6b131](https://github.com/noir-lang/noir/commit/8a6b131402892a570bc2de6f5869de73b0bd979e)) +* Add overflow and underflow checks for unsigned integers in brillig ([#4445](https://github.com/noir-lang/noir/issues/4445)) ([21fc4b8](https://github.com/noir-lang/noir/commit/21fc4b85763dccae6dce0a46a318718c3c913471)) +* Add poseidon2 opcode implementation for acvm/brillig, and Noir ([#4398](https://github.com/noir-lang/noir/issues/4398)) ([10e8292](https://github.com/noir-lang/noir/commit/10e82920798380f50046e52db4a20ca205191ab7)) +* Added cast opcode and cast calldata (https://github.com/AztecProtocol/aztec-packages/pull/4423) ([78ef013](https://github.com/noir-lang/noir/commit/78ef0134b82e76a73dadb6c7975def22290e3a1a)) +* Allow type aliases to reference other aliases ([#4353](https://github.com/noir-lang/noir/issues/4353)) ([c44ef14](https://github.com/noir-lang/noir/commit/c44ef14847a436733206b6dd9590a7ab214ecd97)) +* Backpropagate constants in ACIR during optimization ([#3926](https://github.com/noir-lang/noir/issues/3926)) ([aad0da0](https://github.com/noir-lang/noir/commit/aad0da024c69663f42e6913e674682d5864b26ae)) +* **ci:** Use wasm-opt when compiling wasm packages ([#4334](https://github.com/noir-lang/noir/issues/4334)) ([e382921](https://github.com/noir-lang/noir/commit/e3829213d8411f84e117a14b43816967925095e0)) +* DAP Preflight and debugger compilation options ([#4185](https://github.com/noir-lang/noir/issues/4185)) ([e0ad0b2](https://github.com/noir-lang/noir/commit/e0ad0b2b31f6d46be75d23aec6a82850a9c4bd75)) +* Expose separate functions to compile programs vs contracts in `noir_wasm` ([#4413](https://github.com/noir-lang/noir/issues/4413)) ([7cd5fdb](https://github.com/noir-lang/noir/commit/7cd5fdb3d2a53475b7c8681231d517cab30f9f9b)) +* Internal as a macro (https://github.com/AztecProtocol/aztec-packages/pull/4898) ([5f57ebb](https://github.com/noir-lang/noir/commit/5f57ebb7ff4b810802f90699a10f4325ef904f2e)) +* Note type ids (https://github.com/AztecProtocol/aztec-packages/pull/4500) ([78ef013](https://github.com/noir-lang/noir/commit/78ef0134b82e76a73dadb6c7975def22290e3a1a)) +* Restrict bit sizes ([#4235](https://github.com/noir-lang/noir/issues/4235)) ([1048f81](https://github.com/noir-lang/noir/commit/1048f815abb1f27e9c84ab5b9568a3673c12a50a)) +* Run tests in parallel in `nargo test` ([#4484](https://github.com/noir-lang/noir/issues/4484)) ([761734e](https://github.com/noir-lang/noir/commit/761734e6cb3ff5911aa85d0cee96ad26092b4905)) +* Skip redundant range checks in brillig ([#4460](https://github.com/noir-lang/noir/issues/4460)) ([cb4c1c5](https://github.com/noir-lang/noir/commit/cb4c1c5264b95d01f69d99f916ced71ad9cdc9d1)) +* Sync from aztec-packages ([#4483](https://github.com/noir-lang/noir/issues/4483)) ([fe8f277](https://github.com/noir-lang/noir/commit/fe8f2776ccfde29209a2c3fc162311c99e4f59be)) +* Track stack frames and their variables in the debugger ([#4188](https://github.com/noir-lang/noir/issues/4188)) ([ae1a9d9](https://github.com/noir-lang/noir/commit/ae1a9d923998177516919bbba6ff4b0584fa1e9f)) +* TypeVariableKind for just Integers ([#4118](https://github.com/noir-lang/noir/issues/4118)) ([c956be8](https://github.com/noir-lang/noir/commit/c956be870fb47403a6da6585fce6bea2d40ee268)) +* Update error message when trying to load workspace as dependency ([#4393](https://github.com/noir-lang/noir/issues/4393)) ([d2585e7](https://github.com/noir-lang/noir/commit/d2585e738a63208fca3c9e26242e896d7f1df1e4)) + + +### Bug Fixes + +* **acir:** Array dynamic flatten ([#4351](https://github.com/noir-lang/noir/issues/4351)) ([b2aaeab](https://github.com/noir-lang/noir/commit/b2aaeab319a0c66c431a7db6852f743eccde8e98)) +* **acir:** Use types on dynamic arrays ([#4364](https://github.com/noir-lang/noir/issues/4364)) ([ba2c541](https://github.com/noir-lang/noir/commit/ba2c541ec45de92bba98de34771b73cbb7865c93)) +* Add `follow_bindings` to follow `Type::Alias` links ([#4521](https://github.com/noir-lang/noir/issues/4521)) ([b94adb9](https://github.com/noir-lang/noir/commit/b94adb92657e2b4a51dc7216a88e080aed1cf8b0)) +* Add handling to `noir_wasm` for projects without dependencies ([#4344](https://github.com/noir-lang/noir/issues/4344)) ([4982251](https://github.com/noir-lang/noir/commit/49822511710a7f1c42b8ed343e80456f8e6db2d9)) +* Allow type aliases in main ([#4505](https://github.com/noir-lang/noir/issues/4505)) ([8a5359c](https://github.com/noir-lang/noir/commit/8a5359c012579e54c2766de1074482a36ecada32)) +* Ban Fields in for loop indices and bitwise ops ([#4376](https://github.com/noir-lang/noir/issues/4376)) ([601fd9a](https://github.com/noir-lang/noir/commit/601fd9afc502236af1db0c4492698ba2298c7501)) +* Brillig range check with consistent bit size ([#4357](https://github.com/noir-lang/noir/issues/4357)) ([ea47d4a](https://github.com/noir-lang/noir/commit/ea47d4a67c6a18e4a7d3a49079d9eb24a1026a25)) +* Build noir_codegen when publishing ([#4448](https://github.com/noir-lang/noir/issues/4448)) ([cb1ceee](https://github.com/noir-lang/noir/commit/cb1ceee58b11b0ce6f8845361af3418d13c506bd)) +* Consistent bit size for truncate ([#4370](https://github.com/noir-lang/noir/issues/4370)) ([dcd7a1e](https://github.com/noir-lang/noir/commit/dcd7a1e561a68504b9038ffbb3c80f5c981f9f0c)) +* Correct formatting for databus visibility types ([#4423](https://github.com/noir-lang/noir/issues/4423)) ([cd796de](https://github.com/noir-lang/noir/commit/cd796dea4937dd1a261f154e5f2e599bbc649165)) +* Correct invalid brillig codegen for `EmbeddedCurvePoint.add` ([#4382](https://github.com/noir-lang/noir/issues/4382)) ([5051ec4](https://github.com/noir-lang/noir/commit/5051ec4d434a9e5cf405c68357faaf213e68de9e)) +* **docs:** Update install versions ([#4396](https://github.com/noir-lang/noir/issues/4396)) ([b283637](https://github.com/noir-lang/noir/commit/b283637e092038eb296c468168aec2d41e1c2734)) +* **docs:** Update noirjs_app for 0.23 ([#4378](https://github.com/noir-lang/noir/issues/4378)) ([f77f702](https://github.com/noir-lang/noir/commit/f77f702e0cfb81dcce4dd97e274b831e887ba5d2)) +* Enforce matching types of binary ops in SSA ([#4391](https://github.com/noir-lang/noir/issues/4391)) ([70866ae](https://github.com/noir-lang/noir/commit/70866aea976d59dbcbd4af34067fdd8f46555673)) +* Fix brillig slowdown when assigning arrays in loops ([#4472](https://github.com/noir-lang/noir/issues/4472)) ([2a53545](https://github.com/noir-lang/noir/commit/2a53545f4238c9b8535e6bc5b0720fa15f44f946)) +* **flake:** Stop flake.nix removing ignored-tests.txt ([#4455](https://github.com/noir-lang/noir/issues/4455)) ([ebaf05a](https://github.com/noir-lang/noir/commit/ebaf05ab10834dd10e04c7ea5130f96c6cdf98ed)) +* Force src impl for == on slices ([#4507](https://github.com/noir-lang/noir/issues/4507)) ([1691274](https://github.com/noir-lang/noir/commit/169127444e8b16a8aad4acfe29ba812894fd897c)) +* Handling of gh deps in noir_wasm ([#4499](https://github.com/noir-lang/noir/issues/4499)) ([1d65370](https://github.com/noir-lang/noir/commit/1d653704715bf9999eb6a40ed7500e752e2c73b7)) +* Iterative flattening pass ([#4492](https://github.com/noir-lang/noir/issues/4492)) ([33c1ef7](https://github.com/noir-lang/noir/commit/33c1ef70e7859fdee7babfb5d38191f53e73a0df)) +* Noir test incorrect reporting (https://github.com/AztecProtocol/aztec-packages/pull/4925) ([5f57ebb](https://github.com/noir-lang/noir/commit/5f57ebb7ff4b810802f90699a10f4325ef904f2e)) +* Only add `.nr` files to file manager ([#4380](https://github.com/noir-lang/noir/issues/4380)) ([8536c7c](https://github.com/noir-lang/noir/commit/8536c7c8ea8fc6b740b2ae6d1aef3bc7e1907b8c)) +* Remove panic when generic array length is not resolvable ([#4408](https://github.com/noir-lang/noir/issues/4408)) ([00ab3db](https://github.com/noir-lang/noir/commit/00ab3db86b06111d144516e862902b8604284611)) +* Remove print from monomorphization pass ([#4417](https://github.com/noir-lang/noir/issues/4417)) ([27c66b3](https://github.com/noir-lang/noir/commit/27c66b3d0741e68ed591ae8a16b47b30bc87175f)) +* **ssa:** Handle mergers of slices returned from calls ([#4496](https://github.com/noir-lang/noir/issues/4496)) ([f988d02](https://github.com/noir-lang/noir/commit/f988d020e43cdf36a38613f2052d4518de39193a)) +* Use correct type for numeric generics ([#4386](https://github.com/noir-lang/noir/issues/4386)) ([0a1d109](https://github.com/noir-lang/noir/commit/0a1d109f478c997da5c43876fd12464af638bb15)) +* Variables from trait constraints being permanently bound over when used within a trait impl ([#4450](https://github.com/noir-lang/noir/issues/4450)) ([ac60ef5](https://github.com/noir-lang/noir/commit/ac60ef5e12fcfb907fbdcff709d7cbad05f2b939)) + + +### Miscellaneous Chores + +* Bump msrv to 1.73.0 ([#4406](https://github.com/noir-lang/noir/issues/4406)) ([b5e5c30](https://github.com/noir-lang/noir/commit/b5e5c30f4db52c79ef556e80660f39db369b1911)) +* **ci:** Bump MSRV to 1.72.1 and enforce that ACVM can be published using updated lockfile ([#4385](https://github.com/noir-lang/noir/issues/4385)) ([2fc95d2](https://github.com/noir-lang/noir/commit/2fc95d2d82b3220267ce7d5815e7073e00ef1360)) +* Move noir out of yarn-project (https://github.com/AztecProtocol/aztec-packages/pull/4479) ([78ef013](https://github.com/noir-lang/noir/commit/78ef0134b82e76a73dadb6c7975def22290e3a1a)) +* Remove empty value from bounded vec ([#4431](https://github.com/noir-lang/noir/issues/4431)) ([b9384fb](https://github.com/noir-lang/noir/commit/b9384fb23abf4ab15e880fb7e03c21509a9fa8a6)) +* Reserve `unchecked` keyword ([#4432](https://github.com/noir-lang/noir/issues/4432)) ([9544813](https://github.com/noir-lang/noir/commit/9544813fabbd18a87dd88456e6a5b781bd0cf008)) + ## [0.24.0](https://github.com/noir-lang/noir/compare/v0.23.0...v0.24.0) (2024-02-12) diff --git a/noir/noir-repo/Cargo.lock b/noir/noir-repo/Cargo.lock index 83ac3744274..d5ce8a10509 100644 --- a/noir/noir-repo/Cargo.lock +++ b/noir/noir-repo/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "acir" -version = "0.40.0" +version = "0.41.0" dependencies = [ "acir_field", "base64 0.21.2", @@ -23,7 +23,7 @@ dependencies = [ [[package]] name = "acir_field" -version = "0.40.0" +version = "0.41.0" dependencies = [ "ark-bls12-381", "ark-bn254", @@ -37,7 +37,7 @@ dependencies = [ [[package]] name = "acvm" -version = "0.40.0" +version = "0.41.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "acvm_blackbox_solver" -version = "0.40.0" +version = "0.41.0" dependencies = [ "acir", "blake2", @@ -88,7 +88,7 @@ dependencies = [ [[package]] name = "acvm_js" -version = "0.40.0" +version = "0.41.0" dependencies = [ "acvm", "bn254_blackbox_solver", @@ -232,7 +232,7 @@ checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "arena" -version = "0.24.0" +version = "0.25.0" [[package]] name = "ark-bls12-381" @@ -411,7 +411,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "138985dd8aefbefeaa66b01b7f5b2b6b4c333fcef1cc5f32c63a2aabe37d6de3" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "lsp-types 0.94.1", "pin-project-lite", "rustix", @@ -433,7 +433,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "aztec_macros" -version = "0.24.0" +version = "0.25.0" dependencies = [ "convert_case 0.6.0", "iter-extended", @@ -541,9 +541,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.3" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "bitmaps" @@ -622,7 +622,7 @@ dependencies = [ [[package]] name = "brillig" -version = "0.40.0" +version = "0.41.0" dependencies = [ "acir_field", "serde", @@ -630,7 +630,7 @@ dependencies = [ [[package]] name = "brillig_vm" -version = "0.40.0" +version = "0.41.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -967,14 +967,14 @@ checksum = "55b672471b4e9f9e95499ea597ff64941a309b2cdbffcc46f2cc5e2d971fd335" [[package]] name = "console" -version = "0.15.7" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode 0.3.6", "lazy_static", "libc", - "windows-sys 0.45.0", + "windows-sys 0.52.0", ] [[package]] @@ -1605,12 +1605,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1726,7 +1726,7 @@ dependencies = [ [[package]] name = "fm" -version = "0.24.0" +version = "0.25.0" dependencies = [ "codespan-reporting", "iter-extended", @@ -1763,9 +1763,9 @@ checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -1778,9 +1778,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -1788,15 +1788,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -1806,15 +1806,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", @@ -1823,21 +1823,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures 0.1.31", "futures-channel", @@ -2096,9 +2096,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ "bytes", "futures-channel", @@ -2111,7 +2111,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.9", + "socket2", "tokio", "tower-service", "tracing", @@ -2120,9 +2120,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http", @@ -2318,7 +2318,7 @@ dependencies = [ [[package]] name = "iter-extended" -version = "0.24.0" +version = "0.25.0" [[package]] name = "itertools" @@ -2363,7 +2363,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2b99d4207e2a04fb4581746903c2bb7eb376f88de9c699d0f3e10feeac0cd3a" dependencies = [ "derive_more", - "futures 0.3.28", + "futures 0.3.30", "jsonrpc-core", "jsonrpc-pubsub", "log", @@ -2378,7 +2378,7 @@ version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "futures-executor", "futures-util", "log", @@ -2393,7 +2393,7 @@ version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b51da17abecbdab3e3d4f26b01c5ec075e88d3abe3ab3b05dc9aa69392764ec0" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "jsonrpc-client-transports", ] @@ -2415,7 +2415,7 @@ version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1dea6e07251d9ce6a552abfb5d7ad6bc290a4596c8dcc3d795fae2bbdc1f3ff" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "hyper", "jsonrpc-core", "jsonrpc-server-utils", @@ -2431,7 +2431,7 @@ version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240f87695e6c6f62fb37f05c02c04953cf68d6408b8c1c89de85c7a0125b1011" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "jsonrpc-core", "lazy_static", "log", @@ -2447,7 +2447,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa4fdea130485b572c39a460d50888beb00afb3e35de23ccd7fad8ff19f0e0d4" dependencies = [ "bytes", - "futures 0.3.28", + "futures 0.3.30", "globset", "jsonrpc-core", "lazy_static", @@ -2505,9 +2505,9 @@ checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" [[package]] name = "linux-raw-sys" -version = "0.4.3" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" @@ -2671,7 +2671,7 @@ checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" [[package]] name = "nargo" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "codespan-reporting", @@ -2698,7 +2698,7 @@ dependencies = [ [[package]] name = "nargo_cli" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "assert_cmd", @@ -2750,7 +2750,7 @@ dependencies = [ [[package]] name = "nargo_fmt" -version = "0.24.0" +version = "0.25.0" dependencies = [ "bytecount", "noirc_frontend", @@ -2762,7 +2762,7 @@ dependencies = [ [[package]] name = "nargo_toml" -version = "0.24.0" +version = "0.25.0" dependencies = [ "dirs", "fm", @@ -2835,7 +2835,7 @@ dependencies = [ [[package]] name = "noir_debugger" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "assert_cmd", @@ -2870,7 +2870,7 @@ dependencies = [ [[package]] name = "noir_lsp" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "async-lsp", @@ -2896,7 +2896,7 @@ dependencies = [ [[package]] name = "noir_wasm" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "build-data", @@ -2919,7 +2919,7 @@ dependencies = [ [[package]] name = "noirc_abi" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "iter-extended", @@ -2936,7 +2936,7 @@ dependencies = [ [[package]] name = "noirc_abi_wasm" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "build-data", @@ -2953,7 +2953,7 @@ dependencies = [ [[package]] name = "noirc_driver" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "aztec_macros", @@ -2966,7 +2966,6 @@ dependencies = [ "noirc_errors", "noirc_evaluator", "noirc_frontend", - "noirc_macros", "rust-embed", "serde", "thiserror", @@ -2975,7 +2974,7 @@ dependencies = [ [[package]] name = "noirc_errors" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "base64 0.21.2", @@ -2993,7 +2992,7 @@ dependencies = [ [[package]] name = "noirc_evaluator" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "fxhash", @@ -3009,7 +3008,7 @@ dependencies = [ [[package]] name = "noirc_frontend" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "arena", @@ -3032,17 +3031,9 @@ dependencies = [ "tracing", ] -[[package]] -name = "noirc_macros" -version = "0.24.0" -dependencies = [ - "iter-extended", - "noirc_frontend", -] - [[package]] name = "noirc_printable_type" -version = "0.24.0" +version = "0.25.0" dependencies = [ "acvm", "iter-extended", @@ -3480,7 +3471,7 @@ checksum = "7c003ac8c77cb07bb74f5f198bce836a689bcd5a42574612bf14d17bfd08c20e" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.3.3", + "bitflags 2.4.2", "lazy_static", "num-traits", "rand 0.8.5", @@ -3942,15 +3933,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.4" +version = "0.38.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.2", "errno", "libc", "linux-raw-sys", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -4321,9 +4312,9 @@ dependencies = [ [[package]] name = "shared-buffer" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cf61602ee61e2f83dd016b3e6387245291cf728ea071c378b35088125b4d995" +checksum = "f6c99835bad52957e7aa241d3975ed17c1e5f8c92026377d117a606f36b84b16" dependencies = [ "bytes", "memmap2 0.6.2", @@ -4441,16 +4432,6 @@ dependencies = [ "serde", ] -[[package]] -name = "socket2" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "socket2" version = "0.5.5" @@ -4762,7 +4743,7 @@ dependencies = [ "mio", "num_cpus", "pin-project-lite", - "socket2 0.5.5", + "socket2", "tokio-macros", "windows-sys 0.48.0", ] @@ -5278,9 +5259,9 @@ dependencies = [ [[package]] name = "wasmer" -version = "4.2.4" +version = "4.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce45cc009177ca345a6d041f9062305ad467d15e7d41494f5b81ab46d62d7a58" +checksum = "5c15724dc25d1ee57962334aea8e41ade2675e5ea2ac6b8d42da6051b0face66" dependencies = [ "bytes", "cfg-if 1.0.0", @@ -5294,23 +5275,23 @@ dependencies = [ "shared-buffer", "target-lexicon", "thiserror", + "tracing", "wasm-bindgen", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-derive", "wasmer-types", "wasmer-vm", - "wasmparser 0.83.0", - "wasmparser 0.95.0", + "wasmparser", "wat", "winapi", ] [[package]] name = "wasmer-compiler" -version = "4.2.4" +version = "4.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e044f6140c844602b920deb4526aea3cc9c0d7cf23f00730bb9b2034669f522a" +checksum = "55a7f3b3a96f8d844c25e2c032af9572306dd63fa93dc17bcca4c5458ac569bd" dependencies = [ "backtrace", "bytes", @@ -5329,15 +5310,15 @@ dependencies = [ "thiserror", "wasmer-types", "wasmer-vm", - "wasmparser 0.95.0", + "wasmparser", "winapi", ] [[package]] name = "wasmer-compiler-cranelift" -version = "4.2.4" +version = "4.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ce02358eb44a149d791c1d6648fb7f8b2f99cd55e3c4eef0474653ec8cc889" +checksum = "102e2c5bacac69495c4025767e2fa26797ffb27f242dccb7cf57d9cefd944386" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -5354,9 +5335,9 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "4.2.4" +version = "4.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c782d80401edb08e1eba206733f7859db6c997fc5a7f5fb44edc3ecd801468f6" +checksum = "0ea737fa08f95d6abc4459f42a70a9833e8974b814e74971d77ef473814f4d4c" dependencies = [ "proc-macro-error", "proc-macro2", @@ -5366,9 +5347,9 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "4.2.4" +version = "4.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd09e80d4d74bb9fd0ce6c3c106b1ceba1a050f9948db9d9b78ae53c172d6157" +checksum = "b0689110e291b0f07fc665f2824e5ff81df120848e8a9acfbf1a9bf7990773f9" dependencies = [ "bytecheck", "enum-iterator", @@ -5382,9 +5363,9 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "4.2.4" +version = "4.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdcd8a4fd36414a7b6a003dbfbd32393bce3e155d715dd877c05c1b7a41d224d" +checksum = "4cd41f822a1ac4242d478754e8ceba2806a00ea5072803622e1fe91e8e28b2a1" dependencies = [ "backtrace", "cc", @@ -5410,18 +5391,13 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.83.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" - -[[package]] -name = "wasmparser" -version = "0.95.0" +version = "0.121.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ea896273ea99b15132414be1da01ab0d8836415083298ecaffbe308eaac87a" +checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ - "indexmap 1.9.3", - "url 2.4.0", + "bitflags 2.4.2", + "indexmap 2.0.0", + "semver", ] [[package]] @@ -5514,15 +5490,6 @@ dependencies = [ "windows_x86_64_msvc 0.33.0", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -5533,18 +5500,12 @@ dependencies = [ ] [[package]] -name = "windows-targets" -version = "0.42.2" +name = "windows-sys" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets 0.52.4", ] [[package]] @@ -5563,10 +5524,19 @@ dependencies = [ ] [[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" +name = "windows-targets" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +dependencies = [ + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", +] [[package]] name = "windows_aarch64_gnullvm" @@ -5574,6 +5544,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" + [[package]] name = "windows_aarch64_msvc" version = "0.33.0" @@ -5582,15 +5558,15 @@ checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" @@ -5600,15 +5576,15 @@ checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" @@ -5618,15 +5594,15 @@ checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" @@ -5636,27 +5612,27 @@ checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" @@ -5666,15 +5642,15 @@ checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] name = "winnow" diff --git a/noir/noir-repo/Cargo.toml b/noir/noir-repo/Cargo.toml index 572042f1a6a..b8f9b9ceacc 100644 --- a/noir/noir-repo/Cargo.toml +++ b/noir/noir-repo/Cargo.toml @@ -1,9 +1,8 @@ [workspace] members = [ - # Macros crates for metaprogramming + # Aztec Macro crate for metaprogramming "aztec_macros", - "noirc_macros", # Compiler crates "compiler/noirc_evaluator", "compiler/noirc_frontend", @@ -42,7 +41,7 @@ resolver = "2" [workspace.package] # x-release-please-start-version -version = "0.24.0" +version = "0.25.0" # x-release-please-end authors = ["The Noir Team "] edition = "2021" @@ -53,12 +52,12 @@ repository = "https://github.com/noir-lang/noir/" [workspace.dependencies] # ACVM workspace dependencies -acir_field = { version = "0.40.0", path = "acvm-repo/acir_field", default-features = false } -acir = { version = "0.40.0", path = "acvm-repo/acir", default-features = false } -acvm = { version = "0.40.0", path = "acvm-repo/acvm" } -brillig = { version = "0.40.0", path = "acvm-repo/brillig", default-features = false } -brillig_vm = { version = "0.40.0", path = "acvm-repo/brillig_vm", default-features = false } -acvm_blackbox_solver = { version = "0.40.0", path = "acvm-repo/blackbox_solver", default-features = false } +acir_field = { version = "0.41.0", path = "acvm-repo/acir_field", default-features = false } +acir = { version = "0.41.0", path = "acvm-repo/acir", default-features = false } +acvm = { version = "0.41.0", path = "acvm-repo/acvm" } +brillig = { version = "0.41.0", path = "acvm-repo/brillig", default-features = false } +brillig_vm = { version = "0.41.0", path = "acvm-repo/brillig_vm", default-features = false } +acvm_blackbox_solver = { version = "0.41.0", path = "acvm-repo/blackbox_solver", default-features = false } bn254_blackbox_solver = { version = "0.39.0", path = "acvm-repo/bn254_blackbox_solver", default-features = false } # Noir compiler workspace dependencies diff --git a/noir/noir-repo/acvm-repo/CHANGELOG.md b/noir/noir-repo/acvm-repo/CHANGELOG.md index acb465e5cc9..4f220d6eeba 100644 --- a/noir/noir-repo/acvm-repo/CHANGELOG.md +++ b/noir/noir-repo/acvm-repo/CHANGELOG.md @@ -5,6 +5,70 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.41.0](https://github.com/noir-lang/noir/compare/v0.40.0...v0.41.0) (2024-03-11) + + +### ⚠ BREAKING CHANGES + +* Internal as a macro (https://github.com/AztecProtocol/aztec-packages/pull/4898) +* move noir out of yarn-project (https://github.com/AztecProtocol/aztec-packages/pull/4479) +* note type ids (https://github.com/AztecProtocol/aztec-packages/pull/4500) +* rename bigint_neg into bigint_sub (https://github.com/AztecProtocol/aztec-packages/pull/4420) +* Add expression width into acir (https://github.com/AztecProtocol/aztec-packages/pull/4014) +* init storage macro (https://github.com/AztecProtocol/aztec-packages/pull/4200) +* **acir:** Move `is_recursive` flag to be part of the circuit definition (https://github.com/AztecProtocol/aztec-packages/pull/4221) +* Sync commits from `aztec-packages` ([#4144](https://github.com/noir-lang/noir/issues/4144)) +* Breaking changes from aztec-packages ([#3955](https://github.com/noir-lang/noir/issues/3955)) +* Rename Arithmetic opcode to AssertZero ([#3840](https://github.com/noir-lang/noir/issues/3840)) +* Remove unused methods on ACIR opcodes ([#3841](https://github.com/noir-lang/noir/issues/3841)) +* Remove partial backend feature ([#3805](https://github.com/noir-lang/noir/issues/3805)) + +### Features + +* Add bit size to const opcode (https://github.com/AztecProtocol/aztec-packages/pull/4385) ([158c8ce](https://github.com/noir-lang/noir/commit/158c8cec7f0dc698042e9512001dd2c9d6b40bcc)) +* Add expression width into acir (https://github.com/AztecProtocol/aztec-packages/pull/4014) ([158c8ce](https://github.com/noir-lang/noir/commit/158c8cec7f0dc698042e9512001dd2c9d6b40bcc)) +* Add instrumentation for tracking variables in debugging ([#4122](https://github.com/noir-lang/noir/issues/4122)) ([c58d691](https://github.com/noir-lang/noir/commit/c58d69141b54a918cd1675400c00bfd48720f896)) +* Add poseidon2 opcode implementation for acvm/brillig, and Noir ([#4398](https://github.com/noir-lang/noir/issues/4398)) ([10e8292](https://github.com/noir-lang/noir/commit/10e82920798380f50046e52db4a20ca205191ab7)) +* Add support for overriding expression width ([#4117](https://github.com/noir-lang/noir/issues/4117)) ([c8026d5](https://github.com/noir-lang/noir/commit/c8026d557d535b10fe455165d6445076df7a03de)) +* Added cast opcode and cast calldata (https://github.com/AztecProtocol/aztec-packages/pull/4423) ([78ef013](https://github.com/noir-lang/noir/commit/78ef0134b82e76a73dadb6c7975def22290e3a1a)) +* Allow brillig to read arrays directly from memory (https://github.com/AztecProtocol/aztec-packages/pull/4460) ([158c8ce](https://github.com/noir-lang/noir/commit/158c8cec7f0dc698042e9512001dd2c9d6b40bcc)) +* Allow nested arrays and vectors in Brillig foreign calls (https://github.com/AztecProtocol/aztec-packages/pull/4478) ([158c8ce](https://github.com/noir-lang/noir/commit/158c8cec7f0dc698042e9512001dd2c9d6b40bcc)) +* Allow variables and stack trace inspection in the debugger ([#4184](https://github.com/noir-lang/noir/issues/4184)) ([bf263fc](https://github.com/noir-lang/noir/commit/bf263fc8d843940f328a90f6366edd2671fb2682)) +* **avm:** Back in avm context with macro - refactor context (https://github.com/AztecProtocol/aztec-packages/pull/4438) ([158c8ce](https://github.com/noir-lang/noir/commit/158c8cec7f0dc698042e9512001dd2c9d6b40bcc)) +* **aztec-nr:** Initial work for aztec public vm macro (https://github.com/AztecProtocol/aztec-packages/pull/4400) ([158c8ce](https://github.com/noir-lang/noir/commit/158c8cec7f0dc698042e9512001dd2c9d6b40bcc)) +* Aztec-packages ([#3754](https://github.com/noir-lang/noir/issues/3754)) ([c043265](https://github.com/noir-lang/noir/commit/c043265e550b59bd4296504826fe15d3ce3e9ad2)) +* Backpropagate constants in ACIR during optimization ([#3926](https://github.com/noir-lang/noir/issues/3926)) ([aad0da0](https://github.com/noir-lang/noir/commit/aad0da024c69663f42e6913e674682d5864b26ae)) +* Breaking changes from aztec-packages ([#3955](https://github.com/noir-lang/noir/issues/3955)) ([5be049e](https://github.com/noir-lang/noir/commit/5be049eee6c342649462282ee04f6411e6ea392c)) +* Evaluation of dynamic assert messages ([#4101](https://github.com/noir-lang/noir/issues/4101)) ([c284e01](https://github.com/noir-lang/noir/commit/c284e01bfe20ceae4414dc123624b5cbb8b66d09)) +* Init storage macro (https://github.com/AztecProtocol/aztec-packages/pull/4200) ([158c8ce](https://github.com/noir-lang/noir/commit/158c8cec7f0dc698042e9512001dd2c9d6b40bcc)) +* Internal as a macro (https://github.com/AztecProtocol/aztec-packages/pull/4898) ([5f57ebb](https://github.com/noir-lang/noir/commit/5f57ebb7ff4b810802f90699a10f4325ef904f2e)) +* Note type ids (https://github.com/AztecProtocol/aztec-packages/pull/4500) ([78ef013](https://github.com/noir-lang/noir/commit/78ef0134b82e76a73dadb6c7975def22290e3a1a)) +* Remove range constraints from witnesses which are constrained to be constants ([#3928](https://github.com/noir-lang/noir/issues/3928)) ([afe9c7a](https://github.com/noir-lang/noir/commit/afe9c7a38bb9d4245205d3aa46d4ce23d70a5671)) +* Remove replacement of boolean range opcodes with `AssertZero` opcodes ([#4107](https://github.com/noir-lang/noir/issues/4107)) ([dac0e87](https://github.com/noir-lang/noir/commit/dac0e87ee3be3446b92bbb12ef4832fd493fcee3)) +* Speed up transformation of debug messages ([#3815](https://github.com/noir-lang/noir/issues/3815)) ([2a8af1e](https://github.com/noir-lang/noir/commit/2a8af1e4141ffff61547ee1c2837a6392bd5db48)) +* Sync `aztec-packages` ([#4011](https://github.com/noir-lang/noir/issues/4011)) ([fee2452](https://github.com/noir-lang/noir/commit/fee24523c427c27f0bdaf98ea09a852a2da3e94c)) +* Sync commits from `aztec-packages` ([#4068](https://github.com/noir-lang/noir/issues/4068)) ([7a8f3a3](https://github.com/noir-lang/noir/commit/7a8f3a33b57875e681e3d81e667e3570a1cdbdcc)) +* Sync commits from `aztec-packages` ([#4144](https://github.com/noir-lang/noir/issues/4144)) ([0205d3b](https://github.com/noir-lang/noir/commit/0205d3b4ad0cf5ffd775a43eb5af273a772cf138)) +* Sync from aztec-packages ([#4483](https://github.com/noir-lang/noir/issues/4483)) ([fe8f277](https://github.com/noir-lang/noir/commit/fe8f2776ccfde29209a2c3fc162311c99e4f59be)) + + +### Bug Fixes + +* Deserialize odd length hex literals ([#3747](https://github.com/noir-lang/noir/issues/3747)) ([4000fb2](https://github.com/noir-lang/noir/commit/4000fb279221eb07187d657bfaa7f1c7b311abf2)) +* Noir test incorrect reporting (https://github.com/AztecProtocol/aztec-packages/pull/4925) ([5f57ebb](https://github.com/noir-lang/noir/commit/5f57ebb7ff4b810802f90699a10f4325ef904f2e)) +* Remove panic from `init_log_level` in `acvm_js` ([#4195](https://github.com/noir-lang/noir/issues/4195)) ([2e26530](https://github.com/noir-lang/noir/commit/2e26530bf53006c1ed4fee310bcaa905c95dd95b)) +* Return error rather instead of panicking on invalid circuit ([#3976](https://github.com/noir-lang/noir/issues/3976)) ([67201bf](https://github.com/noir-lang/noir/commit/67201bfc21a9c8858aa86be9cd47d463fb78d925)) + + +### Miscellaneous Chores + +* **acir:** Move `is_recursive` flag to be part of the circuit definition (https://github.com/AztecProtocol/aztec-packages/pull/4221) ([158c8ce](https://github.com/noir-lang/noir/commit/158c8cec7f0dc698042e9512001dd2c9d6b40bcc)) +* Move noir out of yarn-project (https://github.com/AztecProtocol/aztec-packages/pull/4479) ([78ef013](https://github.com/noir-lang/noir/commit/78ef0134b82e76a73dadb6c7975def22290e3a1a)) +* Remove partial backend feature ([#3805](https://github.com/noir-lang/noir/issues/3805)) ([0383100](https://github.com/noir-lang/noir/commit/0383100853a80a5b28b797cdfeae0d271f1b7805)) +* Remove unused methods on ACIR opcodes ([#3841](https://github.com/noir-lang/noir/issues/3841)) ([9e5d0e8](https://github.com/noir-lang/noir/commit/9e5d0e813d61a0bfb5ee68174ed287c5a20f1579)) +* Rename Arithmetic opcode to AssertZero ([#3840](https://github.com/noir-lang/noir/issues/3840)) ([836f171](https://github.com/noir-lang/noir/commit/836f17145c2901060706294461c2d282dd121b3e)) +* Rename bigint_neg into bigint_sub (https://github.com/AztecProtocol/aztec-packages/pull/4420) ([158c8ce](https://github.com/noir-lang/noir/commit/158c8cec7f0dc698042e9512001dd2c9d6b40bcc)) + ## [0.40.0](https://github.com/noir-lang/noir/compare/v0.39.0...v0.40.0) (2024-02-12) diff --git a/noir/noir-repo/acvm-repo/acir/Cargo.toml b/noir/noir-repo/acvm-repo/acir/Cargo.toml index 7021333486f..be859d7d054 100644 --- a/noir/noir-repo/acvm-repo/acir/Cargo.toml +++ b/noir/noir-repo/acvm-repo/acir/Cargo.toml @@ -2,7 +2,7 @@ name = "acir" description = "ACIR is the IR that the VM processes, it is analogous to LLVM IR" # x-release-please-start-version -version = "0.40.0" +version = "0.41.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/noir-repo/acvm-repo/acir_field/Cargo.toml b/noir/noir-repo/acvm-repo/acir_field/Cargo.toml index 6f4971770bd..c2056b73277 100644 --- a/noir/noir-repo/acvm-repo/acir_field/Cargo.toml +++ b/noir/noir-repo/acvm-repo/acir_field/Cargo.toml @@ -2,7 +2,7 @@ name = "acir_field" description = "The field implementation being used by ACIR." # x-release-please-start-version -version = "0.40.0" +version = "0.41.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/noir-repo/acvm-repo/acvm/Cargo.toml b/noir/noir-repo/acvm-repo/acvm/Cargo.toml index fce9a8e8e8b..d585850170a 100644 --- a/noir/noir-repo/acvm-repo/acvm/Cargo.toml +++ b/noir/noir-repo/acvm-repo/acvm/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm" description = "The virtual machine that processes ACIR given a backend/proof system." # x-release-please-start-version -version = "0.40.0" +version = "0.41.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/noir-repo/acvm-repo/acvm_js/Cargo.toml b/noir/noir-repo/acvm-repo/acvm_js/Cargo.toml index 7ec814a72e5..63fca2bd32a 100644 --- a/noir/noir-repo/acvm-repo/acvm_js/Cargo.toml +++ b/noir/noir-repo/acvm-repo/acvm_js/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm_js" description = "Typescript wrapper around the ACVM allowing execution of ACIR code" # x-release-please-start-version -version = "0.40.0" +version = "0.41.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/noir-repo/acvm-repo/acvm_js/package.json b/noir/noir-repo/acvm-repo/acvm_js/package.json index 876db9ccb62..0a9cd7235f5 100644 --- a/noir/noir-repo/acvm-repo/acvm_js/package.json +++ b/noir/noir-repo/acvm-repo/acvm_js/package.json @@ -1,6 +1,6 @@ { "name": "@noir-lang/acvm_js", - "version": "0.40.0", + "version": "0.41.0", "publishConfig": { "access": "public" }, diff --git a/noir/noir-repo/acvm-repo/blackbox_solver/Cargo.toml b/noir/noir-repo/acvm-repo/blackbox_solver/Cargo.toml index 0794b2dbe7e..a783193edba 100644 --- a/noir/noir-repo/acvm-repo/blackbox_solver/Cargo.toml +++ b/noir/noir-repo/acvm-repo/blackbox_solver/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm_blackbox_solver" description = "A solver for the blackbox functions found in ACIR and Brillig" # x-release-please-start-version -version = "0.40.0" +version = "0.41.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/noir-repo/acvm-repo/blackbox_solver/src/ecdsa/mod.rs b/noir/noir-repo/acvm-repo/blackbox_solver/src/ecdsa/mod.rs new file mode 100644 index 00000000000..cb3134bf0ab --- /dev/null +++ b/noir/noir-repo/acvm-repo/blackbox_solver/src/ecdsa/mod.rs @@ -0,0 +1,22 @@ +use crate::BlackBoxResolutionError; + +mod secp256k1; +mod secp256r1; + +pub fn ecdsa_secp256k1_verify( + hashed_msg: &[u8], + public_key_x: &[u8; 32], + public_key_y: &[u8; 32], + signature: &[u8; 64], +) -> Result { + Ok(secp256k1::verify_signature(hashed_msg, public_key_x, public_key_y, signature)) +} + +pub fn ecdsa_secp256r1_verify( + hashed_msg: &[u8], + public_key_x: &[u8; 32], + public_key_y: &[u8; 32], + signature: &[u8; 64], +) -> Result { + Ok(secp256r1::verify_signature(hashed_msg, public_key_x, public_key_y, signature)) +} diff --git a/noir/noir-repo/acvm-repo/blackbox_solver/src/ecdsa/secp256k1.rs b/noir/noir-repo/acvm-repo/blackbox_solver/src/ecdsa/secp256k1.rs new file mode 100644 index 00000000000..17c51353f7f --- /dev/null +++ b/noir/noir-repo/acvm-repo/blackbox_solver/src/ecdsa/secp256k1.rs @@ -0,0 +1,137 @@ +use k256::elliptic_curve::sec1::FromEncodedPoint; +use k256::elliptic_curve::PrimeField; + +use blake2::digest::generic_array::GenericArray; +use k256::{ecdsa::Signature, Scalar}; +use k256::{ + elliptic_curve::{ + sec1::{Coordinates, ToEncodedPoint}, + IsHigh, + }, + AffinePoint, EncodedPoint, ProjectivePoint, PublicKey, +}; + +pub(super) fn verify_signature( + hashed_msg: &[u8], + public_key_x_bytes: &[u8; 32], + public_key_y_bytes: &[u8; 32], + signature: &[u8; 64], +) -> bool { + // Convert the inputs into k256 data structures + let Ok(signature) = Signature::try_from(signature.as_slice()) else { + // Signature `r` and `s` are forbidden from being zero. + return false; + }; + + let point = EncodedPoint::from_affine_coordinates( + public_key_x_bytes.into(), + public_key_y_bytes.into(), + true, + ); + + let pubkey = PublicKey::from_encoded_point(&point); + let pubkey = if pubkey.is_some().into() { + pubkey.unwrap() + } else { + // Public key must sit on the Secp256k1 curve. + return false; + }; + + // Note: This is incorrect as it will panic if `hashed_msg >= k256::Secp256k1::ORDER`. + // In this scenario we should just take the leftmost bits from `hashed_msg` up to the group order length. + let z = Scalar::from_repr(*GenericArray::from_slice(hashed_msg)).unwrap(); + + // Finished converting bytes into data structures + + let r = signature.r(); + let s = signature.s(); + + // Ensure signature is "low S" normalized ala BIP 0062 + if s.is_high().into() { + return false; + } + + let s_inv = s.invert().unwrap(); + let u1 = z * s_inv; + let u2 = *r * s_inv; + + #[allow(non_snake_case)] + let R: AffinePoint = ((ProjectivePoint::GENERATOR * u1) + + (ProjectivePoint::from(*pubkey.as_affine()) * u2)) + .to_affine(); + + match R.to_encoded_point(false).coordinates() { + Coordinates::Uncompressed { x, y: _ } => Scalar::from_repr(*x).unwrap().eq(&r), + _ => unreachable!("Point is uncompressed"), + } +} + +#[cfg(test)] +mod secp256k1_tests { + use super::verify_signature; + + // 0x3a73f4123a5cd2121f21cd7e8d358835476949d035d9c2da6806b4633ac8c1e2, + const HASHED_MESSAGE: [u8; 32] = [ + 0x3a, 0x73, 0xf4, 0x12, 0x3a, 0x5c, 0xd2, 0x12, 0x1f, 0x21, 0xcd, 0x7e, 0x8d, 0x35, 0x88, + 0x35, 0x47, 0x69, 0x49, 0xd0, 0x35, 0xd9, 0xc2, 0xda, 0x68, 0x06, 0xb4, 0x63, 0x3a, 0xc8, + 0xc1, 0xe2, + ]; + // 0xa0434d9e47f3c86235477c7b1ae6ae5d3442d49b1943c2b752a68e2a47e247c7 + const PUB_KEY_X: [u8; 32] = [ + 0xa0, 0x43, 0x4d, 0x9e, 0x47, 0xf3, 0xc8, 0x62, 0x35, 0x47, 0x7c, 0x7b, 0x1a, 0xe6, 0xae, + 0x5d, 0x34, 0x42, 0xd4, 0x9b, 0x19, 0x43, 0xc2, 0xb7, 0x52, 0xa6, 0x8e, 0x2a, 0x47, 0xe2, + 0x47, 0xc7, + ]; + // 0x893aba425419bc27a3b6c7e693a24c696f794c2ed877a1593cbee53b037368d7 + const PUB_KEY_Y: [u8; 32] = [ + 0x89, 0x3a, 0xba, 0x42, 0x54, 0x19, 0xbc, 0x27, 0xa3, 0xb6, 0xc7, 0xe6, 0x93, 0xa2, 0x4c, + 0x69, 0x6f, 0x79, 0x4c, 0x2e, 0xd8, 0x77, 0xa1, 0x59, 0x3c, 0xbe, 0xe5, 0x3b, 0x03, 0x73, + 0x68, 0xd7, + ]; + // 0xe5081c80ab427dc370346f4a0e31aa2bad8d9798c38061db9ae55a4e8df454fd28119894344e71b78770cc931d61f480ecbb0b89d6eb69690161e49a715fcd55 + const SIGNATURE: [u8; 64] = [ + 0xe5, 0x08, 0x1c, 0x80, 0xab, 0x42, 0x7d, 0xc3, 0x70, 0x34, 0x6f, 0x4a, 0x0e, 0x31, 0xaa, + 0x2b, 0xad, 0x8d, 0x97, 0x98, 0xc3, 0x80, 0x61, 0xdb, 0x9a, 0xe5, 0x5a, 0x4e, 0x8d, 0xf4, + 0x54, 0xfd, 0x28, 0x11, 0x98, 0x94, 0x34, 0x4e, 0x71, 0xb7, 0x87, 0x70, 0xcc, 0x93, 0x1d, + 0x61, 0xf4, 0x80, 0xec, 0xbb, 0x0b, 0x89, 0xd6, 0xeb, 0x69, 0x69, 0x01, 0x61, 0xe4, 0x9a, + 0x71, 0x5f, 0xcd, 0x55, + ]; + + #[test] + fn verifies_valid_signature_with_low_s_value() { + let valid = verify_signature(&HASHED_MESSAGE, &PUB_KEY_X, &PUB_KEY_Y, &SIGNATURE); + + assert!(valid); + } + + #[test] + fn rejects_invalid_signature() { + // This signature is invalid as ECDSA specifies that `r` and `s` must be non-zero. + let invalid_signature: [u8; 64] = [0x00; 64]; + + let valid = verify_signature(&HASHED_MESSAGE, &PUB_KEY_X, &PUB_KEY_Y, &invalid_signature); + assert!(!valid); + } + + #[test] + fn rejects_invalid_public_key() { + let invalid_pub_key_x: [u8; 32] = [0xff; 32]; + let invalid_pub_key_y: [u8; 32] = [0xff; 32]; + + let valid = + verify_signature(&HASHED_MESSAGE, &invalid_pub_key_x, &invalid_pub_key_y, &SIGNATURE); + + assert!(!valid); + } + + #[test] + #[ignore = "ECDSA verification does not currently handle long hashes correctly"] + fn trims_overly_long_hashes_to_correct_length() { + let mut long_hashed_message = HASHED_MESSAGE.to_vec(); + long_hashed_message.push(0xff); + + let valid = verify_signature(&long_hashed_message, &PUB_KEY_X, &PUB_KEY_Y, &SIGNATURE); + + assert!(valid); + } +} diff --git a/noir/noir-repo/acvm-repo/blackbox_solver/src/ecdsa/secp256r1.rs b/noir/noir-repo/acvm-repo/blackbox_solver/src/ecdsa/secp256r1.rs new file mode 100644 index 00000000000..54559d7c774 --- /dev/null +++ b/noir/noir-repo/acvm-repo/blackbox_solver/src/ecdsa/secp256r1.rs @@ -0,0 +1,133 @@ +use p256::elliptic_curve::sec1::FromEncodedPoint; +use p256::elliptic_curve::PrimeField; + +use blake2::digest::generic_array::GenericArray; +use p256::{ecdsa::Signature, Scalar}; +use p256::{ + elliptic_curve::{ + sec1::{Coordinates, ToEncodedPoint}, + IsHigh, + }, + AffinePoint, EncodedPoint, ProjectivePoint, PublicKey, +}; + +pub(super) fn verify_signature( + hashed_msg: &[u8], + public_key_x_bytes: &[u8; 32], + public_key_y_bytes: &[u8; 32], + signature: &[u8; 64], +) -> bool { + // Convert the inputs into k256 data structures + let Ok(signature) = Signature::try_from(signature.as_slice()) else { + // Signature `r` and `s` are forbidden from being zero. + return false; + }; + + let point = EncodedPoint::from_affine_coordinates( + public_key_x_bytes.into(), + public_key_y_bytes.into(), + true, + ); + + let pubkey = PublicKey::from_encoded_point(&point); + let pubkey = if pubkey.is_some().into() { + pubkey.unwrap() + } else { + // Public key must sit on the Secp256r1 curve. + return false; + }; + + // Note: This is incorrect as it will panic if `hashed_msg >= p256::NistP256::ORDER`. + // In this scenario we should just take the leftmost bits from `hashed_msg` up to the group order length. + let z = Scalar::from_repr(*GenericArray::from_slice(hashed_msg)).unwrap(); + + // Finished converting bytes into data structures + + let r = signature.r(); + let s = signature.s(); + + // Ensure signature is "low S" normalized ala BIP 0062 + if s.is_high().into() { + return false; + } + + let s_inv = s.invert().unwrap(); + let u1 = z * s_inv; + let u2 = *r * s_inv; + + #[allow(non_snake_case)] + let R: AffinePoint = ((ProjectivePoint::GENERATOR * u1) + + (ProjectivePoint::from(*pubkey.as_affine()) * u2)) + .to_affine(); + + match R.to_encoded_point(false).coordinates() { + Coordinates::Uncompressed { x, y: _ } => Scalar::from_repr(*x).unwrap().eq(&r), + _ => unreachable!("Point is uncompressed"), + } +} + +#[cfg(test)] +mod secp256r1_tests { + use super::verify_signature; + + // 0x54705ba3baafdbdfba8c5f9a70f7a89bee98d906b53e31074da7baecdc0da9ad + const HASHED_MESSAGE: [u8; 32] = [ + 84, 112, 91, 163, 186, 175, 219, 223, 186, 140, 95, 154, 112, 247, 168, 155, 238, 152, 217, + 6, 181, 62, 49, 7, 77, 167, 186, 236, 220, 13, 169, 173, + ]; + // 0x550f471003f3df97c3df506ac797f6721fb1a1fb7b8f6f83d224498a65c88e24 + const PUB_KEY_X: [u8; 32] = [ + 85, 15, 71, 16, 3, 243, 223, 151, 195, 223, 80, 106, 199, 151, 246, 114, 31, 177, 161, 251, + 123, 143, 111, 131, 210, 36, 73, 138, 101, 200, 142, 36, + ]; + // 0x136093d7012e509a73715cbd0b00a3cc0ff4b5c01b3ffa196ab1fb327036b8e6 + const PUB_KEY_Y: [u8; 32] = [ + 19, 96, 147, 215, 1, 46, 80, 154, 115, 113, 92, 189, 11, 0, 163, 204, 15, 244, 181, 192, + 27, 63, 250, 25, 106, 177, 251, 50, 112, 54, 184, 230, + ]; + // 0x2c70a8d084b62bfc5ce03641caf9f72ad4da8c81bfe6ec9487bb5e1bef62a13218ad9ee29eaf351fdc50f1520c425e9b908a07278b43b0ec7b872778c14e0784 + const SIGNATURE: [u8; 64] = [ + 44, 112, 168, 208, 132, 182, 43, 252, 92, 224, 54, 65, 202, 249, 247, 42, 212, 218, 140, + 129, 191, 230, 236, 148, 135, 187, 94, 27, 239, 98, 161, 50, 24, 173, 158, 226, 158, 175, + 53, 31, 220, 80, 241, 82, 12, 66, 94, 155, 144, 138, 7, 39, 139, 67, 176, 236, 123, 135, + 39, 120, 193, 78, 7, 132, + ]; + + #[test] + fn verifies_valid_signature_with_low_s_value() { + let valid = verify_signature(&HASHED_MESSAGE, &PUB_KEY_X, &PUB_KEY_Y, &SIGNATURE); + + assert!(valid); + } + + #[test] + fn rejects_invalid_signature() { + // This signature is invalid as ECDSA specifies that `r` and `s` must be non-zero. + let invalid_signature: [u8; 64] = [0x00; 64]; + + let valid = verify_signature(&HASHED_MESSAGE, &PUB_KEY_X, &PUB_KEY_Y, &invalid_signature); + assert!(!valid); + } + + #[test] + fn rejects_invalid_public_key() { + let invalid_pub_key_x: [u8; 32] = [0xff; 32]; + let invalid_pub_key_y: [u8; 32] = [0xff; 32]; + + let valid = + verify_signature(&HASHED_MESSAGE, &invalid_pub_key_x, &invalid_pub_key_y, &SIGNATURE); + + assert!(!valid); + } + + #[test] + #[ignore = "ECDSA verification does not currently handle long hashes correctly"] + fn trims_overly_long_hashes_to_correct_length() { + let mut long_hashed_message = HASHED_MESSAGE.to_vec(); + long_hashed_message.push(0xff); + + let valid = verify_signature(&long_hashed_message, &PUB_KEY_X, &PUB_KEY_Y, &SIGNATURE); + + assert!(valid); + } +} diff --git a/noir/noir-repo/acvm-repo/blackbox_solver/src/hash.rs b/noir/noir-repo/acvm-repo/blackbox_solver/src/hash.rs new file mode 100644 index 00000000000..ac56029b436 --- /dev/null +++ b/noir/noir-repo/acvm-repo/blackbox_solver/src/hash.rs @@ -0,0 +1,126 @@ +use acir::BlackBoxFunc; +use blake2::digest::generic_array::GenericArray; +use blake2::{Blake2s256, Digest}; +use sha2::Sha256; +use sha3::Keccak256; + +use crate::BlackBoxResolutionError; + +/// Does a generic hash of the inputs returning the resulting 32 bytes separately. +fn generic_hash_256(message: &[u8]) -> Result<[u8; 32], String> { + let output_bytes: [u8; 32] = + D::digest(message).as_slice().try_into().map_err(|_| "digest should be 256 bits")?; + + Ok(output_bytes) +} + +pub fn sha256(inputs: &[u8]) -> Result<[u8; 32], BlackBoxResolutionError> { + generic_hash_256::(inputs) + .map_err(|err| BlackBoxResolutionError::Failed(BlackBoxFunc::SHA256, err)) +} + +pub fn blake2s(inputs: &[u8]) -> Result<[u8; 32], BlackBoxResolutionError> { + generic_hash_256::(inputs) + .map_err(|err| BlackBoxResolutionError::Failed(BlackBoxFunc::Blake2s, err)) +} + +pub fn blake3(inputs: &[u8]) -> Result<[u8; 32], BlackBoxResolutionError> { + Ok(blake3::hash(inputs).into()) +} + +pub fn keccak256(inputs: &[u8]) -> Result<[u8; 32], BlackBoxResolutionError> { + generic_hash_256::(inputs) + .map_err(|err| BlackBoxResolutionError::Failed(BlackBoxFunc::Keccak256, err)) +} + +pub fn sha256compression(state: &mut [u32; 8], msg_blocks: &[u32; 16]) { + let mut blocks = [0_u8; 64]; + for (i, block) in msg_blocks.iter().enumerate() { + let bytes = block.to_be_bytes(); + blocks[i * 4..i * 4 + 4].copy_from_slice(&bytes); + } + let blocks: GenericArray = blocks.into(); + sha2::compress256(state, &[blocks]); +} + +const KECCAK_LANES: usize = 25; + +pub fn keccakf1600( + mut state: [u64; KECCAK_LANES], +) -> Result<[u64; KECCAK_LANES], BlackBoxResolutionError> { + keccak::f1600(&mut state); + Ok(state) +} + +#[cfg(test)] +mod keccakf1600_tests { + use super::keccakf1600; + + #[test] + fn sanity_check() { + // Test vectors are copied from XKCP (eXtended Keccak Code Package) + // https://github.com/XKCP/XKCP/blob/master/tests/TestVectors/KeccakF-1600-IntermediateValues.txt + let zero_state = [0u64; 25]; + + let expected_state_first = [ + 0xF1258F7940E1DDE7, + 0x84D5CCF933C0478A, + 0xD598261EA65AA9EE, + 0xBD1547306F80494D, + 0x8B284E056253D057, + 0xFF97A42D7F8E6FD4, + 0x90FEE5A0A44647C4, + 0x8C5BDA0CD6192E76, + 0xAD30A6F71B19059C, + 0x30935AB7D08FFC64, + 0xEB5AA93F2317D635, + 0xA9A6E6260D712103, + 0x81A57C16DBCF555F, + 0x43B831CD0347C826, + 0x01F22F1A11A5569F, + 0x05E5635A21D9AE61, + 0x64BEFEF28CC970F2, + 0x613670957BC46611, + 0xB87C5A554FD00ECB, + 0x8C3EE88A1CCF32C8, + 0x940C7922AE3A2614, + 0x1841F924A2C509E4, + 0x16F53526E70465C2, + 0x75F644E97F30A13B, + 0xEAF1FF7B5CECA249, + ]; + let expected_state_second = [ + 0x2D5C954DF96ECB3C, + 0x6A332CD07057B56D, + 0x093D8D1270D76B6C, + 0x8A20D9B25569D094, + 0x4F9C4F99E5E7F156, + 0xF957B9A2DA65FB38, + 0x85773DAE1275AF0D, + 0xFAF4F247C3D810F7, + 0x1F1B9EE6F79A8759, + 0xE4FECC0FEE98B425, + 0x68CE61B6B9CE68A1, + 0xDEEA66C4BA8F974F, + 0x33C43D836EAFB1F5, + 0xE00654042719DBD9, + 0x7CF8A9F009831265, + 0xFD5449A6BF174743, + 0x97DDAD33D8994B40, + 0x48EAD5FC5D0BE774, + 0xE3B8C8EE55B7B03C, + 0x91A0226E649E42E9, + 0x900E3129E7BADD7B, + 0x202A9EC5FAA3CCE8, + 0x5B3402464E1C3DB6, + 0x609F4E62A44C1059, + 0x20D06CD26A8FBF5C, + ]; + + let state_first = keccakf1600(zero_state).unwrap(); + let state_second = keccakf1600(state_first).unwrap(); + + assert_eq!(state_first, expected_state_first); + assert_eq!(state_second, expected_state_second); + } +} diff --git a/noir/noir-repo/acvm-repo/blackbox_solver/src/lib.rs b/noir/noir-repo/acvm-repo/blackbox_solver/src/lib.rs index e033344fefa..dc798bdab32 100644 --- a/noir/noir-repo/acvm-repo/blackbox_solver/src/lib.rs +++ b/noir/noir-repo/acvm-repo/blackbox_solver/src/lib.rs @@ -8,456 +8,18 @@ //! For functions that have a reference implementation, such as [keccak256], this crate exports the reference implementation directly. use acir::BlackBoxFunc; -use blake2::digest::generic_array::GenericArray; -use blake2::{Blake2s256, Digest}; -use sha2::Sha256; -use sha3::Keccak256; use thiserror::Error; mod curve_specific_solver; +mod ecdsa; +mod hash; pub use curve_specific_solver::{BlackBoxFunctionSolver, StubbedBlackBoxSolver}; +pub use ecdsa::{ecdsa_secp256k1_verify, ecdsa_secp256r1_verify}; +pub use hash::{blake2s, blake3, keccak256, keccakf1600, sha256, sha256compression}; #[derive(Clone, PartialEq, Eq, Debug, Error)] pub enum BlackBoxResolutionError { #[error("failed to solve blackbox function: {0}, reason: {1}")] Failed(BlackBoxFunc, String), } - -pub fn sha256(inputs: &[u8]) -> Result<[u8; 32], BlackBoxResolutionError> { - generic_hash_256::(inputs) - .map_err(|err| BlackBoxResolutionError::Failed(BlackBoxFunc::SHA256, err)) -} - -pub fn blake2s(inputs: &[u8]) -> Result<[u8; 32], BlackBoxResolutionError> { - generic_hash_256::(inputs) - .map_err(|err| BlackBoxResolutionError::Failed(BlackBoxFunc::Blake2s, err)) -} - -pub fn blake3(inputs: &[u8]) -> Result<[u8; 32], BlackBoxResolutionError> { - Ok(blake3::hash(inputs).into()) -} - -pub fn keccak256(inputs: &[u8]) -> Result<[u8; 32], BlackBoxResolutionError> { - generic_hash_256::(inputs) - .map_err(|err| BlackBoxResolutionError::Failed(BlackBoxFunc::Keccak256, err)) -} - -pub fn sha256compression(state: &mut [u32; 8], msg_blocks: &[u32; 16]) { - let mut blocks = [0_u8; 64]; - for (i, block) in msg_blocks.iter().enumerate() { - let bytes = block.to_be_bytes(); - blocks[i * 4..i * 4 + 4].copy_from_slice(&bytes); - } - let blocks: GenericArray = blocks.into(); - sha2::compress256(state, &[blocks]); -} - -const KECCAK_LANES: usize = 25; - -pub fn keccakf1600( - mut state: [u64; KECCAK_LANES], -) -> Result<[u64; KECCAK_LANES], BlackBoxResolutionError> { - keccak::f1600(&mut state); - Ok(state) -} - -pub fn ecdsa_secp256k1_verify( - hashed_msg: &[u8], - public_key_x: &[u8; 32], - public_key_y: &[u8; 32], - signature: &[u8; 64], -) -> Result { - Ok(verify_secp256k1_ecdsa_signature(hashed_msg, public_key_x, public_key_y, signature)) -} - -pub fn ecdsa_secp256r1_verify( - hashed_msg: &[u8], - public_key_x: &[u8; 32], - public_key_y: &[u8; 32], - signature: &[u8; 64], -) -> Result { - Ok(verify_secp256r1_ecdsa_signature(hashed_msg, public_key_x, public_key_y, signature)) -} - -/// Does a generic hash of the inputs returning the resulting 32 bytes separately. -fn generic_hash_256(message: &[u8]) -> Result<[u8; 32], String> { - let output_bytes: [u8; 32] = - D::digest(message).as_slice().try_into().map_err(|_| "digest should be 256 bits")?; - - Ok(output_bytes) -} - -fn verify_secp256k1_ecdsa_signature( - hashed_msg: &[u8], - public_key_x_bytes: &[u8; 32], - public_key_y_bytes: &[u8; 32], - signature: &[u8; 64], -) -> bool { - use k256::elliptic_curve::sec1::FromEncodedPoint; - use k256::elliptic_curve::PrimeField; - - use k256::{ecdsa::Signature, Scalar}; - use k256::{ - elliptic_curve::{ - sec1::{Coordinates, ToEncodedPoint}, - IsHigh, - }, - AffinePoint, EncodedPoint, ProjectivePoint, PublicKey, - }; - // Convert the inputs into k256 data structures - - let Ok(signature) = Signature::try_from(signature.as_slice()) else { - // Signature `r` and `s` are forbidden from being zero. - return false; - }; - - let point = EncodedPoint::from_affine_coordinates( - public_key_x_bytes.into(), - public_key_y_bytes.into(), - true, - ); - - let pubkey = PublicKey::from_encoded_point(&point); - let pubkey = if pubkey.is_some().into() { - pubkey.unwrap() - } else { - // Public key must sit on the Secp256k1 curve. - return false; - }; - - // Note: This is incorrect as it will panic if `hashed_msg >= k256::Secp256k1::ORDER`. - // In this scenario we should just take the leftmost bits from `hashed_msg` up to the group order length. - let z = Scalar::from_repr(*GenericArray::from_slice(hashed_msg)).unwrap(); - - // Finished converting bytes into data structures - - let r = signature.r(); - let s = signature.s(); - - // Ensure signature is "low S" normalized ala BIP 0062 - if s.is_high().into() { - return false; - } - - let s_inv = s.invert().unwrap(); - let u1 = z * s_inv; - let u2 = *r * s_inv; - - #[allow(non_snake_case)] - let R: AffinePoint = ((ProjectivePoint::GENERATOR * u1) - + (ProjectivePoint::from(*pubkey.as_affine()) * u2)) - .to_affine(); - - match R.to_encoded_point(false).coordinates() { - Coordinates::Uncompressed { x, y: _ } => Scalar::from_repr(*x).unwrap().eq(&r), - _ => unreachable!("Point is uncompressed"), - } -} - -fn verify_secp256r1_ecdsa_signature( - hashed_msg: &[u8], - public_key_x_bytes: &[u8; 32], - public_key_y_bytes: &[u8; 32], - signature: &[u8; 64], -) -> bool { - use p256::elliptic_curve::sec1::FromEncodedPoint; - use p256::elliptic_curve::PrimeField; - - use p256::{ecdsa::Signature, Scalar}; - use p256::{ - elliptic_curve::{ - sec1::{Coordinates, ToEncodedPoint}, - IsHigh, - }, - AffinePoint, EncodedPoint, ProjectivePoint, PublicKey, - }; - - // Convert the inputs into k256 data structures - - let Ok(signature) = Signature::try_from(signature.as_slice()) else { - // Signature `r` and `s` are forbidden from being zero. - return false; - }; - - let point = EncodedPoint::from_affine_coordinates( - public_key_x_bytes.into(), - public_key_y_bytes.into(), - true, - ); - - let pubkey = PublicKey::from_encoded_point(&point); - let pubkey = if pubkey.is_some().into() { - pubkey.unwrap() - } else { - // Public key must sit on the Secp256r1 curve. - return false; - }; - - // Note: This is incorrect as it will panic if `hashed_msg >= p256::NistP256::ORDER`. - // In this scenario we should just take the leftmost bits from `hashed_msg` up to the group order length. - let z = Scalar::from_repr(*GenericArray::from_slice(hashed_msg)).unwrap(); - - // Finished converting bytes into data structures - - let r = signature.r(); - let s = signature.s(); - - // Ensure signature is "low S" normalized ala BIP 0062 - if s.is_high().into() { - return false; - } - - let s_inv = s.invert().unwrap(); - let u1 = z * s_inv; - let u2 = *r * s_inv; - - #[allow(non_snake_case)] - let R: AffinePoint = ((ProjectivePoint::GENERATOR * u1) - + (ProjectivePoint::from(*pubkey.as_affine()) * u2)) - .to_affine(); - - match R.to_encoded_point(false).coordinates() { - Coordinates::Uncompressed { x, y: _ } => Scalar::from_repr(*x).unwrap().eq(&r), - _ => unreachable!("Point is uncompressed"), - } -} - -#[cfg(test)] -mod keccakf1600_tests { - use crate::keccakf1600; - - #[test] - fn sanity_check() { - // Test vectors are copied from XKCP (eXtended Keccak Code Package) - // https://github.com/XKCP/XKCP/blob/master/tests/TestVectors/KeccakF-1600-IntermediateValues.txt - let zero_state = [0u64; 25]; - - let expected_state_first = [ - 0xF1258F7940E1DDE7, - 0x84D5CCF933C0478A, - 0xD598261EA65AA9EE, - 0xBD1547306F80494D, - 0x8B284E056253D057, - 0xFF97A42D7F8E6FD4, - 0x90FEE5A0A44647C4, - 0x8C5BDA0CD6192E76, - 0xAD30A6F71B19059C, - 0x30935AB7D08FFC64, - 0xEB5AA93F2317D635, - 0xA9A6E6260D712103, - 0x81A57C16DBCF555F, - 0x43B831CD0347C826, - 0x01F22F1A11A5569F, - 0x05E5635A21D9AE61, - 0x64BEFEF28CC970F2, - 0x613670957BC46611, - 0xB87C5A554FD00ECB, - 0x8C3EE88A1CCF32C8, - 0x940C7922AE3A2614, - 0x1841F924A2C509E4, - 0x16F53526E70465C2, - 0x75F644E97F30A13B, - 0xEAF1FF7B5CECA249, - ]; - let expected_state_second = [ - 0x2D5C954DF96ECB3C, - 0x6A332CD07057B56D, - 0x093D8D1270D76B6C, - 0x8A20D9B25569D094, - 0x4F9C4F99E5E7F156, - 0xF957B9A2DA65FB38, - 0x85773DAE1275AF0D, - 0xFAF4F247C3D810F7, - 0x1F1B9EE6F79A8759, - 0xE4FECC0FEE98B425, - 0x68CE61B6B9CE68A1, - 0xDEEA66C4BA8F974F, - 0x33C43D836EAFB1F5, - 0xE00654042719DBD9, - 0x7CF8A9F009831265, - 0xFD5449A6BF174743, - 0x97DDAD33D8994B40, - 0x48EAD5FC5D0BE774, - 0xE3B8C8EE55B7B03C, - 0x91A0226E649E42E9, - 0x900E3129E7BADD7B, - 0x202A9EC5FAA3CCE8, - 0x5B3402464E1C3DB6, - 0x609F4E62A44C1059, - 0x20D06CD26A8FBF5C, - ]; - - let state_first = keccakf1600(zero_state).unwrap(); - let state_second = keccakf1600(state_first).unwrap(); - - assert_eq!(state_first, expected_state_first); - assert_eq!(state_second, expected_state_second); - } -} - -#[cfg(test)] -mod secp256k1_tests { - use super::verify_secp256k1_ecdsa_signature; - - // 0x3a73f4123a5cd2121f21cd7e8d358835476949d035d9c2da6806b4633ac8c1e2, - const HASHED_MESSAGE: [u8; 32] = [ - 0x3a, 0x73, 0xf4, 0x12, 0x3a, 0x5c, 0xd2, 0x12, 0x1f, 0x21, 0xcd, 0x7e, 0x8d, 0x35, 0x88, - 0x35, 0x47, 0x69, 0x49, 0xd0, 0x35, 0xd9, 0xc2, 0xda, 0x68, 0x06, 0xb4, 0x63, 0x3a, 0xc8, - 0xc1, 0xe2, - ]; - // 0xa0434d9e47f3c86235477c7b1ae6ae5d3442d49b1943c2b752a68e2a47e247c7 - const PUB_KEY_X: [u8; 32] = [ - 0xa0, 0x43, 0x4d, 0x9e, 0x47, 0xf3, 0xc8, 0x62, 0x35, 0x47, 0x7c, 0x7b, 0x1a, 0xe6, 0xae, - 0x5d, 0x34, 0x42, 0xd4, 0x9b, 0x19, 0x43, 0xc2, 0xb7, 0x52, 0xa6, 0x8e, 0x2a, 0x47, 0xe2, - 0x47, 0xc7, - ]; - // 0x893aba425419bc27a3b6c7e693a24c696f794c2ed877a1593cbee53b037368d7 - const PUB_KEY_Y: [u8; 32] = [ - 0x89, 0x3a, 0xba, 0x42, 0x54, 0x19, 0xbc, 0x27, 0xa3, 0xb6, 0xc7, 0xe6, 0x93, 0xa2, 0x4c, - 0x69, 0x6f, 0x79, 0x4c, 0x2e, 0xd8, 0x77, 0xa1, 0x59, 0x3c, 0xbe, 0xe5, 0x3b, 0x03, 0x73, - 0x68, 0xd7, - ]; - // 0xe5081c80ab427dc370346f4a0e31aa2bad8d9798c38061db9ae55a4e8df454fd28119894344e71b78770cc931d61f480ecbb0b89d6eb69690161e49a715fcd55 - const SIGNATURE: [u8; 64] = [ - 0xe5, 0x08, 0x1c, 0x80, 0xab, 0x42, 0x7d, 0xc3, 0x70, 0x34, 0x6f, 0x4a, 0x0e, 0x31, 0xaa, - 0x2b, 0xad, 0x8d, 0x97, 0x98, 0xc3, 0x80, 0x61, 0xdb, 0x9a, 0xe5, 0x5a, 0x4e, 0x8d, 0xf4, - 0x54, 0xfd, 0x28, 0x11, 0x98, 0x94, 0x34, 0x4e, 0x71, 0xb7, 0x87, 0x70, 0xcc, 0x93, 0x1d, - 0x61, 0xf4, 0x80, 0xec, 0xbb, 0x0b, 0x89, 0xd6, 0xeb, 0x69, 0x69, 0x01, 0x61, 0xe4, 0x9a, - 0x71, 0x5f, 0xcd, 0x55, - ]; - - #[test] - fn verifies_valid_signature_with_low_s_value() { - let valid = - verify_secp256k1_ecdsa_signature(&HASHED_MESSAGE, &PUB_KEY_X, &PUB_KEY_Y, &SIGNATURE); - - assert!(valid); - } - - #[test] - fn rejects_invalid_signature() { - // This signature is invalid as ECDSA specifies that `r` and `s` must be non-zero. - let invalid_signature: [u8; 64] = [0x00; 64]; - - let valid = verify_secp256k1_ecdsa_signature( - &HASHED_MESSAGE, - &PUB_KEY_X, - &PUB_KEY_Y, - &invalid_signature, - ); - assert!(!valid); - } - - #[test] - fn rejects_invalid_public_key() { - let invalid_pub_key_x: [u8; 32] = [0xff; 32]; - let invalid_pub_key_y: [u8; 32] = [0xff; 32]; - - let valid = verify_secp256k1_ecdsa_signature( - &HASHED_MESSAGE, - &invalid_pub_key_x, - &invalid_pub_key_y, - &SIGNATURE, - ); - - assert!(!valid); - } - - #[test] - #[ignore = "ECDSA verification does not currently handle long hashes correctly"] - fn trims_overly_long_hashes_to_correct_length() { - let mut long_hashed_message = HASHED_MESSAGE.to_vec(); - long_hashed_message.push(0xff); - - let valid = verify_secp256k1_ecdsa_signature( - &long_hashed_message, - &PUB_KEY_X, - &PUB_KEY_Y, - &SIGNATURE, - ); - - assert!(valid); - } -} - -#[cfg(test)] -mod secp256r1_tests { - use super::verify_secp256r1_ecdsa_signature; - - // 0x54705ba3baafdbdfba8c5f9a70f7a89bee98d906b53e31074da7baecdc0da9ad - const HASHED_MESSAGE: [u8; 32] = [ - 84, 112, 91, 163, 186, 175, 219, 223, 186, 140, 95, 154, 112, 247, 168, 155, 238, 152, 217, - 6, 181, 62, 49, 7, 77, 167, 186, 236, 220, 13, 169, 173, - ]; - // 0x550f471003f3df97c3df506ac797f6721fb1a1fb7b8f6f83d224498a65c88e24 - const PUB_KEY_X: [u8; 32] = [ - 85, 15, 71, 16, 3, 243, 223, 151, 195, 223, 80, 106, 199, 151, 246, 114, 31, 177, 161, 251, - 123, 143, 111, 131, 210, 36, 73, 138, 101, 200, 142, 36, - ]; - // 0x136093d7012e509a73715cbd0b00a3cc0ff4b5c01b3ffa196ab1fb327036b8e6 - const PUB_KEY_Y: [u8; 32] = [ - 19, 96, 147, 215, 1, 46, 80, 154, 115, 113, 92, 189, 11, 0, 163, 204, 15, 244, 181, 192, - 27, 63, 250, 25, 106, 177, 251, 50, 112, 54, 184, 230, - ]; - // 0x2c70a8d084b62bfc5ce03641caf9f72ad4da8c81bfe6ec9487bb5e1bef62a13218ad9ee29eaf351fdc50f1520c425e9b908a07278b43b0ec7b872778c14e0784 - const SIGNATURE: [u8; 64] = [ - 44, 112, 168, 208, 132, 182, 43, 252, 92, 224, 54, 65, 202, 249, 247, 42, 212, 218, 140, - 129, 191, 230, 236, 148, 135, 187, 94, 27, 239, 98, 161, 50, 24, 173, 158, 226, 158, 175, - 53, 31, 220, 80, 241, 82, 12, 66, 94, 155, 144, 138, 7, 39, 139, 67, 176, 236, 123, 135, - 39, 120, 193, 78, 7, 132, - ]; - - #[test] - fn verifies_valid_signature_with_low_s_value() { - let valid = - verify_secp256r1_ecdsa_signature(&HASHED_MESSAGE, &PUB_KEY_X, &PUB_KEY_Y, &SIGNATURE); - - assert!(valid); - } - - #[test] - fn rejects_invalid_signature() { - // This signature is invalid as ECDSA specifies that `r` and `s` must be non-zero. - let invalid_signature: [u8; 64] = [0x00; 64]; - - let valid = verify_secp256r1_ecdsa_signature( - &HASHED_MESSAGE, - &PUB_KEY_X, - &PUB_KEY_Y, - &invalid_signature, - ); - assert!(!valid); - } - - #[test] - fn rejects_invalid_public_key() { - let invalid_pub_key_x: [u8; 32] = [0xff; 32]; - let invalid_pub_key_y: [u8; 32] = [0xff; 32]; - - let valid = verify_secp256r1_ecdsa_signature( - &HASHED_MESSAGE, - &invalid_pub_key_x, - &invalid_pub_key_y, - &SIGNATURE, - ); - - assert!(!valid); - } - - #[test] - #[ignore = "ECDSA verification does not currently handle long hashes correctly"] - fn trims_overly_long_hashes_to_correct_length() { - let mut long_hashed_message = HASHED_MESSAGE.to_vec(); - long_hashed_message.push(0xff); - - let valid = verify_secp256r1_ecdsa_signature( - &long_hashed_message, - &PUB_KEY_X, - &PUB_KEY_Y, - &SIGNATURE, - ); - - assert!(valid); - } -} diff --git a/noir/noir-repo/acvm-repo/bn254_blackbox_solver/Cargo.toml b/noir/noir-repo/acvm-repo/bn254_blackbox_solver/Cargo.toml index ea601a6b80f..a0a15409604 100644 --- a/noir/noir-repo/acvm-repo/bn254_blackbox_solver/Cargo.toml +++ b/noir/noir-repo/acvm-repo/bn254_blackbox_solver/Cargo.toml @@ -32,7 +32,7 @@ ark-ff = { version = "^0.4.0", default-features = false } num-bigint.workspace = true [target.'cfg(target_arch = "wasm32")'.dependencies] -wasmer = { version = "4.2.3", default-features = false, features = [ +wasmer = { version = "4.2.6", default-features = false, features = [ "js-default", ] } @@ -42,7 +42,7 @@ js-sys.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dependencies] getrandom.workspace = true -wasmer = "4.2.3" +wasmer = "4.2.6" [build-dependencies] pkg-config = "0.3" diff --git a/noir/noir-repo/acvm-repo/brillig/Cargo.toml b/noir/noir-repo/acvm-repo/brillig/Cargo.toml index 8d91d19e117..57f89e091b4 100644 --- a/noir/noir-repo/acvm-repo/brillig/Cargo.toml +++ b/noir/noir-repo/acvm-repo/brillig/Cargo.toml @@ -2,7 +2,7 @@ name = "brillig" description = "Brillig is the bytecode ACIR uses for non-determinism." # x-release-please-start-version -version = "0.40.0" +version = "0.41.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/noir-repo/acvm-repo/brillig_vm/Cargo.toml b/noir/noir-repo/acvm-repo/brillig_vm/Cargo.toml index 272e8389413..1c7add5cb40 100644 --- a/noir/noir-repo/acvm-repo/brillig_vm/Cargo.toml +++ b/noir/noir-repo/acvm-repo/brillig_vm/Cargo.toml @@ -2,7 +2,7 @@ name = "brillig_vm" description = "The virtual machine that processes Brillig bytecode, used to introduce non-determinism to the ACVM" # x-release-please-start-version -version = "0.40.0" +version = "0.41.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/noir-repo/aztec_macros/src/transforms/events.rs b/noir/noir-repo/aztec_macros/src/transforms/events.rs index f8e15f0205d..b02709efacb 100644 --- a/noir/noir-repo/aztec_macros/src/transforms/events.rs +++ b/noir/noir-repo/aztec_macros/src/transforms/events.rs @@ -8,8 +8,8 @@ use noirc_frontend::{ UnresolvedTypeData, }, token::SecondaryAttribute, - ExpressionKind, FunctionDefinition, FunctionReturnType, FunctionVisibility, Literal, - NoirFunction, Visibility, + ExpressionKind, FunctionDefinition, FunctionReturnType, ItemVisibility, Literal, NoirFunction, + Visibility, }; use crate::{ @@ -65,7 +65,7 @@ pub fn generate_selector_impl(structure: &NoirStruct) -> TypeImpl { &return_type, ); - selector_fn_def.visibility = FunctionVisibility::Public; + selector_fn_def.visibility = ItemVisibility::Public; // Seems to be necessary on contract modules selector_fn_def.return_visibility = Visibility::Public; diff --git a/noir/noir-repo/compiler/noirc_driver/Cargo.toml b/noir/noir-repo/compiler/noirc_driver/Cargo.toml index 681976735f3..a7fe0b4b610 100644 --- a/noir/noir-repo/compiler/noirc_driver/Cargo.toml +++ b/noir/noir-repo/compiler/noirc_driver/Cargo.toml @@ -26,4 +26,3 @@ tracing.workspace = true thiserror.workspace = true aztec_macros = { path = "../../aztec_macros" } -noirc_macros = { path = "../../noirc_macros" } diff --git a/noir/noir-repo/compiler/noirc_driver/src/lib.rs b/noir/noir-repo/compiler/noirc_driver/src/lib.rs index 346eb595389..c9494a64b41 100644 --- a/noir/noir-repo/compiler/noirc_driver/src/lib.rs +++ b/noir/noir-repo/compiler/noirc_driver/src/lib.rs @@ -238,17 +238,11 @@ pub fn check_crate( deny_warnings: bool, disable_macros: bool, ) -> CompilationResult<()> { - let macros: Vec<&dyn MacroProcessor> = if disable_macros { - vec![&noirc_macros::AssertMessageMacro as &dyn MacroProcessor] - } else { - vec![ - &aztec_macros::AztecMacro as &dyn MacroProcessor, - &noirc_macros::AssertMessageMacro as &dyn MacroProcessor, - ] - }; + let macros: &[&dyn MacroProcessor] = + if disable_macros { &[] } else { &[&aztec_macros::AztecMacro as &dyn MacroProcessor] }; let mut errors = vec![]; - let diagnostics = CrateDefMap::collect_defs(crate_id, context, ¯os); + let diagnostics = CrateDefMap::collect_defs(crate_id, context, macros); errors.extend(diagnostics.into_iter().map(|(error, file_id)| { let diagnostic: CustomDiagnostic = error.into(); diagnostic.in_file(file_id) diff --git a/noir/noir-repo/compiler/noirc_errors/src/debug_info.rs b/noir/noir-repo/compiler/noirc_errors/src/debug_info.rs index 67ec851d46d..09117bdc3b7 100644 --- a/noir/noir-repo/compiler/noirc_errors/src/debug_info.rs +++ b/noir/noir-repo/compiler/noirc_errors/src/debug_info.rs @@ -24,6 +24,9 @@ use serde::{ #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, PartialOrd, Ord, Deserialize, Serialize)] pub struct DebugVarId(pub u32); +#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, PartialOrd, Ord, Deserialize, Serialize)] +pub struct DebugFnId(pub u32); + #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, PartialOrd, Ord, Deserialize, Serialize)] pub struct DebugTypeId(pub u32); @@ -33,7 +36,14 @@ pub struct DebugVariable { pub debug_type_id: DebugTypeId, } +#[derive(Debug, Clone, Hash, Deserialize, Serialize)] +pub struct DebugFunction { + pub name: String, + pub arg_names: Vec, +} + pub type DebugVariables = BTreeMap; +pub type DebugFunctions = BTreeMap; pub type DebugTypes = BTreeMap; #[serde_as] @@ -45,6 +55,7 @@ pub struct DebugInfo { #[serde_as(as = "BTreeMap")] pub locations: BTreeMap>, pub variables: DebugVariables, + pub functions: DebugFunctions, pub types: DebugTypes, } @@ -60,9 +71,10 @@ impl DebugInfo { pub fn new( locations: BTreeMap>, variables: DebugVariables, + functions: DebugFunctions, types: DebugTypes, ) -> Self { - Self { locations, variables, types } + Self { locations, variables, functions, types } } /// Updates the locations map when the [`Circuit`][acvm::acir::circuit::Circuit] is modified. diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs index 0189a499d49..5b227372396 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs @@ -248,17 +248,6 @@ impl<'block> BrilligBlock<'block> { self.convert_ssa_binary(binary, dfg, result_var); } Instruction::Constrain(lhs, rhs, assert_message) => { - let condition = SingleAddrVariable { - address: self.brillig_context.allocate_register(), - bit_size: 1, - }; - - self.convert_ssa_binary( - &Binary { lhs: *lhs, rhs: *rhs, operator: BinaryOp::Eq }, - dfg, - condition, - ); - let assert_message = if let Some(error) = assert_message { match error.as_ref() { ConstrainError::Static(string) => Some(string.clone()), @@ -282,6 +271,17 @@ impl<'block> BrilligBlock<'block> { None }; + let condition = SingleAddrVariable { + address: self.brillig_context.allocate_register(), + bit_size: 1, + }; + + self.convert_ssa_binary( + &Binary { lhs: *lhs, rhs: *rhs, operator: BinaryOp::Eq }, + dfg, + condition, + ); + self.brillig_context.constrain_instruction(condition.address, assert_message); self.brillig_context.deallocate_register(condition.address); } diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa.rs index 0bb81efe977..56cb76adbe4 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa.rs @@ -88,6 +88,7 @@ pub fn create_circuit( ) -> Result<(Circuit, DebugInfo, Vec, Vec, Vec), RuntimeError> { let debug_variables = program.debug_variables.clone(); let debug_types = program.debug_types.clone(); + let debug_functions = program.debug_functions.clone(); let func_sig = program.main_function_signature.clone(); let recursive = program.recursive; let mut generated_acir = optimize_into_acir( @@ -130,7 +131,7 @@ pub fn create_circuit( .map(|(index, locations)| (index, locations.into_iter().collect())) .collect(); - let mut debug_info = DebugInfo::new(locations, debug_variables, debug_types); + let mut debug_info = DebugInfo::new(locations, debug_variables, debug_functions, debug_types); // Perform any ACIR-level optimizations let (optimized_circuit, transformation_map) = acvm::compiler::optimize(circuit); diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs index 8d4d0668534..140ed0b53ff 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs @@ -2268,11 +2268,9 @@ impl Context { // We can omit the element size array for arrays which don't contain arrays or slices. fn can_omit_element_sizes_array(array_typ: &Type) -> bool { - if array_typ.contains_slice_element() { - return false; - } - let Type::Array(types, _) = array_typ else { - panic!("ICE: expected array type"); + let types = match array_typ { + Type::Array(types, _) | Type::Slice(types) => types, + _ => panic!("ICE: expected array or slice type"), }; !types.iter().any(|typ| typ.contains_an_array()) diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs index 9d27554dcaa..bf34a47485b 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs @@ -393,10 +393,25 @@ impl FunctionBuilder { self.increment_array_reference_count(value); } } - Type::Array(..) | Type::Slice(..) => { - self.insert_instruction(Instruction::IncrementRc { value }, None); + typ @ Type::Array(..) | typ @ Type::Slice(..) => { // If there are nested arrays or slices, we wait until ArrayGet // is issued to increment the count of that array. + self.insert_instruction(Instruction::IncrementRc { value }, None); + + // This is a bit odd, but in brillig the inc_rc instruction operates on + // a copy of the array's metadata, so we need to re-store a loaded array + // even if there have been no other changes to it. + if let Value::Instruction { instruction, .. } = &self.current_function.dfg[value] { + let instruction = &self.current_function.dfg[*instruction]; + if let Instruction::Load { address } = instruction { + // We can't re-use `value` in case the original address was stored + // to again in the meantime. So introduce another load. + let address = *address; + let value = self.insert_load(address, typ); + self.insert_instruction(Instruction::IncrementRc { value }, None); + self.insert_store(address, value); + } + } } } } diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs index 943a57c1bc0..46f1e7a2765 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs @@ -199,22 +199,47 @@ struct Context<'f> { /// found, the top of this conditions stack is popped since we are no longer under that /// condition. If we are under multiple conditions (a nested if), the topmost condition is /// the most recent condition combined with all previous conditions via `And` instructions. - conditions: Vec<(BasicBlockId, ValueId)>, + condition_stack: Vec, /// Maps SSA array values with a slice type to their size. /// This is maintained by appropriate calls to the `SliceCapacityTracker` and is used by the `ValueMerger`. slice_sizes: HashMap, + + /// Stack of block arguments + /// When processing a block, we pop this stack to get its arguments + /// and at the end we push the arguments for his successor + arguments_stack: Vec>, } +#[derive(Clone)] pub(crate) struct Store { old_value: ValueId, new_value: ValueId, } -struct Branch { - condition: ValueId, +#[derive(Clone)] +struct ConditionalBranch { + // Contains the last processed block during the processing of the branch. last_block: BasicBlockId, + // The unresolved condition of the branch + old_condition: ValueId, + // The condition of the branch + condition: ValueId, + // The store values accumulated when processing the branch store_values: HashMap, + // The allocations accumulated when processing the branch + local_allocations: HashSet, +} + +struct ConditionalContext { + // Condition from the conditional statement + condition: ValueId, + // Block containing the conditional statement + entry_block: BasicBlockId, + // First block of the then branch + then_branch: ConditionalBranch, + // First block of the else branch + else_branch: Option, } fn flatten_function_cfg(function: &mut Function) { @@ -233,90 +258,117 @@ fn flatten_function_cfg(function: &mut Function) { store_values: HashMap::default(), local_allocations: HashSet::new(), branch_ends, - conditions: Vec::new(), slice_sizes: HashMap::default(), + condition_stack: Vec::new(), + arguments_stack: Vec::new(), }; context.flatten(); } impl<'f> Context<'f> { fn flatten(&mut self) { - // Start with following the terminator of the entry block since we don't - // need to flatten the entry block into itself. - self.handle_terminator(self.inserter.function.entry_block()); + // Flatten the CFG by inlining all instructions from the queued blocks + // until all blocks have been flattened. + // We follow the terminator of each block to determine which blocks to + // process next + let mut queue = vec![self.inserter.function.entry_block()]; + while let Some(block) = queue.pop() { + self.inline_block(block); + let to_process = self.handle_terminator(block, &queue); + for incoming_block in to_process { + if !queue.contains(&incoming_block) { + queue.push(incoming_block); + } + } + } } - /// Check the terminator of the given block and recursively inline any blocks reachable from - /// it. Since each block from a jmpif terminator is inlined successively, we must handle - /// instructions with side effects like constrain and store specially to preserve correctness. - /// For these instructions we must keep track of what the current condition is and modify - /// the instructions according to the module-level comment at the top of this file. Note that - /// the current condition is all the jmpif conditions required to reach the current block, - /// combined via `And` instructions. - /// - /// Returns the last block to be inlined. This is either the return block of the function or, - /// if self.conditions is not empty, the end block of the most recent condition. - fn handle_terminator(&mut self, block: BasicBlockId) -> BasicBlockId { - // As we recursively flatten inner blocks, we need to track the slice information - // for the outer block before we start recursively inlining - let outer_block_instructions = self.inserter.function.dfg[block].instructions(); - let mut capacity_tracker = SliceCapacityTracker::new(&self.inserter.function.dfg); - for instruction in outer_block_instructions { - let results = self.inserter.function.dfg.instruction_results(*instruction); - let instruction = &self.inserter.function.dfg[*instruction]; + /// Returns the updated condition so that + /// it is 'AND-ed' with the previous condition (if any) + fn link_condition(&mut self, condition: ValueId) -> ValueId { + // Retrieve the previous condition + if let Some(context) = self.condition_stack.last() { + let previous_branch = context.else_branch.as_ref().unwrap_or(&context.then_branch); + let and = Instruction::binary(BinaryOp::And, previous_branch.condition, condition); + self.insert_instruction(and, CallStack::new()) + } else { + condition + } + } + + /// Returns the current condition + fn get_last_condition(&self) -> Option { + self.condition_stack.last().map(|context| match &context.else_branch { + Some(else_branch) => else_branch.condition, + None => context.then_branch.condition, + }) + } + + // Inline all instructions from the given block into the entry block, and track slice capacities + fn inline_block(&mut self, block: BasicBlockId) { + if self.inserter.function.entry_block() == block { + // we do not inline the entry block into itself + // for the outer block before we start inlining + let outer_block_instructions = self.inserter.function.dfg[block].instructions(); + let mut capacity_tracker = SliceCapacityTracker::new(&self.inserter.function.dfg); + for instruction in outer_block_instructions { + let results = self.inserter.function.dfg.instruction_results(*instruction); + let instruction = &self.inserter.function.dfg[*instruction]; + capacity_tracker.collect_slice_information( + instruction, + &mut self.slice_sizes, + results.to_vec(), + ); + } + + return; + } + + let arguments = self.arguments_stack.pop().unwrap(); + self.inserter.remember_block_params(block, &arguments); + + // If this is not a separate variable, clippy gets confused and says the to_vec is + // unnecessary, when removing it actually causes an aliasing/mutability error. + let instructions = self.inserter.function.dfg[block].instructions().to_vec(); + for instruction in instructions.iter() { + let results = self.push_instruction(*instruction); + let (instruction, _) = self.inserter.map_instruction(*instruction); + let mut capacity_tracker = SliceCapacityTracker::new(&self.inserter.function.dfg); capacity_tracker.collect_slice_information( - instruction, + &instruction, &mut self.slice_sizes, - results.to_vec(), + results, ); } + } - match self.inserter.function.dfg[block].unwrap_terminator() { + /// Returns the list of blocks that need to be processed after the given block + /// For a normal block, it would be its successor + /// For blocks related to a conditional statement, we ensure to process + /// the 'then-branch', then the 'else-branch' (if it exists), and finally the end block + fn handle_terminator( + &mut self, + block: BasicBlockId, + work_list: &[BasicBlockId], + ) -> Vec { + let terminator = self.inserter.function.dfg[block].unwrap_terminator().clone(); + match &terminator { TerminatorInstruction::JmpIf { condition, then_destination, else_destination } => { - let old_condition = *condition; - let then_block = *then_destination; - let else_block = *else_destination; - let then_condition = self.inserter.resolve(old_condition); - - let one = FieldElement::one(); - let then_branch = - self.inline_branch(block, then_block, old_condition, then_condition, one); - - let else_condition = - self.insert_instruction(Instruction::Not(then_condition), CallStack::new()); - let zero = FieldElement::zero(); - - // Make sure the else branch sees the previous values of each store - // rather than any values created in the 'then' branch. - self.undo_stores_in_then_branch(&then_branch); - - let else_branch = - self.inline_branch(block, else_block, old_condition, else_condition, zero); - - // We must remember to reset whether side effects are enabled when both branches - // end, in addition to resetting the value of old_condition since it is set to - // known to be true/false within the then/else branch respectively. - self.insert_current_side_effects_enabled(); - - // We must map back to `then_condition` here. Mapping `old_condition` to itself would - // lose any previous mappings. - self.inserter.map_value(old_condition, then_condition); - - // While there is a condition on the stack we don't compile outside the condition - // until it is popped. This ensures we inline the full then and else branches - // before continuing from the end of the conditional here where they can be merged properly. - let end = self.branch_ends[&block]; - self.inline_branch_end(end, then_branch, else_branch) + self.arguments_stack.push(vec![]); + self.if_start(condition, then_destination, else_destination, &block) } TerminatorInstruction::Jmp { destination, arguments, call_stack: _ } => { - if let Some((end_block, _)) = self.conditions.last() { - if destination == end_block { - return block; + let arguments = vecmap(arguments.clone(), |value| self.inserter.resolve(value)); + self.arguments_stack.push(arguments); + if work_list.contains(destination) { + if work_list.last() == Some(destination) { + self.else_stop(&block) + } else { + self.then_stop(&block) } + } else { + vec![*destination] } - let destination = *destination; - let arguments = vecmap(arguments.clone(), |value| self.inserter.resolve(value)); - self.inline_block(destination, &arguments) } TerminatorInstruction::Return { return_values, call_stack } => { let call_stack = call_stack.clone(); @@ -326,133 +378,133 @@ impl<'f> Context<'f> { let entry = self.inserter.function.entry_block(); self.inserter.function.dfg.set_block_terminator(entry, new_return); - block + vec![] } } } - /// Push a condition to the stack of conditions. - /// - /// This condition should be present while we're inlining each block reachable from the 'then' - /// branch of a jmpif instruction, until the branches eventually join back together. Likewise, - /// !condition should be present while we're inlining each block reachable from the 'else' - /// branch of a jmpif instruction until the join block. - fn push_condition(&mut self, start_block: BasicBlockId, condition: ValueId) { - let end_block = self.branch_ends[&start_block]; - - if let Some((_, previous_condition)) = self.conditions.last() { - let and = Instruction::binary(BinaryOp::And, *previous_condition, condition); - let new_condition = self.insert_instruction(and, CallStack::new()); - self.conditions.push((end_block, new_condition)); - } else { - self.conditions.push((end_block, condition)); + /// Process a conditional statement + fn if_start( + &mut self, + condition: &ValueId, + then_destination: &BasicBlockId, + else_destination: &BasicBlockId, + if_entry: &BasicBlockId, + ) -> Vec { + // manage conditions + let old_condition = *condition; + let then_condition = self.inserter.resolve(old_condition); + + let one = FieldElement::one(); + let old_stores = std::mem::take(&mut self.store_values); + let old_allocations = std::mem::take(&mut self.local_allocations); + let branch = ConditionalBranch { + old_condition, + condition: self.link_condition(then_condition), + store_values: old_stores, + local_allocations: old_allocations, + last_block: *then_destination, + }; + let cond_context = ConditionalContext { + condition: then_condition, + entry_block: *if_entry, + then_branch: branch, + else_branch: None, + }; + self.condition_stack.push(cond_context); + self.insert_current_side_effects_enabled(); + // Optimization: within the then branch we know the condition to be true, so replace + // any references of it within this branch with true. Likewise, do the same with false + // with the else branch. We must be careful not to replace the condition if it is a + // known constant, otherwise we can end up setting 1 = 0 or vice-versa. + if self.inserter.function.dfg.get_numeric_constant(old_condition).is_none() { + let known_value = self.inserter.function.dfg.make_constant(one, Type::bool()); + + self.inserter.map_value(old_condition, known_value); } + vec![self.branch_ends[if_entry], *else_destination, *then_destination] } - /// Insert a new instruction into the function's entry block. - /// Unlike push_instruction, this function will not map any ValueIds. - /// within the given instruction, nor will it modify self.values in any way. - fn insert_instruction(&mut self, instruction: Instruction, call_stack: CallStack) -> ValueId { - let block = self.inserter.function.entry_block(); - self.inserter - .function - .dfg - .insert_instruction_and_results(instruction, block, None, call_stack) - .first() + /// Switch context to the 'else-branch' + fn then_stop(&mut self, block: &BasicBlockId) -> Vec { + let mut cond_context = self.condition_stack.pop().unwrap(); + cond_context.then_branch.last_block = *block; + + let else_condition = + self.insert_instruction(Instruction::Not(cond_context.condition), CallStack::new()); + let else_condition = self.link_condition(else_condition); + + let zero = FieldElement::zero(); + // Make sure the else branch sees the previous values of each store + // rather than any values created in the 'then' branch. + let old_stores = std::mem::take(&mut cond_context.then_branch.store_values); + cond_context.then_branch.store_values = std::mem::take(&mut self.store_values); + self.undo_stores_in_then_branch(&cond_context.then_branch.store_values); + + let old_allocations = std::mem::take(&mut self.local_allocations); + let else_branch = ConditionalBranch { + old_condition: cond_context.then_branch.old_condition, + condition: else_condition, + store_values: old_stores, + local_allocations: old_allocations, + last_block: *block, + }; + let old_condition = else_branch.old_condition; + cond_context.then_branch.local_allocations.clear(); + cond_context.else_branch = Some(else_branch); + self.condition_stack.push(cond_context); + + self.insert_current_side_effects_enabled(); + // Optimization: within the then branch we know the condition to be true, so replace + // any references of it within this branch with true. Likewise, do the same with false + // with the else branch. We must be careful not to replace the condition if it is a + // known constant, otherwise we can end up setting 1 = 0 or vice-versa. + if self.inserter.function.dfg.get_numeric_constant(old_condition).is_none() { + let known_value = self.inserter.function.dfg.make_constant(zero, Type::bool()); + + self.inserter.map_value(old_condition, known_value); + } + assert_eq!(self.cfg.successors(*block).len(), 1); + vec![self.cfg.successors(*block).next().unwrap()] } - /// Inserts a new instruction into the function's entry block, using the given - /// control type variables to specify result types if needed. - /// Unlike push_instruction, this function will not map any ValueIds. - /// within the given instruction, nor will it modify self.values in any way. - fn insert_instruction_with_typevars( - &mut self, - instruction: Instruction, - ctrl_typevars: Option>, - ) -> InsertInstructionResult { - let block = self.inserter.function.entry_block(); - self.inserter.function.dfg.insert_instruction_and_results( - instruction, - block, - ctrl_typevars, - CallStack::new(), - ) - } + /// Process the 'exit' block of a conditional statement + fn else_stop(&mut self, block: &BasicBlockId) -> Vec { + let mut cond_context = self.condition_stack.pop().unwrap(); + if cond_context.else_branch.is_none() { + // then_stop() has not been called, this means that the conditional statement has no else branch + // so we simply do the then_stop() now + self.condition_stack.push(cond_context); + self.then_stop(block); + cond_context = self.condition_stack.pop().unwrap(); + } - /// Checks the branch condition on the top of the stack and uses it to build and insert an - /// `EnableSideEffects` instruction into the entry block. - /// - /// If the stack is empty, a "true" u1 constant is taken to be the active condition. This is - /// necessary for re-enabling side-effects when re-emerging to a branch depth of 0. - fn insert_current_side_effects_enabled(&mut self) { - let condition = match self.conditions.last() { - Some((_, cond)) => *cond, - None => { - self.inserter.function.dfg.make_constant(FieldElement::one(), Type::unsigned(1)) - } - }; - let enable_side_effects = Instruction::EnableSideEffects { condition }; - self.insert_instruction_with_typevars(enable_side_effects, None); - } + let mut else_branch = cond_context.else_branch.unwrap(); + let stores_in_branch = std::mem::replace(&mut self.store_values, else_branch.store_values); + self.local_allocations = std::mem::take(&mut else_branch.local_allocations); + else_branch.last_block = *block; + else_branch.store_values = stores_in_branch; + cond_context.else_branch = Some(else_branch); - /// Inline one branch of a jmpif instruction. - /// - /// This will continue inlining recursively until the next end block is reached where each branch - /// of the jmpif instruction is joined back into a single block. - /// - /// Within a branch of a jmpif instruction, we can assume the condition of the jmpif to be - /// always true or false, depending on which branch we're in. - /// - /// Returns the ending block / join block of this branch. - fn inline_branch( - &mut self, - jmpif_block: BasicBlockId, - destination: BasicBlockId, - old_condition: ValueId, - new_condition: ValueId, - condition_value: FieldElement, - ) -> Branch { - if destination == self.branch_ends[&jmpif_block] { - // If the branch destination is the same as the end of the branch, this must be the - // 'else' case of an if with no else - so there is no else branch. - Branch { - condition: new_condition, - // The last block here is somewhat arbitrary. It only matters that it has no Jmp - // args that will be merged by inline_branch_end. Since jmpifs don't have - // block arguments, it is safe to use the jmpif block here. - last_block: jmpif_block, - store_values: HashMap::default(), - } - } else { - self.push_condition(jmpif_block, new_condition); - self.insert_current_side_effects_enabled(); - let old_stores = std::mem::take(&mut self.store_values); - let old_allocations = std::mem::take(&mut self.local_allocations); - - // Optimization: within the then branch we know the condition to be true, so replace - // any references of it within this branch with true. Likewise, do the same with false - // with the else branch. We must be careful not to replace the condition if it is a - // known constant, otherwise we can end up setting 1 = 0 or vice-versa. - if self.inserter.function.dfg.get_numeric_constant(old_condition).is_none() { - let known_value = - self.inserter.function.dfg.make_constant(condition_value, Type::bool()); - - self.inserter.map_value(old_condition, known_value); - } + // We must remember to reset whether side effects are enabled when both branches + // end, in addition to resetting the value of old_condition since it is set to + // known to be true/false within the then/else branch respectively. + self.insert_current_side_effects_enabled(); - let final_block = self.inline_block(destination, &[]); + // We must map back to `then_condition` here. Mapping `old_condition` to itself would + // lose any previous mappings. + self.inserter + .map_value(cond_context.then_branch.old_condition, cond_context.then_branch.condition); - self.conditions.pop(); + // While there is a condition on the stack we don't compile outside the condition + // until it is popped. This ensures we inline the full then and else branches + // before continuing from the end of the conditional here where they can be merged properly. + let end = self.branch_ends[&cond_context.entry_block]; - let stores_in_branch = std::mem::replace(&mut self.store_values, old_stores); - self.local_allocations = old_allocations; + // Merge arguments and stores from the else/end branches + self.inline_branch_end(end, cond_context); - Branch { - condition: new_condition, - last_block: final_block, - store_values: stores_in_branch, - } - } + vec![self.cfg.successors(*block).next().unwrap()] } /// Inline the ending block of a branch, the point where all blocks from a jmpif instruction @@ -467,15 +519,17 @@ impl<'f> Context<'f> { fn inline_branch_end( &mut self, destination: BasicBlockId, - then_branch: Branch, - else_branch: Branch, + cond_context: ConditionalContext, ) -> BasicBlockId { assert_eq!(self.cfg.predecessors(destination).len(), 2); + let last_then = cond_context.then_branch.last_block; + let mut else_args = Vec::new(); + if cond_context.else_branch.is_some() { + let last_else = cond_context.else_branch.clone().unwrap().last_block; + else_args = self.inserter.function.dfg[last_else].terminator_arguments().to_vec(); + } - let then_args = - self.inserter.function.dfg[then_branch.last_block].terminator_arguments().to_vec(); - let else_args = - self.inserter.function.dfg[else_branch.last_block].terminator_arguments().to_vec(); + let then_args = self.inserter.function.dfg[last_then].terminator_arguments().to_vec(); let params = self.inserter.function.dfg.block_parameters(destination); assert_eq!(params.len(), then_args.len()); @@ -500,17 +554,64 @@ impl<'f> Context<'f> { // Cannot include this in the previous vecmap since it requires exclusive access to self let args = vecmap(args, |(then_arg, else_arg)| { value_merger.merge_values( - then_branch.condition, - else_branch.condition, + cond_context.then_branch.condition, + cond_context.else_branch.clone().unwrap().condition, then_arg, else_arg, ) }); - self.merge_stores(then_branch, else_branch); + self.merge_stores(cond_context.then_branch, cond_context.else_branch); + self.arguments_stack.pop(); + self.arguments_stack.pop(); + self.arguments_stack.push(args); + destination + } - // insert merge instruction - self.inline_block(destination, &args) + /// Insert a new instruction into the function's entry block. + /// Unlike push_instruction, this function will not map any ValueIds. + /// within the given instruction, nor will it modify self.values in any way. + fn insert_instruction(&mut self, instruction: Instruction, call_stack: CallStack) -> ValueId { + let block = self.inserter.function.entry_block(); + self.inserter + .function + .dfg + .insert_instruction_and_results(instruction, block, None, call_stack) + .first() + } + + /// Inserts a new instruction into the function's entry block, using the given + /// control type variables to specify result types if needed. + /// Unlike push_instruction, this function will not map any ValueIds. + /// within the given instruction, nor will it modify self.values in any way. + fn insert_instruction_with_typevars( + &mut self, + instruction: Instruction, + ctrl_typevars: Option>, + ) -> InsertInstructionResult { + let block = self.inserter.function.entry_block(); + self.inserter.function.dfg.insert_instruction_and_results( + instruction, + block, + ctrl_typevars, + CallStack::new(), + ) + } + + /// Checks the branch condition on the top of the stack and uses it to build and insert an + /// `EnableSideEffects` instruction into the entry block. + /// + /// If the stack is empty, a "true" u1 constant is taken to be the active condition. This is + /// necessary for re-enabling side-effects when re-emerging to a branch depth of 0. + fn insert_current_side_effects_enabled(&mut self) { + let condition = match self.get_last_condition() { + Some(cond) => cond, + None => { + self.inserter.function.dfg.make_constant(FieldElement::one(), Type::unsigned(1)) + } + }; + let enable_side_effects = Instruction::EnableSideEffects { condition }; + self.insert_instruction_with_typevars(enable_side_effects, None); } /// Merge any store instructions found in each branch. @@ -518,7 +619,11 @@ impl<'f> Context<'f> { /// This function relies on the 'then' branch being merged before the 'else' branch of a jmpif /// instruction. If this ordering is changed, the ordering that store values are merged within /// this function also needs to be changed to reflect that. - fn merge_stores(&mut self, then_branch: Branch, else_branch: Branch) { + fn merge_stores( + &mut self, + then_branch: ConditionalBranch, + else_branch: Option, + ) { // Address -> (then_value, else_value, value_before_the_if) let mut new_map = BTreeMap::new(); @@ -526,11 +631,13 @@ impl<'f> Context<'f> { new_map.insert(address, (store.new_value, store.old_value, store.old_value)); } - for (address, store) in else_branch.store_values { - if let Some(entry) = new_map.get_mut(&address) { - entry.1 = store.new_value; - } else { - new_map.insert(address, (store.old_value, store.new_value, store.old_value)); + if else_branch.is_some() { + for (address, store) in else_branch.clone().unwrap().store_values { + if let Some(entry) = new_map.get_mut(&address) { + entry.1 = store.new_value; + } else { + new_map.insert(address, (store.old_value, store.new_value, store.old_value)); + } } } @@ -544,8 +651,11 @@ impl<'f> Context<'f> { } let then_condition = then_branch.condition; - let else_condition = else_branch.condition; - + let else_condition = if let Some(branch) = else_branch { + branch.condition + } else { + self.inserter.function.dfg.make_constant(FieldElement::zero(), Type::bool()) + }; let block = self.inserter.function.entry_block(); let mut value_merger = @@ -607,35 +717,6 @@ impl<'f> Context<'f> { } } - /// Inline all instructions from the given destination block into the entry block. - /// Afterwards, check the block's terminator and continue inlining recursively. - /// - /// Returns the final block that was inlined. - /// - /// Expects that the `arguments` given are already translated via self.inserter.resolve. - /// If they are not, it is possible some values which no longer exist, such as block - /// parameters, will be kept in the program. - fn inline_block(&mut self, destination: BasicBlockId, arguments: &[ValueId]) -> BasicBlockId { - self.inserter.remember_block_params(destination, arguments); - - // If this is not a separate variable, clippy gets confused and says the to_vec is - // unnecessary, when removing it actually causes an aliasing/mutability error. - let instructions = self.inserter.function.dfg[destination].instructions().to_vec(); - - for instruction in instructions.iter() { - let results = self.push_instruction(*instruction); - let (instruction, _) = self.inserter.map_instruction(*instruction); - let mut capacity_tracker = SliceCapacityTracker::new(&self.inserter.function.dfg); - capacity_tracker.collect_slice_information( - &instruction, - &mut self.slice_sizes, - results, - ); - } - - self.handle_terminator(destination) - } - /// Push the given instruction to the end of the entry block of the current function. /// /// Note that each ValueId of the instruction will be mapped via self.inserter.resolve. @@ -666,7 +747,7 @@ impl<'f> Context<'f> { instruction: Instruction, call_stack: CallStack, ) -> Instruction { - if let Some((_, condition)) = self.conditions.last().copied() { + if let Some(condition) = self.get_last_condition() { match instruction { Instruction::Constrain(lhs, rhs, message) => { // Replace constraint `lhs == rhs` with `condition * lhs == condition * rhs`. @@ -741,8 +822,8 @@ impl<'f> Context<'f> { } } - fn undo_stores_in_then_branch(&mut self, then_branch: &Branch) { - for (address, store) in &then_branch.store_values { + fn undo_stores_in_then_branch(&mut self, store_values: &HashMap) { + for (address, store) in store_values { let address = *address; let value = store.old_value; self.insert_instruction_with_typevars(Instruction::Store { address, value }, None); diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/capacity_tracker.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/capacity_tracker.rs index 7cd0fe3084e..bdfc04f0bbe 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/capacity_tracker.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/capacity_tracker.rs @@ -5,6 +5,7 @@ use crate::ssa::ir::{ value::{Value, ValueId}, }; +use acvm::FieldElement; use fxhash::FxHashMap as HashMap; pub(crate) struct SliceCapacityTracker<'a> { @@ -62,21 +63,27 @@ impl<'a> SliceCapacityTracker<'a> { | Intrinsic::SlicePushFront | Intrinsic::SlicePopBack | Intrinsic::SliceInsert - | Intrinsic::SliceRemove => (1, 1), + | Intrinsic::SliceRemove => (Some(1), 1), // `pop_front` returns the popped element, and then the respective slice. // This means in the case of a slice with structs, the result index of the popped slice // will change depending on the number of elements in the struct. // For example, a slice with four elements will look as such in SSA: // v3, v4, v5, v6, v7, v8 = call slice_pop_front(v1, v2) // where v7 is the slice length and v8 is the popped slice itself. - Intrinsic::SlicePopFront => (1, results.len() - 1), + Intrinsic::SlicePopFront => (Some(1), results.len() - 1), + // The slice capacity of these intrinsics is not determined by the arguments of the function. + Intrinsic::ToBits(_) | Intrinsic::ToRadix(_) => (None, 1), _ => return, }; - let slice_contents = arguments[argument_index]; + let result_slice = results[result_index]; match intrinsic { Intrinsic::SlicePushBack | Intrinsic::SlicePushFront | Intrinsic::SliceInsert => { + let argument_index = argument_index + .expect("ICE: Should have an argument index for slice intrinsics"); + let slice_contents = arguments[argument_index]; + for arg in &arguments[(argument_index + 1)..] { let element_typ = self.dfg.type_of_value(*arg); if element_typ.contains_slice_element() { @@ -85,20 +92,35 @@ impl<'a> SliceCapacityTracker<'a> { } if let Some(contents_capacity) = slice_sizes.get(&slice_contents) { let new_capacity = *contents_capacity + 1; - slice_sizes.insert(results[result_index], new_capacity); + slice_sizes.insert(result_slice, new_capacity); } } Intrinsic::SlicePopBack | Intrinsic::SliceRemove | Intrinsic::SlicePopFront => { + let argument_index = argument_index + .expect("ICE: Should have an argument index for slice intrinsics"); + let slice_contents = arguments[argument_index]; + // We do not decrement the size on intrinsics that could remove values from a slice. // This is because we could potentially go back to the smaller slice and not fill in dummies. // This pass should be tracking the potential max that a slice ***could be*** if let Some(contents_capacity) = slice_sizes.get(&slice_contents) { let new_capacity = *contents_capacity - 1; - slice_sizes.insert(results[result_index], new_capacity); + slice_sizes.insert(result_slice, new_capacity); } } + Intrinsic::ToBits(_) => { + // Compiler sanity check + assert!(matches!(self.dfg.type_of_value(result_slice), Type::Slice(_))); + slice_sizes.insert(result_slice, FieldElement::max_num_bits() as usize); + } + Intrinsic::ToRadix(_) => { + // Compiler sanity check + assert!(matches!(self.dfg.type_of_value(result_slice), Type::Slice(_))); + slice_sizes + .insert(result_slice, FieldElement::max_num_bytes() as usize); + } _ => {} } } diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ssa_gen/mod.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ssa_gen/mod.rs index d95295ae3c9..f3fa5d1d2f8 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ssa_gen/mod.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ssa_gen/mod.rs @@ -722,6 +722,11 @@ impl<'a> FunctionContext<'a> { let lhs = self.extract_current_value(&assign.lvalue)?; let rhs = self.codegen_expression(&assign.expression)?; + rhs.clone().for_each(|value| { + let value = value.eval(self); + self.builder.increment_array_reference_count(value); + }); + self.assign_new_value(lhs, rhs); Ok(Self::unit_value()) } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/ast/expression.rs b/noir/noir-repo/compiler/noirc_frontend/src/ast/expression.rs index 204b3b1de7f..a9ecc1a53e5 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/ast/expression.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/ast/expression.rs @@ -3,7 +3,7 @@ use std::fmt::Display; use crate::token::{Attributes, Token}; use crate::{ - Distinctness, FunctionVisibility, Ident, Path, Pattern, Recoverable, Statement, StatementKind, + Distinctness, Ident, ItemVisibility, Path, Pattern, Recoverable, Statement, StatementKind, UnresolvedTraitConstraint, UnresolvedType, UnresolvedTypeData, Visibility, }; use acvm::FieldElement; @@ -373,7 +373,7 @@ pub struct FunctionDefinition { pub is_unconstrained: bool, /// Indicate if this function was defined with the 'pub' keyword - pub visibility: FunctionVisibility, + pub visibility: ItemVisibility, pub generics: UnresolvedGenerics, pub parameters: Vec, @@ -658,7 +658,7 @@ impl FunctionDefinition { name: name.clone(), attributes: Attributes::empty(), is_unconstrained: false, - visibility: FunctionVisibility::Private, + visibility: ItemVisibility::Private, generics: generics.clone(), parameters: p, body: body.clone(), diff --git a/noir/noir-repo/compiler/noirc_frontend/src/ast/mod.rs b/noir/noir-repo/compiler/noirc_frontend/src/ast/mod.rs index 29edbaca594..8a420c32fb8 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/ast/mod.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/ast/mod.rs @@ -354,8 +354,8 @@ impl UnresolvedTypeExpression { } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -/// Represents whether the function can be called outside its module/crate -pub enum FunctionVisibility { +/// Represents whether the definition can be referenced outside its module/crate +pub enum ItemVisibility { Public, Private, PublicCrate, diff --git a/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs b/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs index f39b71405d3..387840b57c4 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs @@ -240,6 +240,17 @@ pub trait Recoverable { fn error(span: Span) -> Self; } +#[derive(Debug, PartialEq, Eq, Clone)] +pub struct ModuleDeclaration { + pub ident: Ident, +} + +impl std::fmt::Display for ModuleDeclaration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "mod {}", self.ident) + } +} + #[derive(Debug, PartialEq, Eq, Clone)] pub struct ImportStatement { pub path: Path, diff --git a/noir/noir-repo/compiler/noirc_frontend/src/debug/mod.rs b/noir/noir-repo/compiler/noirc_frontend/src/debug/mod.rs index a88567fcaf9..05916502d73 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/debug/mod.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/debug/mod.rs @@ -4,9 +4,11 @@ use crate::{ ast::{Path, PathKind}, parser::{Item, ItemKind}, }; +use noirc_errors::debug_info::{DebugFnId, DebugFunction}; use noirc_errors::{Span, Spanned}; use std::collections::HashMap; use std::collections::VecDeque; +use std::mem::take; const MAX_MEMBER_ASSIGN_DEPTH: usize = 8; @@ -26,8 +28,12 @@ pub struct DebugInstrumenter { // all field names referenced when assigning to a member of a variable pub field_names: HashMap, + // all collected function metadata (name + argument names) + pub functions: HashMap, + next_var_id: u32, next_field_name_id: u32, + next_fn_id: u32, // last seen variable names and their IDs grouped by scope scope: Vec>, @@ -38,9 +44,11 @@ impl Default for DebugInstrumenter { Self { variables: HashMap::default(), field_names: HashMap::default(), + functions: HashMap::default(), scope: vec![], next_var_id: 0, next_field_name_id: 1, + next_fn_id: 0, } } } @@ -76,10 +84,22 @@ impl DebugInstrumenter { field_name_id } + fn insert_function(&mut self, fn_name: String, arguments: Vec) -> DebugFnId { + let fn_id = DebugFnId(self.next_fn_id); + self.next_fn_id += 1; + self.functions.insert(fn_id, DebugFunction { name: fn_name, arg_names: arguments }); + fn_id + } + fn walk_fn(&mut self, func: &mut ast::FunctionDefinition) { + let func_name = func.name.0.contents.clone(); + let func_args = + func.parameters.iter().map(|param| pattern_to_string(¶m.pattern)).collect(); + let fn_id = self.insert_function(func_name, func_args); + let enter_stmt = build_debug_call_stmt("enter", fn_id, func.span); self.scope.push(HashMap::default()); - let set_fn_params = func + let set_fn_params: Vec<_> = func .parameters .iter() .flat_map(|param| { @@ -93,10 +113,21 @@ impl DebugInstrumenter { }) .collect(); - self.walk_scope(&mut func.body.0, func.span); + let func_body = &mut func.body.0; + let mut statements = take(func_body); + + self.walk_scope(&mut statements, func.span); - // prepend fn params: - func.body.0 = [set_fn_params, func.body.0.clone()].concat(); + // walk_scope ensures that the last statement is the return value of the function + let last_stmt = statements.pop().expect("at least one statement after walk_scope"); + let exit_stmt = build_debug_call_stmt("exit", fn_id, last_stmt.span); + + // rebuild function body + func_body.push(enter_stmt); + func_body.extend(set_fn_params); + func_body.extend(statements); + func_body.push(exit_stmt); + func_body.push(last_stmt); } // Modify a vector of statements in-place, adding instrumentation for sets and drops. @@ -427,6 +458,8 @@ impl DebugInstrumenter { use dep::__debug::{{ __debug_var_assign, __debug_var_drop, + __debug_fn_enter, + __debug_fn_exit, __debug_dereference_assign, {member_assigns}, }};"# @@ -451,14 +484,32 @@ pub fn build_debug_crate_file() -> String { } #[oracle(__debug_var_drop)] - unconstrained fn __debug_var_drop_oracle(_var_id: u32) {} - unconstrained fn __debug_var_drop_inner(var_id: u32) { + unconstrained fn __debug_var_drop_oracle(_var_id: u32) {} + unconstrained fn __debug_var_drop_inner(var_id: u32) { __debug_var_drop_oracle(var_id); } - pub fn __debug_var_drop(var_id: u32) { + pub fn __debug_var_drop(var_id: u32) { __debug_var_drop_inner(var_id); } + #[oracle(__debug_fn_enter)] + unconstrained fn __debug_fn_enter_oracle(_fn_id: u32) {} + unconstrained fn __debug_fn_enter_inner(fn_id: u32) { + __debug_fn_enter_oracle(fn_id); + } + pub fn __debug_fn_enter(fn_id: u32) { + __debug_fn_enter_inner(fn_id); + } + + #[oracle(__debug_fn_exit)] + unconstrained fn __debug_fn_exit_oracle(_fn_id: u32) {} + unconstrained fn __debug_fn_exit_inner(fn_id: u32) { + __debug_fn_exit_oracle(fn_id); + } + pub fn __debug_fn_exit(fn_id: u32) { + __debug_fn_exit_inner(fn_id); + } + #[oracle(__debug_dereference_assign)] unconstrained fn __debug_dereference_assign_oracle(_var_id: u32, _value: T) {} unconstrained fn __debug_dereference_assign_inner(var_id: u32, value: T) { @@ -561,6 +612,21 @@ fn build_assign_member_stmt( ast::Statement { kind: ast::StatementKind::Semi(ast::Expression { kind, span }), span } } +fn build_debug_call_stmt(fname: &str, fn_id: DebugFnId, span: Span) -> ast::Statement { + let kind = ast::ExpressionKind::Call(Box::new(ast::CallExpression { + func: Box::new(ast::Expression { + kind: ast::ExpressionKind::Variable(ast::Path { + segments: vec![ident(&format!["__debug_fn_{fname}"], span)], + kind: PathKind::Plain, + span, + }), + span, + }), + arguments: vec![uint_expr(fn_id.0 as u128, span)], + })); + ast::Statement { kind: ast::StatementKind::Semi(ast::Expression { kind, span }), span } +} + fn pattern_vars(pattern: &ast::Pattern) -> Vec<(ast::Ident, bool)> { let mut vars = vec![]; let mut stack = VecDeque::from([(pattern, false)]); @@ -585,6 +651,30 @@ fn pattern_vars(pattern: &ast::Pattern) -> Vec<(ast::Ident, bool)> { vars } +fn pattern_to_string(pattern: &ast::Pattern) -> String { + match pattern { + ast::Pattern::Identifier(id) => id.0.contents.clone(), + ast::Pattern::Mutable(mpat, _, _) => format!("mut {}", pattern_to_string(mpat.as_ref())), + ast::Pattern::Tuple(elements, _) => format!( + "({})", + elements.iter().map(pattern_to_string).collect::>().join(", ") + ), + ast::Pattern::Struct(name, fields, _) => { + format!( + "{} {{ {} }}", + name, + fields + .iter() + .map(|(field_ident, field_pattern)| { + format!("{}: {}", &field_ident.0.contents, pattern_to_string(field_pattern)) + }) + .collect::>() + .join(", "), + ) + } + } +} + fn ident(s: &str, span: Span) -> ast::Ident { ast::Ident(Spanned::from(span, s.to_string())) } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs index 436d2794fb8..8ea9d475539 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -5,13 +5,14 @@ use crate::hir::def_map::{CrateDefMap, LocalModuleId, ModuleId}; use crate::hir::resolution::errors::ResolverError; use crate::hir::resolution::import::{resolve_import, ImportDirective}; -use crate::hir::resolution::resolver::Resolver; use crate::hir::resolution::{ collect_impls, collect_trait_impls, path_resolver, resolve_free_functions, resolve_globals, resolve_impls, resolve_structs, resolve_trait_by_path, resolve_trait_impls, resolve_traits, resolve_type_aliases, }; -use crate::hir::type_check::{type_check_func, TypeCheckError, TypeChecker}; +use crate::hir::type_check::{ + check_trait_impl_method_matches_declaration, type_check_func, TypeCheckError, TypeChecker, +}; use crate::hir::Context; use crate::macros_api::{MacroError, MacroProcessor}; @@ -20,8 +21,7 @@ use crate::node_interner::{FuncId, GlobalId, NodeInterner, StructId, TraitId, Ty use crate::parser::{ParserError, SortedModule}; use crate::{ ExpressionKind, Ident, LetStatement, Literal, NoirFunction, NoirStruct, NoirTrait, - NoirTypeAlias, Path, PathKind, Type, TypeBindings, UnresolvedGenerics, - UnresolvedTraitConstraint, UnresolvedType, + NoirTypeAlias, Path, PathKind, UnresolvedGenerics, UnresolvedTraitConstraint, UnresolvedType, }; use fm::FileId; use iter_extended::vecmap; @@ -279,7 +279,7 @@ impl DefCollector { // Resolve unresolved imports collected from the crate, one by one. for collected_import in def_collector.collected_imports { - match resolve_import(crate_id, collected_import, &context.def_maps) { + match resolve_import(crate_id, &collected_import, &context.def_maps) { Ok(resolved_import) => { // Populate module namespaces according to the imports used let current_def_map = context.def_maps.get_mut(&crate_id).unwrap(); @@ -369,12 +369,12 @@ impl DefCollector { &mut errors, )); - functions.extend(resolve_trait_impls( + let impl_functions = resolve_trait_impls( context, def_collector.collected_traits_impls, crate_id, &mut errors, - )); + ); for macro_processor in macro_processors { macro_processor.process_typed_ast(&crate_id, context).unwrap_or_else( @@ -388,6 +388,8 @@ impl DefCollector { errors.extend(type_check_globals(&mut context.def_interner, resolved_globals.globals)); errors.extend(type_check_functions(&mut context.def_interner, functions)); + errors.extend(type_check_trait_impl_signatures(&mut context.def_interner, &impl_functions)); + errors.extend(type_check_functions(&mut context.def_interner, impl_functions)); errors } } @@ -469,158 +471,24 @@ fn type_check_functions( .into_iter() .flat_map(|(file, func)| { type_check_func(interner, func) - .iter() - .cloned() + .into_iter() .map(|e| (e.into(), file)) .collect::>() }) .collect() } -// TODO(vitkov): Move this out of here and into type_check -#[allow(clippy::too_many_arguments)] -pub(crate) fn check_methods_signatures( - resolver: &mut Resolver, - impl_methods: &[(FileId, FuncId)], - trait_id: TraitId, - trait_name_span: Span, - // These are the generics on the trait itself from the impl. - // E.g. in `impl Foo for Bar`, this is `vec![A, B]`. - trait_generics: Vec, - trait_impl_generic_count: usize, - file_id: FileId, - errors: &mut Vec<(CompilationError, FileId)>, -) { - let self_type = resolver.get_self_type().expect("trait impl must have a Self type").clone(); - let trait_generics = vecmap(trait_generics, |typ| resolver.resolve_type(typ)); - - // Temporarily bind the trait's Self type to self_type so we can type check - let the_trait = resolver.interner.get_trait_mut(trait_id); - the_trait.self_type_typevar.bind(self_type); - - if trait_generics.len() != the_trait.generics.len() { - let error = DefCollectorErrorKind::MismatchGenericCount { - actual_generic_count: trait_generics.len(), - expected_generic_count: the_trait.generics.len(), - // Preferring to use 'here' over a more precise term like 'this reference' - // to try to make the error easier to understand for newer users. - location: "here it", - origin: the_trait.name.to_string(), - span: trait_name_span, - }; - errors.push((error.into(), file_id)); - } - - // We also need to bind the traits generics to the trait's generics on the impl - for (generic, binding) in the_trait.generics.iter().zip(trait_generics) { - generic.bind(binding); - } - - // Temporarily take the trait's methods so we can use both them and a mutable reference - // to the interner within the loop. - let trait_methods = std::mem::take(&mut the_trait.methods); - - for (file_id, func_id) in impl_methods { - let func_name = resolver.interner.function_name(func_id).to_owned(); - - // This is None in the case where the impl block has a method that's not part of the trait. - // If that's the case, a `MethodNotInTrait` error has already been thrown, and we can ignore - // the impl method, since there's nothing in the trait to match its signature against. - if let Some(trait_method) = - trait_methods.iter().find(|method| method.name.0.contents == func_name) - { - let impl_method = resolver.interner.function_meta(func_id); - - let impl_method_generic_count = - impl_method.typ.generic_count() - trait_impl_generic_count; - - // We subtract 1 here to account for the implicit generic `Self` type that is on all - // traits (and thus trait methods) but is not required (or allowed) for users to specify. - let the_trait = resolver.interner.get_trait(trait_id); - let trait_method_generic_count = - trait_method.generics().len() - 1 - the_trait.generics.len(); - - if impl_method_generic_count != trait_method_generic_count { - let trait_name = resolver.interner.get_trait(trait_id).name.clone(); - - let error = DefCollectorErrorKind::MismatchGenericCount { - actual_generic_count: impl_method_generic_count, - expected_generic_count: trait_method_generic_count, - origin: format!("{}::{}", trait_name, func_name), - location: "this method", - span: impl_method.location.span, - }; - errors.push((error.into(), *file_id)); - } - - // This instantiation is technically not needed. We could bind each generic in the - // trait function to the impl's corresponding generic but to do so we'd have to rely - // on the trait function's generics being first in the generic list, since the same - // list also contains the generic `Self` variable, and any generics on the trait itself. - // - // Instantiating the impl method's generics here instead is a bit less precise but - // doesn't rely on any orderings that may be changed. - let impl_function_type = impl_method.typ.instantiate(resolver.interner).0; - - let mut bindings = TypeBindings::new(); - let mut typecheck_errors = Vec::new(); - - if let Type::Function(impl_params, impl_return, _) = impl_function_type.as_monotype() { - if trait_method.arguments().len() != impl_params.len() { - let error = DefCollectorErrorKind::MismatchTraitImplementationNumParameters { - actual_num_parameters: impl_method.parameters.0.len(), - expected_num_parameters: trait_method.arguments().len(), - trait_name: resolver.interner.get_trait(trait_id).name.to_string(), - method_name: func_name.to_string(), - span: impl_method.location.span, - }; - errors.push((error.into(), *file_id)); - } - - // Check the parameters of the impl method against the parameters of the trait method - let args = trait_method.arguments().iter(); - let args_and_params = args.zip(impl_params).zip(&impl_method.parameters.0); - - for (parameter_index, ((expected, actual), (hir_pattern, _, _))) in - args_and_params.enumerate() - { - if expected.try_unify(actual, &mut bindings).is_err() { - typecheck_errors.push(TypeCheckError::TraitMethodParameterTypeMismatch { - method_name: func_name.to_string(), - expected_typ: expected.to_string(), - actual_typ: actual.to_string(), - parameter_span: hir_pattern.span(), - parameter_index: parameter_index + 1, - }); - } - } - - if trait_method.return_type().try_unify(impl_return, &mut bindings).is_err() { - let impl_method = resolver.interner.function_meta(func_id); - let ret_type_span = impl_method.return_type.get_type().span; - let expr_span = ret_type_span.expect("return type must always have a span"); - - let expected_typ = trait_method.return_type().to_string(); - let expr_typ = impl_method.return_type().to_string(); - let error = TypeCheckError::TypeMismatch { expr_typ, expected_typ, expr_span }; - typecheck_errors.push(error); - } - } else { - unreachable!( - "impl_function_type is not a function type, it is: {impl_function_type}" - ); - } - - errors.extend(typecheck_errors.iter().cloned().map(|e| (e.into(), *file_id))); - } - } - - // Now unbind `Self` and the trait's generics - let the_trait = resolver.interner.get_trait_mut(trait_id); - the_trait.set_methods(trait_methods); - the_trait.self_type_typevar.unbind(the_trait.self_type_typevar_id); - - for generic in &the_trait.generics { - generic.unbind(generic.id()); - } +fn type_check_trait_impl_signatures( + interner: &mut NodeInterner, + file_func_ids: &[(FileId, FuncId)], +) -> Vec<(CompilationError, fm::FileId)> { + file_func_ids + .iter() + .flat_map(|(file, func)| { + check_trait_impl_method_matches_declaration(interner, *func) + .into_iter() + .map(|e| (e.into(), *file)) + .collect::>() + }) + .collect() } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs index 9189d031934..ae99e61e534 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs @@ -10,8 +10,8 @@ use crate::{ macros_api::MacroProcessor, node_interner::{FunctionModifiers, TraitId, TypeAliasId}, parser::{SortedModule, SortedSubModule}, - FunctionDefinition, Ident, LetStatement, NoirFunction, NoirStruct, NoirTrait, NoirTraitImpl, - NoirTypeAlias, TraitImplItem, TraitItem, TypeImpl, + FunctionDefinition, Ident, LetStatement, ModuleDeclaration, NoirFunction, NoirStruct, + NoirTrait, NoirTraitImpl, NoirTypeAlias, TraitImplItem, TraitItem, TypeImpl, }; use super::{ @@ -407,7 +407,7 @@ impl<'a> ModCollector<'a> { let modifiers = FunctionModifiers { name: name.to_string(), - visibility: crate::FunctionVisibility::Public, + visibility: crate::ItemVisibility::Public, // TODO(Maddiaa): Investigate trait implementations with attributes see: https://github.com/noir-lang/noir/issues/2629 attributes: crate::token::Attributes::empty(), is_unconstrained: false, @@ -535,16 +535,16 @@ impl<'a> ModCollector<'a> { fn parse_module_declaration( &mut self, context: &mut Context, - mod_name: &Ident, + mod_decl: &ModuleDeclaration, crate_id: CrateId, macro_processors: &[&dyn MacroProcessor], ) -> Vec<(CompilationError, FileId)> { let mut errors: Vec<(CompilationError, FileId)> = vec![]; let child_file_id = - match find_module(&context.file_manager, self.file_id, &mod_name.0.contents) { + match find_module(&context.file_manager, self.file_id, &mod_decl.ident.0.contents) { Ok(child_file_id) => child_file_id, Err(expected_path) => { - let mod_name = mod_name.clone(); + let mod_name = mod_decl.ident.clone(); let err = DefCollectorErrorKind::UnresolvedModuleDecl { mod_name, expected_path }; errors.push((err.into(), self.file_id)); @@ -552,17 +552,17 @@ impl<'a> ModCollector<'a> { } }; - let location = Location { file: self.file_id, span: mod_name.span() }; + let location = Location { file: self.file_id, span: mod_decl.ident.span() }; if let Some(old_location) = context.visited_files.get(&child_file_id) { let error = DefCollectorErrorKind::ModuleAlreadyPartOfCrate { - mod_name: mod_name.clone(), + mod_name: mod_decl.ident.clone(), span: location.span, }; errors.push((error.into(), location.file)); let error = DefCollectorErrorKind::ModuleOriginallyDefined { - mod_name: mod_name.clone(), + mod_name: mod_decl.ident.clone(), span: old_location.span, }; errors.push((error.into(), old_location.file)); @@ -592,7 +592,7 @@ impl<'a> ModCollector<'a> { ); // Add module into def collector and get a ModuleId - match self.push_child_module(mod_name, child_file_id, true, false) { + match self.push_child_module(&mod_decl.ident, child_file_id, true, false) { Ok(child_mod_id) => { errors.extend(collect_defs( self.def_collector, diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/errors.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/errors.rs index de45be48c4e..29daf5d6369 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/errors.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/errors.rs @@ -41,14 +41,6 @@ pub enum DefCollectorErrorKind { OverlappingImplNote { span: Span }, #[error("Cannot `impl` a type defined outside the current crate")] ForeignImpl { span: Span, type_name: String }, - #[error("Mismatched number of parameters in trait implementation")] - MismatchTraitImplementationNumParameters { - actual_num_parameters: usize, - expected_num_parameters: usize, - trait_name: String, - method_name: String, - span: Span, - }, #[error("Mismatched number of generics in {location}")] MismatchGenericCount { actual_generic_count: usize, @@ -176,18 +168,6 @@ impl From for Diagnostic { "".to_string(), trait_path.span(), ), - DefCollectorErrorKind::MismatchTraitImplementationNumParameters { - expected_num_parameters, - actual_num_parameters, - trait_name, - method_name, - span, - } => { - let plural = if expected_num_parameters == 1 { "" } else { "s" }; - let primary_message = format!( - "`{trait_name}::{method_name}` expects {expected_num_parameters} parameter{plural}, but this method has {actual_num_parameters}"); - Diagnostic::simple_error(primary_message, "".to_string(), span) - } DefCollectorErrorKind::MismatchGenericCount { actual_generic_count, expected_generic_count, diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_map/item_scope.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_map/item_scope.rs index 523def89518..178b91e1e84 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_map/item_scope.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_map/item_scope.rs @@ -1,16 +1,11 @@ use super::{namespace::PerNs, ModuleDefId, ModuleId}; use crate::{ node_interner::{FuncId, TraitId}, - Ident, + Ident, ItemVisibility, }; use std::collections::{hash_map::Entry, HashMap}; -type Scope = HashMap, (ModuleDefId, Visibility, bool /*is_prelude*/)>; - -#[derive(Debug, PartialEq, Eq, Copy, Clone)] -pub enum Visibility { - Public, -} +type Scope = HashMap, (ModuleDefId, ItemVisibility, bool /*is_prelude*/)>; #[derive(Default, Debug, PartialEq, Eq)] pub struct ItemScope { @@ -55,12 +50,12 @@ impl ItemScope { Err((old_ident.clone(), name)) } } else { - trait_hashmap.insert(trait_id, (mod_def, Visibility::Public, is_prelude)); + trait_hashmap.insert(trait_id, (mod_def, ItemVisibility::Public, is_prelude)); Ok(()) } } else { let mut trait_hashmap = HashMap::new(); - trait_hashmap.insert(trait_id, (mod_def, Visibility::Public, is_prelude)); + trait_hashmap.insert(trait_id, (mod_def, ItemVisibility::Public, is_prelude)); map.insert(name, trait_hashmap); Ok(()) } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_map/namespace.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_map/namespace.rs index ca14d9f8617..5e349f46e14 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_map/namespace.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_map/namespace.rs @@ -1,15 +1,16 @@ -use super::{item_scope::Visibility, ModuleDefId}; +use super::ModuleDefId; +use crate::ItemVisibility; // This works exactly the same as in r-a, just simplified #[derive(Debug, PartialEq, Eq, Copy, Clone)] pub struct PerNs { - pub types: Option<(ModuleDefId, Visibility, bool)>, - pub values: Option<(ModuleDefId, Visibility, bool)>, + pub types: Option<(ModuleDefId, ItemVisibility, bool)>, + pub values: Option<(ModuleDefId, ItemVisibility, bool)>, } impl PerNs { pub fn types(t: ModuleDefId) -> PerNs { - PerNs { types: Some((t, Visibility::Public, false)), values: None } + PerNs { types: Some((t, ItemVisibility::Public, false)), values: None } } pub fn take_types(self) -> Option { @@ -24,7 +25,7 @@ impl PerNs { self.types.map(|it| it.0).into_iter().chain(self.values.map(|it| it.0)) } - pub fn iter_items(self) -> impl Iterator { + pub fn iter_items(self) -> impl Iterator { self.types.into_iter().chain(self.values) } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs index cba26ab329e..30a1ba2ee34 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs @@ -76,8 +76,6 @@ pub enum ResolverError { PrivateFunctionCalled { name: String, span: Span }, #[error("{name} is not visible from the current crate")] NonCrateFunctionCalled { name: String, span: Span }, - #[error("Only sized types may be used in the entry point to a program")] - InvalidTypeForEntryPoint { span: Span }, #[error("Nested slices are not supported")] NestedSlices { span: Span }, #[error("#[recursive] attribute is only allowed on entry points to a program")] @@ -295,9 +293,6 @@ impl From for Diagnostic { ResolverError::NonCrateFunctionCalled { span, name } => Diagnostic::simple_warning( format!("{name} is not visible from the current crate"), format!("{name} is only visible within its crate"), span), - ResolverError::InvalidTypeForEntryPoint { span } => Diagnostic::simple_error( - "Only sized types may be used in the entry point to a program".to_string(), - "Slices, references, or any type containing them may not be used in main or a contract function".to_string(), span), ResolverError::NestedSlices { span } => Diagnostic::simple_error( "Nested slices are not supported".into(), "Try to use a constant sized array instead".into(), diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/import.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/import.rs index e6ac33053a0..9c8418daf80 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/import.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/import.rs @@ -52,7 +52,7 @@ impl From for CustomDiagnostic { pub fn resolve_import( crate_id: CrateId, - import_directive: ImportDirective, + import_directive: &ImportDirective, def_maps: &BTreeMap, ) -> Result { let def_map = &def_maps[&crate_id]; @@ -62,10 +62,10 @@ pub fn resolve_import( let module_scope = import_directive.module_id; let resolved_namespace = - resolve_path_to_ns(&import_directive, def_map, def_maps, allow_contracts) + resolve_path_to_ns(import_directive, def_map, def_maps, allow_contracts) .map_err(|error| (error, module_scope))?; - let name = resolve_path_name(&import_directive); + let name = resolve_path_name(import_directive); Ok(ResolvedImport { name, resolved_namespace, diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/resolver.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/resolver.rs index 2f6ccffee95..00b1b443430 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/resolver.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/resolver.rs @@ -37,11 +37,11 @@ use crate::{ StatementKind, }; use crate::{ - ArrayLiteral, Distinctness, ForRange, FunctionDefinition, FunctionReturnType, - FunctionVisibility, Generics, LValue, NoirStruct, NoirTypeAlias, Param, Path, PathKind, - Pattern, Shared, StructType, Type, TypeAlias, TypeVariable, TypeVariableKind, UnaryOp, - UnresolvedGenerics, UnresolvedTraitConstraint, UnresolvedType, UnresolvedTypeData, - UnresolvedTypeExpression, Visibility, ERROR_IDENT, + ArrayLiteral, Distinctness, ForRange, FunctionDefinition, FunctionReturnType, Generics, + ItemVisibility, LValue, NoirStruct, NoirTypeAlias, Param, Path, PathKind, Pattern, Shared, + StructType, Type, TypeAlias, TypeVariable, TypeVariableKind, UnaryOp, UnresolvedGenerics, + UnresolvedTraitConstraint, UnresolvedType, UnresolvedTypeData, UnresolvedTypeExpression, + Visibility, ERROR_IDENT, }; use fm::FileId; use iter_extended::vecmap; @@ -217,6 +217,7 @@ impl<'a> Resolver<'a> { pub fn resolve_trait_function( &mut self, name: &Ident, + generics: &UnresolvedGenerics, parameters: &[(Ident, UnresolvedType)], return_type: &FunctionReturnType, where_clause: &[UnresolvedTraitConstraint], @@ -234,8 +235,8 @@ impl<'a> Resolver<'a> { name: name.clone(), attributes: Attributes::empty(), is_unconstrained: false, - visibility: FunctionVisibility::Public, // Trait functions are always public - generics: Vec::new(), // self.generics should already be set + visibility: ItemVisibility::Public, // Trait functions are always public + generics: generics.clone(), parameters: vecmap(parameters, |(name, typ)| Param { visibility: Visibility::Private, pattern: Pattern::Identifier(name.clone()), @@ -909,10 +910,6 @@ impl<'a> Resolver<'a> { }); } - if self.is_entry_point_function(func) { - self.verify_type_valid_for_program_input(&typ); - } - let pattern = self.resolve_pattern(pattern, DefinitionKind::Local(None)); let typ = self.resolve_type_inner(typ, &mut generics); @@ -974,11 +971,18 @@ impl<'a> Resolver<'a> { self.interner.push_definition_type(name_ident.id, typ.clone()); + let direct_generics = func.def.generics.iter(); + let direct_generics = direct_generics + .filter_map(|generic| self.find_generic(&generic.0.contents)) + .map(|(name, typevar, _span)| (name.clone(), typevar.clone())) + .collect(); + FuncMeta { name: name_ident, kind: func.kind, location, typ, + direct_generics, trait_impl: self.current_trait_impl, parameters: parameters.into(), return_type: func.def.return_type.clone(), @@ -986,6 +990,7 @@ impl<'a> Resolver<'a> { return_distinctness: func.def.return_distinctness, has_body: !func.def.body.is_empty(), trait_constraints: self.resolve_trait_constraints(&func.def.where_clause), + is_entry_point: self.is_entry_point_function(func), } } @@ -1231,13 +1236,17 @@ impl<'a> Resolver<'a> { let is_in_stdlib = self.path_resolver.module_id().krate.is_stdlib(); let assert_msg_call_path = if is_in_stdlib { ExpressionKind::Variable(Path { - segments: vec![Ident::from("resolve_assert_message")], + segments: vec![Ident::from("internal"), Ident::from("resolve_assert_message")], kind: PathKind::Crate, span, }) } else { ExpressionKind::Variable(Path { - segments: vec![Ident::from("std"), Ident::from("resolve_assert_message")], + segments: vec![ + Ident::from("std"), + Ident::from("internal"), + Ident::from("resolve_assert_message"), + ], kind: PathKind::Dep, span, }) @@ -1286,7 +1295,7 @@ impl<'a> Resolver<'a> { &mut self, func: FuncId, span: Span, - visibility: FunctionVisibility, + visibility: ItemVisibility, ) { let function_module = self.interner.function_module(func); let current_module = self.path_resolver.module_id(); @@ -1296,8 +1305,8 @@ impl<'a> Resolver<'a> { let current_module = current_module.local_id; let name = self.interner.function_name(&func).to_string(); match visibility { - FunctionVisibility::Public => (), - FunctionVisibility::Private => { + ItemVisibility::Public => (), + ItemVisibility::Private => { if !same_crate || !self.module_descendent_of_target( krate, @@ -1308,7 +1317,7 @@ impl<'a> Resolver<'a> { self.errors.push(ResolverError::PrivateFunctionCalled { span, name }); } } - FunctionVisibility::PublicCrate => { + ItemVisibility::PublicCrate => { if !same_crate { self.errors.push(ResolverError::NonCrateFunctionCalled { span, name }); } @@ -1417,9 +1426,7 @@ impl<'a> Resolver<'a> { self.interner.add_function_dependency(current_item, id); } - if self.interner.function_visibility(id) - != FunctionVisibility::Public - { + if self.interner.function_visibility(id) != ItemVisibility::Public { let span = hir_ident.location.span; self.check_can_reference_function( id, @@ -1974,89 +1981,6 @@ impl<'a> Resolver<'a> { } HirLiteral::FmtStr(str, fmt_str_idents) } - - /// Only sized types are valid to be used as main's parameters or the parameters to a contract - /// function. If the given type is not sized (e.g. contains a slice or NamedGeneric type), an - /// error is issued. - fn verify_type_valid_for_program_input(&mut self, typ: &UnresolvedType) { - match &typ.typ { - UnresolvedTypeData::FieldElement - | UnresolvedTypeData::Integer(_, _) - | UnresolvedTypeData::Bool - | UnresolvedTypeData::Unit - | UnresolvedTypeData::Error => (), - - UnresolvedTypeData::MutableReference(_) - | UnresolvedTypeData::Function(_, _, _) - | UnresolvedTypeData::FormatString(_, _) - | UnresolvedTypeData::TraitAsType(..) - | UnresolvedTypeData::Unspecified => { - let span = typ.span.expect("Function parameters should always have spans"); - self.push_err(ResolverError::InvalidTypeForEntryPoint { span }); - } - - UnresolvedTypeData::Array(length, element) => { - if let Some(length) = length { - self.verify_type_expression_valid_for_program_input(length); - } else { - let span = typ.span.expect("Function parameters should always have spans"); - self.push_err(ResolverError::InvalidTypeForEntryPoint { span }); - } - self.verify_type_valid_for_program_input(element); - } - UnresolvedTypeData::Expression(expression) => { - self.verify_type_expression_valid_for_program_input(expression); - } - UnresolvedTypeData::String(length) => { - if let Some(length) = length { - self.verify_type_expression_valid_for_program_input(length); - } else { - let span = typ.span.expect("Function parameters should always have spans"); - self.push_err(ResolverError::InvalidTypeForEntryPoint { span }); - } - } - UnresolvedTypeData::Named(path, generics, _) => { - // Since the type is named, we need to resolve it to see what it actually refers to - // in order to check whether it is valid. Since resolving it may lead to a - // resolution error, we have to truncate our error count to the previous count just - // in case. This is to ensure resolution errors are not issued twice when this type - // is later resolved properly. - let error_count = self.errors.len(); - let resolved = self.resolve_named_type(path.clone(), generics.clone(), &mut vec![]); - self.errors.truncate(error_count); - - if !resolved.is_valid_for_program_input() { - let span = typ.span.expect("Function parameters should always have spans"); - self.push_err(ResolverError::InvalidTypeForEntryPoint { span }); - } - } - UnresolvedTypeData::Tuple(elements) => { - for element in elements { - self.verify_type_valid_for_program_input(element); - } - } - UnresolvedTypeData::Parenthesized(typ) => self.verify_type_valid_for_program_input(typ), - } - } - - fn verify_type_expression_valid_for_program_input(&mut self, expr: &UnresolvedTypeExpression) { - match expr { - UnresolvedTypeExpression::Constant(_, _) => (), - UnresolvedTypeExpression::Variable(path) => { - let error_count = self.errors.len(); - let resolved = self.resolve_named_type(path.clone(), vec![], &mut vec![]); - self.errors.truncate(error_count); - - if !resolved.is_valid_for_program_input() { - self.push_err(ResolverError::InvalidTypeForEntryPoint { span: path.span() }); - } - } - UnresolvedTypeExpression::BinaryOperation(lhs, _, rhs, _) => { - self.verify_type_expression_valid_for_program_input(lhs); - self.verify_type_expression_valid_for_program_input(rhs); - } - } - } } /// Gives an error if a user tries to create a mutable reference diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/traits.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/traits.rs index 8f966be312b..5d546954f0d 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/traits.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/traits.rs @@ -8,9 +8,7 @@ use crate::{ graph::CrateId, hir::{ def_collector::{ - dc_crate::{ - check_methods_signatures, CompilationError, UnresolvedTrait, UnresolvedTraitImpl, - }, + dc_crate::{CompilationError, UnresolvedTrait, UnresolvedTraitImpl}, errors::{DefCollectorErrorKind, DuplicateType}, }, def_map::{CrateDefMap, ModuleDefId, ModuleId}, @@ -131,6 +129,7 @@ fn resolve_trait_methods( let func_id = unresolved_trait.method_ids[&name.0.contents]; let (_, func_meta) = resolver.resolve_trait_function( name, + generics, parameters, return_type, where_clause, @@ -365,6 +364,7 @@ pub(crate) fn resolve_trait_by_path( Err(_) => Err(DefCollectorErrorKind::TraitNotFound { trait_path: path }), } } + pub(crate) fn resolve_trait_impls( context: &mut Context, traits: Vec, @@ -424,17 +424,6 @@ pub(crate) fn resolve_trait_impls( new_resolver.set_self_type(Some(self_type.clone())); if let Some(trait_id) = maybe_trait_id { - check_methods_signatures( - &mut new_resolver, - &impl_methods, - trait_id, - trait_impl.trait_path.span(), - trait_impl.trait_generics, - trait_impl.generics.len(), - trait_impl.file_id, - errors, - ); - let where_clause = trait_impl .where_clause .into_iter() diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/errors.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/errors.rs index 96d30100d8b..7eacc8eb2d1 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/errors.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/errors.rs @@ -44,7 +44,7 @@ pub enum TypeCheckError { #[error("Expected type {expected} is not the same as {actual}")] TypeMismatchWithSource { expected: Type, actual: Type, span: Span, source: Source }, #[error("Expected {expected:?} found {found:?}")] - ArityMisMatch { expected: u16, found: u16, span: Span }, + ArityMisMatch { expected: usize, found: usize, span: Span }, #[error("Return type in a function cannot be public")] PublicReturnType { typ: Type, span: Span }, #[error("Cannot cast type {from}, 'as' is only for primitive field or integer types")] @@ -53,8 +53,10 @@ pub enum TypeCheckError { ExpectedFunction { found: Type, span: Span }, #[error("Type {lhs_type} has no member named {field_name}")] AccessUnknownMember { lhs_type: Type, field_name: String, span: Span }, - #[error("Function expects {expected} parameters but {found} given")] + #[error("Function expects {expected} parameters but {found} were given")] ParameterCountMismatch { expected: usize, found: usize, span: Span }, + #[error("{item} expects {expected} generics but {found} were given")] + GenericCountMismatch { item: String, expected: usize, found: usize, span: Span }, #[error("Only integer and Field types may be casted to")] UnsupportedCast { span: Span }, #[error("Index {index} is out of bounds for this tuple {lhs_type} of length {length}")] @@ -122,6 +124,16 @@ pub enum TypeCheckError { ConstrainedReferenceToUnconstrained { span: Span }, #[error("Slices cannot be returned from an unconstrained runtime to a constrained runtime")] UnconstrainedSliceReturnToConstrained { span: Span }, + #[error("Only sized types may be used in the entry point to a program")] + InvalidTypeForEntryPoint { span: Span }, + #[error("Mismatched number of parameters in trait implementation")] + MismatchTraitImplNumParameters { + actual_num_parameters: usize, + expected_num_parameters: usize, + trait_name: String, + method_name: String, + span: Span, + }, } impl TypeCheckError { @@ -191,6 +203,12 @@ impl From for Diagnostic { let msg = format!("Function expects {expected} parameter{empty_or_s} but {found} {was_or_were} given"); Diagnostic::simple_error(msg, String::new(), span) } + TypeCheckError::GenericCountMismatch { item, expected, found, span } => { + let empty_or_s = if expected == 1 { "" } else { "s" }; + let was_or_were = if found == 1 { "was" } else { "were" }; + let msg = format!("{item} expects {expected} generic{empty_or_s} but {found} {was_or_were} given"); + Diagnostic::simple_error(msg, String::new(), span) + } TypeCheckError::InvalidCast { span, .. } | TypeCheckError::ExpectedFunction { span, .. } | TypeCheckError::AccessUnknownMember { span, .. } @@ -284,6 +302,21 @@ impl From for Diagnostic { let msg = format!("Constraint for `{typ}: {trait_name}` is not needed, another matching impl is already in scope"); Diagnostic::simple_warning(msg, "Unnecessary trait constraint in where clause".into(), span) } + TypeCheckError::InvalidTypeForEntryPoint { span } => Diagnostic::simple_error( + "Only sized types may be used in the entry point to a program".to_string(), + "Slices, references, or any type containing them may not be used in main or a contract function".to_string(), span), + TypeCheckError::MismatchTraitImplNumParameters { + expected_num_parameters, + actual_num_parameters, + trait_name, + method_name, + span, + } => { + let plural = if expected_num_parameters == 1 { "" } else { "s" }; + let primary_message = format!( + "`{trait_name}::{method_name}` expects {expected_num_parameters} parameter{plural}, but this method has {actual_num_parameters}"); + Diagnostic::simple_error(primary_message, "".to_string(), span) + } } } } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/expr.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/expr.rs index 7b854e58fca..7219f4d09c6 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/expr.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/expr.rs @@ -863,7 +863,13 @@ impl<'interner> TypeChecker<'interner> { span: op.location.span, }); - self.comparator_operand_type_rules(x_type, y_type, op, span) + let (_, use_impl) = self.comparator_operand_type_rules(x_type, y_type, op, span)?; + + // If the size is not constant, we must fall back to a user-provided impl for + // equality on slices. + let size = x_size.follow_bindings(); + let use_impl = use_impl || size.evaluate_to_u64().is_none(); + Ok((Bool, use_impl)) } (String(x_size), String(y_size)) => { @@ -1034,9 +1040,9 @@ impl<'interner> TypeChecker<'interner> { } ret } + // ignoring env for subtype on purpose Type::Function(parameters, ret, _env) => { - // ignoring env for subtype on purpose - self.bind_function_type_impl(parameters.as_ref(), ret.as_ref(), args.as_ref(), span) + self.bind_function_type_impl(¶meters, &ret, &args, span) } Type::Error => Type::Error, found => { diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/mod.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/mod.rs index 21d1c75a0f2..ab759f454e5 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/mod.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/mod.rs @@ -12,11 +12,17 @@ mod expr; mod stmt; pub use errors::TypeCheckError; +use noirc_errors::Span; use crate::{ - hir_def::{expr::HirExpression, stmt::HirStatement, traits::TraitConstraint}, + hir_def::{ + expr::HirExpression, + function::{Param, Parameters}, + stmt::HirStatement, + traits::TraitConstraint, + }, node_interner::{ExprId, FuncId, GlobalId, NodeInterner}, - Type, + Type, TypeBindings, }; use self::errors::Source; @@ -74,6 +80,7 @@ pub fn type_check_func(interner: &mut NodeInterner, func_id: FuncId) -> Vec Vec, + func_id: FuncId, + param: &Param, + errors: &mut Vec, +) { + let meta = type_checker.interner.function_meta(&func_id); + if meta.is_entry_point && !param.1.is_valid_for_program_input() { + let span = param.0.span(); + errors.push(TypeCheckError::InvalidTypeForEntryPoint { span }); + } +} + fn function_info(interner: &NodeInterner, function_body_id: &ExprId) -> (noirc_errors::Span, bool) { let (expr_span, empty_function) = if let HirExpression::Block(block) = interner.expression(function_body_id) { @@ -162,6 +185,154 @@ fn function_info(interner: &NodeInterner, function_body_id: &ExprId) -> (noirc_e (expr_span, empty_function) } +/// Checks that the type of a function in a trait impl matches the type +/// of the corresponding function declaration in the trait itself. +/// +/// To do this, given a trait such as: +/// `trait Foo { fn foo(...); }` +/// +/// And an impl such as: +/// `impl Foo for Bar { fn foo(...); } ` +/// +/// We have to substitute: +/// - Self for Bar +/// - A for D +/// - B for F +/// +/// Before we can type check. Finally, we must also check that the unification +/// result does not introduce any new bindings. This can happen if the impl +/// function's type is more general than that of the trait function. E.g. +/// `fn baz(a: A, b: B)` when the impl required `fn baz(a: A, b: A)`. +/// +/// This does not type check the body of the impl function. +pub(crate) fn check_trait_impl_method_matches_declaration( + interner: &mut NodeInterner, + function: FuncId, +) -> Vec { + let meta = interner.function_meta(&function); + let method_name = interner.function_name(&function); + let mut errors = Vec::new(); + + let definition_type = meta.typ.as_monotype(); + + let impl_ = + meta.trait_impl.expect("Trait impl function should have a corresponding trait impl"); + let impl_ = interner.get_trait_implementation(impl_); + let impl_ = impl_.borrow(); + let trait_info = interner.get_trait(impl_.trait_id); + + let mut bindings = TypeBindings::new(); + bindings.insert( + trait_info.self_type_typevar_id, + (trait_info.self_type_typevar.clone(), impl_.typ.clone()), + ); + + if trait_info.generics.len() != impl_.trait_generics.len() { + let expected = trait_info.generics.len(); + let found = impl_.trait_generics.len(); + let span = impl_.ident.span(); + let item = trait_info.name.to_string(); + errors.push(TypeCheckError::GenericCountMismatch { item, expected, found, span }); + } + + // Substitute each generic on the trait with the corresponding generic on the impl + for (generic, arg) in trait_info.generics.iter().zip(&impl_.trait_generics) { + bindings.insert(generic.id(), (generic.clone(), arg.clone())); + } + + // If this is None, the trait does not have the corresponding function. + // This error should have been caught in name resolution already so we don't + // issue an error for it here. + if let Some(trait_fn_id) = trait_info.method_ids.get(method_name) { + let trait_fn_meta = interner.function_meta(trait_fn_id); + + if trait_fn_meta.direct_generics.len() != meta.direct_generics.len() { + let expected = trait_fn_meta.direct_generics.len(); + let found = meta.direct_generics.len(); + let span = meta.name.location.span; + let item = method_name.to_string(); + errors.push(TypeCheckError::GenericCountMismatch { item, expected, found, span }); + } + + // Substitute each generic on the trait function with the corresponding generic on the impl function + for ((_, trait_fn_generic), (name, impl_fn_generic)) in + trait_fn_meta.direct_generics.iter().zip(&meta.direct_generics) + { + let arg = Type::NamedGeneric(impl_fn_generic.clone(), name.clone()); + bindings.insert(trait_fn_generic.id(), (trait_fn_generic.clone(), arg)); + } + + let (declaration_type, _) = trait_fn_meta.typ.instantiate_with_bindings(bindings, interner); + + check_function_type_matches_expected_type( + &declaration_type, + definition_type, + method_name, + &meta.parameters, + meta.name.location.span, + &trait_info.name.0.contents, + &mut errors, + ); + } + + errors +} + +fn check_function_type_matches_expected_type( + expected: &Type, + actual: &Type, + method_name: &str, + actual_parameters: &Parameters, + span: Span, + trait_name: &str, + errors: &mut Vec, +) { + let mut bindings = TypeBindings::new(); + // Shouldn't need to unify envs, they should always be equal since they're both free functions + if let (Type::Function(params_a, ret_a, _env_a), Type::Function(params_b, ret_b, _env_b)) = + (expected, actual) + { + if params_a.len() == params_b.len() { + for (i, (a, b)) in params_a.iter().zip(params_b.iter()).enumerate() { + if a.try_unify(b, &mut bindings).is_err() { + errors.push(TypeCheckError::TraitMethodParameterTypeMismatch { + method_name: method_name.to_string(), + expected_typ: a.to_string(), + actual_typ: b.to_string(), + parameter_span: actual_parameters.0[i].0.span(), + parameter_index: i + 1, + }); + } + } + + if ret_b.try_unify(ret_a, &mut bindings).is_err() { + errors.push(TypeCheckError::TypeMismatch { + expected_typ: ret_a.to_string(), + expr_typ: ret_b.to_string(), + expr_span: span, + }); + } + } else { + errors.push(TypeCheckError::MismatchTraitImplNumParameters { + actual_num_parameters: params_b.len(), + expected_num_parameters: params_a.len(), + trait_name: trait_name.to_string(), + method_name: method_name.to_string(), + span, + }); + } + } + + // If result bindings is not empty, a type variable was bound which means the two + // signatures were not a perfect match. Note that this relies on us already binding + // all the expected generics to each other prior to this check. + if !bindings.is_empty() { + let expected_typ = expected.to_string(); + let expr_typ = actual.to_string(); + errors.push(TypeCheckError::TypeMismatch { expected_typ, expr_typ, expr_span: span }); + } +} + impl<'interner> TypeChecker<'interner> { fn new(interner: &'interner mut NodeInterner) -> Self { Self { interner, errors: Vec::new(), trait_constraints: Vec::new(), current_function: None } @@ -329,6 +500,8 @@ mod test { trait_impl: None, return_type: FunctionReturnType::Default(Span::default()), trait_constraints: Vec::new(), + direct_generics: Vec::new(), + is_entry_point: true, }; interner.push_fn_meta(func_meta, func_id); diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir_def/function.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir_def/function.rs index d3ab2a9393b..56543e8185c 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir_def/function.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir_def/function.rs @@ -1,12 +1,14 @@ use iter_extended::vecmap; use noirc_errors::{Location, Span}; +use std::rc::Rc; + use super::expr::{HirBlockExpression, HirExpression, HirIdent}; use super::stmt::HirPattern; use super::traits::TraitConstraint; use crate::node_interner::{ExprId, NodeInterner, TraitImplId}; use crate::FunctionKind; -use crate::{Distinctness, FunctionReturnType, Type, Visibility}; +use crate::{Distinctness, FunctionReturnType, Type, TypeVariable, Visibility}; /// A Hir function is a block expression /// with a list of statements @@ -103,6 +105,12 @@ pub struct FuncMeta { /// or a Type::Forall for generic functions. pub typ: Type, + /// The set of generics that are declared directly on this function in the source code. + /// This does not include generics from an outer scope, like those introduced by + /// an `impl` block. This also does not include implicit generics added by the compiler + /// such as a trait's `Self` type variable. + pub direct_generics: Vec<(Rc, TypeVariable)>, + pub location: Location, // This flag is needed for the attribute check pass @@ -112,6 +120,10 @@ pub struct FuncMeta { /// The trait impl this function belongs to, if any pub trait_impl: Option, + + /// True if this function is an entry point to the program. + /// For non-contracts, this means the function is `main`. + pub is_entry_point: bool, } impl FuncMeta { diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir_def/types.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir_def/types.rs index b70aa43701c..5ab036eef5b 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir_def/types.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir_def/types.rs @@ -703,10 +703,10 @@ impl Type { | Type::TraitAsType(..) | Type::NotConstant => false, - // This function is called during name resolution before we've verified aliases - // are not cyclic. As a result, it wouldn't be safe to check this alias' definition - // to see if the aliased type is valid. - Type::Alias(..) => false, + Type::Alias(alias, generics) => { + let alias = alias.borrow(); + alias.get_type(generics).is_valid_for_program_input() + } Type::Array(length, element) => { length.is_valid_for_program_input() && element.is_valid_for_program_input() @@ -1768,9 +1768,11 @@ impl From<&Type> for PrintableType { Type::TypeVariable(_, _) => unreachable!(), Type::NamedGeneric(..) => unreachable!(), Type::Forall(..) => unreachable!(), - Type::Function(_, _, env) => { - PrintableType::Function { env: Box::new(env.as_ref().into()) } - } + Type::Function(arguments, return_type, env) => PrintableType::Function { + arguments: arguments.iter().map(|arg| arg.into()).collect(), + return_type: Box::new(return_type.as_ref().into()), + env: Box::new(env.as_ref().into()), + }, Type::MutableReference(typ) => { PrintableType::MutableReference { typ: Box::new(typ.as_ref().into()) } } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/lib.rs b/noir/noir-repo/compiler/noirc_frontend/src/lib.rs index 30b221a2788..1871b594ae7 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/lib.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/lib.rs @@ -56,14 +56,13 @@ pub mod macros_api { pub use crate::hir::def_map::ModuleDefId; pub use crate::{ hir::Context as HirContext, BlockExpression, CallExpression, CastExpression, Distinctness, - Expression, ExpressionKind, FunctionReturnType, Ident, IndexExpression, LetStatement, - Literal, MemberAccessExpression, MethodCallExpression, NoirFunction, Path, PathKind, - Pattern, Statement, UnresolvedType, UnresolvedTypeData, Visibility, + Expression, ExpressionKind, FunctionReturnType, Ident, IndexExpression, ItemVisibility, + LetStatement, Literal, MemberAccessExpression, MethodCallExpression, NoirFunction, Path, + PathKind, Pattern, Statement, UnresolvedType, UnresolvedTypeData, Visibility, }; pub use crate::{ - ArrayLiteral, ForLoopStatement, ForRange, FunctionDefinition, FunctionVisibility, - ImportStatement, NoirStruct, Param, PrefixExpression, Signedness, StatementKind, - StructType, Type, TypeImpl, UnaryOp, + ForLoopStatement, ForRange, FunctionDefinition, ImportStatement, NoirStruct, Param, + PrefixExpression, Signedness, StatementKind, StructType, Type, TypeImpl, UnaryOp, }; /// Methods to process the AST before and after type checking diff --git a/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/ast.rs b/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/ast.rs index e4e619d5d92..7fcf8e87792 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/ast.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/ast.rs @@ -1,7 +1,7 @@ use acvm::FieldElement; use iter_extended::vecmap; use noirc_errors::{ - debug_info::{DebugTypes, DebugVariables}, + debug_info::{DebugFunctions, DebugTypes, DebugVariables}, Location, }; @@ -253,6 +253,7 @@ pub struct Program { /// Indicates to a backend whether a SNARK-friendly prover should be used. pub recursive: bool, pub debug_variables: DebugVariables, + pub debug_functions: DebugFunctions, pub debug_types: DebugTypes, } @@ -266,6 +267,7 @@ impl Program { return_visibility: Visibility, recursive: bool, debug_variables: DebugVariables, + debug_functions: DebugFunctions, debug_types: DebugTypes, ) -> Program { Program { @@ -276,6 +278,7 @@ impl Program { return_visibility, recursive, debug_variables, + debug_functions, debug_types, } } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/debug.rs b/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/debug.rs index a8ff4399f99..cf4e0ab792e 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/debug.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/debug.rs @@ -76,7 +76,7 @@ impl<'interner> Monomorphizer<'interner> { let var_type = self.interner.id_type(call.arguments[DEBUG_VALUE_ARG_SLOT]); let source_var_id = source_var_id.to_u128().into(); // then update the ID used for tracking at runtime - let var_id = self.debug_type_tracker.insert_var(source_var_id, var_type); + let var_id = self.debug_type_tracker.insert_var(source_var_id, &var_type); let interned_var_id = self.intern_var_id(var_id, &call.location); arguments[DEBUG_VAR_ID_ARG_SLOT] = self.expr(interned_var_id)?; Ok(()) diff --git a/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/debug_types.rs b/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/debug_types.rs index fea073d394f..16b82d1e7b9 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/debug_types.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/debug_types.rs @@ -3,7 +3,8 @@ use crate::{ hir_def::types::Type, }; use noirc_errors::debug_info::{ - DebugTypeId, DebugTypes, DebugVarId, DebugVariable, DebugVariables, + DebugFnId, DebugFunction, DebugFunctions, DebugTypeId, DebugTypes, DebugVarId, DebugVariable, + DebugVariables, }; use noirc_printable_type::PrintableType; use std::collections::HashMap; @@ -30,7 +31,10 @@ pub struct DebugTypeTracker { // All instances of tracked variables variables: HashMap, - // Types of tracked variables + // Function metadata collected during instrumentation injection + functions: HashMap, + + // Types of tracked variables and functions types: HashMap, types_reverse: HashMap, @@ -43,34 +47,29 @@ impl DebugTypeTracker { DebugTypeTracker { source_variables: instrumenter.variables.clone(), source_field_names: instrumenter.field_names.clone(), + functions: instrumenter.functions.clone(), ..DebugTypeTracker::default() } } - pub fn extract_vars_and_types(&self) -> (DebugVariables, DebugTypes) { + pub fn extract_vars_and_types(&self) -> (DebugVariables, DebugFunctions, DebugTypes) { let debug_variables = self .variables .clone() .into_iter() .map(|(var_id, (source_var_id, type_id))| { - ( - var_id, - DebugVariable { - name: self.source_variables.get(&source_var_id).cloned().unwrap_or_else( - || { - unreachable!( - "failed to retrieve variable name for {source_var_id:?}" - ); - }, - ), - debug_type_id: type_id, - }, - ) + let var_name = + self.source_variables.get(&source_var_id).cloned().unwrap_or_else(|| { + unreachable!("failed to retrieve variable name for {source_var_id:?}"); + }); + (var_id, DebugVariable { name: var_name, debug_type_id: type_id }) }) .collect(); + + let debug_functions = self.functions.clone().into_iter().collect(); let debug_types = self.types.clone().into_iter().collect(); - (debug_variables, debug_types) + (debug_variables, debug_functions, debug_types) } pub fn resolve_field_index( @@ -83,19 +82,24 @@ impl DebugTypeTracker { .and_then(|field_name| get_field(cursor_type, field_name)) } - pub fn insert_var(&mut self, source_var_id: SourceVarId, var_type: Type) -> DebugVarId { - if !self.source_variables.contains_key(&source_var_id) { - unreachable!("cannot find source debug variable {source_var_id:?}"); - } - - let ptype: PrintableType = var_type.follow_bindings().into(); - let type_id = self.types_reverse.get(&ptype).copied().unwrap_or_else(|| { + fn insert_type(&mut self, the_type: &Type) -> DebugTypeId { + let ptype: PrintableType = the_type.follow_bindings().into(); + self.types_reverse.get(&ptype).copied().unwrap_or_else(|| { let type_id = DebugTypeId(self.next_type_id); self.next_type_id += 1; self.types_reverse.insert(ptype.clone(), type_id); self.types.insert(type_id, ptype); type_id - }); + }) + } + + pub fn insert_var(&mut self, source_var_id: SourceVarId, var_type: &Type) -> DebugVarId { + if !self.source_variables.contains_key(&source_var_id) { + unreachable!("cannot find source debug variable {source_var_id:?}"); + } + + let type_id = self.insert_type(var_type); + // check if we need to instantiate the var with a new type let existing_var_id = self.source_to_debug_vars.get(&source_var_id).and_then(|var_id| { let (_, existing_type_id) = self.variables.get(var_id).unwrap(); diff --git a/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/mod.rs b/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/mod.rs index 10493154521..4938d33aff9 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/mod.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/mod.rs @@ -165,7 +165,8 @@ pub fn monomorphize_debug( let FuncMeta { return_distinctness, return_visibility, kind, .. } = monomorphizer.interner.function_meta(&main); - let (debug_variables, debug_types) = monomorphizer.debug_type_tracker.extract_vars_and_types(); + let (debug_variables, debug_functions, debug_types) = + monomorphizer.debug_type_tracker.extract_vars_and_types(); let program = Program::new( functions, function_sig, @@ -174,6 +175,7 @@ pub fn monomorphize_debug( *return_visibility, *kind == FunctionKind::Recursive, debug_variables, + debug_functions, debug_types, ); Ok(program) @@ -1688,23 +1690,15 @@ impl<'interner> Monomorphizer<'interner> { } fn unwrap_tuple_type(typ: &HirType) -> Vec { - match typ { + match typ.follow_bindings() { HirType::Tuple(fields) => fields.clone(), - HirType::TypeVariable(binding, TypeVariableKind::Normal) => match &*binding.borrow() { - TypeBinding::Bound(binding) => unwrap_tuple_type(binding), - TypeBinding::Unbound(_) => unreachable!(), - }, other => unreachable!("unwrap_tuple_type: expected tuple, found {:?}", other), } } fn unwrap_struct_type(typ: &HirType) -> Vec<(String, HirType)> { - match typ { - HirType::Struct(def, args) => def.borrow().get_fields(args), - HirType::TypeVariable(binding, TypeVariableKind::Normal) => match &*binding.borrow() { - TypeBinding::Bound(binding) => unwrap_struct_type(binding), - TypeBinding::Unbound(_) => unreachable!(), - }, + match typ.follow_bindings() { + HirType::Struct(def, args) => def.borrow().get_fields(&args), other => unreachable!("unwrap_struct_type: expected struct, found {:?}", other), } } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/node_interner.rs b/noir/noir-repo/compiler/noirc_frontend/src/node_interner.rs index 5aab683aff3..b83d2008530 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/node_interner.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/node_interner.rs @@ -28,8 +28,8 @@ use crate::hir_def::{ }; use crate::token::{Attributes, SecondaryAttribute}; use crate::{ - BinaryOpKind, FunctionDefinition, FunctionVisibility, Generics, Shared, TypeAlias, - TypeBindings, TypeVariable, TypeVariableId, TypeVariableKind, + BinaryOpKind, FunctionDefinition, Generics, ItemVisibility, Shared, TypeAlias, TypeBindings, + TypeVariable, TypeVariableId, TypeVariableKind, }; /// An arbitrary number to limit the recursion depth when searching for trait impls. @@ -236,7 +236,7 @@ pub struct FunctionModifiers { pub name: String, /// Whether the function is `pub` or not. - pub visibility: FunctionVisibility, + pub visibility: ItemVisibility, pub attributes: Attributes, @@ -250,7 +250,7 @@ impl FunctionModifiers { pub fn new() -> Self { Self { name: String::new(), - visibility: FunctionVisibility::Public, + visibility: ItemVisibility::Public, attributes: Attributes::empty(), is_unconstrained: false, } @@ -782,7 +782,7 @@ impl NodeInterner { /// /// The underlying function_visibilities map is populated during def collection, /// so this function can be called anytime afterward. - pub fn function_visibility(&self, func: FuncId) -> FunctionVisibility { + pub fn function_visibility(&self, func: FuncId) -> ItemVisibility { self.function_modifiers[&func].visibility } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/parser/mod.rs b/noir/noir-repo/compiler/noirc_frontend/src/parser/mod.rs index 0ff7819c00f..ea96dee8a47 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/parser/mod.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/parser/mod.rs @@ -14,8 +14,8 @@ mod parser; use crate::token::{Keyword, Token}; use crate::{ast::ImportStatement, Expression, NoirStruct}; use crate::{ - Ident, LetStatement, NoirFunction, NoirTrait, NoirTraitImpl, NoirTypeAlias, Recoverable, - StatementKind, TypeImpl, UseTree, + Ident, LetStatement, ModuleDeclaration, NoirFunction, NoirTrait, NoirTraitImpl, NoirTypeAlias, + Recoverable, StatementKind, TypeImpl, UseTree, }; use chumsky::prelude::*; @@ -28,7 +28,7 @@ pub use parser::parse_program; #[derive(Debug, Clone)] pub(crate) enum TopLevelStatement { Function(NoirFunction), - Module(Ident), + Module(ModuleDeclaration), Import(UseTree), Struct(NoirStruct), Trait(NoirTrait), @@ -220,7 +220,7 @@ pub struct SortedModule { pub globals: Vec, /// Module declarations like `mod foo;` - pub module_decls: Vec, + pub module_decls: Vec, /// Full submodules as in `mod foo { ... definitions ... }` pub submodules: Vec, @@ -229,7 +229,7 @@ pub struct SortedModule { impl std::fmt::Display for SortedModule { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { for decl in &self.module_decls { - writeln!(f, "mod {decl};")?; + writeln!(f, "{decl};")?; } for import in &self.imports { @@ -309,7 +309,7 @@ pub enum ItemKind { Impl(TypeImpl), TypeAlias(NoirTypeAlias), Global(LetStatement), - ModuleDecl(Ident), + ModuleDecl(ModuleDeclaration), Submodules(ParsedSubModule), } @@ -380,8 +380,8 @@ impl SortedModule { self.imports.extend(import_stmt.desugar(None)); } - fn push_module_decl(&mut self, mod_name: Ident) { - self.module_decls.push(mod_name); + fn push_module_decl(&mut self, mod_decl: ModuleDeclaration) { + self.module_decls.push(mod_decl); } fn push_submodule(&mut self, submodule: SortedSubModule) { @@ -474,7 +474,7 @@ impl std::fmt::Display for TopLevelStatement { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { TopLevelStatement::Function(fun) => fun.fmt(f), - TopLevelStatement::Module(m) => write!(f, "mod {m}"), + TopLevelStatement::Module(m) => m.fmt(f), TopLevelStatement::Import(tree) => write!(f, "use {tree}"), TopLevelStatement::Trait(t) => t.fmt(f), TopLevelStatement::TraitImpl(i) => i.fmt(f), diff --git a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser.rs b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser.rs index 75f4a6359bf..383a1ffafc9 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser.rs @@ -40,9 +40,9 @@ use crate::parser::{force, ignore_then_commit, statement_recovery}; use crate::token::{Keyword, Token, TokenKind}; use crate::{ BinaryOp, BinaryOpKind, BlockExpression, Distinctness, ForLoopStatement, ForRange, - FunctionReturnType, Ident, IfExpression, InfixExpression, LValue, Literal, NoirTypeAlias, - Param, Path, Pattern, Recoverable, Statement, TraitBound, TypeImpl, UnresolvedTraitConstraint, - UnresolvedTypeExpression, UseTree, UseTreeKind, Visibility, + FunctionReturnType, Ident, IfExpression, InfixExpression, LValue, Literal, ModuleDeclaration, + NoirTypeAlias, Param, Path, Pattern, Recoverable, Statement, TraitBound, TypeImpl, + UnresolvedTraitConstraint, UnresolvedTypeExpression, UseTree, UseTreeKind, Visibility, }; use chumsky::prelude::*; @@ -370,7 +370,9 @@ fn optional_type_annotation<'a>() -> impl NoirParser + 'a { } fn module_declaration() -> impl NoirParser { - keyword(Keyword::Mod).ignore_then(ident()).map(TopLevelStatement::Module) + keyword(Keyword::Mod) + .ignore_then(ident()) + .map(|ident| TopLevelStatement::Module(ModuleDeclaration { ident })) } fn use_statement() -> impl NoirParser { diff --git a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/function.rs b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/function.rs index a26df542076..7c365e7eb5a 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/function.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/function.rs @@ -8,7 +8,7 @@ use crate::parser::labels::ParsingRuleLabel; use crate::parser::spanned; use crate::token::{Keyword, Token}; use crate::{ - Distinctness, FunctionDefinition, FunctionReturnType, FunctionVisibility, Ident, NoirFunction, + Distinctness, FunctionDefinition, FunctionReturnType, Ident, ItemVisibility, NoirFunction, Param, Visibility, }; @@ -50,24 +50,24 @@ pub(super) fn function_definition(allow_self: bool) -> impl NoirParser impl NoirParser { +fn visibility_modifier() -> impl NoirParser { let is_pub_crate = (keyword(Keyword::Pub) .then_ignore(just(Token::LeftParen)) .then_ignore(keyword(Keyword::Crate)) .then_ignore(just(Token::RightParen))) - .map(|_| FunctionVisibility::PublicCrate); + .map(|_| ItemVisibility::PublicCrate); - let is_pub = keyword(Keyword::Pub).map(|_| FunctionVisibility::Public); + let is_pub = keyword(Keyword::Pub).map(|_| ItemVisibility::Public); - let is_private = empty().map(|_| FunctionVisibility::Private); + let is_private = empty().map(|_| ItemVisibility::Private); choice((is_pub_crate, is_pub, is_private)) } /// function_modifiers: 'unconstrained'? (visibility)? /// -/// returns (is_unconstrained, visibility) for whether each keyword was present -fn function_modifiers() -> impl NoirParser<(bool, FunctionVisibility)> { +/// returns (is_unconstrained, visibility, is_open) for whether each keyword was present +fn function_modifiers() -> impl NoirParser<(bool, ItemVisibility)> { keyword(Keyword::Unconstrained) .or_not() .then(visibility_modifier()) diff --git a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/traits.rs b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/traits.rs index 4f46be83b7c..1e2a6b4d65d 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/traits.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/traits.rs @@ -11,7 +11,7 @@ use crate::{ ParserErrorReason, TopLevelStatement, }, token::{Keyword, Token}, - Expression, FunctionVisibility, NoirTrait, NoirTraitImpl, TraitBound, TraitImplItem, TraitItem, + Expression, ItemVisibility, NoirTrait, NoirTraitImpl, TraitBound, TraitImplItem, TraitItem, UnresolvedTraitConstraint, UnresolvedType, }; @@ -120,11 +120,11 @@ pub(super) fn trait_implementation() -> impl NoirParser { fn trait_implementation_body() -> impl NoirParser> { let function = function::function_definition(true).validate(|mut f, span, emit| { - if f.def().is_unconstrained || f.def().visibility != FunctionVisibility::Private { + if f.def().is_unconstrained || f.def().visibility != ItemVisibility::Private { emit(ParserError::with_reason(ParserErrorReason::TraitImplFunctionModifiers, span)); } // Trait impl functions are always public - f.def_mut().visibility = FunctionVisibility::Public; + f.def_mut().visibility = ItemVisibility::Public; TraitImplItem::Function(f) }); diff --git a/noir/noir-repo/compiler/noirc_frontend/src/tests.rs b/noir/noir-repo/compiler/noirc_frontend/src/tests.rs index f8f333d4b2b..3f78bd43ba9 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/tests.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/tests.rs @@ -81,7 +81,7 @@ mod test { &mut context, program.clone().into_sorted(), root_file_id, - &Vec::new(), // No macro processors + &[], // No macro processors )); } (program, context, errors) @@ -535,15 +535,13 @@ mod test { assert!(errors.len() == 1, "Expected 1 error, got: {:?}", errors); for (err, _file_id) in errors { match &err { - CompilationError::DefinitionError( - DefCollectorErrorKind::MismatchTraitImplementationNumParameters { - actual_num_parameters, - expected_num_parameters, - trait_name, - method_name, - .. - }, - ) => { + CompilationError::TypeError(TypeCheckError::MismatchTraitImplNumParameters { + actual_num_parameters, + expected_num_parameters, + trait_name, + method_name, + .. + }) => { assert_eq!(actual_num_parameters, &1_usize); assert_eq!(expected_num_parameters, &2_usize); assert_eq!(method_name, "default"); @@ -1206,4 +1204,13 @@ fn lambda$f1(mut env$l1: (Field)) -> Field { "#; assert_eq!(get_program_errors(src).len(), 1); } + + #[test] + fn type_aliases_in_entry_point() { + let src = r#" + type Foo = u8; + fn main(_x: Foo) {} + "#; + assert_eq!(get_program_errors(src).len(), 0); + } } diff --git a/noir/noir-repo/compiler/noirc_printable_type/src/lib.rs b/noir/noir-repo/compiler/noirc_printable_type/src/lib.rs index 24f4f275a14..60f233cd86d 100644 --- a/noir/noir-repo/compiler/noirc_printable_type/src/lib.rs +++ b/noir/noir-repo/compiler/noirc_printable_type/src/lib.rs @@ -33,6 +33,8 @@ pub enum PrintableType { length: u64, }, Function { + arguments: Vec, + return_type: Box, env: Box, }, MutableReference { @@ -176,8 +178,8 @@ fn to_string(value: &PrintableValue, typ: &PrintableType) -> Option { output.push_str("false"); } } - (PrintableValue::Field(_), PrintableType::Function { .. }) => { - output.push_str("<>"); + (PrintableValue::Field(_), PrintableType::Function { arguments, return_type, .. }) => { + output.push_str(&format!("< {:?}>>", arguments, return_type,)); } (_, PrintableType::MutableReference { .. }) => { output.push_str("<>"); @@ -350,7 +352,7 @@ pub fn decode_value( PrintableValue::Struct(struct_map) } - PrintableType::Function { env } => { + PrintableType::Function { env, .. } => { let field_element = field_iterator.next().unwrap(); let func_ref = PrintableValue::Field(field_element); // we want to consume the fields from the environment, but for now they are not actually printed diff --git a/noir/noir-repo/compiler/wasm/package.json b/noir/noir-repo/compiler/wasm/package.json index 67584a2def1..6dfa3215483 100644 --- a/noir/noir-repo/compiler/wasm/package.json +++ b/noir/noir-repo/compiler/wasm/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.24.0", + "version": "0.25.0", "license": "(MIT OR Apache-2.0)", "main": "dist/main.js", "types": "./dist/types/src/index.d.cts", diff --git a/noir/noir-repo/compiler/wasm/src/noir/package.ts b/noir/noir-repo/compiler/wasm/src/noir/package.ts index 81178e6ae96..2856798273a 100644 --- a/noir/noir-repo/compiler/wasm/src/noir/package.ts +++ b/noir/noir-repo/compiler/wasm/src/noir/package.ts @@ -105,7 +105,12 @@ export class Package { handles .filter((handle) => SOURCE_EXTENSIONS.find((ext) => handle.endsWith(ext))) .map(async (file) => { - const suffix = file.replace(this.#srcPath, ''); + // Github deps are directly added to the file manager, which causes them to be missing the absolute path to the source file + // and only include the extraction directory relative to the fm root directory + // This regexp ensures we remove the "real" source path for all dependencies, providing the compiler with what it expects for each source file: + // -> for bin/contract packages + // -> for libs + const suffix = file.replace(new RegExp(`.*${this.#srcPath}`), ''); return { path: this.getType() === 'lib' ? `${alias ? alias : this.#config.package.name}${suffix}` : file, source: (await fm.readFile(file, 'utf-8')).toString(), diff --git a/noir/noir-repo/cspell.json b/noir/noir-repo/cspell.json index a96e3de901a..d961b600f40 100644 --- a/noir/noir-repo/cspell.json +++ b/noir/noir-repo/cspell.json @@ -154,6 +154,8 @@ "sdiv", "secp256k1", "secp256r1", + "Secpk", + "Secpr", "signedness", "signorecello", "smol", diff --git a/noir/noir-repo/deny.toml b/noir/noir-repo/deny.toml index 72150f08a3c..578f8427263 100644 --- a/noir/noir-repo/deny.toml +++ b/noir/noir-repo/deny.toml @@ -2,11 +2,13 @@ # More documentation for the advisories section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html [advisories] -vulnerability = "deny" -unmaintained = "warn" -unsound = "warn" +version = 2 yanked = "warn" -notice = "warn" + +ignore = [ + "RUSTSEC-2020-0168", # mach unmaintained + "RUSTSEC-2020-0016" # net2 unmaintained +] # This section is considered when running `cargo deny check bans`. # More documentation about the 'bans' section can be found here: @@ -32,9 +34,8 @@ skip = [] skip-tree = [] [licenses] -unlicensed = "deny" +version = 2 confidence-threshold = 0.9 -# copyleft = "deny" # List of explicitly allowed licenses # See https://spdx.org/licenses/ for list of possible licenses diff --git a/noir/noir-repo/docs/.markdownlint.json b/noir/noir-repo/docs/.markdownlint.json new file mode 100644 index 00000000000..40896b4542f --- /dev/null +++ b/noir/noir-repo/docs/.markdownlint.json @@ -0,0 +1,3 @@ +{ + "no-missing-space-atx": false +} diff --git a/noir/noir-repo/docs/docs/noir/standard_library/bigint.md b/noir/noir-repo/docs/docs/noir/standard_library/bigint.md new file mode 100644 index 00000000000..7d7931840cf --- /dev/null +++ b/noir/noir-repo/docs/docs/noir/standard_library/bigint.md @@ -0,0 +1,102 @@ +--- +title: Big Integers +description: How to use big integers from Noir standard library +keywords: + [ + Big Integer, + Noir programming language, + Noir libraries, + ] +--- + +The BigInt module in the standard library exposes some class of integers which do not fit (well) into a Noir native field. It implements modulo arithmetic, modulo a 'big' prime number. + +:::note + +The module can currently be considered as `Field`s with fixed modulo sizes used by a set of elliptic curves, in addition to just the native curve. [More work](https://github.com/noir-lang/noir/issues/510) is needed to achieve arbitrarily sized big integers. + +::: + +Currently 6 classes of integers (i.e 'big' prime numbers) are available in the module, namely: + +- BN254 Fq: Bn254Fq +- BN254 Fr: Bn254Fr +- Secp256k1 Fq: Secpk1Fq +- Secp256k1 Fr: Secpk1Fr +- Secp256r1 Fr: Secpr1Fr +- Secp256r1 Fq: Secpr1Fq + +Where XXX Fq and XXX Fr denote respectively the order of the base and scalar field of the (usual) elliptic curve XXX. +For instance the big integer 'Secpk1Fq' in the standard library refers to integers modulo $2^{256}-2^{32}-977$. + +Feel free to explore the source code for the other primes: + +#include_code curve_order_base noir_stdlib/src/bigint.nr rust + +## Example usage + +A common use-case is when constructing a big integer from its bytes representation, and performing arithmetic operations on it: + +#include_code big_int_example test_programs/execution_success/bigint/src/main.nr rust + +## Methods + +The available operations for each big integer are: + +### from_le_bytes + +Construct a big integer from its little-endian bytes representation. Example: + +```rust + let a = Secpk1Fq::from_le_bytes([x, y, 0, 45, 2]); + ``` + +Sure, here's the formatted version of the remaining methods: + +### to_le_bytes + +Return the little-endian bytes representation of a big integer. Example: + +```rust +let bytes = a.to_le_bytes(); +``` + +### add + +Add two big integers. Example: + +```rust +let sum = a + b; +``` + +### sub + +Subtract two big integers. Example: + +```rust +let difference = a - b; +``` + +### mul + +Multiply two big integers. Example: + +```rust +let product = a * b; +``` + +### div + +Divide two big integers. Note that division is field division and not euclidean division. Example: + +```rust +let quotient = a / b; +``` + +### eq + +Compare two big integers. Example: + +```rust +let are_equal = a == b; +``` diff --git a/noir/noir-repo/docs/docs/noir/standard_library/containers/hashmap.md b/noir/noir-repo/docs/docs/noir/standard_library/containers/hashmap.md new file mode 100644 index 00000000000..093b6d38d11 --- /dev/null +++ b/noir/noir-repo/docs/docs/noir/standard_library/containers/hashmap.md @@ -0,0 +1,270 @@ +--- +title: HashMap +keywords: [noir, map, hash, hashmap] +sidebar_position: 1 +--- + +`HashMap` is used to efficiently store and look up key-value pairs. + +`HashMap` is a bounded type which can store anywhere from zero to `MaxLen` total elements. +Note that due to hash collisions, the actual maximum number of elements stored by any particular +hashmap is likely lower than `MaxLen`. This is true even with cryptographic hash functions since +every hash value will be performed modulo `MaxLen`. + +When creating `HashMap`s, the `MaxLen` generic should always be specified if it is not already +known. Otherwise, the compiler may infer a different value for `MaxLen` (such as zero), which +will likely change the result of the program. This behavior is set to become an error in future +versions instead. + +Example: + +```rust +// Create a mapping from Fields to u32s with a maximum length of 12 +// using a pedersen hash +let mut map: HashMap> = HashMap::default(); + +map.insert(1, 2); +map.insert(3, 4); + +let two = map.get(1).unwrap(); +``` + +## Methods + +### default + +#include_code default noir_stdlib/src/collections/map.nr rust + +Creates a fresh, empty HashMap. + +When using this function, always make sure to specify the maximum size of the hash map. + +This is the same `default` from the `Default` implementation given further below. It is +repeated here for convenience since it is the recommended way to create a hashmap. + +Example: + +#include_code default_example test_programs/execution_success/hashmap/src/main.nr rust + +Because `HashMap` has so many generic arguments that are likely to be the same throughout +your program, it may be helpful to create a type alias: + +#include_code type_alias test_programs/execution_success/hashmap/src/main.nr rust + +### with_hasher + +#include_code with_hasher noir_stdlib/src/collections/map.nr rust + +Creates a hashmap with an existing `BuildHasher`. This can be used to ensure multiple +hashmaps are created with the same hasher instance. + +Example: + +#include_code with_hasher_example test_programs/execution_success/hashmap/src/main.nr rust + +### get + +#include_code get noir_stdlib/src/collections/map.nr rust + +Retrieves a value from the hashmap, returning `Option::none()` if it was not found. + +Example: + +#include_code get_example test_programs/execution_success/hashmap/src/main.nr rust + +### insert + +#include_code insert noir_stdlib/src/collections/map.nr rust + +Inserts a new key-value pair into the map. If the key was already in the map, its +previous value will be overridden with the newly provided one. + +Example: + +#include_code insert_example test_programs/execution_success/hashmap/src/main.nr rust + +### remove + +#include_code remove noir_stdlib/src/collections/map.nr rust + +Removes the given key-value pair from the map. If the key was not already present +in the map, this does nothing. + +Example: + +#include_code remove_example test_programs/execution_success/hashmap/src/main.nr rust + +### is_empty + +#include_code is_empty noir_stdlib/src/collections/map.nr rust + +True if the length of the hash map is empty. + +Example: + +#include_code is_empty_example test_programs/execution_success/hashmap/src/main.nr rust + +### len + +#include_code len noir_stdlib/src/collections/map.nr rust + +Returns the current length of this hash map. + +Example: + +#include_code len_example test_programs/execution_success/hashmap/src/main.nr rust + +### capacity + +#include_code capacity noir_stdlib/src/collections/map.nr rust + +Returns the maximum capacity of this hashmap. This is always equal to the capacity +specified in the hashmap's type. + +Unlike hashmaps in general purpose programming languages, hashmaps in Noir have a +static capacity that does not increase as the map grows larger. Thus, this capacity +is also the maximum possible element count that can be inserted into the hashmap. +Due to hash collisions (modulo the hashmap length), it is likely the actual maximum +element count will be lower than the full capacity. + +Example: + +#include_code capacity_example test_programs/execution_success/hashmap/src/main.nr rust + +### clear + +#include_code clear noir_stdlib/src/collections/map.nr rust + +Clears the hashmap, removing all key-value pairs from it. + +Example: + +#include_code clear_example test_programs/execution_success/hashmap/src/main.nr rust + +### contains_key + +#include_code contains_key noir_stdlib/src/collections/map.nr rust + +True if the hashmap contains the given key. Unlike `get`, this will not also return +the value associated with the key. + +Example: + +#include_code contains_key_example test_programs/execution_success/hashmap/src/main.nr rust + +### entries + +#include_code entries noir_stdlib/src/collections/map.nr rust + +Returns a vector of each key-value pair present in the hashmap. + +The length of the returned vector is always equal to the length of the hashmap. + +Example: + +#include_code entries_example test_programs/execution_success/hashmap/src/main.nr rust + +### keys + +#include_code keys noir_stdlib/src/collections/map.nr rust + +Returns a vector of each key present in the hashmap. + +The length of the returned vector is always equal to the length of the hashmap. + +Example: + +#include_code keys_example test_programs/execution_success/hashmap/src/main.nr rust + +### values + +#include_code values noir_stdlib/src/collections/map.nr rust + +Returns a vector of each value present in the hashmap. + +The length of the returned vector is always equal to the length of the hashmap. + +Example: + +#include_code values_example test_programs/execution_success/hashmap/src/main.nr rust + +### iter_mut + +#include_code iter_mut noir_stdlib/src/collections/map.nr rust + +Iterates through each key-value pair of the HashMap, setting each key-value pair to the +result returned from the given function. + +Note that since keys can be mutated, the HashMap needs to be rebuilt as it is iterated +through. If this is not desired, use `iter_values_mut` if only values need to be mutated, +or `entries` if neither keys nor values need to be mutated. + +The iteration order is left unspecified. As a result, if two keys are mutated to become +equal, which of the two values that will be present for the key in the resulting map is also unspecified. + +Example: + +#include_code iter_mut_example test_programs/execution_success/hashmap/src/main.nr rust + +### iter_keys_mut + +#include_code iter_keys_mut noir_stdlib/src/collections/map.nr rust + +Iterates through the HashMap, mutating each key to the result returned from +the given function. + +Note that since keys can be mutated, the HashMap needs to be rebuilt as it is iterated +through. If only iteration is desired and the keys are not intended to be mutated, +prefer using `entries` instead. + +The iteration order is left unspecified. As a result, if two keys are mutated to become +equal, which of the two values that will be present for the key in the resulting map is also unspecified. + +Example: + +#include_code iter_keys_mut_example test_programs/execution_success/hashmap/src/main.nr rust + +### iter_values_mut + +#include_code iter_values_mut noir_stdlib/src/collections/map.nr rust + +Iterates through the HashMap, applying the given function to each value and mutating the +value to equal the result. This function is more efficient than `iter_mut` and `iter_keys_mut` +because the keys are untouched and the underlying hashmap thus does not need to be reordered. + +Example: + +#include_code iter_values_mut_example test_programs/execution_success/hashmap/src/main.nr rust + +### retain + +#include_code retain noir_stdlib/src/collections/map.nr rust + +Retains only the key-value pairs for which the given function returns true. +Any key-value pairs for which the function returns false will be removed from the map. + +Example: + +#include_code retain_example test_programs/execution_success/hashmap/src/main.nr rust + +## Trait Implementations + +### default + +#include_code default noir_stdlib/src/collections/map.nr rust + +Constructs an empty HashMap. + +Example: + +#include_code default_example test_programs/execution_success/hashmap/src/main.nr rust + +### eq + +#include_code eq noir_stdlib/src/collections/map.nr rust + +Checks if two HashMaps are equal. + +Example: + +#include_code eq_example test_programs/execution_success/hashmap/src/main.nr rust diff --git a/noir/noir-repo/docs/docs/noir/standard_library/cryptographic_primitives/eddsa.mdx b/noir/noir-repo/docs/docs/noir/standard_library/cryptographic_primitives/eddsa.mdx index 99b7f830a20..c2c0624dfad 100644 --- a/noir/noir-repo/docs/docs/noir/standard_library/cryptographic_primitives/eddsa.mdx +++ b/noir/noir-repo/docs/docs/noir/standard_library/cryptographic_primitives/eddsa.mdx @@ -15,6 +15,14 @@ Verifier for EdDSA signatures fn eddsa_poseidon_verify(public_key_x : Field, public_key_y : Field, signature_s: Field, signature_r8_x: Field, signature_r8_y: Field, message: Field) -> bool ``` +It is also possible to specify the hash algorithm used for the signature by using the `eddsa_verify_with_hasher` function with a parameter implementing the Hasher trait. For instance, if you want to use Poseidon2 instead, you can do the following: +```rust +use dep::std::hash::poseidon2::Poseidon2Hasher; + +let mut hasher = Poseidon2Hasher::default(); +eddsa_verify_with_hasher(pub_key_a.x, pub_key_a.y, s_a, r8_a.x, r8_a.y, msg, &mut hasher); +``` + ## eddsa::eddsa_to_pub diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/explainers/explainer-oracle.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/explainers/explainer-oracle.md new file mode 100644 index 00000000000..b84ca5dd986 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/explainers/explainer-oracle.md @@ -0,0 +1,57 @@ +--- +title: Oracles +description: This guide provides an in-depth understanding of how Oracles work in Noir programming. Learn how to use outside calculations in your programs, constrain oracles, and understand their uses and limitations. +keywords: + - Noir Programming + - Oracles + - JSON-RPC + - Foreign Call Handlers + - Constrained Functions + - Blockchain Programming +sidebar_position: 1 +--- + +If you've seen "The Matrix" you may recall "The Oracle" as Gloria Foster smoking cigarettes and baking cookies. While she appears to "know things", she is actually providing a calculation of a pre-determined future. Noir Oracles are similar, in a way. They don't calculate the future (yet), but they allow you to use outside calculations in your programs. + +![matrix oracle prediction](@site/static/img/memes/matrix_oracle.jpeg) + +A Noir program is usually self-contained. You can pass certain inputs to it, and it will generate a deterministic output for those inputs. But what if you wanted to defer some calculation to an outside process or source? + +Oracles are functions that provide this feature. + +## Use cases + +An example usage for Oracles is proving something on-chain. For example, proving that the ETH-USDC quote was below a certain target at a certain block time. Or even making more complex proofs like proving the ownership of an NFT as an anonymous login method. + +Another interesting use case is to defer expensive calculations to be made outside of the Noir program, and then constraining the result; similar to the use of [unconstrained functions](../noir/concepts//unconstrained.md). + +In short, anything that can be constrained in a Noir program but needs to be fetched from an external source is a great candidate to be used in oracles. + +## Constraining oracles + +Just like in The Matrix, Oracles are powerful. But with great power, comes great responsibility. Just because you're using them in a Noir program doesn't mean they're true. Noir has no superpowers. If you want to prove that Portugal won the Euro Cup 2016, you're still relying on potentially untrusted information. + +To give a concrete example, Alice wants to login to the [NounsDAO](https://nouns.wtf/) forum with her username "noir_nouner" by proving she owns a noun without revealing her ethereum address. Her Noir program could have a oracle call like this: + +```rust +#[oracle(getNoun)] +unconstrained fn get_noun(address: Field) -> Field +``` + +This oracle could naively resolve with the number of Nouns she possesses. However, it is useless as a trusted source, as the oracle could resolve to anything Alice wants. In order to make this oracle call actually useful, Alice would need to constrain the response from the oracle, by proving her address and the noun count belongs to the state tree of the contract. + +In short, **Oracles don't prove anything. Your Noir program does.** + +:::danger + +If you don't constrain the return of your oracle, you could be clearly opening an attack vector on your Noir program. Make double-triple sure that the return of an oracle call is constrained! + +::: + +## How to use Oracles + +On CLI, Nargo resolves oracles by making JSON RPC calls, which means it would require an RPC node to be running. + +In JavaScript, NoirJS accepts and resolves arbitrary call handlers (that is, not limited to JSON) as long as they matches the expected types the developer defines. Refer to [Foreign Call Handler](../reference/NoirJS/noir_js/type-aliases/ForeignCallHandler.md) to learn more about NoirJS's call handling. + +If you want to build using oracles, follow through to the [oracle guide](../how_to/how-to-oracles.md) for a simple example on how to do that. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/explainers/explainer-recursion.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/explainers/explainer-recursion.md new file mode 100644 index 00000000000..18846176ca7 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/explainers/explainer-recursion.md @@ -0,0 +1,176 @@ +--- +title: Recursive proofs +description: Explore the concept of recursive proofs in Zero-Knowledge programming. Understand how recursion works in Noir, a language for writing smart contracts on the EVM blockchain. Learn through practical examples like Alice and Bob's guessing game, Charlie's recursive merkle tree, and Daniel's reusable components. Discover how to use recursive proofs to optimize computational resources and improve efficiency. + +keywords: + [ + "Recursive Proofs", + "Zero-Knowledge Programming", + "Noir", + "EVM Blockchain", + "Smart Contracts", + "Recursion in Noir", + "Alice and Bob Guessing Game", + "Recursive Merkle Tree", + "Reusable Components", + "Optimizing Computational Resources", + "Improving Efficiency", + "Verification Key", + "Aggregation", + "Recursive zkSNARK schemes", + "PLONK", + "Proving and Verification Keys" + ] +sidebar_position: 1 +pagination_next: how_to/how-to-recursion +--- + +In programming, we tend to think of recursion as something calling itself. A classic example would be the calculation of the factorial of a number: + +```js +function factorial(n) { + if (n === 0 || n === 1) { + return 1; + } else { + return n * factorial(n - 1); + } +} +``` + +In this case, while `n` is not `1`, this function will keep calling itself until it hits the base case, bubbling up the result on the call stack: + +```md + Is `n` 1? <--------- + /\ / + / \ n = n -1 + / \ / + Yes No -------- +``` + +In Zero-Knowledge, recursion has some similarities. + +It is not a Noir function calling itself, but a proof being used as an input to another circuit. In short, you verify one proof *inside* another proof, returning the proof that both proofs are valid. + +This means that, given enough computational resources, you can prove the correctness of any arbitrary number of proofs in a single proof. This could be useful to design state channels (for which a common example would be [Bitcoin's Lightning Network](https://en.wikipedia.org/wiki/Lightning_Network)), to save on gas costs by settling one proof on-chain, or simply to make business logic less dependent on a consensus mechanism. + +## Examples + +Let us look at some of these examples + +### Alice and Bob - Guessing game + +Alice and Bob are friends, and they like guessing games. They want to play a guessing game online, but for that, they need a trusted third-party that knows both of their secrets and finishes the game once someone wins. + +So, they use zero-knowledge proofs. Alice tries to guess Bob's number, and Bob will generate a ZK proof stating whether she succeeded or failed. + +This ZK proof can go on a smart contract, revealing the winner and even giving prizes. However, this means every turn needs to be verified on-chain. This incurs some cost and waiting time that may simply make the game too expensive or time-consuming to be worth it. + +As a solution, Alice proposes the following: "what if Bob generates his proof, and instead of sending it on-chain, I verify it *within* my own proof before playing my own turn?". + +She can then generate a proof that she verified his proof, and so on. + +```md + Did you fail? <-------------------------- + / \ / + / \ n = n -1 + / \ / + Yes No / + | | / + | | / + | You win / + | / + | / +Generate proof of that / + + / + my own guess ---------------- +``` + +### Charlie - Recursive merkle tree + +Charlie is a concerned citizen, and wants to be sure his vote in an election is accounted for. He votes with a ZK proof, but he has no way of knowing that his ZK proof was included in the total vote count! + +If the vote collector puts all of the votes into a [Merkle tree](https://en.wikipedia.org/wiki/Merkle_tree), everyone can prove the verification of two proofs within one proof, as such: + +```md + abcd + __________|______________ + | | + ab cd + _____|_____ ______|______ + | | | | + alice bob charlie daniel +``` + +Doing this recursively allows us to arrive on a final proof `abcd` which if true, verifies the correctness of all the votes. + +### Daniel - Reusable components + +Daniel has a big circuit and a big headache. A part of his circuit is a setup phase that finishes with some assertions that need to be made. But that section alone takes most of the proving time, and is largely independent of the rest of the circuit. + +He might find it more efficient to generate a proof for that setup phase separately, and verify that proof recursively in the actual business logic section of his circuit. This will allow for parallelization of both proofs, which results in a considerable speedup. + +## What params do I need + +As you can see in the [recursion reference](noir/standard_library/recursion.md), a simple recursive proof requires: + +- The proof to verify +- The Verification Key of the circuit that generated the proof +- A hash of this verification key, as it's needed for some backends +- The public inputs for the proof + +:::info + +Recursive zkSNARK schemes do not necessarily "verify a proof" in the sense that you expect a true or false to be spit out by the verifier. Rather an aggregation object is built over the public inputs. + +So, taking the example of Alice and Bob and their guessing game: + +- Alice makes her guess. Her proof is *not* recursive: it doesn't verify any proof within it! It's just a standard `assert(x != y)` circuit +- Bob verifies Alice's proof and makes his own guess. In this circuit, he doesn't exactly *prove* the verification of Alice's proof. Instead, he *aggregates* his proof to Alice's proof. The actual verification is done when the full proof is verified, for example when using `nargo verify` or through the verifier smart contract. + +We can imagine recursive proofs a [relay race](https://en.wikipedia.org/wiki/Relay_race). The first runner doesn't have to receive the baton from anyone else, as he/she already starts with it. But when his/her turn is over, the next runner needs to receive it, run a bit more, and pass it along. Even though every runner could theoretically verify the baton mid-run (why not? 🏃🔍), only at the end of the race does the referee verify that the whole race is valid. + +::: + +## Some architecture + +As with everything in computer science, there's no one-size-fits all. But there are some patterns that could help understanding and implementing them. To give three examples: + +### Adding some logic to a proof verification + +This would be an approach for something like our guessing game, where proofs are sent back and forth and are verified by each opponent. This circuit would be divided in two sections: + +- A `recursive verification` section, which would be just the call to `std::verify_proof`, and that would be skipped on the first move (since there's no proof to verify) +- A `guessing` section, which is basically the logic part where the actual guessing happens + +In such a situation, and assuming Alice is first, she would skip the first part and try to guess Bob's number. Bob would then verify her proof on the first section of his run, and try to guess Alice's number on the second part, and so on. + +### Aggregating proofs + +In some one-way interaction situations, recursion would allow for aggregation of simple proofs that don't need to be immediately verified on-chain or elsewhere. + +To give a practical example, a barman wouldn't need to verify a "proof-of-age" on-chain every time he serves alcohol to a customer. Instead, the architecture would comprise two circuits: + +- A `main`, non-recursive circuit with some logic +- A `recursive` circuit meant to verify two proofs in one proof + +The customer's proofs would be intermediate, and made on their phones, and the barman could just verify them locally. He would then aggregate them into a final proof sent on-chain (or elsewhere) at the end of the day. + +### Recursively verifying different circuits + +Nothing prevents you from verifying different circuits in a recursive proof, for example: + +- A `circuit1` circuit +- A `circuit2` circuit +- A `recursive` circuit + +In this example, a regulator could verify that taxes were paid for a specific purchase by aggregating both a `payer` circuit (proving that a purchase was made and taxes were paid), and a `receipt` circuit (proving that the payment was received) + +## How fast is it + +At the time of writing, verifying recursive proofs is surprisingly fast. This is because most of the time is spent on generating the verification key that will be used to generate the next proof. So you are able to cache the verification key and reuse it later. + +Currently, Noir JS packages don't expose the functionality of loading proving and verification keys, but that feature exists in the underlying `bb.js` package. + +## How can I try it + +Learn more about using recursion in Nargo and NoirJS in the [how-to guide](../how_to/how-to-recursion.md) and see a full example in [noir-examples](https://github.com/noir-lang/noir-examples). diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/_category_.json new file mode 100644 index 00000000000..5d694210bbf --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/_category_.json @@ -0,0 +1,5 @@ +{ + "position": 0, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/hello_noir/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/hello_noir/_category_.json new file mode 100644 index 00000000000..23b560f610b --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/hello_noir/_category_.json @@ -0,0 +1,5 @@ +{ + "position": 1, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/hello_noir/index.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/hello_noir/index.md new file mode 100644 index 00000000000..743c4d8d634 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/hello_noir/index.md @@ -0,0 +1,142 @@ +--- +title: Creating a Project +description: + Learn how to create and verify your first Noir program using Nargo, a programming language for + zero-knowledge proofs. +keywords: + [ + Nargo, + Noir, + zero-knowledge proofs, + programming language, + create Noir program, + verify Noir program, + step-by-step guide, + ] +sidebar_position: 1 + +--- + +Now that we have installed Nargo, it is time to make our first hello world program! + +## Create a Project Directory + +Noir code can live anywhere on your computer. Let us create a _projects_ folder in the home +directory to house our Noir programs. + +For Linux, macOS, and Windows PowerShell, create the directory and change directory into it by +running: + +```sh +mkdir ~/projects +cd ~/projects +``` + +## Create Our First Nargo Project + +Now that we are in the projects directory, create a new Nargo project by running: + +```sh +nargo new hello_world +``` + +> **Note:** `hello_world` can be any arbitrary project name, we are simply using `hello_world` for +> demonstration. +> +> In production, the common practice is to name the project folder as `circuits` for better +> identifiability when sitting alongside other folders in the codebase (e.g. `contracts`, `scripts`, +> `test`). + +A `hello_world` folder would be created. Similar to Rust, the folder houses _src/main.nr_ and +_Nargo.toml_ which contain the source code and environmental options of your Noir program +respectively. + +### Intro to Noir Syntax + +Let us take a closer look at _main.nr_. The default _main.nr_ generated should look like this: + +```rust +fn main(x : Field, y : pub Field) { + assert(x != y); +} +``` + +The first line of the program specifies the program's inputs: + +```rust +x : Field, y : pub Field +``` + +Program inputs in Noir are private by default (e.g. `x`), but can be labeled public using the +keyword `pub` (e.g. `y`). To learn more about private and public values, check the +[Data Types](../../noir/concepts/data_types/index.md) section. + +The next line of the program specifies its body: + +```rust +assert(x != y); +``` + +The Noir syntax `assert` can be interpreted as something similar to constraints in other zk-contract languages. + +For more Noir syntax, check the [Language Concepts](../../noir/concepts/comments.md) chapter. + +## Build In/Output Files + +Change directory into _hello_world_ and build in/output files for your Noir program by running: + +```sh +cd hello_world +nargo check +``` + +Two additional files would be generated in your project directory: + +_Prover.toml_ houses input values, and _Verifier.toml_ houses public values. + +## Prove Our Noir Program + +Now that the project is set up, we can create a proof of correct execution of our Noir program. + +Fill in input values for execution in the _Prover.toml_ file. For example: + +```toml +x = "1" +y = "2" +``` + +Prove the valid execution of your Noir program: + +```sh +nargo prove +``` + +A new folder _proofs_ would then be generated in your project directory, containing the proof file +`.proof`, where the project name is defined in Nargo.toml. + +The _Verifier.toml_ file would also be updated with the public values computed from program +execution (in this case the value of `y`): + +```toml +y = "0x0000000000000000000000000000000000000000000000000000000000000002" +``` + +> **Note:** Values in _Verifier.toml_ are computed as 32-byte hex values. + +## Verify Our Noir Program + +Once a proof is generated, we can verify correct execution of our Noir program by verifying the +proof file. + +Verify your proof by running: + +```sh +nargo verify +``` + +The verification will complete in silence if it is successful. If it fails, it will log the +corresponding error instead. + +Congratulations, you have now created and verified a proof for your very first Noir program! + +In the [next section](./project_breakdown.md), we will go into more detail on each step performed. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/hello_noir/project_breakdown.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/hello_noir/project_breakdown.md new file mode 100644 index 00000000000..6160a102c6c --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/hello_noir/project_breakdown.md @@ -0,0 +1,199 @@ +--- +title: Project Breakdown +description: + Learn about the anatomy of a Nargo project, including the purpose of the Prover and Verifier TOML + files, and how to prove and verify your program. +keywords: + [Nargo, Nargo project, Prover.toml, Verifier.toml, proof verification, private asset transfer] +sidebar_position: 2 +--- + +This section breaks down our hello world program from the previous section. We elaborate on the project +structure and what the `prove` and `verify` commands did. + +## Anatomy of a Nargo Project + +Upon creating a new project with `nargo new` and building the in/output files with `nargo check` +commands, you would get a minimal Nargo project of the following structure: + + - src + - Prover.toml + - Verifier.toml + - Nargo.toml + +The source directory _src_ holds the source code for your Noir program. By default only a _main.nr_ +file will be generated within it. + +### Prover.toml + +_Prover.toml_ is used for specifying the input values for executing and proving the program. You can specify `toml` files with different names by using the `--prover-name` or `-p` flags, see the [Prover](#provertoml) section below. Optionally you may specify expected output values for prove-time checking as well. + +### Verifier.toml + +_Verifier.toml_ contains public in/output values computed when executing the Noir program. + +### Nargo.toml + +_Nargo.toml_ contains the environmental options of your project. It contains a "package" section and a "dependencies" section. + +Example Nargo.toml: + +```toml +[package] +name = "noir_starter" +type = "bin" +authors = ["Alice"] +compiler_version = "0.9.0" +description = "Getting started with Noir" +entry = "circuit/main.nr" +license = "MIT" + +[dependencies] +ecrecover = {tag = "v0.9.0", git = "https://github.com/colinnielsen/ecrecover-noir.git"} +``` + +Nargo.toml for a [workspace](../../noir/modules_packages_crates/workspaces.md) will look a bit different. For example: + +```toml +[workspace] +members = ["crates/a", "crates/b"] +default-member = "crates/a" +``` + +#### Package section + +The package section defines a number of fields including: + +- `name` (**required**) - the name of the package +- `type` (**required**) - can be "bin", "lib", or "contract" to specify whether its a binary, library or Aztec contract +- `authors` (optional) - authors of the project +- `compiler_version` - specifies the version of the compiler to use. This is enforced by the compiler and follow's [Rust's versioning](https://doc.rust-lang.org/cargo/reference/manifest.html#the-version-field), so a `compiler_version = 0.18.0` will enforce Nargo version 0.18.0, `compiler_version = ^0.18.0` will enforce anything above 0.18.0 but below 0.19.0, etc. For more information, see how [Rust handles these operators](https://docs.rs/semver/latest/semver/enum.Op.html) +- `description` (optional) +- `entry` (optional) - a relative filepath to use as the entry point into your package (overrides the default of `src/lib.nr` or `src/main.nr`) +- `backend` (optional) +- `license` (optional) + +#### Dependencies section + +This is where you will specify any dependencies for your project. See the [Dependencies page](../../noir/modules_packages_crates/dependencies.md) for more info. + +`./proofs/` and `./contract/` directories will not be immediately visible until you create a proof or +verifier contract respectively. + +### main.nr + +The _main.nr_ file contains a `main` method, this method is the entry point into your Noir program. + +In our sample program, _main.nr_ looks like this: + +```rust +fn main(x : Field, y : Field) { + assert(x != y); +} +``` + +The parameters `x` and `y` can be seen as the API for the program and must be supplied by the +prover. Since neither `x` nor `y` is marked as public, the verifier does not supply any inputs, when +verifying the proof. + +The prover supplies the values for `x` and `y` in the _Prover.toml_ file. + +As for the program body, `assert` ensures that the condition to be satisfied (e.g. `x != y`) is +constrained by the proof of the execution of said program (i.e. if the condition was not met, the +verifier would reject the proof as an invalid proof). + +### Prover.toml + +The _Prover.toml_ file is a file which the prover uses to supply his witness values(both private and +public). + +In our hello world program the _Prover.toml_ file looks like this: + +```toml +x = "1" +y = "2" +``` + +When the command `nargo prove` is executed, two processes happen: + +1. Noir creates a proof that `x`, which holds the value of `1`, and `y`, which holds the value of `2`, + is not equal. This inequality constraint is due to the line `assert(x != y)`. + +2. Noir creates and stores the proof of this statement in the _proofs_ directory in a file called your-project.proof. So if your project is named "private_voting" (defined in the project Nargo.toml), the proof will be saved at `./proofs/private_voting.proof`. Opening this file will display the proof in hex format. + +#### Arrays of Structs + +The following code shows how to pass an array of structs to a Noir program to generate a proof. + +```rust +// main.nr +struct Foo { + bar: Field, + baz: Field, +} + +fn main(foos: [Foo; 3]) -> pub Field { + foos[2].bar + foos[2].baz +} +``` + +Prover.toml: + +```toml +[[foos]] # foos[0] +bar = 0 +baz = 0 + +[[foos]] # foos[1] +bar = 0 +baz = 0 + +[[foos]] # foos[2] +bar = 1 +baz = 2 +``` + +#### Custom toml files + +You can specify a `toml` file with a different name to use for proving by using the `--prover-name` or `-p` flags. + +This command looks for proof inputs in the default **Prover.toml** and generates the proof and saves it at `./proofs/.proof`: + +```bash +nargo prove +``` + +This command looks for proof inputs in the custom **OtherProver.toml** and generates proof and saves it at `./proofs/.proof`: + +```bash +nargo prove -p OtherProver +``` + +## Verifying a Proof + +When the command `nargo verify` is executed, two processes happen: + +1. Noir checks in the _proofs_ directory for a proof file with the project name (eg. test_project.proof) + +2. If that file is found, the proof's validity is checked + +> **Note:** The validity of the proof is linked to the current Noir program; if the program is +> changed and the verifier verifies the proof, it will fail because the proof is not valid for the +> _modified_ Noir program. + +In production, the prover and the verifier are usually two separate entities. A prover would +retrieve the necessary inputs, execute the Noir program, generate a proof and pass it to the +verifier. The verifier would then retrieve the public inputs, usually from external sources, and +verify the validity of the proof against it. + +Take a private asset transfer as an example: + +A person using a browser as the prover would retrieve private inputs locally (e.g. the user's private key) and +public inputs (e.g. the user's encrypted balance on-chain), compute the transfer, generate a proof +and submit it to the verifier smart contract. + +The verifier contract would then draw the user's encrypted balance directly from the blockchain and +verify the proof submitted against it. If the verification passes, additional functions in the +verifier contract could trigger (e.g. approve the asset transfer). + +Now that you understand the concepts, you'll probably want some editor feedback while you are writing more complex code. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/installation/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/installation/_category_.json new file mode 100644 index 00000000000..0c02fb5d4d7 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/installation/_category_.json @@ -0,0 +1,6 @@ +{ + "position": 0, + "label": "Install Nargo", + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/installation/index.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/installation/index.md new file mode 100644 index 00000000000..4ef86aa5914 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/installation/index.md @@ -0,0 +1,48 @@ +--- +title: Nargo Installation +description: + nargo is a command line tool for interacting with Noir programs. This page is a quick guide on how to install Nargo through the most common and easy method, noirup +keywords: [ + Nargo + Noir + Rust + Cargo + Noirup + Installation + Terminal Commands + Version Check + Nightlies + Specific Versions + Branches + Noirup Repository +] +pagination_next: getting_started/hello_noir/index +--- + +`nargo` is the one-stop-shop for almost everything related with Noir. The name comes from our love for Rust and its package manager `cargo`. + +With `nargo`, you can start new projects, compile, execute, prove, verify, test, generate solidity contracts, and do pretty much all that is available in Noir. + +Similarly to `rustup`, we also maintain an easy installation method that covers most machines: `noirup`. + +## Installing Noirup + +Open a terminal on your machine, and write: + +```bash +curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash +``` + +Close the terminal, open another one, and run + +```bash +noirup +``` + +Done. That's it. You should have the latest version working. You can check with `nargo --version`. + +You can also install nightlies, specific versions +or branches. Check out the [noirup repository](https://github.com/noir-lang/noirup) for more +information. + +Now we're ready to start working on [our first Noir program!](../hello_noir/index.md) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/installation/other_install_methods.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/installation/other_install_methods.md new file mode 100644 index 00000000000..a35e34aaf9c --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/installation/other_install_methods.md @@ -0,0 +1,254 @@ +--- +title: Alternative Install Methods +description: There are different ways to install Nargo, the one-stop shop and command-line tool for developing Noir programs. This guide explains other methods that don't rely on noirup, such as compiling from source, installing from binaries, and using WSL for windows +keywords: [ + Installation + Nargo + Noirup + Binaries + Compiling from Source + WSL for Windows + macOS + Linux + Nix + Direnv + Shell & editor experience + Building and testing + Uninstalling Nargo + Noir vs code extension, + ] +sidebar_position: 1 +--- + +## Encouraged Installation Method: Noirup + +Noirup is the endorsed method for installing Nargo, streamlining the process of fetching binaries or compiling from source. It supports a range of options to cater to your specific needs, from nightly builds and specific versions to compiling from various sources. + +### Installing Noirup + +First, ensure you have `noirup` installed: + +```sh +curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash +``` + +### Fetching Binaries + +With `noirup`, you can easily switch between different Nargo versions, including nightly builds: + +- **Nightly Version**: Install the latest nightly build. + + ```sh + noirup --version nightly + ``` + +- **Specific Version**: Install a specific version of Nargo. + ```sh + noirup --version + ``` + +### Compiling from Source + +`noirup` also enables compiling Nargo from various sources: + +- **From a Specific Branch**: Install from the latest commit on a branch. + + ```sh + noirup --branch + ``` + +- **From a Fork**: Install from the main branch of a fork. + + ```sh + noirup --repo + ``` + +- **From a Specific Branch in a Fork**: Install from a specific branch in a fork. + + ```sh + noirup --repo --branch + ``` + +- **From a Specific Pull Request**: Install from a specific PR. + + ```sh + noirup --pr + ``` + +- **From a Specific Commit**: Install from a specific commit. + + ```sh + noirup -C + ``` + +- **From Local Source**: Compile and install from a local directory. + ```sh + noirup --path ./path/to/local/source + ``` + +## Alternate Installation Methods (No Longer Recommended) + +While the following methods are available, they are no longer recommended. We advise using noirup for a more efficient and flexible installation experience. + +However, there are other methods for installing Nargo: + +- [Binaries](#option-1-installing-from-binaries) +- [Compiling from Source](#option-2-compile-from-source) +- [WSL for Windows](#option-3-wsl-for-windows) + +### Option 1: Installing from Binaries + +See [GitHub Releases](https://github.com/noir-lang/noir/releases) for the latest and previous +platform specific binaries. + +#### Step 1 + +Paste and run the following in the terminal to extract and install the binary: + +> **macOS / Linux:** If you are prompted with `Permission denied` when running commands, prepend +> `sudo` and re-run it. + +##### macOS (Apple Silicon) + +```bash +mkdir -p $HOME/.nargo/bin && \ +curl -o $HOME/.nargo/bin/nargo-aarch64-apple-darwin.tar.gz -L https://github.com/noir-lang/noir/releases/download/v0.24.0/nargo-aarch64-apple-darwin.tar.gz && \ +tar -xvf $HOME/.nargo/bin/nargo-aarch64-apple-darwin.tar.gz -C $HOME/.nargo/bin/ && \ +echo '\nexport PATH=$PATH:$HOME/.nargo/bin' >> ~/.zshrc && \ +source ~/.zshrc +``` + +##### macOS (Intel) + +```bash +mkdir -p $HOME/.nargo/bin && \ +curl -o $HOME/.nargo/bin/nargo-x86_64-apple-darwin.tar.gz -L https://github.com/noir-lang/noir/releases/download/v0.24.0/nargo-x86_64-apple-darwin.tar.gz && \ +tar -xvf $HOME/.nargo/bin/nargo-x86_64-apple-darwin.tar.gz -C $HOME/.nargo/bin/ && \ +echo '\nexport PATH=$PATH:$HOME/.nargo/bin' >> ~/.zshrc && \ +source ~/.zshrc +``` + +##### Linux (Bash) + +```bash +mkdir -p $HOME/.nargo/bin && \ +curl -o $HOME/.nargo/bin/nargo-x86_64-unknown-linux-gnu.tar.gz -L https://github.com/noir-lang/noir/releases/download/v0.24.0/nargo-x86_64-unknown-linux-gnu.tar.gz && \ +tar -xvf $HOME/.nargo/bin/nargo-x86_64-unknown-linux-gnu.tar.gz -C $HOME/.nargo/bin/ && \ +echo -e '\nexport PATH=$PATH:$HOME/.nargo/bin' >> ~/.bashrc && \ +source ~/.bashrc +``` + +#### Step 2 + +Check if the installation was successful by running `nargo --version`. You should get a version number. + +> **macOS:** If you are prompted with an OS alert, right-click and open the _nargo_ executable from +> Finder. Close the new terminal popped up and `nargo` should now be accessible. + +### Option 2: Compile from Source + +Due to the large number of native dependencies, Noir projects uses [Nix](https://nixos.org/) and [direnv](https://direnv.net/) to streamline the development experience. It helps mitigating issues commonly associated with dependency management, such as conflicts between required package versions for different projects (often referred to as "dependency hell"). + +Combined with direnv, which automatically sets or clears environment variables based on the directory, it further simplifies the development process by seamlessly integrating with the developer's shell, facilitating an efficient and reliable workflow for managing and deploying Noir projects with multiple dependencies. + +#### Setting up your environment + +For the best experience, please follow these instructions to setup your environment: + +1. Install Nix following [their guide](https://nixos.org/download.html) for your operating system. +2. Create the file `~/.config/nix/nix.conf` with the contents: + +```ini +experimental-features = nix-command +extra-experimental-features = flakes +``` + +3. Install direnv into your Nix profile by running: + +```sh +nix profile install nixpkgs#direnv +``` + +4. Add direnv to your shell following [their guide](https://direnv.net/docs/hook.html). + 1. For bash or zshell, add `eval "$(direnv hook bash)"` or `eval "$(direnv hook zsh)"` to your ~/.bashrc or ~/.zshrc file, respectively. +5. Restart your shell. + +#### Shell & editor experience + +Now that your environment is set up, you can get to work on the project. + +1. Clone the repository, such as: + +```sh +git clone git@github.com:noir-lang/noir +``` + +> Replacing `noir` with whichever repository you want to work on. + +2. Navigate to the directory: + +```sh +cd noir +``` + +> Replacing `noir` with whichever repository you cloned. + +3. You should see a **direnv error** because projects aren't allowed by default. Make sure you've reviewed and trust our `.envrc` file, then you need to run: + +```sh +direnv allow +``` + +4. Now, wait awhile for all the native dependencies to be built. This will take some time and direnv will warn you that it is taking a long time, but we just need to let it run. + +5. Once you are presented with your prompt again, you can start your editor within the project directory (we recommend [VSCode](https://code.visualstudio.com/)): + +```sh +code . +``` + +6. (Recommended) When launching VSCode for the first time, you should be prompted to install our recommended plugins. We highly recommend installing these for the best development experience. + +#### Building and testing + +Assuming you are using `direnv` to populate your environment, building and testing the project can be done +with the typical `cargo build`, `cargo test`, and `cargo clippy` commands. You'll notice that the `cargo` version matches the version we specify in `rust-toolchain.toml`, which is 1.73.0 at the time of this writing. + +If you want to build the entire project in an isolated sandbox, you can use Nix commands: + +1. `nix build .` (or `nix build . -L` for verbose output) to build the project in a Nix sandbox. +2. `nix flake check` (or `nix flake check -L` for verbose output) to run clippy and tests in a Nix sandbox. + +#### Without `direnv` + +If you have hesitations with using direnv, you can launch a subshell with `nix develop` and then launch your editor from within the subshell. However, if VSCode was already launched in the project directory, the environment won't be updated. + +Advanced: If you aren't using direnv nor launching your editor within the subshell, you can try to install Barretenberg and other global dependencies the package needs. This is an advanced workflow and likely won't receive support! + +### Option 3: WSL (for Windows) + +The default backend for Noir (Barretenberg) doesn't provide Windows binaries at this time. For that reason, Noir cannot be installed natively. However, it is available by using Windows Subsystem for Linux (WSL). + +Step 1: Follow the instructions [here](https://learn.microsoft.com/en-us/windows/wsl/install) to install and run WSL. + +step 2: Follow the [Noirup instructions](#encouraged-installation-method-noirup). + +## Uninstalling Nargo + +### Noirup + +If you installed Nargo with `noirup` or through directly downloading binaries, you can uninstall Nargo by removing the files in `~/.nargo`, `~/nargo`, and `~/noir_cache`. This ensures that all installed binaries, configurations, and cache related to Nargo are fully removed from your system. + +```bash +rm -r ~/.nargo +rm -r ~/nargo +rm -r ~/noir_cache +``` + +### Nix + +If you installed Nargo with Nix or compiled it from source, you can remove the binary located at `~/.nix-profile/bin/nargo`. + +```bash +rm ~/.nix-profile/bin/nargo +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/tooling/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/tooling/_category_.json new file mode 100644 index 00000000000..55804c03a71 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/tooling/_category_.json @@ -0,0 +1,6 @@ +{ + "position": 2, + "label": "Tooling", + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/tooling/index.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/tooling/index.mdx new file mode 100644 index 00000000000..ac480f3c9f5 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/tooling/index.mdx @@ -0,0 +1,38 @@ +--- +title: Tooling +Description: This section provides information about the various tools and utilities available for Noir development. It covers the Noir playground, IDE tools, Codespaces, and community projects. +Keywords: [Noir, Development, Playground, IDE Tools, Language Service Provider, VS Code Extension, Codespaces, noir-starter, Community Projects, Awesome Noir Repository, Developer Tooling] +--- + +Noir is meant to be easy to develop with. For that reason, a number of utilities have been put together to ease the development process as much as feasible in the zero-knowledge world. + +## Playground + +The Noir playground is an easy way to test small ideas, share snippets, and integrate in other websites. You can access it at [play.noir-lang.org](https://play.noir-lang.org). + +## IDE tools + +When you install Nargo, you're also installing a Language Service Provider (LSP), which can be used by IDEs to provide syntax highlighting, codelens, warnings, and more. + +The easiest way to use these tools is by installing the [Noir VS Code extension](https://marketplace.visualstudio.com/items?itemName=noir-lang.vscode-noir). + +## Codespaces + +Some Noir repos have leveraged Codespaces in order to ease the development process. You can visit the [noir-starter](https://github.com/noir-lang/noir-starter) for an example. + + + +## GitHub Actions + +You can use `noirup` with GitHub Actions for CI/CD and automated testing. It is as simple as +installing `noirup` and running tests in your GitHub Action `yml` file. + +See the +[config file in the Noir repo](https://github.com/TomAFrench/noir-hashes/blob/master/.github/workflows/noir.yml) for an example usage. + +## Community projects + +As an open-source project, Noir has received many contributions over time. Some of them are related with developer tooling, and you can see some of them in [Awesome Noir repository](https://github.com/noir-lang/awesome-noir#dev-tools) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/tooling/language_server.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/tooling/language_server.md new file mode 100644 index 00000000000..81e0356ef8a --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/tooling/language_server.md @@ -0,0 +1,43 @@ +--- +title: Language Server +description: Learn about the Noir Language Server, how to install the components, and configuration that may be required. +keywords: [Nargo, Language Server, LSP, VSCode, Visual Studio Code] +sidebar_position: 0 +--- + +This section helps you install and configure the Noir Language Server. + +The Language Server Protocol (LSP) has two components, the [Server](#language-server) and the [Client](#language-client). Below we describe each in the context of Noir. + +## Language Server + +The Server component is provided by the Nargo command line tool that you installed at the beginning of this guide. +As long as Nargo is installed and you've used it to run other commands in this guide, it should be good to go! + +If you'd like to verify that the `nargo lsp` command is available, you can run `nargo --help` and look for `lsp` in the list of commands. If you see it, you're using a version of Noir with LSP support. + +## Language Client + +The Client component is usually an editor plugin that launches the Server. It communicates LSP messages between the editor and the Server. For example, when you save a file, the Client will alert the Server, so it can try to compile the project and report any errors. + +Currently, Noir provides a Language Client for Visual Studio Code via the [vscode-noir](https://github.com/noir-lang/vscode-noir) extension. You can install it via the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=noir-lang.vscode-noir). + +> **Note:** Noir's Language Server Protocol support currently assumes users' VSCode workspace root to be the same as users' Noir project root (i.e. where Nargo.toml lies). +> +> If LSP features seem to be missing / malfunctioning, make sure you are opening your Noir project directly (instead of as a sub-folder) in your VSCode instance. + +When your language server is running correctly and the VSCode plugin is installed, you should see handy codelens buttons for compilation, measuring circuit size, execution, and tests: + +![Compile and Execute](@site/static/img/codelens_compile_execute.png) +![Run test](@site/static/img/codelens_run_test.png) + +You should also see your tests in the `testing` panel: + +![Testing panel](@site/static/img/codelens_testing_panel.png) + +### Configuration + +- **Noir: Enable LSP** - If checked, the extension will launch the Language Server via `nargo lsp` and communicate with it. +- **Noir: Nargo Flags** - Additional flags may be specified if you require them to be added when the extension calls `nargo lsp`. +- **Noir: Nargo Path** - An absolute path to a Nargo binary with the `lsp` command. This may be useful if Nargo is not within the `PATH` of your editor. +- **Noir > Trace: Server** - Setting this to `"messages"` or `"verbose"` will log LSP messages between the Client and Server. Useful for debugging. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/tooling/testing.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/tooling/testing.md new file mode 100644 index 00000000000..d3e0c522473 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/getting_started/tooling/testing.md @@ -0,0 +1,62 @@ +--- +title: Testing in Noir +description: Learn how to use Nargo to test your Noir program in a quick and easy way +keywords: [Nargo, testing, Noir, compile, test] +sidebar_position: 1 +--- + +You can test your Noir programs using Noir circuits. + +Nargo will automatically compile and run any functions which have the decorator `#[test]` on them if +you run `nargo test`. + +For example if you have a program like: + +```rust +fn add(x: u64, y: u64) -> u64 { + x + y +} +#[test] +fn test_add() { + assert(add(2,2) == 4); + assert(add(0,1) == 1); + assert(add(1,0) == 1); +} +``` + +Running `nargo test` will test that the `test_add` function can be executed while satisfying all +the constraints which allows you to test that add returns the expected values. Test functions can't +have any arguments currently. + +### Test fail + +You can write tests that are expected to fail by using the decorator `#[test(should_fail)]`. For example: + +```rust +fn add(x: u64, y: u64) -> u64 { + x + y +} +#[test(should_fail)] +fn test_add() { + assert(add(2,2) == 5); +} +``` + +You can be more specific and make it fail with a specific reason by using `should_fail_with = "`: + +```rust +fn main(african_swallow_avg_speed : Field) { + assert(african_swallow_avg_speed == 65, "What is the airspeed velocity of an unladen swallow"); +} + +#[test] +fn test_king_arthur() { + main(65); +} + +#[test(should_fail_with = "What is the airspeed velocity of an unladen swallow")] +fn test_bridgekeeper() { + main(32); +} + +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/_category_.json new file mode 100644 index 00000000000..23b560f610b --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/_category_.json @@ -0,0 +1,5 @@ +{ + "position": 1, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/how-to-oracles.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/how-to-oracles.md new file mode 100644 index 00000000000..0d84d992320 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/how-to-oracles.md @@ -0,0 +1,280 @@ +--- +title: How to use Oracles +description: Learn how to use oracles in your Noir program with examples in both Nargo and NoirJS. This guide also covers writing a JSON RPC server and providing custom foreign call handlers for NoirJS. +keywords: + - Noir Programming + - Oracles + - Nargo + - NoirJS + - JSON RPC Server + - Foreign Call Handlers +sidebar_position: 1 +--- + +This guide shows you how to use oracles in your Noir program. For the sake of clarity, it assumes that: + +- You have read the [explainer on Oracles](../explainers/explainer-oracle.md) and are comfortable with the concept. +- You have a Noir program to add oracles to. You can create one using the [vite-hardhat starter](https://github.com/noir-lang/noir-starter/tree/main/vite-hardhat) as a boilerplate. +- You understand the concept of a JSON-RPC server. Visit the [JSON-RPC website](https://www.jsonrpc.org/) if you need a refresher. +- You are comfortable with server-side JavaScript (e.g. Node.js, managing packages, etc.). + +For reference, you can find the snippets used in this tutorial on the [Aztec DevRel Repository](https://github.com/AztecProtocol/dev-rel/tree/main/code-snippets/how-to-oracles). + +## Rundown + +This guide has 3 major steps: + +1. How to modify our Noir program to make use of oracle calls as unconstrained functions +2. How to write a JSON RPC Server to resolve these oracle calls with Nargo +3. How to use them in Nargo and how to provide a custom resolver in NoirJS + +## Step 1 - Modify your Noir program + +An oracle is defined in a Noir program by defining two methods: + +- An unconstrained method - This tells the compiler that it is executing an [unconstrained functions](../noir/concepts//unconstrained.md). +- A decorated oracle method - This tells the compiler that this method is an RPC call. + +An example of an oracle that returns a `Field` would be: + +```rust +#[oracle(getSqrt)] +unconstrained fn sqrt(number: Field) -> Field { } + +unconstrained fn get_sqrt(number: Field) -> Field { + sqrt(number) +} +``` + +In this example, we're wrapping our oracle function in a unconstrained method, and decorating it with `oracle(getSqrt)`. We can then call the unconstrained function as we would call any other function: + +```rust +fn main(input: Field) { + let sqrt = get_sqrt(input); +} +``` + +In the next section, we will make this `getSqrt` (defined on the `sqrt` decorator) be a method of the RPC server Noir will use. + +:::danger + +As explained in the [Oracle Explainer](../explainers/explainer-oracle.md), this `main` function is unsafe unless you constrain its return value. For example: + +```rust +fn main(input: Field) { + let sqrt = get_sqrt(input); + assert(sqrt.pow_32(2) as u64 == input as u64); // <---- constrain the return of an oracle! +} +``` + +::: + +:::info + +Currently, oracles only work with single params or array params. For example: + +```rust +#[oracle(getSqrt)] +unconstrained fn sqrt([Field; 2]) -> [Field; 2] { } +``` + +::: + +## Step 2 - Write an RPC server + +Brillig will call *one* RPC server. Most likely you will have to write your own, and you can do it in whatever language you prefer. In this guide, we will do it in Javascript. + +Let's use the above example of an oracle that consumes an array with two `Field` and returns their square roots: + +```rust +#[oracle(getSqrt)] +unconstrained fn sqrt(input: [Field; 2]) -> [Field; 2] { } + +unconstrained fn get_sqrt(input: [Field; 2]) -> [Field; 2] { + sqrt(input) +} + +fn main(input: [Field; 2]) { + let sqrt = get_sqrt(input); + assert(sqrt[0].pow_32(2) as u64 == input[0] as u64); + assert(sqrt[1].pow_32(2) as u64 == input[1] as u64); +} +``` + +:::info + +Why square root? + +In general, computing square roots is computationally more expensive than multiplications, which takes a toll when speaking about ZK applications. In this case, instead of calculating the square root in Noir, we are using our oracle to offload that computation to be made in plain. In our circuit we can simply multiply the two values. + +::: + +Now, we should write the correspondent RPC server, starting with the [default JSON-RPC 2.0 boilerplate](https://www.npmjs.com/package/json-rpc-2.0#example): + +```js +import { JSONRPCServer } from "json-rpc-2.0"; +import express from "express"; +import bodyParser from "body-parser"; + +const app = express(); +app.use(bodyParser.json()); + +const server = new JSONRPCServer(); +app.post("/", (req, res) => { + const jsonRPCRequest = req.body; + server.receive(jsonRPCRequest).then((jsonRPCResponse) => { + if (jsonRPCResponse) { + res.json(jsonRPCResponse); + } else { + res.sendStatus(204); + } + }); +}); + +app.listen(5555); +``` + +Now, we will add our `getSqrt` method, as expected by the `#[oracle(getSqrt)]` decorator in our Noir code. It maps through the params array and returns their square roots: + +```js +server.addMethod("getSqrt", async (params) => { + const values = params[0].Array.map(({ inner }) => { + return { inner: `${Math.sqrt(parseInt(inner, 16))}` }; + }); + return { values: [{ Array: values }] }; +}); +``` + +:::tip + +Brillig expects an object with an array of values. Each value is an object declaring to be `Single` or `Array` and returning a `inner` property *as a string*. For example: + +```json +{ "values": [{ "Array": [{ "inner": "1" }, { "inner": "2"}]}]} +{ "values": [{ "Single": { "inner": "1" }}]} +{ "values": [{ "Single": { "inner": "1" }}, { "Array": [{ "inner": "1", { "inner": "2" }}]}]} +``` + +If you're using Typescript, the following types may be helpful in understanding the expected return value and making sure they're easy to follow: + +```js +interface Value { + inner: string, +} + +interface SingleForeignCallParam { + Single: Value, +} + +interface ArrayForeignCallParam { + Array: Value[], +} + +type ForeignCallParam = SingleForeignCallParam | ArrayForeignCallParam; + +interface ForeignCallResult { + values: ForeignCallParam[], +} +``` + +::: + +## Step 3 - Usage with Nargo + +Using the [`nargo` CLI tool](../getting_started/installation/index.md), you can use oracles in the `nargo test`, `nargo execute` and `nargo prove` commands by passing a value to `--oracle-resolver`. For example: + +```bash +nargo test --oracle-resolver http://localhost:5555 +``` + +This tells `nargo` to use your RPC Server URL whenever it finds an oracle decorator. + +## Step 4 - Usage with NoirJS + +In a JS environment, an RPC server is not strictly necessary, as you may want to resolve your oracles without needing any JSON call at all. NoirJS simply expects that you pass a callback function when you generate proofs, and that callback function can be anything. + +For example, if your Noir program expects the host machine to provide CPU pseudo-randomness, you could simply pass it as the `foreignCallHandler`. You don't strictly need to create an RPC server to serve pseudo-randomness, as you may as well get it directly in your app: + +```js +const foreignCallHandler = (name, inputs) => crypto.randomBytes(16) // etc + +await noir.generateFinalProof(inputs, foreignCallHandler) +``` + +As one can see, in NoirJS, the [`foreignCallHandler`](../reference/NoirJS/noir_js/type-aliases/ForeignCallHandler.md) function simply means "a callback function that returns a value of type [`ForeignCallOutput`](../reference/NoirJS/noir_js/type-aliases/ForeignCallOutput.md). It doesn't have to be an RPC call like in the case for Nargo. + +:::tip + +Does this mean you don't have to write an RPC server like in [Step #2](#step-2---write-an-rpc-server)? + +You don't technically have to, but then how would you run `nargo test` or `nargo prove`? To use both `Nargo` and `NoirJS` in your development flow, you will have to write a JSON RPC server. + +::: + +In this case, let's make `foreignCallHandler` call the JSON RPC Server we created in [Step #2](#step-2---write-an-rpc-server), by making it a JSON RPC Client. + +For example, using the same `getSqrt` program in [Step #1](#step-1---modify-your-noir-program) (comments in the code): + +```js +import { JSONRPCClient } from "json-rpc-2.0"; + +// declaring the JSONRPCClient +const client = new JSONRPCClient((jsonRPCRequest) => { +// hitting the same JSON RPC Server we coded above + return fetch("http://localhost:5555", { + method: "POST", + headers: { + "content-type": "application/json", + }, + body: JSON.stringify(jsonRPCRequest), + }).then((response) => { + if (response.status === 200) { + return response + .json() + .then((jsonRPCResponse) => client.receive(jsonRPCResponse)); + } else if (jsonRPCRequest.id !== undefined) { + return Promise.reject(new Error(response.statusText)); + } + }); +}); + +// declaring a function that takes the name of the foreign call (getSqrt) and the inputs +const foreignCallHandler = async (name, input) => { + // notice that the "inputs" parameter contains *all* the inputs + // in this case we to make the RPC request with the first parameter "numbers", which would be input[0] + const oracleReturn = await client.request(name, [ + { Array: input[0].map((i) => ({ inner: i.toString("hex") })) }, + ]); + return [oracleReturn.values[0].Array.map((x) => x.inner)]; +}; + +// the rest of your NoirJS code +const input = { input: [4, 16] }; +const { witness } = await noir.execute(numbers, foreignCallHandler); +``` + +:::tip + +If you're in a NoirJS environment running your RPC server together with a frontend app, you'll probably hit a familiar problem in full-stack development: requests being blocked by [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) policy. For development only, you can simply install and use the [`cors` npm package](https://www.npmjs.com/package/cors) to get around the problem: + +```bash +yarn add cors +``` + +and use it as a middleware: + +```js +import cors from "cors"; + +const app = express(); +app.use(cors()) +``` + +::: + +## Conclusion + +Hopefully by the end of this guide, you should be able to: + +- Write your own logic around Oracles and how to write a JSON RPC server to make them work with your Nargo commands. +- Provide custom foreign call handlers for NoirJS. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/how-to-recursion.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/how-to-recursion.md new file mode 100644 index 00000000000..4c45bb87ae2 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/how-to-recursion.md @@ -0,0 +1,179 @@ +--- +title: How to use recursion on NoirJS +description: Learn how to implement recursion with NoirJS, a powerful tool for creating smart contracts on the EVM blockchain. This guide assumes familiarity with NoirJS, solidity verifiers, and the Barretenberg proving backend. Discover how to generate both final and intermediate proofs using `noir_js` and `backend_barretenberg`. +keywords: + [ + "NoirJS", + "EVM blockchain", + "smart contracts", + "recursion", + "solidity verifiers", + "Barretenberg backend", + "noir_js", + "backend_barretenberg", + "intermediate proofs", + "final proofs", + "nargo compile", + "json import", + "recursive circuit", + "recursive app" + ] +sidebar_position: 1 +--- + +This guide shows you how to use recursive proofs in your NoirJS app. For the sake of clarity, it is assumed that: + +- You already have a NoirJS app. If you don't, please visit the [NoirJS tutorial](../tutorials/noirjs_app.md) and the [reference](../reference/NoirJS/noir_js/index.md). +- You are familiar with what are recursive proofs and you have read the [recursion explainer](../explainers/explainer-recursion.md) +- You already built a recursive circuit following [the reference](../noir/standard_library/recursion.md), and understand how it works. + +It is also assumed that you're not using `noir_wasm` for compilation, and instead you've used [`nargo compile`](../reference/nargo_commands.md) to generate the `json` you're now importing into your project. However, the guide should work just the same if you're using `noir_wasm`. + +:::info + +As you've read in the [explainer](../explainers/explainer-recursion.md), a recursive proof is an intermediate proof. This means that it doesn't necessarily generate the final step that makes it verifiable in a smart contract. However, it is easy to verify within another circuit. + +While "standard" usage of NoirJS packages abstracts final proofs, it currently lacks the necessary interface to abstract away intermediate proofs. This means that these proofs need to be created by using the backend directly. + +In short: + +- `noir_js` generates *only* final proofs +- `backend_barretenberg` generates both types of proofs + +::: + +In a standard recursive app, you're also dealing with at least two circuits. For the purpose of this guide, we will assume the following: + +- `main`: a circuit of type `assert(x != y)`, where `main` is marked with a `#[recursive]` attribute. This attribute states that the backend should generate proofs that are friendly for verification within another circuit. +- `recursive`: a circuit that verifies `main` + +For a full example on how recursive proofs work, please refer to the [noir-examples](https://github.com/noir-lang/noir-examples) repository. We will *not* be using it as a reference for this guide. + +## Step 1: Setup + +In a common NoirJS app, you need to instantiate a backend with something like `const backend = new Backend(circuit)`. Then you feed it to the `noir_js` interface. + +For recursion, this doesn't happen, and the only need for `noir_js` is only to `execute` a circuit and get its witness and return value. Everything else is not interfaced, so it needs to happen on the `backend` object. + +It is also recommended that you instantiate the backend with as many threads as possible, to allow for maximum concurrency: + +```js +const backend = new Backend(circuit, { threads: 8 }) +``` + +:::tip +You can use the [`os.cpus()`](https://nodejs.org/api/os.html#oscpus) object in `nodejs` or [`navigator.hardwareConcurrency`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/hardwareConcurrency) on the browser to make the most out of those glorious cpu cores +::: + +## Step 2: Generating the witness and the proof for `main` + +After instantiating the backend, you should also instantiate `noir_js`. We will use it to execute the circuit and get the witness. + +```js +const noir = new Noir(circuit, backend) +const { witness } = noir.execute(input) +``` + +With this witness, you are now able to generate the intermediate proof for the main circuit: + +```js +const { proof, publicInputs } = await backend.generateProof(witness) +``` + +:::warning + +Always keep in mind what is actually happening on your development process, otherwise you'll quickly become confused about what circuit we are actually running and why! + +In this case, you can imagine that Alice (running the `main` circuit) is proving something to Bob (running the `recursive` circuit), and Bob is verifying her proof within his proof. + +With this in mind, it becomes clear that our intermediate proof is the one *meant to be verified within another circuit*, so it must be Alice's. Actually, the only final proof in this theoretical scenario would be the last one, sent on-chain. + +::: + +## Step 3 - Verification and proof artifacts + +Optionally, you are able to verify the intermediate proof: + +```js +const verified = await backend.verifyProof({ proof, publicInputs }) +``` + +This can be useful to make sure our intermediate proof was correctly generated. But the real goal is to do it within another circuit. For that, we need to generate recursive proof artifacts that will be passed to the circuit that is verifying the proof we just generated. 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: + +```js +const { proofAsFields, vkAsFields, vkHash } = await backend.generateRecursiveProofArtifacts( { publicInputs, proof }, publicInputsCount) +``` + +This call takes the public inputs and the proof, but also the public inputs count. While this is easily retrievable by simply counting the `publicInputs` length, the backend interface doesn't currently abstract it away. + +:::info + +The `proofAsFields` has a constant size `[Field; 93]` and verification keys in Barretenberg are always `[Field; 114]`. + +::: + +:::warning + +One common mistake is to forget *who* makes this call. + +In a situation where Alice is generating the `main` proof, if she generates the proof artifacts and sends them to Bob, which gladly takes them as true, this would mean Alice could prove anything! + +Instead, Bob needs to make sure *he* extracts the proof artifacts, using his own instance of the `main` circuit backend. This way, Alice has to provide a valid proof for the correct `main` circuit. + +::: + +## Step 4 - Recursive proof generation + +With the artifacts, generating a recursive proof is no different from a normal proof. You simply use the `backend` (with the recursive circuit) to generate it: + +```js +const recursiveInputs = { + verification_key: vkAsFields, // array of length 114 + proof: proofAsFields, // array of length 93 + size of public inputs + publicInputs: [mainInput.y], // using the example above, where `y` is the only public input + key_hash: vkHash, +} + +const { witness, returnValue } = noir.execute(recursiveInputs) // we're executing the recursive circuit now! +const { proof, publicInputs } = backend.generateProof(witness) +const verified = backend.verifyProof({ proof, publicInputs }) +``` + +You can obviously chain this proof into another proof. In fact, if you're using recursive proofs, you're probably interested of using them this way! + +:::tip + +Managing circuits and "who does what" can be confusing. To make sure your naming is consistent, you can keep them in an object. For example: + +```js +const circuits = { + main: mainJSON, + recursive: recursiveJSON +} +const backends = { + main: new BarretenbergBackend(circuits.main), + recursive: new BarretenbergBackend(circuits.recursive) +} +const noir_programs = { + main: new Noir(circuits.main, backends.main), + recursive: new Noir(circuits.recursive, backends.recursive) +} +``` + +This allows you to neatly call exactly the method you want without conflicting names: + +```js +// Alice runs this 👇 +const { witness: mainWitness } = await noir_programs.main.execute(input) +const proof = await backends.main.generateProof(mainWitness) + +// Bob runs this 👇 +const verified = await backends.main.verifyProof(proof) +const { proofAsFields, vkAsFields, vkHash } = await backends.main.generateRecursiveProofArtifacts( + proof, + numPublicInputs, +); +const recursiveProof = await noir_programs.recursive.generateProof(recursiveInputs) +``` + +::: diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/how-to-solidity-verifier.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/how-to-solidity-verifier.md new file mode 100644 index 00000000000..e3c7c1065da --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/how-to-solidity-verifier.md @@ -0,0 +1,231 @@ +--- +title: Generate a Solidity Verifier +description: + Learn how to run the verifier as a smart contract on the blockchain. Compile a Solidity verifier + contract for your Noir program and deploy it on any EVM blockchain acting as a verifier smart + contract. Read more to find out +keywords: + [ + solidity verifier, + smart contract, + blockchain, + compiler, + plonk_vk.sol, + EVM blockchain, + verifying Noir programs, + proving backend, + Barretenberg, + ] +sidebar_position: 0 +pagination_next: tutorials/noirjs_app +--- + +Noir has the ability to generate a verifier contract in Solidity, which can be deployed in many EVM-compatible blockchains such as Ethereum. + +This allows for a powerful feature set, as one can make use of the conciseness and the privacy provided by Noir in an immutable ledger. Applications can range from simple P2P guessing games, to complex private DeFi interactions. + +This guide shows you how to generate a Solidity Verifier and deploy it on the [Remix IDE](https://remix.ethereum.org/). It is assumed that: + +- You are comfortable with the Solidity programming language and understand how contracts are deployed on the Ethereum network +- You have Noir installed and you have a Noir program. If you don't, [get started](../getting_started/installation/index.md) with Nargo and the example Hello Noir circuit +- You are comfortable navigating RemixIDE. If you aren't or you need a refresher, you can find some video tutorials [here](https://www.youtube.com/channel/UCjTUPyFEr2xDGN6Cg8nKDaA) that could help you. + +## Rundown + +Generating a Solidity Verifier contract is actually a one-command process. However, compiling it and deploying it can have some caveats. Here's the rundown of this guide: + +1. How to generate a solidity smart contract +2. How to compile the smart contract in the RemixIDE +3. How to deploy it to a testnet + +## Step 1 - Generate a contract + +This is by far the most straight-forward step. Just run: + +```sh +nargo codegen-verifier +``` + +A new `contract` folder would then be generated in your project directory, containing the Solidity +file `plonk_vk.sol`. It can be deployed to any EVM blockchain acting as a verifier smart contract. + +:::info + +It is possible to generate verifier contracts of Noir programs for other smart contract platforms as long as the proving backend supplies an implementation. + +Barretenberg, the default proving backend for Nargo, supports generation of verifier contracts, for the time being these are only in Solidity. +::: + +## Step 2 - Compiling + +We will mostly skip the details of RemixIDE, as the UI can change from version to version. For now, we can just open +Remix and create a blank workspace. + +![Create Workspace](@site/static/img/how-tos/solidity_verifier_1.png) + +We will create a new file to contain the contract Nargo generated, and copy-paste its content. + +:::warning + +You'll likely see a warning advising you to not trust pasted code. While it is an important warning, it is irrelevant in the context of this guide and can be ignored. We will not be deploying anywhere near a mainnet. + +::: + +To compile our the verifier, we can navigate to the compilation tab: + +![Compilation Tab](@site/static/img/how-tos/solidity_verifier_2.png) + +Remix should automatically match a suitable compiler version. However, hitting the "Compile" button will most likely generate a "Stack too deep" error: + +![Stack too deep](@site/static/img/how-tos/solidity_verifier_3.png) + +This is due to the verify function needing to put many variables on the stack, but enabling the optimizer resolves the issue. To do this, let's open the "Advanced Configurations" tab and enable optimization. The default 200 runs will suffice. + +:::info + +This time we will see a warning about an unused function parameter. This is expected, as the `verify` function doesn't use the `_proof` parameter inside a solidity block, it is loaded from calldata and used in assembly. + +::: + +![Compilation success](@site/static/img/how-tos/solidity_verifier_4.png) + +## Step 3 - Deploying + +At this point we should have a compiled contract read to deploy. If we navigate to the deploy section in Remix, we will see many different environments we can deploy to. The steps to deploy on each environment would be out-of-scope for this guide, so we will just use the default Remix VM. + +Looking closely, we will notice that our "Solidity Verifier" is actually three contracts working together: + +- An `UltraVerificationKey` library which simply stores the verification key for our circuit. +- An abstract contract `BaseUltraVerifier` containing most of the verifying logic. +- A main `UltraVerifier` contract that inherits from the Base and uses the Key contract. + +Remix will take care of the dependencies for us so we can simply deploy the UltraVerifier contract by selecting it and hitting "deploy": + +![Deploying UltraVerifier](@site/static/img/how-tos/solidity_verifier_5.png) + +A contract will show up in the "Deployed Contracts" section, where we can retrieve the Verification Key Hash. This is particularly useful for double-checking the deployer contract is the correct one. + +:::note + +Why "UltraVerifier"? + +To be precise, the Noir compiler (`nargo`) doesn't generate the verifier contract directly. It compiles the Noir code into an intermediate language (ACIR), which is then executed by the backend. So it is the backend that returns the verifier smart contract, not Noir. + +In this case, the Barretenberg Backend uses the UltraPlonk proving system, hence the "UltraVerifier" name. + +::: + +## Step 4 - Verifying + +To verify a proof using the Solidity verifier contract, we call the `verify` function in this extended contract: + +```solidity +function verify(bytes calldata _proof, bytes32[] calldata _publicInputs) external view returns (bool) +``` + +When using the default example in the [Hello Noir](../getting_started/hello_noir/index.md) guide, the easiest way to confirm that the verifier contract is doing its job is by calling the `verify` function via remix with the required parameters. For `_proof`, run `nargo prove` and use the string in `proof/.proof` (adding the hex `0x` prefix). We can also copy the public input from `Verifier.toml`, as it will be properly formatted as 32-byte strings: + +``` +0x...... , [0x0000.....02] +``` + +A programmatic example of how the `verify` function is called can be seen in the example zk voting application [here](https://github.com/noir-lang/noir-examples/blob/33e598c257e2402ea3a6b68dd4c5ad492bce1b0a/foundry-voting/src/zkVote.sol#L35): + +```solidity +function castVote(bytes calldata proof, uint proposalId, uint vote, bytes32 nullifierHash) public returns (bool) { + // ... + bytes32[] memory publicInputs = new bytes32[](4); + publicInputs[0] = merkleRoot; + publicInputs[1] = bytes32(proposalId); + publicInputs[2] = bytes32(vote); + publicInputs[3] = nullifierHash; + require(verifier.verify(proof, publicInputs), "Invalid proof"); +``` + +:::info[Return Values] + +A circuit doesn't have the concept of a return value. Return values are just syntactic sugar in +Noir. + +Under the hood, the return value is passed as an input to the circuit and is checked at the end of +the circuit program. + +For example, if you have Noir program like this: + +```rust +fn main( + // Public inputs + pubkey_x: pub Field, + pubkey_y: pub Field, + // Private inputs + priv_key: Field, +) -> pub Field +``` + +the `verify` function will expect the public inputs array (second function parameter) to be of length 3, the two inputs and the return value. Like before, these values are populated in Verifier.toml after running `nargo prove`. + +Passing only two inputs will result in an error such as `PUBLIC_INPUT_COUNT_INVALID(3, 2)`. + +In this case, the inputs parameter to `verify` would be an array ordered as `[pubkey_x, pubkey_y, return]`. + +::: + +:::tip[Structs] + +You can pass structs to the verifier contract. They will be flattened so that the array of inputs is 1-dimensional array. + +For example, consider the following program: + +```rust +struct Type1 { + val1: Field, + val2: Field, +} + +struct Nested { + t1: Type1, + is_true: bool, +} + +fn main(x: pub Field, nested: pub Nested, y: pub Field) { + //... +} +``` + +The order of these inputs would be flattened to: `[x, nested.t1.val1, nested.t1.val2, nested.is_true, y]` + +::: + +The other function you can call is our entrypoint `verify` function, as defined above. + +:::tip + +It's worth noticing that the `verify` function is actually a `view` function. A `view` function does not alter the blockchain state, so it doesn't need to be distributed (i.e. it will run only on the executing node), and therefore doesn't cost any gas. + +This can be particularly useful in some situations. If Alice generated a proof and wants Bob to verify its correctness, Bob doesn't need to run Nargo, NoirJS, or any Noir specific infrastructure. He can simply make a call to the blockchain with the proof and verify it is correct without paying any gas. + +It would be incorrect to say that a Noir proof verification costs any gas at all. However, most of the time the result of `verify` is used to modify state (for example, to update a balance, a game state, etc). In that case the whole network needs to execute it, which does incur gas costs (calldata and execution, but not storage). + +::: + +## A Note on EVM chains + +ZK-SNARK verification depends on some precompiled cryptographic primitives such as Elliptic Curve Pairings (if you like complex math, you can read about EC Pairings [here](https://medium.com/@VitalikButerin/exploring-elliptic-curve-pairings-c73c1864e627)). Not all EVM chains support EC Pairings, notably some of the ZK-EVMs. This means that you won't be able to use the verifier contract in all of them. + +For example, chains like `zkSync ERA` and `Polygon zkEVM` do not currently support these precompiles, so proof verification via Solidity verifier contracts won't work. Here's a quick list of EVM chains that have been tested and are known to work: + +- Optimism +- Arbitrum +- Polygon PoS +- Scroll +- Celo + +If you test any other chains, please open a PR on this page to update the list. See [this doc](https://github.com/noir-lang/noir-starter/tree/main/with-foundry#testing-on-chain) for more info about testing verifier contracts on different EVM chains. + +## What's next + +Now that you know how to call a Noir Solidity Verifier on a smart contract using Remix, you should be comfortable with using it with some programmatic frameworks, such as [hardhat](https://github.com/noir-lang/noir-starter/tree/main/vite-hardhat) and [foundry](https://github.com/noir-lang/noir-starter/tree/main/with-foundry). + +You can find other tools, examples, boilerplates and libraries in the [awesome-noir](https://github.com/noir-lang/awesome-noir) repository. + +You should also be ready to write and deploy your first NoirJS app and start generating proofs on websites, phones, and NodeJS environments! Head on to the [NoirJS tutorial](../tutorials/noirjs_app.md) to learn how to do that. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/merkle-proof.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/merkle-proof.mdx new file mode 100644 index 00000000000..34074659ac1 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/merkle-proof.mdx @@ -0,0 +1,48 @@ +--- +title: Prove Merkle Tree Membership +description: + Learn how to use merkle membership proof in Noir to prove that a given leaf is a member of a + merkle tree with a specified root, at a given index. +keywords: + [merkle proof, merkle membership proof, Noir, rust, hash function, Pedersen, sha256, merkle tree] +--- + +Let's walk through an example of a merkle membership proof in Noir that proves that a given leaf is +in a merkle tree. + +```rust +use dep::std; + +fn main(message : [Field; 62], index : Field, hashpath : [Field; 40], root : Field) { + let leaf = std::hash::hash_to_field(message); + let merkle_root = std::merkle::compute_merkle_root(leaf, index, hashpath); + assert(merkle_root == root); +} + +``` + +The message is hashed using `hash_to_field`. The specific hash function that is being used is chosen +by the backend. The only requirement is that this hash function can heuristically be used as a +random oracle. If only collision resistance is needed, then one can call `std::hash::pedersen_hash` +instead. + +```rust +let leaf = std::hash::hash_to_field(message); +``` + +The leaf is then passed to a compute_merkle_root function with the root, index and hashpath. The returned root can then be asserted to be the same as the provided root. + +```rust +let merkle_root = std::merkle::compute_merkle_root(leaf, index, hashpath); +assert (merkle_root == root); +``` + +> **Note:** It is possible to re-implement the merkle tree implementation without standard library. +> However, for most usecases, it is enough. In general, the standard library will always opt to be +> as conservative as possible, while striking a balance with efficiency. + +An example, the merkle membership proof, only requires a hash function that has collision +resistance, hence a hash function like Pedersen is allowed, which in most cases is more efficient +than the even more conservative sha256. + +[View an example on the starter repo](https://github.com/noir-lang/noir-examples/blob/3ea09545cabfa464124ec2f3ea8e60c608abe6df/stealthdrop/circuits/src/main.nr#L20) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/using-devcontainers.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/using-devcontainers.mdx new file mode 100644 index 00000000000..727ec6ca667 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/how_to/using-devcontainers.mdx @@ -0,0 +1,110 @@ +--- +title: Developer Containers and Codespaces +description: "Learn how to set up a devcontainer in your GitHub repository for a seamless coding experience with Codespaces. Follow our easy 8-step guide to create your own Noir environment without installing Nargo locally." +keywords: ["Devcontainer", "Codespaces", "GitHub", "Noir Environment", "Docker Image", "Development Environment", "Remote Coding", "GitHub Codespaces", "Noir Programming", "Nargo", "VSCode Extensions", "Noirup"] +sidebar_position: 1 +--- + +Adding a developer container configuration file to your Noir project is one of the easiest way to unlock coding in browser. + +## What's a devcontainer after all? + +A [Developer Container](https://containers.dev/) (devcontainer for short) is a Docker image that comes preloaded with tools, extensions, and other tools you need to quickly get started or continue a project, without having to install Nargo locally. Think of it as a development environment in a box. + +There are many advantages to this: + +- It's platform and architecture agnostic +- You don't need to have an IDE installed, or Nargo, or use a terminal at all +- It's safer for using on a public machine or public network + +One of the best ways of using devcontainers is... not using your machine at all, for maximum control, performance, and ease of use. +Enter Codespaces. + +## Codespaces + +If a devcontainer is just a Docker image, then what stops you from provisioning a `p3dn.24xlarge` AWS EC2 instance with 92 vCPUs and 768 GiB RAM and using it to prove your 10-gate SNARK proof? + +Nothing! Except perhaps the 30-40$ per hour it will cost you. + +The problem is that provisioning takes time, and I bet you don't want to see the AWS console every time you want to code something real quick. + +Fortunately, there's an easy and free way to get a decent remote machine ready and loaded in less than 2 minutes: Codespaces. [Codespaces is a Github feature](https://github.com/features/codespaces) that allows you to code in a remote machine by using devcontainers, and it's pretty cool: + +- You can start coding Noir in less than a minute +- It uses the resources of a remote machine, so you can code on your grandma's phone if needed be +- It makes it easy to share work with your frens +- It's fully reusable, you can stop and restart whenever you need to + +:::info + +Don't take out your wallet just yet. Free GitHub accounts get about [15-60 hours of coding](https://github.com/features/codespaces) for free per month, depending on the size of your provisioned machine. + +::: + +## Tell me it's _actually_ easy + +It is! + +Github comes with a default codespace and you can use it to code your own devcontainer. That's exactly what we will be doing in this guide. + + + +8 simple steps: + +#### 1. Create a new repository on GitHub. + +#### 2. Click "Start coding with Codespaces". This will use the default image. + +#### 3. Create a folder called `.devcontainer` in the root of your repository. + +#### 4. Create a Dockerfile in that folder, and paste the following code: + +```docker +FROM --platform=linux/amd64 node:lts-bookworm-slim +SHELL ["/bin/bash", "-c"] +RUN apt update && apt install -y curl bash git tar gzip libc++-dev +RUN curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash +ENV PATH="/root/.nargo/bin:$PATH" +RUN noirup +ENTRYPOINT ["nargo"] +``` +#### 5. Create a file called `devcontainer.json` in the same folder, and paste the following code: + +```json +{ + "name": "Noir on Codespaces", + "build": { + "context": ".", + "dockerfile": "Dockerfile" + }, + "customizations": { + "vscode": { + "extensions": ["noir-lang.vscode-noir"] + } + } +} +``` +#### 6. Commit and push your changes + +This will pull the new image and build it, so it could take a minute or so + +#### 8. Done! +Just wait for the build to finish, and there's your easy Noir environment. + + +Refer to [noir-starter](https://github.com/noir-lang/noir-starter/) as an example of how devcontainers can be used together with codespaces. + + + +## How do I use it? + +Using the codespace is obviously much easier than setting it up. +Just navigate to your repository and click "Code" -> "Open with Codespaces". It should take a few seconds to load, and you're ready to go. + +:::info + +If you really like the experience, you can add a badge to your readme, links to existing codespaces, and more. +Check out the [official docs](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/setting-up-your-repository/facilitating-quick-creation-and-resumption-of-codespaces) for more info. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/index.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/index.mdx new file mode 100644 index 00000000000..75086ddcdde --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/index.mdx @@ -0,0 +1,67 @@ +--- +title: Noir Lang +hide_title: true +description: + Learn about the public alpha release of Noir, a domain specific language heavily influenced by Rust that compiles to + an intermediate language which can be compiled to an arithmetic circuit or a rank-1 constraint system. +keywords: + [Noir, + Domain Specific Language, + Rust, + Intermediate Language, + Arithmetic Circuit, + Rank-1 Constraint System, + Ethereum Developers, + Protocol Developers, + Blockchain Developers, + Proving System, + Smart Contract Language] +sidebar_position: 0 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +Noir Logo + +Noir is a Domain-Specific Language for SNARK proving systems developed by [Aztec Labs](https://aztec.network/). It allows you to generate complex Zero-Knowledge Programs (ZKP) by using simple and flexible syntax, requiring no previous knowledge on the underlying mathematics or cryptography. + +ZK programs are programs that can generate short proofs of a certain statement without revealing some details about it. You can read more about ZKPs [here](https://dev.to/spalladino/a-beginners-intro-to-coding-zero-knowledge-proofs-c56). + +## What's new about Noir? + +Noir works differently from most ZK languages by taking a two-pronged path. First, it compiles the program to an adaptable intermediate language known as ACIR. From there, depending on a given project's needs, ACIR can be further compiled into an arithmetic circuit for integration with the proving backend. + +:::info + +Noir is backend agnostic, which means it makes no assumptions on which proving backend powers the ZK proof. Being the language that powers [Aztec Contracts](https://docs.aztec.network/developers/contracts/main), it defaults to Aztec's Barretenberg proving backend. + +However, the ACIR output can be transformed to be compatible with other PLONK-based backends, or into a [rank-1 constraint system](https://www.rareskills.io/post/rank-1-constraint-system) suitable for backends such as Arkwork's Marlin. + +::: + +## Who is Noir for? + +Noir can be used both in complex cloud-based backends and in user's smartphones, requiring no knowledge on the underlying math or cryptography. From authorization systems that keep a password in the user's device, to complex on-chain verification of recursive proofs, Noir is designed to abstract away complexity without any significant overhead. Here are some examples of situations where Noir can be used: + + + + Noir Logo + + Aztec Contracts leverage Noir to allow for the storage and execution of private information. Writing an Aztec Contract is as easy as writing Noir, and Aztec developers can easily interact with the network storage and execution through the [Aztec.nr](https://docs.aztec.network/developers/contracts/main) library. + + + Soliditry Verifier Example + Noir can auto-generate Solidity verifier contracts that verify Noir proofs. This allows for non-interactive verification of proofs containing private information in an immutable system. This feature powers a multitude of use-case scenarios, from P2P chess tournaments, to [Aztec Layer-2 Blockchain](https://docs.aztec.network/) + + + Aztec Labs developed NoirJS, an easy interface to generate and verify Noir proofs in a Javascript environment. This allows for Noir to be used in webpages, mobile apps, games, and any other environment supporting JS execution in a standalone manner. + + + + +## Libraries + +Noir is meant to be easy to extend by simply importing Noir libraries just like in Rust. +The [awesome-noir repo](https://github.com/noir-lang/awesome-noir#libraries) is a collection of libraries developed by the Noir community. +Writing a new library is easy and makes code be composable and easy to reuse. See the section on [dependencies](noir/modules_packages_crates/dependencies.md) for more information. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/migration_notes.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/migration_notes.md new file mode 100644 index 00000000000..6bd740024e5 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/migration_notes.md @@ -0,0 +1,105 @@ +--- +title: Migration notes +description: Read about migration notes from previous versions, which could solve problems while updating +keywords: [Noir, notes, migration, updating, upgrading] +--- + +Noir is in full-speed development. Things break fast, wild, and often. This page attempts to leave some notes on errors you might encounter when upgrading and how to resolve them until proper patches are built. + +### `backend encountered an error: libc++.so.1` + +Depending on your OS, you may encounter the following error when running `nargo prove` for the first time: + +```text +The backend encountered an error: "/home/codespace/.nargo/backends/acvm-backend-barretenberg/backend_binary: error while loading shared libraries: libc++.so.1: cannot open shared object file: No such file or directory\n" +``` + +Install the `libc++-dev` library with: + +```bash +sudo apt install libc++-dev +``` + +## ≥0.19 + +### Enforcing `compiler_version` + +From this version on, the compiler will check for the `compiler_version` field in `Nargo.toml`, and will error if it doesn't match the current Nargo version in use. + +To update, please make sure this field in `Nargo.toml` matches the output of `nargo --version`. + +## ≥0.14 + +The index of the [for loops](noir/concepts/control_flow.md#loops) is now of type `u64` instead of `Field`. An example refactor would be: + +```rust +for i in 0..10 { + let i = i as Field; +} +``` + +## ≥v0.11.0 and Nargo backend + +From this version onwards, Nargo starts managing backends through the `nargo backend` command. Upgrading to the versions per usual steps might lead to: + +### `backend encountered an error` + +This is likely due to the existing locally installed version of proving backend (e.g. barretenberg) is incompatible with the version of Nargo in use. + +To fix the issue: + +1. Uninstall the existing backend + +```bash +nargo backend uninstall acvm-backend-barretenberg +``` + +You may replace _acvm-backend-barretenberg_ with the name of your backend listed in `nargo backend ls` or in ~/.nargo/backends. + +2. Reinstall a compatible version of the proving backend. + +If you are using the default barretenberg backend, simply run: + +``` +nargo prove +``` + +with your Noir program. + +This will trigger the download and installation of the latest version of barretenberg compatible with your Nargo in use. + +### `backend encountered an error: illegal instruction` + +On certain Intel-based systems, an `illegal instruction` error may arise due to incompatibility of barretenberg with certain CPU instructions. + +To fix the issue: + +1. Uninstall the existing backend + +```bash +nargo backend uninstall acvm-backend-barretenberg +``` + +You may replace _acvm-backend-barretenberg_ with the name of your backend listed in `nargo backend ls` or in ~/.nargo/backends. + +2. Reinstall a compatible version of the proving backend. + +If you are using the default barretenberg backend, simply run: + +``` +nargo backend install acvm-backend-barretenberg https://github.com/noir-lang/barretenberg-js-binary/raw/master/run-bb.tar.gz +``` + +This downloads and installs a specific bb.js based version of barretenberg binary from GitHub. + +The gzipped file is running [this bash script](https://github.com/noir-lang/barretenberg-js-binary/blob/master/run-bb-js.sh), where we need to gzip it as the Nargo currently expect the backend to be zipped up. + +Then run: + +``` +DESIRED_BINARY_VERSION=0.8.1 nargo info +``` + +This overrides the bb native binary with a bb.js node application instead, which should be compatible with most if not all hardware. This does come with the drawback of being generally slower than native binary. + +0.8.1 indicates bb.js version 0.8.1, so if you change that it will update to a different version or the default version in the script if none was supplied. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/_category_.json new file mode 100644 index 00000000000..7da08f8a8c5 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Concepts", + "position": 0, + "collapsible": true, + "collapsed": true +} \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/assert.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/assert.md new file mode 100644 index 00000000000..bcff613a695 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/assert.md @@ -0,0 +1,45 @@ +--- +title: Assert Function +description: + Learn about the assert function in Noir, which can be used to explicitly constrain the predicate or + comparison expression that follows to be true, and what happens if the expression is false at + runtime. +keywords: [Noir programming language, assert statement, predicate expression, comparison expression] +sidebar_position: 4 +--- + +Noir includes a special `assert` function which will explicitly constrain the predicate/comparison +expression that follows to be true. If this expression is false at runtime, the program will fail to +be proven. Example: + +```rust +fn main(x : Field, y : Field) { + assert(x == y); +} +``` + +> Assertions only work for predicate operations, such as `==`. If there's any ambiguity on the operation, the program will fail to compile. For example, it is unclear if `assert(x + y)` would check for `x + y == 0` or simply would return `true`. + +You can optionally provide a message to be logged when the assertion fails: + +```rust +assert(x == y, "x and y are not equal"); +``` + +Aside string literals, the optional message can be a format string or any other type supported as input for Noir's [print](../standard_library/logging.md) functions. This feature lets you incorporate runtime variables into your failed assertion logs: + +```rust +assert(x == y, f"Expected x == y, but got {x} == {y}"); +``` + +Using a variable as an assertion message directly: + +```rust +struct myStruct { + myField: Field +} + +let s = myStruct { myField: y }; +assert(s.myField == x, s); +``` + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/comments.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/comments.md new file mode 100644 index 00000000000..b51a85f5c94 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/comments.md @@ -0,0 +1,33 @@ +--- +title: Comments +description: + Learn how to write comments in Noir programming language. A comment is a line of code that is + ignored by the compiler, but it can be read by programmers. Single-line and multi-line comments + are supported in Noir. +keywords: [Noir programming language, comments, single-line comments, multi-line comments] +sidebar_position: 10 +--- + +A comment is a line in your codebase which the compiler ignores, however it can be read by +programmers. + +Here is a single line comment: + +```rust +// This is a comment and is ignored +``` + +`//` is used to tell the compiler to ignore the rest of the line. + +Noir also supports multi-line block comments. Start a block comment with `/*` and end the block with `*/`. + +Noir does not natively support doc comments. You may be able to use [Rust doc comments](https://doc.rust-lang.org/reference/comments.html) in your code to leverage some Rust documentation build tools with Noir code. + +```rust +/* + This is a block comment describing a complex function. +*/ +fn main(x : Field, y : pub Field) { + assert(x != y); +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/control_flow.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/control_flow.md new file mode 100644 index 00000000000..4ce65236db3 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/control_flow.md @@ -0,0 +1,45 @@ +--- +title: Control Flow +description: + Learn how to use loops and if expressions in the Noir programming language. Discover the syntax + and examples for for loops and if-else statements. +keywords: [Noir programming language, loops, for loop, if-else statements, Rust syntax] +sidebar_position: 2 +--- + +## Loops + +Noir has one kind of loop: the `for` loop. `for` loops allow you to repeat a block of code multiple +times. + +The following block of code between the braces is run 10 times. + +```rust +for i in 0..10 { + // do something +}; +``` + +The index for loops is of type `u64`. + +## If Expressions + +Noir supports `if-else` statements. The syntax is most similar to Rust's where it is not required +for the statement's conditional to be surrounded by parentheses. + +```rust +let a = 0; +let mut x: u32 = 0; + +if a == 0 { + if a != 0 { + x = 6; + } else { + x = 2; + } +} else { + x = 5; + assert(x == 5); +} +assert(x == 2); +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_bus.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_bus.md new file mode 100644 index 00000000000..e54fc861257 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_bus.md @@ -0,0 +1,21 @@ +--- +title: Data Bus +sidebar_position: 13 +--- +**Disclaimer** this feature is experimental, do not use it! + +The data bus is an optimization that the backend can use to make recursion more efficient. +In order to use it, you must define some inputs of the program entry points (usually the `main()` +function) with the `call_data` modifier, and the return values with the `return_data` modifier. +These modifiers are incompatible with `pub` and `mut` modifiers. + +## Example + +```rust +fn main(mut x: u32, y: call_data u32, z: call_data [u32;4] ) -> return_data u32 { + let a = z[x]; + a+y +} +``` + +As a result, both call_data and return_data will be treated as private inputs and encapsulated into a read-only array each, for the backend to process. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/_category_.json new file mode 100644 index 00000000000..5d694210bbf --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/_category_.json @@ -0,0 +1,5 @@ +{ + "position": 0, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/arrays.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/arrays.md new file mode 100644 index 00000000000..a8bd338e736 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/arrays.md @@ -0,0 +1,251 @@ +--- +title: Arrays +description: + Dive into the Array data type in Noir. Grasp its methods, practical examples, and best practices for efficiently using Arrays in your Noir code. +keywords: + [ + noir, + array type, + methods, + examples, + indexing, + ] +sidebar_position: 4 +--- + +An array is one way of grouping together values into one compound type. Array types can be inferred +or explicitly specified via the syntax `[; ]`: + +```rust +fn main(x : Field, y : Field) { + let my_arr = [x, y]; + let your_arr: [Field; 2] = [x, y]; +} +``` + +Here, both `my_arr` and `your_arr` are instantiated as an array containing two `Field` elements. + +Array elements can be accessed using indexing: + +```rust +fn main() { + let a = [1, 2, 3, 4, 5]; + + let first = a[0]; + let second = a[1]; +} +``` + +All elements in an array must be of the same type (i.e. homogeneous). That is, an array cannot group +a `Field` value and a `u8` value together for example. + +You can write mutable arrays, like: + +```rust +fn main() { + let mut arr = [1, 2, 3, 4, 5]; + assert(arr[0] == 1); + + arr[0] = 42; + assert(arr[0] == 42); +} +``` + +You can instantiate a new array of a fixed size with the same value repeated for each element. The following example instantiates an array of length 32 where each element is of type Field and has the value 0. + +```rust +let array: [Field; 32] = [0; 32]; +``` + +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: + +```rust +let array: [Field; 32] = [0; 32]; +let sl = array.as_slice() +``` + +You can define multidimensional arrays: + +```rust +let array : [[Field; 2]; 2]; +let element = array[0][0]; +``` +However, multidimensional slices are not supported. For example, the following code will error at compile time: +```rust +let slice : [[Field]] = []; +``` + +## Types + +You can create arrays of primitive types or structs. There is not yet support for nested arrays +(arrays of arrays) or arrays of structs that contain arrays. + +## Methods + +For convenience, the STD provides some ready-to-use, common methods for arrays. +Each of these functions are located within the generic impl `impl [T; N] {`. +So anywhere `self` appears, it refers to the variable `self: [T; N]`. + +### len + +Returns the length of an array + +```rust +fn len(self) -> Field +``` + +example + +```rust +fn main() { + let array = [42, 42]; + assert(array.len() == 2); +} +``` + +### sort + +Returns a new sorted array. The original array remains untouched. Notice that this function will +only work for arrays of fields or integers, not for any arbitrary type. This is because the sorting +logic it uses internally is optimized specifically for these values. If you need a sort function to +sort any type, you should use the function `sort_via` described below. + +```rust +fn sort(self) -> [T; N] +``` + +example + +```rust +fn main() { + let arr = [42, 32]; + let sorted = arr.sort(); + assert(sorted == [32, 42]); +} +``` + +### sort_via + +Sorts the array with a custom comparison function + +```rust +fn sort_via(self, ordering: fn(T, T) -> bool) -> [T; N] +``` + +example + +```rust +fn main() { + let arr = [42, 32] + let sorted_ascending = arr.sort_via(|a, b| a < b); + assert(sorted_ascending == [32, 42]); // verifies + + let sorted_descending = arr.sort_via(|a, b| a > b); + assert(sorted_descending == [32, 42]); // does not verify +} +``` + +### map + +Applies a function to each element of the array, returning a new array containing the mapped elements. + +```rust +fn map(self, f: fn(T) -> U) -> [U; N] +``` + +example + +```rust +let a = [1, 2, 3]; +let b = a.map(|a| a * 2); // b is now [2, 4, 6] +``` + +### fold + +Applies a function to each element of the array, returning the final accumulated value. The first +parameter is the initial value. + +```rust +fn fold(self, mut accumulator: U, f: fn(U, T) -> U) -> U +``` + +This is a left fold, so the given function will be applied to the accumulator and first element of +the array, then the second, and so on. For a given call the expected result would be equivalent to: + +```rust +let a1 = [1]; +let a2 = [1, 2]; +let a3 = [1, 2, 3]; + +let f = |a, b| a - b; +a1.fold(10, f) //=> f(10, 1) +a2.fold(10, f) //=> f(f(10, 1), 2) +a3.fold(10, f) //=> f(f(f(10, 1), 2), 3) +``` + +example: + +```rust + +fn main() { + let arr = [2, 2, 2, 2, 2]; + let folded = arr.fold(0, |a, b| a + b); + assert(folded == 10); +} + +``` + +### reduce + +Same as fold, but uses the first element as starting element. + +```rust +fn reduce(self, f: fn(T, T) -> T) -> T +``` + +example: + +```rust +fn main() { + let arr = [2, 2, 2, 2, 2]; + let reduced = arr.reduce(|a, b| a + b); + assert(reduced == 10); +} +``` + +### all + +Returns true if all the elements satisfy the given predicate + +```rust +fn all(self, predicate: fn(T) -> bool) -> bool +``` + +example: + +```rust +fn main() { + let arr = [2, 2, 2, 2, 2]; + let all = arr.all(|a| a == 2); + assert(all); +} +``` + +### any + +Returns true if any of the elements satisfy the given predicate + +```rust +fn any(self, predicate: fn(T) -> bool) -> bool +``` + +example: + +```rust +fn main() { + let arr = [2, 2, 2, 2, 5]; + let any = arr.any(|a| a == 5); + assert(any); +} + +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/booleans.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/booleans.md new file mode 100644 index 00000000000..69826fcd724 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/booleans.md @@ -0,0 +1,31 @@ +--- +title: Booleans +description: + Delve into the Boolean data type in Noir. Understand its methods, practical examples, and best practices for using Booleans in your Noir programs. +keywords: + [ + noir, + boolean type, + methods, + examples, + logical operations, + ] +sidebar_position: 2 +--- + + +The `bool` type in Noir has two possible values: `true` and `false`: + +```rust +fn main() { + let t = true; + let f: bool = false; +} +``` + +> **Note:** When returning a boolean value, it will show up as a value of 1 for `true` and 0 for +> `false` in _Verifier.toml_. + +The boolean type is most commonly used in conditionals like `if` expressions and `assert` +statements. More about conditionals is covered in the [Control Flow](../control_flow) and +[Assert Function](../assert) sections. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/fields.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/fields.md new file mode 100644 index 00000000000..99b4aa63549 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/fields.md @@ -0,0 +1,192 @@ +--- +title: Fields +description: + Dive deep into the Field data type in Noir. Understand its methods, practical examples, and best practices to effectively use Fields in your Noir programs. +keywords: + [ + noir, + field type, + methods, + examples, + best practices, + ] +sidebar_position: 0 +--- + +The field type corresponds to the native field type of the proving backend. + +The size of a Noir field depends on the elliptic curve's finite field for the proving backend +adopted. For example, a field would be a 254-bit integer when paired with the default backend that +spans the Grumpkin curve. + +Fields support integer arithmetic and are often used as the default numeric type in Noir: + +```rust +fn main(x : Field, y : Field) { + let z = x + y; +} +``` + +`x`, `y` and `z` are all private fields in this example. Using the `let` keyword we defined a new +private value `z` constrained to be equal to `x + y`. + +If proving efficiency is of priority, fields should be used as a default for solving problems. +Smaller integer types (e.g. `u64`) incur extra range constraints. + +## Methods + +After declaring a Field, you can use these common methods on it: + +### to_le_bits + +Transforms the field into an array of bits, Little Endian. + +```rust +fn to_le_bits(_x : Field, _bit_size: u32) -> [u1; N] +``` + +example: + +```rust +fn main() { + let field = 2; + let bits = field.to_le_bits(32); +} +``` + +### to_be_bits + +Transforms the field into an array of bits, Big Endian. + +```rust +fn to_be_bits(_x : Field, _bit_size: u32) -> [u1; N] +``` + +example: + +```rust +fn main() { + let field = 2; + let bits = field.to_be_bits(32); +} +``` + +### to_le_bytes + +Transforms into an array of bytes, Little Endian + +```rust +fn to_le_bytes(_x : Field, byte_size: u32) -> [u8] +``` + +example: + +```rust +fn main() { + let field = 2; + let bytes = field.to_le_bytes(4); +} +``` + +### to_be_bytes + +Transforms into an array of bytes, Big Endian + +```rust +fn to_be_bytes(_x : Field, byte_size: u32) -> [u8] +``` + +example: + +```rust +fn main() { + let field = 2; + let bytes = field.to_be_bytes(4); +} +``` + +### to_le_radix + +Decomposes into a vector over the specified base, Little Endian + +```rust +fn to_le_radix(_x : Field, _radix: u32, _result_len: u32) -> [u8] +``` + +example: + +```rust +fn main() { + let field = 2; + let radix = field.to_le_radix(256, 4); +} +``` + +### to_be_radix + +Decomposes into a vector over the specified base, Big Endian + +```rust +fn to_be_radix(_x : Field, _radix: u32, _result_len: u32) -> [u8] +``` + +example: + +```rust +fn main() { + let field = 2; + let radix = field.to_be_radix(256, 4); +} +``` + +### pow_32 + +Returns the value to the power of the specified exponent + +```rust +fn pow_32(self, exponent: Field) -> Field +``` + +example: + +```rust +fn main() { + let field = 2 + let pow = field.pow_32(4); + assert(pow == 16); +} +``` + +### assert_max_bit_size + +Adds a constraint to specify that the field can be represented with `bit_size` number of bits + +```rust +fn assert_max_bit_size(self, bit_size: u32) +``` + +example: + +```rust +fn main() { + let field = 2 + field.assert_max_bit_size(32); +} +``` + +### sgn0 + +Parity of (prime) Field element, i.e. sgn0(x mod p) = 0 if x ∈ \{0, ..., p-1\} is even, otherwise sgn0(x mod p) = 1. + +```rust +fn sgn0(self) -> u1 +``` + + +### lt + +Returns true if the field is less than the other field + +```rust +pub fn lt(self, another: Field) -> bool +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/function_types.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/function_types.md new file mode 100644 index 00000000000..f6121af17e2 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/function_types.md @@ -0,0 +1,26 @@ +--- +title: Function types +sidebar_position: 10 +--- + +Noir supports higher-order functions. The syntax for a function type is as follows: + +```rust +fn(arg1_type, arg2_type, ...) -> return_type +``` + +Example: + +```rust +fn assert_returns_100(f: fn() -> Field) { // f takes no args and returns a Field + assert(f() == 100); +} + +fn main() { + assert_returns_100(|| 100); // ok + assert_returns_100(|| 150); // fails +} +``` + +A function type also has an optional capture environment - this is necessary to support closures. +See [Lambdas](../lambdas.md) for more details. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/index.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/index.md new file mode 100644 index 00000000000..97b3b2cb094 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/index.md @@ -0,0 +1,110 @@ +--- +title: Data Types +description: + Get a clear understanding of the two categories of Noir data types - primitive types and compound + types. Learn about their characteristics, differences, and how to use them in your Noir + programming. +keywords: + [ + noir, + data types, + primitive types, + compound types, + private types, + public types, + ] +--- + +Every value in Noir has a type, which determines which operations are valid for it. + +All values in Noir are fundamentally composed of `Field` elements. For a more approachable +developing experience, abstractions are added on top to introduce different data types in Noir. + +Noir has two category of data types: primitive types (e.g. `Field`, integers, `bool`) and compound +types that group primitive types (e.g. arrays, tuples, structs). Each value can either be private or +public. + +## Private & Public Types + +A **private value** is known only to the Prover, while a **public value** is known by both the +Prover and Verifier. Mark values as `private` when the value should only be known to the prover. All +primitive types (including individual fields of compound types) in Noir are private by default, and +can be marked public when certain values are intended to be revealed to the Verifier. + +> **Note:** For public values defined in Noir programs paired with smart contract verifiers, once +> the proofs are verified on-chain the values can be considered known to everyone that has access to +> that blockchain. + +Public data types are treated no differently to private types apart from the fact that their values +will be revealed in proofs generated. Simply changing the value of a public type will not change the +circuit (where the same goes for changing values of private types as well). + +_Private values_ are also referred to as _witnesses_ sometimes. + +> **Note:** The terms private and public when applied to a type (e.g. `pub Field`) have a different +> meaning than when applied to a function (e.g. `pub fn foo() {}`). +> +> The former is a visibility modifier for the Prover to interpret if a value should be made known to +> the Verifier, while the latter is a visibility modifier for the compiler to interpret if a +> function should be made accessible to external Noir programs like in other languages. + +### pub Modifier + +All data types in Noir are private by default. Types are explicitly declared as public using the +`pub` modifier: + +```rust +fn main(x : Field, y : pub Field) -> pub Field { + x + y +} +``` + +In this example, `x` is **private** while `y` and `x + y` (the return value) are **public**. Note +that visibility is handled **per variable**, so it is perfectly valid to have one input that is +private and another that is public. + +> **Note:** Public types can only be declared through parameters on `main`. + +## Type Aliases + +A type alias is a new name for an existing type. Type aliases are declared with the keyword `type`: + +```rust +type Id = u8; + +fn main() { + let id: Id = 1; + let zero: u8 = 0; + assert(zero + 1 == id); +} +``` + +Type aliases can also be used with [generics](@site/docs/noir/concepts/generics.md): + +```rust +type Id = Size; + +fn main() { + let id: Id = 1; + let zero: u32 = 0; + assert(zero + 1 == id); +} +``` + +Type aliases can even refer to other aliases. An error will be issued if they form a cycle: + +```rust +// Ok! +type A = B; +type B = Field; + +type Bad1 = Bad2; + +// error: Dependency cycle found +type Bad2 = Bad1; +// ^^^^^^^^^^^ 'Bad2' recursively depends on itself: Bad2 -> Bad1 -> Bad2 +``` + +### BigInt + +You can achieve BigInt functionality using the [Noir BigInt](https://github.com/shuklaayush/noir-bigint) library. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/integers.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/integers.md new file mode 100644 index 00000000000..4d58d96fed5 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/integers.md @@ -0,0 +1,155 @@ +--- +title: Integers +description: Explore the Integer data type in Noir. Learn about its methods, see real-world examples, and grasp how to efficiently use Integers in your Noir code. +keywords: [noir, integer types, methods, examples, arithmetic] +sidebar_position: 1 +--- + +An integer type is a range constrained field type. The Noir frontend supports both unsigned and signed integer types. The allowed sizes are 1, 8, 32 and 64 bits. + +:::info + +When an integer is defined in Noir without a specific type, it will default to `Field`. + +The one exception is for loop indices which default to `u64` since comparisons on `Field`s are not possible. + +::: + +## Unsigned Integers + +An unsigned integer type is specified first with the letter `u` (indicating its unsigned nature) followed by its bit size (e.g. `8`): + +```rust +fn main() { + let x: u8 = 1; + let y: u8 = 1; + let z = x + y; + assert (z == 2); +} +``` + +The bit size determines the maximum value the integer type can store. For example, a `u8` variable can store a value in the range of 0 to 255 (i.e. $\\2^{8}-1\\$). + +## Signed Integers + +A signed integer type is specified first with the letter `i` (which stands for integer) followed by its bit size (e.g. `8`): + +```rust +fn main() { + let x: i8 = -1; + let y: i8 = -1; + let z = x + y; + assert (z == -2); +} +``` + +The bit size determines the maximum and minimum range of value the integer type can store. For example, an `i8` variable can store a value in the range of -128 to 127 (i.e. $\\-2^{7}\\$ to $\\2^{7}-1\\$). + +## 128 bits Unsigned Integers + +The built-in structure `U128` allows you to use 128-bit unsigned integers almost like a native integer type. However, there are some differences to keep in mind: +- You cannot cast between a native integer and `U128` +- There is a higher performance cost when using `U128`, compared to a native type. + +Conversion between unsigned integer types and U128 are done through the use of `from_integer` and `to_integer` functions. + +```rust +fn main() { + let x = U128::from_integer(23); + let y = U128::from_hex("0x7"); + let z = x + y; + assert(z.to_integer() == 30); +} +``` + +`U128` is implemented with two 64 bits limbs, representing the low and high bits, which explains the performance cost. You should expect `U128` to be twice more costly for addition and four times more costly for multiplication. +You can construct a U128 from its limbs: +```rust +fn main(x: u64, y: u64) { + let x = U128::from_u64s_be(x,y); + assert(z.hi == x as Field); + assert(z.lo == y as Field); +} +``` + +Note that the limbs are stored as Field elements in order to avoid unnecessary conversions. +Apart from this, most operations will work as usual: + +```rust +fn main(x: U128, y: U128) { + // multiplication + let c = x * y; + // addition and subtraction + let c = c - x + y; + // division + let c = x / y; + // bit operation; + let c = x & y | y; + // bit shift + let c = x << y; + // comparisons; + let c = x < y; + let c = x == y; +} +``` + +## Overflows + +Computations that exceed the type boundaries will result in overflow errors. This happens with both signed and unsigned integers. For example, attempting to prove: + +```rust +fn main(x: u8, y: u8) { + let z = x + y; +} +``` + +With: + +```toml +x = "255" +y = "1" +``` + +Would result in: + +``` +$ nargo prove +error: Assertion failed: 'attempt to add with overflow' +┌─ ~/src/main.nr:9:13 +│ +│ let z = x + y; +│ ----- +│ += Call stack: + ... +``` + +A similar error would happen with signed integers: + +```rust +fn main() { + let x: i8 = -118; + let y: i8 = -11; + let z = x + y; +} +``` + +### Wrapping methods + +Although integer overflow is expected to error, some use-cases rely on wrapping. For these use-cases, the standard library provides `wrapping` variants of certain common operations: + +```rust +fn wrapping_add(x: T, y: T) -> T; +fn wrapping_sub(x: T, y: T) -> T; +fn wrapping_mul(x: T, y: T) -> T; +``` + +Example of how it is used: + +```rust +use dep::std; + +fn main(x: u8, y: u8) -> pub u8 { + std::wrapping_add(x, y) +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/references.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/references.md new file mode 100644 index 00000000000..a5293d11cfb --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/references.md @@ -0,0 +1,23 @@ +--- +title: References +sidebar_position: 9 +--- + +Noir supports first-class references. References are a bit like pointers: they point to a specific address that can be followed to access the data stored at that address. You can use Rust-like syntax to use pointers in Noir: the `&` operator references the variable, the `*` operator dereferences it. + +Example: + +```rust +fn main() { + let mut x = 2; + + // you can reference x as &mut and pass it to multiplyBy2 + multiplyBy2(&mut x); +} + +// you can access &mut here +fn multiplyBy2(x: &mut Field) { + // and dereference it with * + *x = *x * 2; +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/slices.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/slices.mdx new file mode 100644 index 00000000000..4a6ee816aa2 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/slices.mdx @@ -0,0 +1,147 @@ +--- +title: Slices +description: Explore the Slice data type in Noir. Understand its methods, see real-world examples, and learn how to effectively use Slices in your Noir programs. +keywords: [noir, slice type, methods, examples, subarrays] +sidebar_position: 5 +--- + +import Experimental from '@site/src/components/Notes/_experimental.mdx'; + + + +A slice is a dynamically-sized view into a sequence of elements. They can be resized at runtime, but because they don't own the data, they cannot be returned from a circuit. You can treat slices as arrays without a constrained size. + +```rust +use dep::std::slice; + +fn main() -> pub Field { + let mut slice: [Field] = [0; 2]; + + let mut new_slice = slice.push_back(6); + new_slice.len() +} +``` + +View the corresponding test file [here][test-file]. + +[test-file]: https://github.com/noir-lang/noir/blob/f387ec1475129732f72ba294877efdf6857135ac/crates/nargo_cli/tests/test_data_ssa_refactor/slices/src/main.nr + +## Methods + +For convenience, the STD provides some ready-to-use, common methods for slices: + +### push_back + +Pushes a new element to the end of the slice, returning a new slice with a length one greater than the original unmodified slice. + +```rust +fn push_back(_self: [T], _elem: T) -> [T] +``` + +example: + +```rust +fn main() -> pub Field { + let mut slice: [Field] = [0; 2]; + + let mut new_slice = slice.push_back(6); + new_slice.len() +} +``` + +View the corresponding test file [here][test-file]. + +### push_front + +Returns a new array with the specified element inserted at index 0. The existing elements indexes are incremented by 1. + +```rust +fn push_front(_self: Self, _elem: T) -> Self +``` + +Example: + +```rust +let mut new_slice: [Field] = []; +new_slice = new_slice.push_front(20); +assert(new_slice[0] == 20); // returns true +``` + +View the corresponding test file [here][test-file]. + +### pop_front + +Returns a tuple of two items, the first element of the array and the rest of the array. + +```rust +fn pop_front(_self: Self) -> (T, Self) +``` + +Example: + +```rust +let (first_elem, rest_of_slice) = slice.pop_front(); +``` + +View the corresponding test file [here][test-file]. + +### pop_back + +Returns a tuple of two items, the beginning of the array with the last element omitted and the last element. + +```rust +fn pop_back(_self: Self) -> (Self, T) +``` + +Example: + +```rust +let (popped_slice, last_elem) = slice.pop_back(); +``` + +View the corresponding test file [here][test-file]. + +### append + +Loops over a slice and adds it to the end of another. + +```rust +fn append(mut self, other: Self) -> Self +``` + +Example: + +```rust +let append = [1, 2].append([3, 4, 5]); +``` + +### insert + +Inserts an element at a specified index and shifts all following elements by 1. + +```rust +fn insert(_self: Self, _index: Field, _elem: T) -> Self +``` + +Example: + +```rust +new_slice = rest_of_slice.insert(2, 100); +assert(new_slice[2] == 100); +``` + +View the corresponding test file [here][test-file]. + +### remove + +Remove an element at a specified index, shifting all elements after it to the left, returning the altered slice and the removed element. + +```rust +fn remove(_self: Self, _index: Field) -> (Self, T) +``` + +Example: + +```rust +let (remove_slice, removed_elem) = slice.remove(3); +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/strings.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/strings.md new file mode 100644 index 00000000000..311dfd64416 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/strings.md @@ -0,0 +1,80 @@ +--- +title: Strings +description: + Discover the String data type in Noir. Learn about its methods, see real-world examples, and understand how to effectively manipulate and use Strings in Noir. +keywords: + [ + noir, + string type, + methods, + examples, + concatenation, + ] +sidebar_position: 3 +--- + + +The string type is a fixed length value defined with `str`. + +You can use strings in `assert()` functions or print them with +`println()`. See more about [Logging](../../standard_library/logging). + +```rust +use dep::std; + +fn main(message : pub str<11>, hex_as_string : str<4>) { + println(message); + assert(message == "hello world"); + assert(hex_as_string == "0x41"); +} +``` + +You can convert a `str` to a byte array by calling `as_bytes()` +or a vector by calling `as_bytes_vec()`. + +```rust +fn main() { + let message = "hello world"; + let message_bytes = message.as_bytes(); + let mut message_vec = message.as_bytes_vec(); + assert(message_bytes.len() == 11); + assert(message_bytes[0] == 104); + assert(message_bytes[0] == message_vec.get(0)); +} +``` + +## Escape characters + +You can use escape characters for your strings: + +| Escape Sequence | Description | +|-----------------|-----------------| +| `\r` | Carriage Return | +| `\n` | Newline | +| `\t` | Tab | +| `\0` | Null Character | +| `\"` | Double Quote | +| `\\` | Backslash | + +Example: + +```rust +let s = "Hello \"world" // prints "Hello "world" +let s = "hey \tyou"; // prints "hey you" +``` + +## Raw strings + +A raw string begins with the letter `r` and is optionally delimited by a number of hashes `#`. + +Escape characters are *not* processed within raw strings. All contents are interpreted literally. + +Example: + +```rust +let s = r"Hello world"; +let s = r#"Simon says "hello world""#; + +// Any number of hashes may be used (>= 1) as long as the string also terminates with the same number of hashes +let s = r#####"One "#, Two "##, Three "###, Four "####, Five will end the string."#####; +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/structs.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/structs.md new file mode 100644 index 00000000000..dbf68c99813 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/structs.md @@ -0,0 +1,70 @@ +--- +title: Structs +description: + Explore the Struct data type in Noir. Learn about its methods, see real-world examples, and grasp how to effectively define and use Structs in your Noir programs. +keywords: + [ + noir, + struct type, + methods, + examples, + data structures, + ] +sidebar_position: 8 +--- + +A struct also allows for grouping multiple values of different types. Unlike tuples, we can also +name each field. + +> **Note:** The usage of _field_ here refers to each element of the struct and is unrelated to the +> field type of Noir. + +Defining a struct requires giving it a name and listing each field within as `: ` pairs: + +```rust +struct Animal { + hands: Field, + legs: Field, + eyes: u8, +} +``` + +An instance of a struct can then be created with actual values in `: ` pairs in any +order. Struct fields are accessible using their given names: + +```rust +fn main() { + let legs = 4; + + let dog = Animal { + eyes: 2, + hands: 0, + legs, + }; + + let zero = dog.hands; +} +``` + +Structs can also be destructured in a pattern, binding each field to a new variable: + +```rust +fn main() { + let Animal { hands, legs: feet, eyes } = get_octopus(); + + let ten = hands + feet + eyes as u8; +} + +fn get_octopus() -> Animal { + let octopus = Animal { + hands: 0, + legs: 8, + eyes: 2, + }; + + octopus +} +``` + +The new variables can be bound with names different from the original struct field names, as +showcased in the `legs --> feet` binding in the example above. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/tuples.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/tuples.md new file mode 100644 index 00000000000..2ec5c9c4113 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/tuples.md @@ -0,0 +1,48 @@ +--- +title: Tuples +description: + Dive into the Tuple data type in Noir. Understand its methods, practical examples, and best practices for efficiently using Tuples in your Noir code. +keywords: + [ + noir, + tuple type, + methods, + examples, + multi-value containers, + ] +sidebar_position: 7 +--- + +A tuple collects multiple values like an array, but with the added ability to collect values of +different types: + +```rust +fn main() { + let tup: (u8, u64, Field) = (255, 500, 1000); +} +``` + +One way to access tuple elements is via destructuring using pattern matching: + +```rust +fn main() { + let tup = (1, 2); + + let (one, two) = tup; + + let three = one + two; +} +``` + +Another way to access tuple elements is via direct member access, using a period (`.`) followed by +the index of the element we want to access. Index `0` corresponds to the first tuple element, `1` to +the second and so on: + +```rust +fn main() { + let tup = (5, 6, 7, 8); + + let five = tup.0; + let eight = tup.3; +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/distinct.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/distinct.md new file mode 100644 index 00000000000..6c993b8b5e0 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/distinct.md @@ -0,0 +1,64 @@ +--- +title: Distinct Witnesses +sidebar_position: 11 +--- + +The `distinct` keyword prevents repetitions of witness indices in the program's ABI. This ensures +that the witnesses being returned as public inputs are all unique. + +The `distinct` keyword is only used for return values on program entry points (usually the `main()` +function). + +When using `distinct` and `pub` simultaneously, `distinct` comes first. See the example below. + +You can read more about the problem this solves +[here](https://github.com/noir-lang/noir/issues/1183). + +## Example + +Without the `distinct` keyword, the following program + +```rust +fn main(x : pub Field, y : pub Field) -> pub [Field; 4] { + let a = 1; + let b = 1; + [x + 1, y, a, b] +} +``` + +compiles to + +```json +{ + //... + "abi": { + //... + "param_witnesses": { "x": [1], "y": [2] }, + "return_witnesses": [3, 2, 4, 4] + } +} +``` + +Whereas (with the `distinct` keyword) + +```rust +fn main(x : pub Field, y : pub Field) -> distinct pub [Field; 4] { + let a = 1; + let b = 1; + [x + 1, y, a, b] +} +``` + +compiles to + +```json +{ + //... + "abi": { + //... + "param_witnesses": { "x": [1], "y": [2] }, + //... + "return_witnesses": [3, 4, 5, 6] + } +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/functions.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/functions.md new file mode 100644 index 00000000000..48aba9cd058 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/functions.md @@ -0,0 +1,226 @@ +--- +title: Functions +description: + Learn how to declare functions and methods in Noir, a programming language with Rust semantics. + This guide covers parameter declaration, return types, call expressions, and more. +keywords: [Noir, Rust, functions, methods, parameter declaration, return types, call expressions] +sidebar_position: 1 +--- + +Functions in Noir follow the same semantics of Rust, though Noir does not support early returns. + +To declare a function the `fn` keyword is used. + +```rust +fn foo() {} +``` + +By default, functions are visible only within the package they are defined. To make them visible outside of that package (for example, as part of a [library](../modules_packages_crates/crates_and_packages.md#libraries)), you should mark them as `pub`: + +```rust +pub fn foo() {} +``` + +You can also restrict the visibility of the function to only the crate it was defined in, by specifying `pub(crate)`: + +```rust +pub(crate) fn foo() {} //foo can only be called within its crate +``` + +All parameters in a function must have a type and all types are known at compile time. The parameter +is pre-pended with a colon and the parameter type. Multiple parameters are separated using a comma. + +```rust +fn foo(x : Field, y : Field){} +``` + +The return type of a function can be stated by using the `->` arrow notation. The function below +states that the foo function must return a `Field`. If the function returns no value, then the arrow +is omitted. + +```rust +fn foo(x : Field, y : Field) -> Field { + x + y +} +``` + +Note that a `return` keyword is unneeded in this case - the last expression in a function's body is +returned. + +## Main function + +If you're writing a binary, the `main` function is the starting point of your program. You can pass all types of expressions to it, as long as they have a fixed size at compile time: + +```rust +fn main(x : Field) // this is fine: passing a Field +fn main(x : [Field; 2]) // this is also fine: passing a Field with known size at compile-time +fn main(x : (Field, bool)) // 👌: passing a (Field, bool) tuple means size 2 +fn main(x : str<5>) // this is fine, as long as you pass a string of size 5 + +fn main(x : Vec) // can't compile, has variable size +fn main(x : [Field]) // can't compile, has variable size +fn main(....// i think you got it by now +``` + +Keep in mind [tests](../../getting_started/tooling/testing.md) don't differentiate between `main` and any other function. The following snippet passes tests, but won't compile or prove: + +```rust +fn main(x : [Field]) { + assert(x[0] == 1); +} + +#[test] +fn test_one() { + main([1, 2]); +} +``` + +```bash +$ nargo test +[testing] Running 1 test functions +[testing] Testing test_one... ok +[testing] All tests passed + +$ nargo check +The application panicked (crashed). +Message: Cannot have variable sized arrays as a parameter to main +``` + +## Call Expressions + +Calling a function in Noir is executed by using the function name and passing in the necessary +arguments. + +Below we show how to call the `foo` function from the `main` function using a call expression: + +```rust +fn main(x : Field, y : Field) { + let z = foo(x); +} + +fn foo(x : Field) -> Field { + x + x +} +``` + +## Methods + +You can define methods in Noir on any struct type in scope. + +```rust +struct MyStruct { + foo: Field, + bar: Field, +} + +impl MyStruct { + fn new(foo: Field) -> MyStruct { + MyStruct { + foo, + bar: 2, + } + } + + fn sum(self) -> Field { + self.foo + self.bar + } +} + +fn main() { + let s = MyStruct::new(40); + assert(s.sum() == 42); +} +``` + +Methods are just syntactic sugar for functions, so if we wanted to we could also call `sum` as +follows: + +```rust +assert(MyStruct::sum(s) == 42); +``` + +It is also possible to specialize which method is chosen depending on the [generic](./generics.md) type that is used. In this example, the `foo` function returns different values depending on its type: + +```rust +struct Foo {} + +impl Foo { + fn foo(self) -> Field { 1 } +} + +impl Foo { + fn foo(self) -> Field { 2 } +} + +fn main() { + let f1: Foo = Foo{}; + let f2: Foo = Foo{}; + assert(f1.foo() + f2.foo() == 3); +} +``` + +Also note that impls with the same method name defined in them cannot overlap. For example, if we already have `foo` defined for `Foo` and `Foo` like we do above, we cannot also define `foo` in an `impl Foo` since it would be ambiguous which version of `foo` to choose. + +```rust +// Including this impl in the same project as the above snippet would +// cause an overlapping impls error +impl Foo { + fn foo(self) -> Field { 3 } +} +``` + +## Lambdas + +Lambdas are anonymous functions. They follow the syntax of Rust - `|arg1, arg2, ..., argN| return_expression`. + +```rust +let add_50 = |val| val + 50; +assert(add_50(100) == 150); +``` + +See [Lambdas](./lambdas.md) for more details. + +## Attributes + +Attributes are metadata that can be applied to a function, using the following syntax: `#[attribute(value)]`. + +Supported attributes include: + +- **builtin**: the function is implemented by the compiler, for efficiency purposes. +- **deprecated**: mark the function as _deprecated_. Calling the function will generate a warning: `warning: use of deprecated function` +- **field**: Used to enable conditional compilation of code depending on the field size. See below for more details +- **oracle**: mark the function as _oracle_; meaning it is an external unconstrained function, implemented in noir_js. See [Unconstrained](./unconstrained.md) and [NoirJS](../../reference/NoirJS/noir_js/index.md) for more details. +- **test**: mark the function as unit tests. See [Tests](../../getting_started/tooling/testing.md) for more details + +### Field Attribute + +The field attribute defines which field the function is compatible for. The function is conditionally compiled, under the condition that the field attribute matches the Noir native field. +The field can be defined implicitly, by using the name of the elliptic curve usually associated to it - for instance bn254, bls12_381 - or explicitly by using the field (prime) order, in decimal or hexadecimal form. +As a result, it is possible to define multiple versions of a function with each version specialized for a different field attribute. This can be useful when a function requires different parameters depending on the underlying elliptic curve. + +Example: we define the function `foo()` three times below. Once for the default Noir bn254 curve, once for the field $\mathbb F_{23}$, which will normally never be used by Noir, and once again for the bls12_381 curve. + +```rust +#[field(bn254)] +fn foo() -> u32 { + 1 +} + +#[field(23)] +fn foo() -> u32 { + 2 +} + +// This commented code would not compile as foo would be defined twice because it is the same field as bn254 +// #[field(21888242871839275222246405745257275088548364400416034343698204186575808495617)] +// fn foo() -> u32 { +// 2 +// } + +#[field(bls12_381)] +fn foo() -> u32 { + 3 +} +``` + +If the field name is not known to Noir, it will discard the function. Field names are case insensitive. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/generics.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/generics.md new file mode 100644 index 00000000000..ddd42bf1f9b --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/generics.md @@ -0,0 +1,106 @@ +--- +title: Generics +description: Learn how to use Generics in Noir +keywords: [Noir, Rust, generics, functions, structs] +sidebar_position: 7 +--- + +Generics allow you to use the same functions with multiple different concrete data types. You can +read more about the concept of generics in the Rust documentation +[here](https://doc.rust-lang.org/book/ch10-01-syntax.html). + +Here is a trivial example showing the identity function that supports any type. In Rust, it is +common to refer to the most general type as `T`. We follow the same convention in Noir. + +```rust +fn id(x: T) -> T { + x +} +``` + +## In Structs + +Generics are useful for specifying types in structs. For example, we can specify that a field in a +struct will be of a certain generic type. In this case `value` is of type `T`. + +```rust +struct RepeatedValue { + value: T, + count: Field, +} + +impl RepeatedValue { + fn print(self) { + for _i in 0 .. self.count { + println(self.value); + } + } +} + +fn main() { + let repeated = RepeatedValue { value: "Hello!", count: 2 }; + repeated.print(); +} +``` + +The `print` function will print `Hello!` an arbitrary number of times, twice in this case. + +If we want to be generic over array lengths (which are type-level integers), we can use numeric +generics. Using these looks just like using regular generics, but these generics can resolve to +integers at compile-time, rather than resolving to types. Here's an example of a struct that is +generic over the size of the array it contains internally: + +```rust +struct BigInt { + limbs: [u32; N], +} + +impl BigInt { + // `N` is in scope of all methods in the impl + fn first(first: BigInt, second: BigInt) -> Self { + assert(first.limbs != second.limbs); + first + + fn second(first: BigInt, second: Self) -> Self { + assert(first.limbs != second.limbs); + second + } +} +``` + +## Calling functions on generic parameters + +Since a generic type `T` can represent any type, how can we call functions on the underlying type? +In other words, how can we go from "any type `T`" to "any type `T` that has certain methods available?" + +This is what [traits](../concepts/traits) are for in Noir. Here's an example of a function generic over +any type `T` that implements the `Eq` trait for equality: + +```rust +fn first_element_is_equal(array1: [T; N], array2: [T; N]) -> bool + where T: Eq +{ + if (array1.len() == 0) | (array2.len() == 0) { + true + } else { + array1[0] == array2[0] + } +} + +fn main() { + assert(first_element_is_equal([1, 2, 3], [1, 5, 6])); + + // We can use first_element_is_equal for arrays of any type + // as long as we have an Eq impl for the types we pass in + let array = [MyStruct::new(), MyStruct::new()]; + assert(array_eq(array, array, MyStruct::eq)); +} + +impl Eq for MyStruct { + fn eq(self, other: MyStruct) -> bool { + self.foo == other.foo + } +} +``` + +You can find more details on traits and trait implementations on the [traits page](../concepts/traits). diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/globals.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/globals.md new file mode 100644 index 00000000000..063a3d89248 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/globals.md @@ -0,0 +1,72 @@ +--- +title: Global Variables +description: + Learn about global variables in Noir. Discover how + to declare, modify, and use them in your programs. +keywords: [noir programming language, globals, global variables, constants] +sidebar_position: 8 +--- + +## Globals + + +Noir supports global variables. The global's type can be inferred by the compiler entirely: + +```rust +global N = 5; // Same as `global N: Field = 5` + +global TUPLE = (3, 2); + +fn main() { + assert(N == 5); + assert(N == TUPLE.0 + TUPLE.1); +} +``` + +:::info + +Globals can be defined as any expression, so long as they don't depend on themselves - otherwise there would be a dependency cycle! For example: + +```rust +global T = foo(T); // dependency error +``` + +::: + + +If they are initialized to a literal integer, globals can be used to specify an array's length: + +```rust +global N: Field = 2; + +fn main(y : [Field; N]) { + assert(y[0] == y[1]) +} +``` + +A global from another module can be imported or referenced externally like any other name: + +```rust +global N = 20; + +fn main() { + assert(my_submodule::N != N); +} + +mod my_submodule { + global N: Field = 10; +} +``` + +When a global is used, Noir replaces the name with its definition on each occurrence. +This means globals defined using function calls will repeat the call each time they're used: + +```rust +global RESULT = foo(); + +fn foo() -> [Field; 100] { ... } +``` + +This is usually fine since Noir will generally optimize any function call that does not +refer to a program input into a constant. It should be kept in mind however, if the called +function performs side-effects like `println`, as these will still occur on each use. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/lambdas.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/lambdas.md new file mode 100644 index 00000000000..be3c7e0b5ca --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/lambdas.md @@ -0,0 +1,81 @@ +--- +title: Lambdas +description: Learn how to use anonymous functions in Noir programming language. +keywords: [Noir programming language, lambda, closure, function, anonymous function] +sidebar_position: 9 +--- + +## Introduction + +Lambdas are anonymous functions. The syntax is `|arg1, arg2, ..., argN| return_expression`. + +```rust +let add_50 = |val| val + 50; +assert(add_50(100) == 150); +``` + +A block can be used as the body of a lambda, allowing you to declare local variables inside it: + +```rust +let cool = || { + let x = 100; + let y = 100; + x + y +} + +assert(cool() == 200); +``` + +## Closures + +Inside the body of a lambda, you can use variables defined in the enclosing function. Such lambdas are called **closures**. In this example `x` is defined inside `main` and is accessed from within the lambda: + +```rust +fn main() { + let x = 100; + let closure = || x + 150; + assert(closure() == 250); +} +``` + +## Passing closures to higher-order functions + +It may catch you by surprise that the following code fails to compile: + +```rust +fn foo(f: fn () -> Field) -> Field { + f() +} + +fn main() { + let (x, y) = (50, 50); + assert(foo(|| x + y) == 100); // error :( +} +``` + +The reason is that the closure's capture environment affects its type - we have a closure that captures two Fields and `foo` +expects a regular function as an argument - those are incompatible. +:::note + +Variables contained within the `||` are the closure's parameters, and the expression that follows it is the closure's body. The capture environment is comprised of any variables used in the closure's body that are not parameters. + +E.g. in |x| x + y, y would be a captured variable, but x would not be, since it is a parameter of the closure. + +::: +The syntax for the type of a closure is `fn[env](args) -> ret_type`, where `env` is the capture environment of the closure - +in this example that's `(Field, Field)`. + +The best solution in our case is to make `foo` generic over the environment type of its parameter, so that it can be called +with closures with any environment, as well as with regular functions: + +```rust +fn foo(f: fn[Env]() -> Field) -> Field { + f() +} + +fn main() { + let (x, y) = (50, 50); + assert(foo(|| x + y) == 100); // compiles fine + assert(foo(|| 60) == 60); // compiles fine +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/mutability.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/mutability.md new file mode 100644 index 00000000000..fdeef6a87c5 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/mutability.md @@ -0,0 +1,121 @@ +--- +title: Mutability +description: + Learn about mutable variables in Noir. Discover how + to declare, modify, and use them in your programs. +keywords: [noir programming language, mutability in noir, mutable variables] +sidebar_position: 8 +--- + +Variables in noir can be declared mutable via the `mut` keyword. Mutable variables can be reassigned +to via an assignment expression. + +```rust +let x = 2; +x = 3; // error: x must be mutable to be assigned to + +let mut y = 3; +let y = 4; // OK +``` + +The `mut` modifier can also apply to patterns: + +```rust +let (a, mut b) = (1, 2); +a = 11; // error: a must be mutable to be assigned to +b = 12; // OK + +let mut (c, d) = (3, 4); +c = 13; // OK +d = 14; // OK + +// etc. +let MyStruct { x: mut y } = MyStruct { x: a }; +// y is now in scope +``` + +Note that mutability in noir is local and everything is passed by value, so if a called function +mutates its parameters then the parent function will keep the old value of the parameters. + +```rust +fn main() -> pub Field { + let x = 3; + helper(x); + x // x is still 3 +} + +fn helper(mut x: i32) { + x = 4; +} +``` + +## Non-local mutability + +Non-local mutability can be achieved through the mutable reference type `&mut T`: + +```rust +fn set_to_zero(x: &mut Field) { + *x = 0; +} + +fn main() { + let mut y = 42; + set_to_zero(&mut y); + assert(*y == 0); +} +``` + +When creating a mutable reference, the original variable being referred to (`y` in this +example) must also be mutable. Since mutable references are a reference type, they must +be explicitly dereferenced via `*` to retrieve the underlying value. Note that this yields +a copy of the value, so mutating this copy will not change the original value behind the +reference: + +```rust +fn main() { + let mut x = 1; + let x_ref = &mut x; + + let mut y = *x_ref; + let y_ref = &mut y; + + x = 2; + *x_ref = 3; + + y = 4; + *y_ref = 5; + + assert(x == 3); + assert(*x_ref == 3); + assert(y == 5); + assert(*y_ref == 5); +} +``` + +Note that types in Noir are actually deeply immutable so the copy that occurs when +dereferencing is only a conceptual copy - no additional constraints will occur. + +Mutable references can also be stored within structs. Note that there is also +no lifetime parameter on these unlike rust. This is because the allocated memory +always lasts the entire program - as if it were an array of one element. + +```rust +struct Foo { + x: &mut Field +} + +impl Foo { + fn incr(mut self) { + *self.x += 1; + } +} + +fn main() { + let foo = Foo { x: &mut 0 }; + foo.incr(); + assert(*foo.x == 1); +} +``` + +In general, you should avoid non-local & shared mutability unless it is needed. Sticking +to only local mutability will improve readability and potentially improve compiler optimizations as well. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/ops.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/ops.md new file mode 100644 index 00000000000..60425cb8994 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/ops.md @@ -0,0 +1,98 @@ +--- +title: Logical Operations +description: + Learn about the supported arithmetic and logical operations in the Noir programming language. + Discover how to perform operations on private input types, integers, and booleans. +keywords: + [ + Noir programming language, + supported operations, + arithmetic operations, + logical operations, + predicate operators, + bitwise operations, + short-circuiting, + backend, + ] +sidebar_position: 3 +--- + +# Operations + +## Table of Supported Operations + +| Operation | Description | Requirements | +| :-------- | :------------------------------------------------------------: | -------------------------------------: | +| + | Adds two private input types together | Types must be private input | +| - | Subtracts two private input types together | Types must be private input | +| \* | Multiplies two private input types together | Types must be private input | +| / | Divides two private input types together | Types must be private input | +| ^ | XOR two private input types together | Types must be integer | +| & | AND two private input types together | Types must be integer | +| \| | OR two private input types together | Types must be integer | +| \<\< | Left shift an integer by another integer amount | Types must be integer | +| >> | Right shift an integer by another integer amount | Types must be integer | +| ! | Bitwise not of a value | Type must be integer or boolean | +| \< | returns a bool if one value is less than the other | Upper bound must have a known bit size | +| \<= | returns a bool if one value is less than or equal to the other | Upper bound must have a known bit size | +| > | returns a bool if one value is more than the other | Upper bound must have a known bit size | +| >= | returns a bool if one value is more than or equal to the other | Upper bound must have a known bit size | +| == | returns a bool if one value is equal to the other | Both types must not be constants | +| != | returns a bool if one value is not equal to the other | Both types must not be constants | + +### Predicate Operators + +`<,<=, !=, == , >, >=` are known as predicate/comparison operations because they compare two values. +This differs from the operations such as `+` where the operands are used in _computation_. + +### Bitwise Operations Example + +```rust +fn main(x : Field) { + let y = x as u32; + let z = y & y; +} +``` + +`z` is implicitly constrained to be the result of `y & y`. The `&` operand is used to denote bitwise +`&`. + +> `x & x` would not compile as `x` is a `Field` and not an integer type. + +### Logical Operators + +Noir has no support for the logical operators `||` and `&&`. This is because encoding the +short-circuiting that these operators require can be inefficient for Noir's backend. Instead you can +use the bitwise operators `|` and `&` which operate identically for booleans, just without the +short-circuiting. + +```rust +let my_val = 5; + +let mut flag = 1; +if (my_val > 6) | (my_val == 0) { + flag = 0; +} +assert(flag == 1); + +if (my_val != 10) & (my_val < 50) { + flag = 0; +} +assert(flag == 0); +``` + +### Shorthand operators + +Noir shorthand operators for most of the above operators, namely `+=, -=, *=, /=, %=, &=, |=, ^=, <<=`, and `>>=`. These allow for more concise syntax. For example: + +```rust +let mut i = 0; +i = i + 1; +``` + +could be written as: + +```rust +let mut i = 0; +i += 1; +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/oracles.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/oracles.md new file mode 100644 index 00000000000..2e6a6818d48 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/oracles.md @@ -0,0 +1,23 @@ +--- +title: Oracles +description: Dive into how Noir supports Oracles via RPC calls, and learn how to declare an Oracle in Noir with our comprehensive guide. +keywords: + - Noir + - Oracles + - RPC Calls + - Unconstrained Functions + - Programming + - Blockchain +sidebar_position: 6 +--- + +Noir has support for Oracles via RPC calls. This means Noir will make an RPC call and use the return value for proof generation. + +Since Oracles are not resolved by Noir, they are [`unconstrained` functions](./unconstrained.md) + +You can declare an Oracle through the `#[oracle()]` flag. Example: + +```rust +#[oracle(get_number_sequence)] +unconstrained fn get_number_sequence(_size: Field) -> [Field] {} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/shadowing.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/shadowing.md new file mode 100644 index 00000000000..5ce6130d201 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/shadowing.md @@ -0,0 +1,44 @@ +--- +title: Shadowing +sidebar_position: 12 +--- + +Noir allows for inheriting variables' values and re-declaring them with the same name similar to Rust, known as shadowing. + +For example, the following function is valid in Noir: + +```rust +fn main() { + let x = 5; + + { + let x = x * 2; + assert (x == 10); + } + + assert (x == 5); +} +``` + +In this example, a variable x is first defined with the value 5. + +The local scope that follows shadows the original x, i.e. creates a local mutable x based on the value of the original x. It is given a value of 2 times the original x. + +When we return to the main scope, x once again refers to just the original x, which stays at the value of 5. + +## Temporal mutability + +One way that shadowing is useful, in addition to ergonomics across scopes, is for temporarily mutating variables. + +```rust +fn main() { + let age = 30; + // age = age + 5; // Would error as `age` is immutable by default. + + let mut age = age + 5; // Temporarily mutates `age` with a new value. + + let age = age; // Locks `age`'s mutability again. + + assert (age == 35); +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/traits.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/traits.md new file mode 100644 index 00000000000..ef1445a5907 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/traits.md @@ -0,0 +1,389 @@ +--- +title: Traits +description: + Traits in Noir can be used to abstract out a common interface for functions across + several data types. +keywords: [noir programming language, traits, interfaces, generic, protocol] +sidebar_position: 14 +--- + +## Overview + +Traits in Noir are a useful abstraction similar to interfaces or protocols in other languages. Each trait defines +the interface of several methods contained within the trait. Types can then implement this trait by providing +implementations for these methods. For example in the program: + +```rust +struct Rectangle { + width: Field, + height: Field, +} + +impl Rectangle { + fn area(self) -> Field { + self.width * self.height + } +} + +fn log_area(r: Rectangle) { + println(r.area()); +} +``` + +We have a function `log_area` to log the area of a `Rectangle`. Now how should we change the program if we want this +function to work on `Triangle`s as well?: + +```rust +struct Triangle { + width: Field, + height: Field, +} + +impl Triangle { + fn area(self) -> Field { + self.width * self.height / 2 + } +} +``` + +Making `log_area` generic over all types `T` would be invalid since not all types have an `area` method. Instead, we can +introduce a new `Area` trait and make `log_area` generic over all types `T` that implement `Area`: + +```rust +trait Area { + fn area(self) -> Field; +} + +fn log_area(shape: T) where T: Area { + println(shape.area()); +} +``` + +We also need to explicitly implement `Area` for `Rectangle` and `Triangle`. We can do that by changing their existing +impls slightly. Note that the parameter types and return type of each of our `area` methods must match those defined +by the `Area` trait. + +```rust +impl Area for Rectangle { + fn area(self) -> Field { + self.width * self.height + } +} + +impl Area for Triangle { + fn area(self) -> Field { + self.width * self.height / 2 + } +} +``` + +Now we have a working program that is generic over any type of Shape that is used! Others can even use this program +as a library with their own types - such as `Circle` - as long as they also implement `Area` for these types. + +## Where Clauses + +As seen in `log_area` above, when we want to create a function or method that is generic over any type that implements +a trait, we can add a where clause to the generic function. + +```rust +fn log_area(shape: T) where T: Area { + println(shape.area()); +} +``` + +It is also possible to apply multiple trait constraints on the same variable at once by combining traits with the `+` +operator. Similarly, we can have multiple trait constraints by separating each with a comma: + +```rust +fn foo(elements: [T], thing: U) where + T: Default + Add + Eq, + U: Bar, +{ + let mut sum = T::default(); + + for element in elements { + sum += element; + } + + if sum == T::default() { + thing.bar(); + } +} +``` + +## Generic Implementations + +You can add generics to a trait implementation by adding the generic list after the `impl` keyword: + +```rust +trait Second { + fn second(self) -> Field; +} + +impl Second for (T, Field) { + fn second(self) -> Field { + self.1 + } +} +``` + +You can also implement a trait for every type this way: + +```rust +trait Debug { + fn debug(self); +} + +impl Debug for T { + fn debug(self) { + println(self); + } +} + +fn main() { + 1.debug(); +} +``` + +### Generic Trait Implementations With Where Clauses + +Where clauses can also be placed on trait implementations themselves to restrict generics in a similar way. +For example, while `impl Foo for T` implements the trait `Foo` for every type, `impl Foo for T where T: Bar` +will implement `Foo` only for types that also implement `Bar`. This is often used for implementing generic types. +For example, here is the implementation for array equality: + +```rust +impl Eq for [T; N] where T: Eq { + // Test if two arrays have the same elements. + // Because both arrays must have length N, we know their lengths already match. + fn eq(self, other: Self) -> bool { + let mut result = true; + + for i in 0 .. self.len() { + // The T: Eq constraint is needed to call == on the array elements here + result &= self[i] == other[i]; + } + + result + } +} +``` + +## Generic Traits + +Traits themselves can also be generic by placing the generic arguments after the trait name. These generics are in +scope of every item within the trait. + +```rust +trait Into { + // Convert `self` to type `T` + fn into(self) -> T; +} +``` + +When implementing generic traits the generic arguments of the trait must be specified. This is also true anytime +when referencing a generic trait (e.g. in a `where` clause). + +```rust +struct MyStruct { + array: [Field; 2], +} + +impl Into<[Field; 2]> for MyStruct { + fn into(self) -> [Field; 2] { + self.array + } +} + +fn as_array(x: T) -> [Field; 2] + where T: Into<[Field; 2]> +{ + x.into() +} + +fn main() { + let array = [1, 2]; + let my_struct = MyStruct { array }; + + assert_eq(as_array(my_struct), array); +} +``` + +## Trait Methods With No `self` + +A trait can contain any number of methods, each of which have access to the `Self` type which represents each type +that eventually implements the trait. Similarly, the `self` variable is available as well but is not required to be used. +For example, we can define a trait to create a default value for a type. This trait will need to return the `Self` type +but doesn't need to take any parameters: + +```rust +trait Default { + fn default() -> Self; +} +``` + +Implementing this trait can be done similarly to any other trait: + +```rust +impl Default for Field { + fn default() -> Field { + 0 + } +} + +struct MyType {} + +impl Default for MyType { + fn default() -> Field { + MyType {} + } +} +``` + +However, since there is no `self` parameter, we cannot call it via the method call syntax `object.method()`. +Instead, we'll need to refer to the function directly. This can be done either by referring to the +specific impl `MyType::default()` or referring to the trait itself `Default::default()`. In the later +case, type inference determines the impl that is selected. + +```rust +let my_struct = MyStruct::default(); + +let x: Field = Default::default(); +let result = x + Default::default(); +``` + +:::warning + +```rust +let _ = Default::default(); +``` + +If type inference cannot select which impl to use because of an ambiguous `Self` type, an impl will be +arbitrarily selected. This occurs most often when the result of a trait function call with no parameters +is unused. To avoid this, when calling a trait function with no `self` or `Self` parameters or return type, +always refer to it via the implementation type's namespace - e.g. `MyType::default()`. +This is set to change to an error in future Noir versions. + +::: + +## Default Method Implementations + +A trait can also have default implementations of its methods by giving a body to the desired functions. +Note that this body must be valid for all types that may implement the trait. As a result, the only +valid operations on `self` will be operations valid for any type or other operations on the trait itself. + +```rust +trait Numeric { + fn add(self, other: Self) -> Self; + + // Default implementation of double is (self + self) + fn double(self) -> Self { + self.add(self) + } +} +``` + +When implementing a trait with default functions, a type may choose to implement only the required functions: + +```rust +impl Numeric for Field { + fn add(self, other: Field) -> Field { + self + other + } +} +``` + +Or it may implement the optional methods as well: + +```rust +impl Numeric for u32 { + fn add(self, other: u32) -> u32 { + self + other + } + + fn double(self) -> u32 { + self * 2 + } +} +``` + +## Impl Specialization + +When implementing traits for a generic type it is possible to implement the trait for only a certain combination +of generics. This can be either as an optimization or because those specific generics are required to implement the trait. + +```rust +trait Sub { + fn sub(self, other: Self) -> Self; +} + +struct NonZero { + value: T, +} + +impl Sub for NonZero { + fn sub(self, other: Self) -> Self { + let value = self.value - other.value; + assert(value != 0); + NonZero { value } + } +} +``` + +## Overlapping Implementations + +Overlapping implementations are disallowed by Noir to ensure Noir's decision on which impl to select is never ambiguous. +This means if a trait `Foo` is already implemented +by a type `Bar` for all `T`, then we cannot also have a separate impl for `Bar` (or any other +type argument). Similarly, if there is an impl for all `T` such as `impl Debug for T`, we cannot create +any more impls to `Debug` for other types since it would be ambiguous which impl to choose for any given +method call. + +```rust +trait Trait {} + +// Previous impl defined here +impl Trait for (A, B) {} + +// error: Impl for type `(Field, Field)` overlaps with existing impl +impl Trait for (Field, Field) {} +``` + +## Trait Coherence + +Another restriction on trait implementations is coherence. This restriction ensures other crates cannot create +impls that may overlap with other impls, even if several unrelated crates are used as dependencies in the same +program. + +The coherence restriction is: to implement a trait, either the trait itself or the object type must be declared +in the crate the impl is in. + +In practice this often comes up when using types provided by libraries. If a library provides a type `Foo` that does +not implement a trait in the standard library such as `Default`, you may not `impl Default for Foo` in your own crate. +While restrictive, this prevents later issues or silent changes in the program if the `Foo` library later added its +own impl for `Default`. If you are a user of the `Foo` library in this scenario and need a trait not implemented by the +library your choices are to either submit a patch to the library or use the newtype pattern. + +### The Newtype Pattern + +The newtype pattern gets around the coherence restriction by creating a new wrapper type around the library type +that we cannot create `impl`s for. Since the new wrapper type is defined in our current crate, we can create +impls for any trait we need on it. + +```rust +struct Wrapper { + foo: dep::some_library::Foo, +} + +impl Default for Wrapper { + fn default() -> Wrapper { + Wrapper { + foo: dep::some_library::Foo::new(), + } + } +} +``` + +Since we have an impl for our own type, the behavior of this code will not change even if `some_library` is updated +to provide its own `impl Default for Foo`. The downside of this pattern is that it requires extra wrapping and +unwrapping of values when converting to and from the `Wrapper` and `Foo` types. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/unconstrained.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/unconstrained.md new file mode 100644 index 00000000000..89d12c1c971 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/concepts/unconstrained.md @@ -0,0 +1,95 @@ +--- +title: Unconstrained Functions +description: "Learn about what unconstrained functions in Noir are, how to use them and when you'd want to." + +keywords: [Noir programming language, unconstrained, open] +sidebar_position: 5 +--- + +Unconstrained functions are functions which do not constrain any of the included computation and allow for non-deterministic computation. + +## Why? + +Zero-knowledge (ZK) domain-specific languages (DSL) enable developers to generate ZK proofs from their programs by compiling code down to the constraints of an NP complete language (such as R1CS or PLONKish languages). However, the hard bounds of a constraint system can be very limiting to the functionality of a ZK DSL. + +Enabling a circuit language to perform unconstrained execution is a powerful tool. Said another way, unconstrained execution lets developers generate witnesses from code that does not generate any constraints. Being able to execute logic outside of a circuit is critical for both circuit performance and constructing proofs on information that is external to a circuit. + +Fetching information from somewhere external to a circuit can also be used to enable developers to improve circuit efficiency. + +A ZK DSL does not just prove computation, but proves that some computation was handled correctly. Thus, it is necessary that when we switch from performing some operation directly inside of a circuit to inside of an unconstrained environment that the appropriate constraints are still laid down elsewhere in the circuit. + +## Example + +An in depth example might help drive the point home. This example comes from the excellent [post](https://discord.com/channels/1113924620781883405/1124022445054111926/1128747641853972590) by Tom in the Noir Discord. + +Let's look at how we can optimize a function to turn a `u72` into an array of `u8`s. + +```rust +fn main(num: u72) -> pub [u8; 8] { + let mut out: [u8; 8] = [0; 8]; + for i in 0..8 { + out[i] = (num >> (56 - (i * 8)) as u72 & 0xff) as u8; + } + + out +} +``` + +``` +Total ACIR opcodes generated for language PLONKCSat { width: 3 }: 91 +Backend circuit size: 3619 +``` + +A lot of the operations in this function are optimized away by the compiler (all the bit-shifts turn into divisions by constants). However we can save a bunch of gates by casting to u8 a bit earlier. This automatically truncates the bit-shifted value to fit in a u8 which allows us to remove the AND against 0xff. This saves us ~480 gates in total. + +```rust +fn main(num: u72) -> pub [u8; 8] { + let mut out: [u8; 8] = [0; 8]; + for i in 0..8 { + out[i] = (num >> (56 - (i * 8)) as u8; + } + + out +} +``` + +``` +Total ACIR opcodes generated for language PLONKCSat { width: 3 }: 75 +Backend circuit size: 3143 +``` + +Those are some nice savings already but we can do better. This code is all constrained so we're proving every step of calculating out using num, but we don't actually care about how we calculate this, just that it's correct. This is where brillig comes in. + +It turns out that truncating a u72 into a u8 is hard to do inside a snark, each time we do as u8 we lay down 4 ACIR opcodes which get converted into multiple gates. It's actually much easier to calculate num from out than the other way around. All we need to do is multiply each element of out by a constant and add them all together, both relatively easy operations inside a snark. + +We can then run u72_to_u8 as unconstrained brillig code in order to calculate out, then use that result in our constrained function and assert that if we were to do the reverse calculation we'd get back num. This looks a little like the below: + +```rust +fn main(num: u72) -> pub [u8; 8] { + let out = u72_to_u8(num); + + let mut reconstructed_num: u72 = 0; + for i in 0..8 { + reconstructed_num += (out[i] as u72 << (56 - (8 * i))); + } + assert(num == reconstructed_num); + out +} + +unconstrained fn u72_to_u8(num: u72) -> [u8; 8] { + let mut out: [u8; 8] = [0; 8]; + for i in 0..8 { + out[i] = (num >> (56 - (i * 8))) as u8; + } + out +} +``` + +``` +Total ACIR opcodes generated for language PLONKCSat { width: 3 }: 78 +Backend circuit size: 2902 +``` + +This ends up taking off another ~250 gates from our circuit! We've ended up with more ACIR opcodes than before but they're easier for the backend to prove (resulting in fewer gates). + +Generally we want to use brillig whenever there's something that's easy to verify but hard to compute within the circuit. For example, if you wanted to calculate a square root of a number it'll be a much better idea to calculate this in brillig and then assert that if you square the result you get back your number. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/_category_.json new file mode 100644 index 00000000000..1debcfe7675 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Modules, Packages and Crates", + "position": 2, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/crates_and_packages.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/crates_and_packages.md new file mode 100644 index 00000000000..95ee9f52ab2 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/crates_and_packages.md @@ -0,0 +1,43 @@ +--- +title: Crates and Packages +description: Learn how to use Crates and Packages in your Noir project +keywords: [Nargo, dependencies, package management, crates, package] +sidebar_position: 0 +--- + +## Crates + +A crate is the smallest amount of code that the Noir compiler considers at a time. +Crates can contain modules, and the modules may be defined in other files that get compiled with the crate, as we’ll see in the coming sections. + +### Crate Types + +A Noir crate can come in several forms: binaries, libraries or contracts. + +#### Binaries + +_Binary crates_ are programs which you can compile to an ACIR circuit which you can then create proofs against. Each must have a function called `main` that defines the ACIR circuit which is to be proved. + +#### Libraries + +_Library crates_ don't have a `main` function and they don't compile down to ACIR. Instead they define functionality intended to be shared with multiple projects, and eventually included in a binary crate. + +#### Contracts + +Contract crates are similar to binary crates in that they compile to ACIR which you can create proofs against. They are different in that they do not have a single `main` function, but are a collection of functions to be deployed to the [Aztec network](https://aztec.network). You can learn more about the technical details of Aztec in the [monorepo](https://github.com/AztecProtocol/aztec-packages) or contract [examples](https://github.com/AztecProtocol/aztec-packages/tree/master/noir-projects/noir-contracts/contracts). + +### Crate Root + +Every crate has a root, which is the source file that the compiler starts, this is also known as the root module. The Noir compiler does not enforce any conditions on the name of the file which is the crate root, however if you are compiling via Nargo the crate root must be called `lib.nr` or `main.nr` for library or binary crates respectively. + +## Packages + +A Nargo _package_ is a collection of one of more crates that provides a set of functionality. A package must include a Nargo.toml file. + +A package _must_ contain either a library or a binary crate, but not both. + +### Differences from Cargo Packages + +One notable difference between Rust's Cargo and Noir's Nargo is that while Cargo allows a package to contain an unlimited number of binary crates and a single library crate, Nargo currently only allows a package to contain a single crate. + +In future this restriction may be lifted to allow a Nargo package to contain both a binary and library crate or multiple binary crates. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/dependencies.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/dependencies.md new file mode 100644 index 00000000000..04c1703d929 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/dependencies.md @@ -0,0 +1,124 @@ +--- +title: Dependencies +description: + Learn how to specify and manage dependencies in Nargo, allowing you to upload packages to GitHub + and use them easily in your project. +keywords: [Nargo, dependencies, GitHub, package management, versioning] +sidebar_position: 1 +--- + +Nargo allows you to upload packages to GitHub and use them as dependencies. + +## Specifying a dependency + +Specifying a dependency requires a tag to a specific commit and the git url to the url containing +the package. + +Currently, there are no requirements on the tag contents. If requirements are added, it would follow +semver 2.0 guidelines. + +> Note: Without a `tag` , there would be no versioning and dependencies would change each time you +> compile your project. + +For example, to add the [ecrecover-noir library](https://github.com/colinnielsen/ecrecover-noir) to your project, add it to `Nargo.toml`: + +```toml +# Nargo.toml + +[dependencies] +ecrecover = {tag = "v0.8.0", git = "https://github.com/colinnielsen/ecrecover-noir"} +``` + +If the module is in a subdirectory, you can define a subdirectory in your git repository, for example: + +```toml +# Nargo.toml + +[dependencies] +easy_private_token_contract = {tag ="v0.1.0-alpha62", git = "https://github.com/AztecProtocol/aztec-packages", directory = "noir-contracts/contracts/easy_private_token_contract"} +``` + +## Specifying a local dependency + +You can also specify dependencies that are local to your machine. + +For example, this file structure has a library and binary crate + +```tree +├── binary_crate +│   ├── Nargo.toml +│   └── src +│   └── main.nr +└── lib_a + ├── Nargo.toml + └── src + └── lib.nr +``` + +Inside of the binary crate, you can specify: + +```toml +# Nargo.toml + +[dependencies] +lib_a = { path = "../lib_a" } +``` + +## Importing dependencies + +You can import a dependency to a Noir file using the following syntax. For example, to import the +ecrecover-noir library and local lib_a referenced above: + +```rust +use dep::ecrecover; +use dep::lib_a; +``` + +You can also import only the specific parts of dependency that you want to use, like so: + +```rust +use dep::std::hash::sha256; +use dep::std::scalar_mul::fixed_base_embedded_curve; +``` + +Lastly, as demonstrated in the +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +can import multiple items in the same line by enclosing them in curly braces: + +```rust +use dep::std::ec::tecurve::affine::{Curve, Point}; +``` + +We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. + +Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. + +## Dependencies of Dependencies + +Note that when you import a dependency, you also get access to all of the dependencies of that package. + +For example, the [phy_vector](https://github.com/resurgencelabs/phy_vector) library imports an [fraction](https://github.com/resurgencelabs/fraction) library. If you're importing the phy_vector library, then you can access the functions in fractions library like so: + +```rust +use dep::phy_vector; + +fn main(x : Field, y : pub Field) { + //... + let f = phy_vector::fraction::toFraction(true, 2, 1); + //... +} +``` + +## Available Libraries + +Noir does not currently have an official package manager. You can find a list of available Noir libraries in the [awesome-noir repo here](https://github.com/noir-lang/awesome-noir#libraries). + +Some libraries that are available today include: + +- [Standard Library](https://github.com/noir-lang/noir/tree/master/noir_stdlib) - the Noir Standard Library +- [Ethereum Storage Proof Verification](https://github.com/aragonzkresearch/noir-trie-proofs) - a library that contains the primitives necessary for RLP decoding (in the form of look-up table construction) and Ethereum state and storage proof verification (or verification of any trie proof involving 32-byte long keys) +- [BigInt](https://github.com/shuklaayush/noir-bigint) - a library that provides a custom BigUint56 data type, allowing for computations on large unsigned integers +- [ECrecover](https://github.com/colinnielsen/ecrecover-noir/tree/main) - a library to verify an ECDSA signature and return the source Ethereum address +- [Sparse Merkle Tree Verifier](https://github.com/vocdoni/smtverifier-noir/tree/main) - a library for verification of sparse Merkle trees +- [Signed Int](https://github.com/resurgencelabs/signed_int) - a library for accessing a custom Signed Integer data type, allowing access to negative numbers on Noir +- [Fraction](https://github.com/resurgencelabs/fraction) - a library for accessing fractional number data type in Noir, allowing results that aren't whole numbers diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/modules.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/modules.md new file mode 100644 index 00000000000..ae822a1cff4 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/modules.md @@ -0,0 +1,105 @@ +--- +title: Modules +description: + Learn how to organize your files using modules in Noir, following the same convention as Rust's + module system. Examples included. +keywords: [Noir, Rust, modules, organizing files, sub-modules] +sidebar_position: 2 +--- + +Noir's module system follows the same convention as the _newer_ version of Rust's module system. + +## Purpose of Modules + +Modules are used to organize files. Without modules all of your code would need to live in a single +file. In Noir, the compiler does not automatically scan all of your files to detect modules. This +must be done explicitly by the developer. + +## Examples + +### Importing a module in the crate root + +Filename : `src/main.nr` + +```rust +mod foo; + +fn main() { + foo::hello_world(); +} +``` + +Filename : `src/foo.nr` + +```rust +fn from_foo() {} +``` + +In the above snippet, the crate root is the `src/main.nr` file. The compiler sees the module +declaration `mod foo` which prompts it to look for a foo.nr file. + +Visually this module hierarchy looks like the following : + +``` +crate + ├── main + │ + └── foo + └── from_foo + +``` + +### Importing a module throughout the tree + +All modules are accessible from the `crate::` namespace. + +``` +crate + ├── bar + ├── foo + └── main + +``` + +In the above snippet, if `bar` would like to use functions in `foo`, it can do so by `use crate::foo::function_name`. + +### Sub-modules + +Filename : `src/main.nr` + +```rust +mod foo; + +fn main() { + foo::from_foo(); +} +``` + +Filename : `src/foo.nr` + +```rust +mod bar; +fn from_foo() {} +``` + +Filename : `src/foo/bar.nr` + +```rust +fn from_bar() {} +``` + +In the above snippet, we have added an extra module to the module tree; `bar`. `bar` is a submodule +of `foo` hence we declare bar in `foo.nr` with `mod bar`. Since `foo` is not the crate root, the +compiler looks for the file associated with the `bar` module in `src/foo/bar.nr` + +Visually the module hierarchy looks as follows: + +``` +crate + ├── main + │ + └── foo + ├── from_foo + └── bar + └── from_bar +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/workspaces.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/workspaces.md new file mode 100644 index 00000000000..67a1dafa372 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/workspaces.md @@ -0,0 +1,40 @@ +--- +title: Workspaces +sidebar_position: 3 +--- + +Workspaces are a feature of nargo that allow you to manage multiple related Noir packages in a single repository. A workspace is essentially a group of related projects that share common build output directories and configurations. + +Each Noir project (with it's own Nargo.toml file) can be thought of as a package. Each package is expected to contain exactly one "named circuit", being the "name" defined in Nargo.toml with the program logic defined in `./src/main.nr`. + +For a project with the following structure: + +```tree +├── crates +│   ├── a +│   │   ├── Nargo.toml +│   │   └── src +│   │   └── main.nr +│   └── b +│   ├── Nargo.toml +│   └── src +│   └── main.nr +├── Nargo.toml +└── Prover.toml +``` + +You can define a workspace in Nargo.toml like so: + +```toml +[workspace] +members = ["crates/a", "crates/b"] +default-member = "crates/a" +``` + +`members` indicates which packages are included in the workspace. As such, all member packages of a workspace will be processed when the `--workspace` flag is used with various commands or if a `default-member` is not specified. + +`default-member` indicates which package various commands process by default. + +Libraries can be defined in a workspace. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. + +Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/_category_.json new file mode 100644 index 00000000000..af04c0933fd --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Standard Library", + "position": 1, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/black_box_fns.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/black_box_fns.md new file mode 100644 index 00000000000..eae8744abf0 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/black_box_fns.md @@ -0,0 +1,31 @@ +--- +title: Black Box Functions +description: Black box functions are functions in Noir that rely on backends implementing support for specialized constraints. +keywords: [noir, black box functions] +--- + +Black box functions are functions in Noir that rely on backends implementing support for specialized constraints. This makes certain zk-snark unfriendly computations cheaper than if they were implemented in Noir. + +The ACVM spec defines a set of blackbox functions which backends will be expected to implement. This allows backends to use optimized implementations of these constraints if they have them, however they may also fallback to less efficient naive implementations if not. + +## Function list + +Here is a list of the current black box functions: + +- [SHA256](./cryptographic_primitives/hashes#sha256) +- [Schnorr signature verification](./cryptographic_primitives/schnorr) +- [Blake2s](./cryptographic_primitives/hashes#blake2s) +- [Blake3](./cryptographic_primitives/hashes#blake3) +- [Pedersen Hash](./cryptographic_primitives/hashes#pedersen_hash) +- [Pedersen Commitment](./cryptographic_primitives/hashes#pedersen_commitment) +- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification) +- [Fixed base scalar multiplication](./cryptographic_primitives/scalar) +- AND +- XOR +- RANGE +- [Keccak256](./cryptographic_primitives/hashes#keccak256) +- [Recursive proof verification](./recursion) + +Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. + +You can view the black box functions defined in the ACVM code [here](https://github.com/noir-lang/noir/blob/master/acvm-repo/acir/src/circuit/black_box_functions.rs). diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/bn254.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/bn254.md new file mode 100644 index 00000000000..3294f005dbb --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/bn254.md @@ -0,0 +1,46 @@ +--- +title: Bn254 Field Library +--- + +Noir provides a module in standard library with some optimized functions for bn254 Fr in `std::field::bn254`. + +## decompose + +```rust +fn decompose(x: Field) -> (Field, Field) {} +``` + +Decomposes a single field into two fields, low and high. The low field contains the lower 16 bytes of the input field and the high field contains the upper 16 bytes of the input field. Both field results are range checked to 128 bits. + + +## assert_gt + +```rust +fn assert_gt(a: Field, b: Field) {} +``` + +Asserts that a > b. This will generate less constraints than using `assert(gt(a, b))`. + +## assert_lt + +```rust +fn assert_lt(a: Field, b: Field) {} +``` + +Asserts that a < b. This will generate less constraints than using `assert(lt(a, b))`. + +## gt + +```rust +fn gt(a: Field, b: Field) -> bool {} +``` + +Returns true if a > b. + +## lt + +```rust +fn lt(a: Field, b: Field) -> bool {} +``` + +Returns true if a < b. \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/containers/boundedvec.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/containers/boundedvec.md new file mode 100644 index 00000000000..ce4529f6e57 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/containers/boundedvec.md @@ -0,0 +1,326 @@ +--- +title: Bounded Vectors +keywords: [noir, vector, bounded vector, slice] +sidebar_position: 1 +--- + +A `BoundedVec` is a growable storage similar to a `Vec` except that it +is bounded with a maximum possible length. Unlike `Vec`, `BoundedVec` is not implemented +via slices and thus is not subject to the same restrictions slices are (notably, nested +slices - and thus nested vectors as well - are disallowed). + +Since a BoundedVec is backed by a normal array under the hood, growing the BoundedVec by +pushing an additional element is also more efficient - the length only needs to be increased +by one. + +For these reasons `BoundedVec` should generally be preferred over `Vec` when there +is a reasonable maximum bound that can be placed on the vector. + +Example: + +```rust +let mut vector: BoundedVec = BoundedVec::new(); +for i in 0..5 { + vector.push(i); +} +assert(vector.len() == 5); +assert(vector.max_len() == 10); +``` + +## Methods + +### new + +```rust +pub fn new() -> Self +``` + +Creates a new, empty vector of length zero. + +Since this container is backed by an array internally, it still needs an initial value +to give each element. To resolve this, each element is zeroed internally. This value +is guaranteed to be inaccessible unless `get_unchecked` is used. + +Example: + +```rust +let empty_vector: BoundedVec = BoundedVec::new(); +assert(empty_vector.len() == 0); +``` + +Note that whenever calling `new` the maximum length of the vector should always be specified +via a type signature: + +```rust title="new_example" showLineNumbers +fn foo() -> BoundedVec { + // Ok! MaxLen is specified with a type annotation + let v1: BoundedVec = BoundedVec::new(); + let v2 = BoundedVec::new(); + + // Ok! MaxLen is known from the type of foo's return value + v2 +} + +fn bad() { + let mut v3 = BoundedVec::new(); + + // Not Ok! We don't know if v3's MaxLen is at least 1, and the compiler often infers 0 by default. + v3.push(5); +} +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L11-L27 + + +This defaulting of `MaxLen` (and numeric generics in general) to zero may change in future noir versions +but for now make sure to use type annotations when using bounded vectors. Otherwise, you will receive a constraint failure at runtime when the vec is pushed to. + +### get + +```rust +pub fn get(mut self: Self, index: u64) -> T { +``` + +Retrieves an element from the vector at the given index, starting from zero. + +If the given index is equal to or greater than the length of the vector, this +will issue a constraint failure. + +Example: + +```rust +fn foo(v: BoundedVec) { + let first = v.get(0); + let last = v.get(v.len() - 1); + assert(first != last); +} +``` + +### get_unchecked + +```rust +pub fn get_unchecked(mut self: Self, index: u64) -> T { +``` + +Retrieves an element from the vector at the given index, starting from zero, without +performing a bounds check. + +Since this function does not perform a bounds check on length before accessing the element, +it is unsafe! Use at your own risk! + +Example: + +```rust title="get_unchecked_example" showLineNumbers +fn sum_of_first_three(v: BoundedVec) -> u32 { + // Always ensure the length is larger than the largest + // index passed to get_unchecked + assert(v.len() > 2); + let first = v.get_unchecked(0); + let second = v.get_unchecked(1); + let third = v.get_unchecked(2); + first + second + third +} +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L54-L64 + + + +### push + +```rust +pub fn push(&mut self, elem: T) { +``` + +Pushes an element to the end of the vector. This increases the length +of the vector by one. + +Panics if the new length of the vector will be greater than the max length. + +Example: + +```rust title="bounded-vec-push-example" showLineNumbers +let mut v: BoundedVec = BoundedVec::new(); + + v.push(1); + v.push(2); + + // Panics with failed assertion "push out of bounds" + v.push(3); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L68-L76 + + +### pop + +```rust +pub fn pop(&mut self) -> T +``` + +Pops the element at the end of the vector. This will decrease the length +of the vector by one. + +Panics if the vector is empty. + +Example: + +```rust title="bounded-vec-pop-example" showLineNumbers +let mut v: BoundedVec = BoundedVec::new(); + v.push(1); + v.push(2); + + let two = v.pop(); + let one = v.pop(); + + assert(two == 2); + assert(one == 1); + // error: cannot pop from an empty vector + // let _ = v.pop(); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L81-L93 + + +### len + +```rust +pub fn len(self) -> u64 { +``` + +Returns the current length of this vector + +Example: + +```rust title="bounded-vec-len-example" showLineNumbers +let mut v: BoundedVec = BoundedVec::new(); + assert(v.len() == 0); + + v.push(100); + assert(v.len() == 1); + + v.push(200); + v.push(300); + v.push(400); + assert(v.len() == 4); + + let _ = v.pop(); + let _ = v.pop(); + assert(v.len() == 2); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L98-L113 + + +### max_len + +```rust +pub fn max_len(_self: BoundedVec) -> u64 { +``` + +Returns the maximum length of this vector. This is always +equal to the `MaxLen` parameter this vector was initialized with. + +Example: + +```rust title="bounded-vec-max-len-example" showLineNumbers +let mut v: BoundedVec = BoundedVec::new(); + + assert(v.max_len() == 5); + v.push(10); + assert(v.max_len() == 5); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L118-L124 + + +### storage + +```rust +pub fn storage(self) -> [T; MaxLen] { +``` + +Returns the internal array within this vector. +Since arrays in Noir are immutable, mutating the returned storage array will not mutate +the storage held internally by this vector. + +Note that uninitialized elements may be zeroed out! + +Example: + +```rust title="bounded-vec-storage-example" showLineNumbers +let mut v: BoundedVec = BoundedVec::new(); + + assert(v.storage() == [0, 0, 0, 0, 0]); + + v.push(57); + assert(v.storage() == [57, 0, 0, 0, 0]); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L129-L136 + + +### extend_from_array + +```rust +pub fn extend_from_array(&mut self, array: [T; Len]) +``` + +Pushes each element from the given array to this vector. + +Panics if pushing each element would cause the length of this vector +to exceed the maximum length. + +Example: + +```rust title="bounded-vec-extend-from-array-example" showLineNumbers +let mut vec: BoundedVec = BoundedVec::new(); + vec.extend_from_array([2, 4]); + + assert(vec.len == 2); + assert(vec.get(0) == 2); + assert(vec.get(1) == 4); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L141-L148 + + +### extend_from_bounded_vec + +```rust +pub fn extend_from_bounded_vec(&mut self, vec: BoundedVec) +``` + +Pushes each element from the other vector to this vector. The length of +the other vector is left unchanged. + +Panics if pushing each element would cause the length of this vector +to exceed the maximum length. + +Example: + +```rust title="bounded-vec-extend-from-bounded-vec-example" showLineNumbers +let mut v1: BoundedVec = BoundedVec::new(); + let mut v2: BoundedVec = BoundedVec::new(); + + v2.extend_from_array([1, 2, 3]); + v1.extend_from_bounded_vec(v2); + + assert(v1.storage() == [1, 2, 3, 0, 0]); + assert(v2.storage() == [1, 2, 3, 0, 0, 0, 0]); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L153-L162 + + +### any + +```rust +pub fn any(self, predicate: fn[Env](T) -> bool) -> bool +``` + +Returns true if the given predicate returns true for any element +in this vector. + +Example: + +```rust title="bounded-vec-any-example" showLineNumbers +let mut v: BoundedVec = BoundedVec::new(); + v.extend_from_array([2, 4, 6]); + + let all_even = !v.any(|elem: u32| elem % 2 != 0); + assert(all_even); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L229-L235 + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/containers/hashmap.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/containers/hashmap.md new file mode 100644 index 00000000000..91604af765d --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/containers/hashmap.md @@ -0,0 +1,569 @@ +--- +title: HashMap +keywords: [noir, map, hash, hashmap] +sidebar_position: 1 +--- + +`HashMap` is used to efficiently store and look up key-value pairs. + +`HashMap` is a bounded type which can store anywhere from zero to `MaxLen` total elements. +Note that due to hash collisions, the actual maximum number of elements stored by any particular +hashmap is likely lower than `MaxLen`. This is true even with cryptographic hash functions since +every hash value will be performed modulo `MaxLen`. + +When creating `HashMap`s, the `MaxLen` generic should always be specified if it is not already +known. Otherwise, the compiler may infer a different value for `MaxLen` (such as zero), which +will likely change the result of the program. This behavior is set to become an error in future +versions instead. + +Example: + +```rust +// Create a mapping from Fields to u32s with a maximum length of 12 +// using a pedersen hash +let mut map: HashMap> = HashMap::default(); + +map.insert(1, 2); +map.insert(3, 4); + +let two = map.get(1).unwrap(); +``` + +## Methods + +### default + +```rust title="default" showLineNumbers +impl Default for HashMap +where + B: BuildHasher + Default, + H: Hasher + Default +{ + fn default() -> Self { +``` +> Source code: noir_stdlib/src/collections/map.nr#L462-L469 + + +Creates a fresh, empty HashMap. + +When using this function, always make sure to specify the maximum size of the hash map. + +This is the same `default` from the `Default` implementation given further below. It is +repeated here for convenience since it is the recommended way to create a hashmap. + +Example: + +```rust title="default_example" showLineNumbers +let hashmap: HashMap> = HashMap::default(); + assert(hashmap.is_empty()); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L202-L205 + + +Because `HashMap` has so many generic arguments that are likely to be the same throughout +your program, it may be helpful to create a type alias: + +```rust title="type_alias" showLineNumbers +type MyMap = HashMap>; +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L196-L198 + + +### with_hasher + +```rust title="with_hasher" showLineNumbers +pub fn with_hasher(_build_hasher: B) -> Self + where + B: BuildHasher { +``` +> Source code: noir_stdlib/src/collections/map.nr#L82-L86 + + +Creates a hashmap with an existing `BuildHasher`. This can be used to ensure multiple +hashmaps are created with the same hasher instance. + +Example: + +```rust title="with_hasher_example" showLineNumbers +let my_hasher: BuildHasherDefault = Default::default(); + let hashmap: HashMap> = HashMap::with_hasher(my_hasher); + assert(hashmap.is_empty()); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L207-L211 + + +### get + +```rust title="get" showLineNumbers +pub fn get( + self, + key: K + ) -> Option + where + K: Eq + Hash, + B: BuildHasher, + H: Hasher { +``` +> Source code: noir_stdlib/src/collections/map.nr#L278-L287 + + +Retrieves a value from the hashmap, returning `Option::none()` if it was not found. + +Example: + +```rust title="get_example" showLineNumbers +fn get_example(map: HashMap>) { + let x = map.get(12); + + if x.is_some() { + assert(x.unwrap() == 42); + } +} +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L299-L307 + + +### insert + +```rust title="insert" showLineNumbers +pub fn insert( + &mut self, + key: K, + value: V + ) + where + K: Eq + Hash, + B: BuildHasher, + H: Hasher { +``` +> Source code: noir_stdlib/src/collections/map.nr#L313-L323 + + +Inserts a new key-value pair into the map. If the key was already in the map, its +previous value will be overridden with the newly provided one. + +Example: + +```rust title="insert_example" showLineNumbers +let mut map: HashMap> = HashMap::default(); + map.insert(12, 42); + assert(map.len() == 1); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L213-L217 + + +### remove + +```rust title="remove" showLineNumbers +pub fn remove( + &mut self, + key: K + ) + where + K: Eq + Hash, + B: BuildHasher, + H: Hasher { +``` +> Source code: noir_stdlib/src/collections/map.nr#L356-L365 + + +Removes the given key-value pair from the map. If the key was not already present +in the map, this does nothing. + +Example: + +```rust title="remove_example" showLineNumbers +map.remove(12); + assert(map.is_empty()); + + // If a key was not present in the map, remove does nothing + map.remove(12); + assert(map.is_empty()); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L221-L228 + + +### is_empty + +```rust title="is_empty" showLineNumbers +pub fn is_empty(self) -> bool { +``` +> Source code: noir_stdlib/src/collections/map.nr#L115-L117 + + +True if the length of the hash map is empty. + +Example: + +```rust title="is_empty_example" showLineNumbers +assert(map.is_empty()); + + map.insert(1, 2); + assert(!map.is_empty()); + + map.remove(1); + assert(map.is_empty()); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L230-L238 + + +### len + +```rust title="len" showLineNumbers +pub fn len(self) -> u64 { +``` +> Source code: noir_stdlib/src/collections/map.nr#L264-L266 + + +Returns the current length of this hash map. + +Example: + +```rust title="len_example" showLineNumbers +// This is equivalent to checking map.is_empty() + assert(map.len() == 0); + + map.insert(1, 2); + map.insert(3, 4); + map.insert(5, 6); + assert(map.len() == 3); + + // 3 was already present as a key in the hash map, so the length is unchanged + map.insert(3, 7); + assert(map.len() == 3); + + map.remove(1); + assert(map.len() == 2); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L240-L255 + + +### capacity + +```rust title="capacity" showLineNumbers +pub fn capacity(_self: Self) -> u64 { +``` +> Source code: noir_stdlib/src/collections/map.nr#L271-L273 + + +Returns the maximum capacity of this hashmap. This is always equal to the capacity +specified in the hashmap's type. + +Unlike hashmaps in general purpose programming languages, hashmaps in Noir have a +static capacity that does not increase as the map grows larger. Thus, this capacity +is also the maximum possible element count that can be inserted into the hashmap. +Due to hash collisions (modulo the hashmap length), it is likely the actual maximum +element count will be lower than the full capacity. + +Example: + +```rust title="capacity_example" showLineNumbers +let empty_map: HashMap> = HashMap::default(); + assert(empty_map.len() == 0); + assert(empty_map.capacity() == 42); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L257-L261 + + +### clear + +```rust title="clear" showLineNumbers +pub fn clear(&mut self) { +``` +> Source code: noir_stdlib/src/collections/map.nr#L93-L95 + + +Clears the hashmap, removing all key-value pairs from it. + +Example: + +```rust title="clear_example" showLineNumbers +assert(!map.is_empty()); + map.clear(); + assert(map.is_empty()); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L263-L267 + + +### contains_key + +```rust title="contains_key" showLineNumbers +pub fn contains_key( + self, + key: K + ) -> bool + where + K: Hash + Eq, + B: BuildHasher, + H: Hasher { +``` +> Source code: noir_stdlib/src/collections/map.nr#L101-L110 + + +True if the hashmap contains the given key. Unlike `get`, this will not also return +the value associated with the key. + +Example: + +```rust title="contains_key_example" showLineNumbers +if map.contains_key(7) { + let value = map.get(7); + assert(value.is_some()); + } else { + println("No value for key 7!"); + } +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L269-L276 + + +### entries + +```rust title="entries" showLineNumbers +pub fn entries(self) -> BoundedVec<(K, V), N> { +``` +> Source code: noir_stdlib/src/collections/map.nr#L123-L125 + + +Returns a vector of each key-value pair present in the hashmap. + +The length of the returned vector is always equal to the length of the hashmap. + +Example: + +```rust title="entries_example" showLineNumbers +let entries = map.entries(); + + // The length of a hashmap may not be compile-time known, so we + // need to loop over its capacity instead + for i in 0..map.capacity() { + if i < entries.len() { + let (key, value) = entries.get(i); + println(f"{key} -> {value}"); + } + } +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L310-L321 + + +### keys + +```rust title="keys" showLineNumbers +pub fn keys(self) -> BoundedVec { +``` +> Source code: noir_stdlib/src/collections/map.nr#L144-L146 + + +Returns a vector of each key present in the hashmap. + +The length of the returned vector is always equal to the length of the hashmap. + +Example: + +```rust title="keys_example" showLineNumbers +let keys = map.keys(); + + for i in 0..keys.max_len() { + if i < keys.len() { + let key = keys.get_unchecked(i); + let value = map.get(key).unwrap_unchecked(); + println(f"{key} -> {value}"); + } + } +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L323-L333 + + +### values + +```rust title="values" showLineNumbers +pub fn values(self) -> BoundedVec { +``` +> Source code: noir_stdlib/src/collections/map.nr#L164-L166 + + +Returns a vector of each value present in the hashmap. + +The length of the returned vector is always equal to the length of the hashmap. + +Example: + +```rust title="values_example" showLineNumbers +let values = map.values(); + + for i in 0..values.max_len() { + if i < values.len() { + let value = values.get_unchecked(i); + println(f"Found value {value}"); + } + } +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L335-L344 + + +### iter_mut + +```rust title="iter_mut" showLineNumbers +pub fn iter_mut( + &mut self, + f: fn(K, V) -> (K, V) + ) + where + K: Eq + Hash, + B: BuildHasher, + H: Hasher { +``` +> Source code: noir_stdlib/src/collections/map.nr#L183-L192 + + +Iterates through each key-value pair of the HashMap, setting each key-value pair to the +result returned from the given function. + +Note that since keys can be mutated, the HashMap needs to be rebuilt as it is iterated +through. If this is not desired, use `iter_values_mut` if only values need to be mutated, +or `entries` if neither keys nor values need to be mutated. + +The iteration order is left unspecified. As a result, if two keys are mutated to become +equal, which of the two values that will be present for the key in the resulting map is also unspecified. + +Example: + +```rust title="iter_mut_example" showLineNumbers +// Add 1 to each key in the map, and double the value associated with that key. + map.iter_mut(|k, v| (k + 1, v * 2)); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L348-L351 + + +### iter_keys_mut + +```rust title="iter_keys_mut" showLineNumbers +pub fn iter_keys_mut( + &mut self, + f: fn(K) -> K + ) + where + K: Eq + Hash, + B: BuildHasher, + H: Hasher { +``` +> Source code: noir_stdlib/src/collections/map.nr#L208-L217 + + +Iterates through the HashMap, mutating each key to the result returned from +the given function. + +Note that since keys can be mutated, the HashMap needs to be rebuilt as it is iterated +through. If only iteration is desired and the keys are not intended to be mutated, +prefer using `entries` instead. + +The iteration order is left unspecified. As a result, if two keys are mutated to become +equal, which of the two values that will be present for the key in the resulting map is also unspecified. + +Example: + +```rust title="iter_keys_mut_example" showLineNumbers +// Double each key, leaving the value associated with that key untouched + map.iter_keys_mut(|k| k * 2); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L353-L356 + + +### iter_values_mut + +```rust title="iter_values_mut" showLineNumbers +pub fn iter_values_mut(&mut self, f: fn(V) -> V) { +``` +> Source code: noir_stdlib/src/collections/map.nr#L233-L235 + + +Iterates through the HashMap, applying the given function to each value and mutating the +value to equal the result. This function is more efficient than `iter_mut` and `iter_keys_mut` +because the keys are untouched and the underlying hashmap thus does not need to be reordered. + +Example: + +```rust title="iter_values_mut_example" showLineNumbers +// Halve each value + map.iter_values_mut(|v| v / 2); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L358-L361 + + +### retain + +```rust title="retain" showLineNumbers +pub fn retain(&mut self, f: fn(K, V) -> bool) { +``` +> Source code: noir_stdlib/src/collections/map.nr#L247-L249 + + +Retains only the key-value pairs for which the given function returns true. +Any key-value pairs for which the function returns false will be removed from the map. + +Example: + +```rust title="retain_example" showLineNumbers +map.retain(|k, v| (k != 0) & (v != 0)); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L281-L283 + + +## Trait Implementations + +### default + +```rust title="default" showLineNumbers +impl Default for HashMap +where + B: BuildHasher + Default, + H: Hasher + Default +{ + fn default() -> Self { +``` +> Source code: noir_stdlib/src/collections/map.nr#L462-L469 + + +Constructs an empty HashMap. + +Example: + +```rust title="default_example" showLineNumbers +let hashmap: HashMap> = HashMap::default(); + assert(hashmap.is_empty()); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L202-L205 + + +### eq + +```rust title="eq" showLineNumbers +impl Eq for HashMap +where + K: Eq + Hash, + V: Eq, + B: BuildHasher, + H: Hasher +{ + fn eq(self, other: HashMap) -> bool { +``` +> Source code: noir_stdlib/src/collections/map.nr#L426-L435 + + +Checks if two HashMaps are equal. + +Example: + +```rust title="eq_example" showLineNumbers +let mut map1: HashMap> = HashMap::default(); + let mut map2: HashMap> = HashMap::default(); + + map1.insert(1, 2); + map1.insert(3, 4); + + map2.insert(3, 4); + map2.insert(1, 2); + + assert(map1 == map2); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L285-L296 + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/containers/index.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/containers/index.md new file mode 100644 index 00000000000..ea84c6d5c21 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/containers/index.md @@ -0,0 +1,5 @@ +--- +title: Containers +description: Container types provided by Noir's standard library for storing and retrieving data +keywords: [containers, data types, vec, hashmap] +--- diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/containers/vec.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/containers/vec.mdx new file mode 100644 index 00000000000..1954f05bc76 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/containers/vec.mdx @@ -0,0 +1,151 @@ +--- +title: Vectors +description: Delve into the Vec data type in Noir. Learn about its methods, practical examples, and best practices for using Vectors in your Noir code. +keywords: [noir, vector type, methods, examples, dynamic arrays] +sidebar_position: 6 +--- + +import Experimental from '@site/src/components/Notes/_experimental.mdx'; + + + +A vector is a collection type similar to Rust's `Vec` type. In Noir, it is a convenient way to use slices as mutable arrays. + +Example: + +```rust +let mut vector: Vec = Vec::new(); +for i in 0..5 { + vector.push(i); +} +assert(vector.len() == 5); +``` + +## Methods + +### new + +Creates a new, empty vector. + +```rust +pub fn new() -> Self +``` + +Example: + +```rust +let empty_vector: Vec = Vec::new(); +assert(empty_vector.len() == 0); +``` + +### from_slice + +Creates a vector containing each element from a given slice. Mutations to the resulting vector will not affect the original slice. + +```rust +pub fn from_slice(slice: [T]) -> Self +``` + +Example: + +```rust +let arr: [Field] = [1, 2, 3]; +let vector_from_slice = Vec::from_slice(arr); +assert(vector_from_slice.len() == 3); +``` + +### len + +Returns the number of elements in the vector. + +```rust +pub fn len(self) -> Field +``` + +Example: + +```rust +let empty_vector: Vec = Vec::new(); +assert(empty_vector.len() == 0); +``` + +### get + +Retrieves an element from the vector at a given index. Panics if the index points beyond the vector's end. + +```rust +pub fn get(self, index: Field) -> T +``` + +Example: + +```rust +let vector: Vec = Vec::from_slice([10, 20, 30]); +assert(vector.get(1) == 20); +``` + +### push + +Adds a new element to the vector's end, returning a new vector with a length one greater than the original unmodified vector. + +```rust +pub fn push(&mut self, elem: T) +``` + +Example: + +```rust +let mut vector: Vec = Vec::new(); +vector.push(10); +assert(vector.len() == 1); +``` + +### pop + +Removes an element from the vector's end, returning a new vector with a length one less than the original vector, along with the removed element. Panics if the vector's length is zero. + +```rust +pub fn pop(&mut self) -> T +``` + +Example: + +```rust +let mut vector = Vec::from_slice([10, 20]); +let popped_elem = vector.pop(); +assert(popped_elem == 20); +assert(vector.len() == 1); +``` + +### insert + +Inserts an element at a specified index, shifting subsequent elements to the right. + +```rust +pub fn insert(&mut self, index: Field, elem: T) +``` + +Example: + +```rust +let mut vector = Vec::from_slice([10, 30]); +vector.insert(1, 20); +assert(vector.get(1) == 20); +``` + +### remove + +Removes an element at a specified index, shifting subsequent elements to the left, and returns the removed element. + +```rust +pub fn remove(&mut self, index: Field) -> T +``` + +Example: + +```rust +let mut vector = Vec::from_slice([10, 20, 30]); +let removed_elem = vector.remove(1); +assert(removed_elem == 20); +assert(vector.len() == 2); +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/_category_.json new file mode 100644 index 00000000000..5d694210bbf --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/_category_.json @@ -0,0 +1,5 @@ +{ + "position": 0, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/ec_primitives.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/ec_primitives.md new file mode 100644 index 00000000000..d2b42d67b7c --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/ec_primitives.md @@ -0,0 +1,102 @@ +--- +title: Elliptic Curve Primitives +keywords: [cryptographic primitives, Noir project] +sidebar_position: 4 +--- + +Data structures and methods on them that allow you to carry out computations involving elliptic +curves over the (mathematical) field corresponding to `Field`. For the field currently at our +disposal, applications would involve a curve embedded in BN254, e.g. the +[Baby Jubjub curve](https://eips.ethereum.org/EIPS/eip-2494). + +## Data structures + +### Elliptic curve configurations + +(`std::ec::{tecurve,montcurve,swcurve}::{affine,curvegroup}::Curve`), i.e. the specific elliptic +curve you want to use, which would be specified using any one of the methods +`std::ec::{tecurve,montcurve,swcurve}::{affine,curvegroup}::new` which take the coefficients in the +defining equation together with a generator point as parameters. You can find more detail in the +comments in +[`noir_stdlib/src/ec.nr`](https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/ec.nr), but +the gist of it is that the elliptic curves of interest are usually expressed in one of the standard +forms implemented here (Twisted Edwards, Montgomery and Short Weierstraß), and in addition to that, +you could choose to use `affine` coordinates (Cartesian coordinates - the usual (x,y) - possibly +together with a point at infinity) or `curvegroup` coordinates (some form of projective coordinates +requiring more coordinates but allowing for more efficient implementations of elliptic curve +operations). Conversions between all of these forms are provided, and under the hood these +conversions are done whenever an operation is more efficient in a different representation (or a +mixed coordinate representation is employed). + +### Points + +(`std::ec::{tecurve,montcurve,swcurve}::{affine,curvegroup}::Point`), i.e. points lying on the +elliptic curve. For a curve configuration `c` and a point `p`, it may be checked that `p` +does indeed lie on `c` by calling `c.contains(p1)`. + +## Methods + +(given a choice of curve representation, e.g. use `std::ec::tecurve::affine::Curve` and use +`std::ec::tecurve::affine::Point`) + +- The **zero element** is given by `Point::zero()`, and we can verify whether a point `p: Point` is + zero by calling `p.is_zero()`. +- **Equality**: Points `p1: Point` and `p2: Point` may be checked for equality by calling + `p1.eq(p2)`. +- **Addition**: For `c: Curve` and points `p1: Point` and `p2: Point` on the curve, adding these two + points is accomplished by calling `c.add(p1,p2)`. +- **Negation**: For a point `p: Point`, `p.negate()` is its negation. +- **Subtraction**: For `c` and `p1`, `p2` as above, subtracting `p2` from `p1` is accomplished by + calling `c.subtract(p1,p2)`. +- **Scalar multiplication**: For `c` as above, `p: Point` a point on the curve and `n: Field`, + scalar multiplication is given by `c.mul(n,p)`. If instead `n :: [u1; N]`, i.e. `n` is a bit + array, the `bit_mul` method may be used instead: `c.bit_mul(n,p)` +- **Multi-scalar multiplication**: For `c` as above and arrays `n: [Field; N]` and `p: [Point; N]`, + multi-scalar multiplication is given by `c.msm(n,p)`. +- **Coordinate representation conversions**: The `into_group` method converts a point or curve + configuration in the affine representation to one in the CurveGroup representation, and + `into_affine` goes in the other direction. +- **Curve representation conversions**: `tecurve` and `montcurve` curves and points are equivalent + and may be converted between one another by calling `into_montcurve` or `into_tecurve` on their + configurations or points. `swcurve` is more general and a curve c of one of the other two types + may be converted to this representation by calling `c.into_swcurve()`, whereas a point `p` lying + on the curve given by `c` may be mapped to its corresponding `swcurve` point by calling + `c.map_into_swcurve(p)`. +- **Map-to-curve methods**: The Elligator 2 method of mapping a field element `n: Field` into a + `tecurve` or `montcurve` with configuration `c` may be called as `c.elligator2_map(n)`. For all of + the curve configurations, the SWU map-to-curve method may be called as `c.swu_map(z,n)`, where + `z: Field` depends on `Field` and `c` and must be chosen by the user (the conditions it needs to + satisfy are specified in the comments + [here](https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/ec.nr)). + +## Examples + +The +[ec_baby_jubjub test](https://github.com/noir-lang/noir/blob/master/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr) +illustrates all of the above primitives on various forms of the Baby Jubjub curve. A couple of more +interesting examples in Noir would be: + +Public-key cryptography: Given an elliptic curve and a 'base point' on it, determine the public key +from the private key. This is a matter of using scalar multiplication. In the case of Baby Jubjub, +for example, this code would do: + +```rust +use dep::std::ec::tecurve::affine::{Curve, Point}; + +fn bjj_pub_key(priv_key: Field) -> Point +{ + + let bjj = Curve::new(168700, 168696, G::new(995203441582195749578291179787384436505546430278305826713579947235728471134,5472060717959818805561601436314318772137091100104008585924551046643952123905)); + + let base_pt = Point::new(5299619240641551281634865583518297030282874472190772894086521144482721001553, 16950150798460657717958625567821834550301663161624707787222815936182638968203); + + bjj.mul(priv_key,base_pt) +} +``` + +This would come in handy in a Merkle proof. + +- EdDSA signature verification: This is a matter of combining these primitives with a suitable hash + function. See + [feat(stdlib): EdDSA sig verification noir#1136](https://github.com/noir-lang/noir/pull/1136) for + the case of Baby Jubjub and the Poseidon hash function. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/ecdsa_sig_verification.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/ecdsa_sig_verification.mdx new file mode 100644 index 00000000000..4bf09cef178 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/ecdsa_sig_verification.mdx @@ -0,0 +1,60 @@ +--- +title: ECDSA Signature Verification +description: Learn about the cryptographic primitives regarding ECDSA over the secp256k1 and secp256r1 curves +keywords: [cryptographic primitives, Noir project, ecdsa, secp256k1, secp256r1, signatures] +sidebar_position: 3 +--- + +import BlackBoxInfo from '@site/src/components/Notes/_blackbox.mdx'; + +Noir supports ECDSA signatures verification over the secp256k1 and secp256r1 curves. + +## ecdsa_secp256k1::verify_signature + +Verifier for ECDSA Secp256k1 signatures + +```rust title="ecdsa_secp256k1" showLineNumbers +pub fn verify_signature( + public_key_x: [u8; 32], + public_key_y: [u8; 32], + signature: [u8; 64], + message_hash: [u8; N] +) -> bool +``` +> Source code: noir_stdlib/src/ecdsa_secp256k1.nr#L2-L9 + + +example: + +```rust +fn main(hashed_message : [u8;32], pub_key_x : [u8;32], pub_key_y : [u8;32], signature : [u8;64]) { + let valid_signature = std::ecdsa_secp256k1::verify_signature(pub_key_x, pub_key_y, signature, hashed_message); + assert(valid_signature); +} +``` + +## ecdsa_secp256r1::verify_signature + +Verifier for ECDSA Secp256r1 signatures + +```rust title="ecdsa_secp256r1" showLineNumbers +pub fn verify_signature( + public_key_x: [u8; 32], + public_key_y: [u8; 32], + signature: [u8; 64], + message_hash: [u8; N] +) -> bool +``` +> Source code: noir_stdlib/src/ecdsa_secp256r1.nr#L2-L9 + + +example: + +```rust +fn main(hashed_message : [u8;32], pub_key_x : [u8;32], pub_key_y : [u8;32], signature : [u8;64]) { + let valid_signature = std::ecdsa_secp256r1::verify_signature(pub_key_x, pub_key_y, signature, hashed_message); + assert(valid_signature); +} +``` + + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/eddsa.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/eddsa.mdx new file mode 100644 index 00000000000..c2c0624dfad --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/eddsa.mdx @@ -0,0 +1,37 @@ +--- +title: EdDSA Verification +description: Learn about the cryptographic primitives regarding EdDSA +keywords: [cryptographic primitives, Noir project, eddsa, signatures] +sidebar_position: 5 +--- + +import BlackBoxInfo from '@site/src/components/Notes/_blackbox.mdx'; + +## eddsa::eddsa_poseidon_verify + +Verifier for EdDSA signatures + +```rust +fn eddsa_poseidon_verify(public_key_x : Field, public_key_y : Field, signature_s: Field, signature_r8_x: Field, signature_r8_y: Field, message: Field) -> bool +``` + +It is also possible to specify the hash algorithm used for the signature by using the `eddsa_verify_with_hasher` function with a parameter implementing the Hasher trait. For instance, if you want to use Poseidon2 instead, you can do the following: +```rust +use dep::std::hash::poseidon2::Poseidon2Hasher; + +let mut hasher = Poseidon2Hasher::default(); +eddsa_verify_with_hasher(pub_key_a.x, pub_key_a.y, s_a, r8_a.x, r8_a.y, msg, &mut hasher); +``` + + + +## eddsa::eddsa_to_pub + +Private to public key conversion. + +Returns `(pub_key_x, pub_key_y)` + +```rust +fn eddsa_to_pub(secret : Field) -> (Field, Field) +``` + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/hashes.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/hashes.mdx new file mode 100644 index 00000000000..119d8ccc70e --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/hashes.mdx @@ -0,0 +1,251 @@ +--- +title: Hash methods +description: + Learn about the cryptographic primitives ready to use for any Noir project, including sha256, + blake2s, pedersen, mimc_bn254 and mimc +keywords: + [cryptographic primitives, Noir project, sha256, blake2s, pedersen, mimc_bn254, mimc, hash] +sidebar_position: 0 +--- + +import BlackBoxInfo from '@site/src/components/Notes/_blackbox.mdx'; + +## sha256 + +Given an array of bytes, returns the resulting sha256 hash. + +```rust title="sha256" showLineNumbers +pub fn sha256(input: [u8; N]) -> [u8; 32] +``` +> Source code: noir_stdlib/src/hash.nr#L9-L11 + + +example: + +```rust +fn main() { + let x = [163, 117, 178, 149]; // some random bytes + let hash = std::hash::sha256(x); +} +``` + + + +## blake2s + +Given an array of bytes, returns an array with the Blake2 hash + +```rust title="blake2s" showLineNumbers +pub fn blake2s(input: [u8; N]) -> [u8; 32] +``` +> Source code: noir_stdlib/src/hash.nr#L15-L17 + + +example: + +```rust +fn main() { + let x = [163, 117, 178, 149]; // some random bytes + let hash = std::hash::blake2s(x); +} +``` + + + +## blake3 + +Given an array of bytes, returns an array with the Blake3 hash + +```rust title="blake3" showLineNumbers +pub fn blake3(input: [u8; N]) -> [u8; 32] +``` +> Source code: noir_stdlib/src/hash.nr#L21-L23 + + +example: + +```rust +fn main() { + let x = [163, 117, 178, 149]; // some random bytes + let hash = std::hash::blake3(x); +} +``` + + + +## pedersen_hash + +Given an array of Fields, returns the Pedersen hash. + +```rust title="pedersen_hash" showLineNumbers +pub fn pedersen_hash(input: [Field; N]) -> Field +``` +> Source code: noir_stdlib/src/hash.nr#L46-L48 + + +example: + +```rust title="pedersen-hash" showLineNumbers +use dep::std; + +fn main(x: Field, y: Field, expected_hash: Field) { + let hash = std::hash::pedersen_hash([x, y]); + assert_eq(hash, expected_hash); +} +``` +> Source code: test_programs/execution_success/pedersen_hash/src/main.nr#L1-L8 + + + + + +## pedersen_commitment + +Given an array of Fields, returns the Pedersen commitment. + +```rust title="pedersen_commitment" showLineNumbers +struct PedersenPoint { + x : Field, + y : Field, +} + +pub fn pedersen_commitment(input: [Field; N]) -> PedersenPoint +``` +> Source code: noir_stdlib/src/hash.nr#L26-L33 + + +example: + +```rust title="pedersen-commitment" showLineNumbers +use dep::std; + +fn main(x: Field, y: Field, expected_commitment: std::hash::PedersenPoint) { + let commitment = std::hash::pedersen_commitment([x, y]); + assert_eq(commitment.x, expected_commitment.x); + assert_eq(commitment.y, expected_commitment.y); +} +``` +> Source code: test_programs/execution_success/pedersen_commitment/src/main.nr#L1-L9 + + + + +## keccak256 + +Given an array of bytes (`u8`), returns the resulting keccak hash as an array of 32 bytes +(`[u8; 32]`). Specify a message_size to hash only the first `message_size` bytes +of the input. + +```rust title="keccak256" showLineNumbers +pub fn keccak256(input: [u8; N], message_size: u32) -> [u8; 32] +``` +> Source code: noir_stdlib/src/hash.nr#L71-L73 + + +example: + +```rust title="keccak256" showLineNumbers +use dep::std; + +fn main(x: Field, result: [u8; 32]) { + // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x Field + // The padding is taken care of by the program + let digest = std::hash::keccak256([x as u8], 1); + assert(digest == result); + + //#1399: variable message size + let message_size = 4; + let hash_a = std::hash::keccak256([1, 2, 3, 4], message_size); + let hash_b = std::hash::keccak256([1, 2, 3, 4, 0, 0, 0, 0], message_size); + + assert(hash_a == hash_b); + + let message_size_big = 8; + let hash_c = std::hash::keccak256([1, 2, 3, 4, 0, 0, 0, 0], message_size_big); + + assert(hash_a != hash_c); +} +``` +> Source code: test_programs/execution_success/keccak256/src/main.nr#L1-L22 + + + + +## poseidon + +Given an array of Fields, returns a new Field with the Poseidon Hash. Mind that you need to specify +how many inputs are there to your Poseidon function. + +```rust +// example for hash_1, hash_2 accepts an array of length 2, etc +fn hash_1(input: [Field; 1]) -> Field +``` + +example: + +```rust title="poseidon" showLineNumbers +use dep::std::hash::poseidon; +use dep::std::hash::poseidon2; + +fn main(x1: [Field; 2], y1: pub Field, x2: [Field; 4], y2: pub Field, x3: [Field; 4], y3: Field) { + let hash1 = poseidon::bn254::hash_2(x1); + assert(hash1 == y1); + + let hash2 = poseidon::bn254::hash_4(x2); + assert(hash2 == y2); + + let hash3 = poseidon2::Poseidon2::hash(x3, x3.len()); + assert(hash3 == y3); +} +``` +> Source code: test_programs/execution_success/poseidon_bn254_hash/src/main.nr#L1-L15 + + +## poseidon 2 + +Given an array of Fields, returns a new Field with the Poseidon2 Hash. Contrary to the Poseidon +function, there is only one hash and you can specify a message_size to hash only the first +`message_size` bytes of the input, + +```rust +// example for hashing the first three elements of the input +Poseidon2::hash(input, 3); +``` + +The above example for Poseidon also includes Poseidon2. + +## mimc_bn254 and mimc + +`mimc_bn254` is `mimc`, but with hardcoded parameters for the BN254 curve. You can use it by +providing an array of Fields, and it returns a Field with the hash. You can use the `mimc` method if +you're willing to input your own constants: + +```rust +fn mimc(x: Field, k: Field, constants: [Field; N], exp : Field) -> Field +``` + +otherwise, use the `mimc_bn254` method: + +```rust +fn mimc_bn254(array: [Field; N]) -> Field +``` + +example: + +```rust + +fn main() { + let x = [163, 117, 178, 149]; // some random bytes + let hash = std::hash::mimc::mimc_bn254(x); +} +``` + +## hash_to_field + +```rust +fn hash_to_field(_input : [Field; N]) -> Field {} +``` + +Calculates the `blake2s` hash of the inputs and returns the hash modulo the field modulus to return +a value which can be represented as a `Field`. + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/index.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/index.md new file mode 100644 index 00000000000..650f30165d5 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/index.md @@ -0,0 +1,14 @@ +--- +title: Cryptographic Primitives +description: + Learn about the cryptographic primitives ready to use for any Noir project +keywords: + [ + cryptographic primitives, + Noir project, + ] +--- + +The Noir team is progressively adding new cryptographic primitives to the standard library. Reach out for news or if you would be interested in adding more of these calculations in Noir. + +Some methods are available thanks to the Aztec backend, not being performed using Noir. When using other backends, these methods may or may not be supplied. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/scalar.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/scalar.mdx new file mode 100644 index 00000000000..df411ca5443 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/scalar.mdx @@ -0,0 +1,33 @@ +--- +title: Scalar multiplication +description: See how you can perform scalar multiplications over a fixed base in Noir +keywords: [cryptographic primitives, Noir project, scalar multiplication] +sidebar_position: 1 +--- + +import BlackBoxInfo from '@site/src/components/Notes/_blackbox.mdx'; + +## scalar_mul::fixed_base_embedded_curve + +Performs scalar multiplication over the embedded curve whose coordinates are defined by the +configured noir field. For the BN254 scalar field, this is BabyJubJub or Grumpkin. + +```rust title="fixed_base_embedded_curve" showLineNumbers +pub fn fixed_base_embedded_curve( + low: Field, + high: Field +) -> [Field; 2] +``` +> Source code: noir_stdlib/src/scalar_mul.nr#L27-L32 + + +example + +```rust +fn main(x : Field) { + let scal = std::scalar_mul::fixed_base_embedded_curve(x); + println(scal); +} +``` + + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/schnorr.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/schnorr.mdx new file mode 100644 index 00000000000..ae12e6c12dc --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/cryptographic_primitives/schnorr.mdx @@ -0,0 +1,45 @@ +--- +title: Schnorr Signatures +description: Learn how you can verify Schnorr signatures using Noir +keywords: [cryptographic primitives, Noir project, schnorr, signatures] +sidebar_position: 2 +--- + +import BlackBoxInfo from '@site/src/components/Notes/_blackbox.mdx'; + +## schnorr::verify_signature + +Verifier for Schnorr signatures over the embedded curve (for BN254 it is Grumpkin). + +```rust title="schnorr_verify" showLineNumbers +pub fn verify_signature( + public_key_x: Field, + public_key_y: Field, + signature: [u8; 64], + message: [u8; N] +) -> bool +``` +> Source code: noir_stdlib/src/schnorr.nr#L2-L9 + + +where `_signature` can be generated like so using the npm package +[@noir-lang/barretenberg](https://www.npmjs.com/package/@noir-lang/barretenberg) + +```js +const { BarretenbergWasm } = require('@noir-lang/barretenberg/dest/wasm'); +const { Schnorr } = require('@noir-lang/barretenberg/dest/crypto/schnorr'); + +... + +const barretenberg = await BarretenbergWasm.new(); +const schnorr = new Schnorr(barretenberg); +const pubKey = schnorr.computePublicKey(privateKey); +const message = ... +const signature = Array.from( + schnorr.constructSignature(hash, privateKey).toBuffer() +); + +... +``` + + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/logging.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/logging.md new file mode 100644 index 00000000000..db75ef9f86f --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/logging.md @@ -0,0 +1,78 @@ +--- +title: Logging +description: + Learn how to use the println statement for debugging in Noir with this tutorial. Understand the + basics of logging in Noir and how to implement it in your code. +keywords: + [ + noir logging, + println statement, + print statement, + debugging in noir, + noir std library, + logging tutorial, + basic logging in noir, + noir logging implementation, + noir debugging techniques, + rust, + ] +--- + +The standard library provides two familiar statements you can use: `println` and `print`. Despite being a limited implementation of rust's `println!` and `print!` macros, these constructs can be useful for debugging. + +You can print the output of both statements in your Noir code by using the `nargo execute` command or the `--show-output` flag when using `nargo test` (provided there are print statements in your tests). + +It is recommended to use `nargo execute` if you want to debug failing constraints with `println` or `print` statements. This is due to every input in a test being a constant rather than a witness, so we issue an error during compilation while we only print during execution (which comes after compilation). Neither `println`, nor `print` are callable for failed constraints caught at compile time. + +Both `print` and `println` are generic functions which can work on integers, fields, strings, and even structs or expressions. Note however, that slices are currently unsupported. For example: + +```rust +struct Person { + age: Field, + height: Field, +} + +fn main(age: Field, height: Field) { + let person = Person { + age: age, + height: height, + }; + println(person); + println(age + height); + println("Hello world!"); +} +``` + +You can print different types in the same statement (including strings) with a type called `fmtstr`. It can be specified in the same way as a normal string, just prepended with an "f" character: + +```rust + let fmt_str = f"i: {i}, j: {j}"; + println(fmt_str); + + let s = myStruct { y: x, x: y }; + println(s); + + println(f"i: {i}, s: {s}"); + + println(x); + println([x, y]); + + let foo = fooStruct { my_struct: s, foo: 15 }; + println(f"s: {s}, foo: {foo}"); + + println(15); // prints 0x0f, implicit Field + println(-1 as u8); // prints 255 + println(-1 as i8); // prints -1 +``` + +Examples shown above are interchangeable between the two `print` statements: + +```rust +let person = Person { age : age, height : height }; + +println(person); +print(person); + +println("Hello world!"); // Prints with a newline at the end of the input +print("Hello world!"); // Prints the input and keeps cursor on the same line +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/merkle_trees.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/merkle_trees.md new file mode 100644 index 00000000000..fa488677884 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/merkle_trees.md @@ -0,0 +1,58 @@ +--- +title: Merkle Trees +description: Learn about Merkle Trees in Noir with this tutorial. Explore the basics of computing a merkle root using a proof, with examples. +keywords: + [ + Merkle trees in Noir, + Noir programming language, + check membership, + computing root from leaf, + Noir Merkle tree implementation, + Merkle tree tutorial, + Merkle tree code examples, + Noir libraries, + pedersen hash., + ] +--- + +## compute_merkle_root + +Returns the root of the tree from the provided leaf and its hash path, using a [Pedersen hash](./cryptographic_primitives/hashes.mdx#pedersen_hash). + +```rust +fn compute_merkle_root(leaf : Field, index : Field, hash_path: [Field]) -> Field +``` + +example: + +```rust +/** + // these values are for this example only + index = "0" + priv_key = "0x000000000000000000000000000000000000000000000000000000616c696365" + secret = "0x1929ea3ab8d9106a899386883d9428f8256cfedb3c4f6b66bf4aa4d28a79988f" + note_hash_path = [ + "0x1e61bdae0f027b1b2159e1f9d3f8d00fa668a952dddd822fda80dc745d6f65cc", + "0x0e4223f3925f98934393c74975142bd73079ab0621f4ee133cee050a3c194f1a", + "0x2fd7bb412155bf8693a3bd2a3e7581a679c95c68a052f835dddca85fa1569a40" + ] + */ +fn main(index: Field, priv_key: Field, secret: Field, note_hash_path: [Field; 3]) { + + let pubkey = std::scalar_mul::fixed_base_embedded_curve(priv_key); + let pubkey_x = pubkey[0]; + let pubkey_y = pubkey[1]; + let note_commitment = std::hash::pedersen([pubkey_x, pubkey_y, secret]); + + let root = std::merkle::compute_merkle_root(note_commitment[0], index, note_hash_path); + println(root); +} +``` + +To check merkle tree membership: + +1. Include a merkle root as a program input. +2. Compute the merkle root of a given leaf, index and hash path. +3. Assert the merkle roots are equal. + +For more info about merkle trees, see the Wikipedia [page](https://en.wikipedia.org/wiki/Merkle_tree). diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/options.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/options.md new file mode 100644 index 00000000000..a1bd4e1de5f --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/options.md @@ -0,0 +1,101 @@ +--- +title: Option Type +--- + +The `Option` type is a way to express that a value might be present (`Some(T))` or absent (`None`). It's a safer way to handle potential absence of values, compared to using nulls in many other languages. + +```rust +struct Option { + None, + Some(T), +} +``` + +The `Option` type, already imported into your Noir program, can be used directly: + +```rust +fn main() { + let none = Option::none(); + let some = Option::some(3); +} +``` + +See [this test](https://github.com/noir-lang/noir/blob/5cbfb9c4a06c8865c98ff2b594464b037d821a5c/crates/nargo_cli/tests/test_data/option/src/main.nr) for a more comprehensive set of examples of each of the methods described below. + +## Methods + +### none + +Constructs a none value. + +### some + +Constructs a some wrapper around a given value. + +### is_none + +Returns true if the Option is None. + +### is_some + +Returns true of the Option is Some. + +### unwrap + +Asserts `self.is_some()` and returns the wrapped value. + +### unwrap_unchecked + +Returns the inner value without asserting `self.is_some()`. This method can be useful within an if condition when we already know that `option.is_some()`. If the option is None, there is no guarantee what value will be returned, only that it will be of type T for an `Option`. + +### unwrap_or + +Returns the wrapped value if `self.is_some()`. Otherwise, returns the given default value. + +### unwrap_or_else + +Returns the wrapped value if `self.is_some()`. Otherwise, calls the given function to return a default value. + +### expect + +Asserts `self.is_some()` with a provided custom message and returns the contained `Some` value. The custom message is expected to be a format string. + +### map + +If self is `Some(x)`, this returns `Some(f(x))`. Otherwise, this returns `None`. + +### map_or + +If self is `Some(x)`, this returns `f(x)`. Otherwise, this returns the given default value. + +### map_or_else + +If self is `Some(x)`, this returns `f(x)`. Otherwise, this returns `default()`. + +### and + +Returns None if self is None. Otherwise, this returns `other`. + +### and_then + +If self is None, this returns None. Otherwise, this calls the given function with the Some value contained within self, and returns the result of that call. In some languages this function is called `flat_map` or `bind`. + +### or + +If self is Some, return self. Otherwise, return `other`. + +### or_else + +If self is Some, return self. Otherwise, return `default()`. + +### xor + +If only one of the two Options is Some, return that option. Otherwise, if both options are Some or both are None, None is returned. + +### filter + +Returns `Some(x)` if self is `Some(x)` and `predicate(x)` is true. Otherwise, this returns `None`. + +### flatten + +Flattens an `Option>` into a `Option`. This returns `None` if the outer Option is None. Otherwise, this returns the inner Option. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/recursion.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/recursion.md new file mode 100644 index 00000000000..9337499dac8 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/recursion.md @@ -0,0 +1,88 @@ +--- +title: Recursive Proofs +description: Learn about how to write recursive proofs in Noir. +keywords: [recursion, recursive proofs, verification_key, verify_proof] +--- + +Noir supports recursively verifying proofs, meaning you verify the proof of a Noir program in another Noir program. This enables creating proofs of arbitrary size by doing step-wise verification of smaller components of a large proof. + +Read [the explainer on recursion](../../explainers/explainer-recursion.md) to know more about this function and the [guide on how to use it.](../../how_to/how-to-recursion.md) + +## The `#[recursive]` Attribute + +In Noir, the `#[recursive]` attribute is used to indicate that a circuit is designed for recursive proof generation. When applied, it informs the compiler and the tooling that the circuit should be compiled in a way that makes its proofs suitable for recursive verification. This attribute eliminates the need for manual flagging of recursion at the tooling level, streamlining the proof generation process for recursive circuits. + +### Example usage with `#[recursive]` + +```rust +#[recursive] +fn main(x: Field, y: pub Field) { + assert(x == y, "x and y are not equal"); +} + +// This marks the circuit as recursion-friendly and indicates that proofs generated from this circuit +// are intended for recursive verification. +``` + +By incorporating this attribute directly in the circuit's definition, tooling like Nargo and NoirJS can automatically execute recursive-specific duties for Noir programs (e.g. recursive-friendly proof artifact generation) without additional flags or configurations. + +## Verifying Recursive Proofs + +```rust +#[foreign(verify_proof)] +fn verify_proof(_verification_key : [Field], _proof : [Field], _public_input : Field, _key_hash : Field) {} +``` + +:::info + +This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. + +::: + +## Example usage + +```rust +use dep::std; + +fn main( + verification_key : [Field; 114], + proof : [Field; 93], + public_inputs : [Field; 1], + key_hash : Field, + proof_b : [Field; 93], +) { + std::verify_proof( + verification_key.as_slice(), + proof.as_slice(), + public_inputs.as_slice(), + key_hash + ); + + std::verify_proof( + verification_key.as_slice(), + proof_b.as_slice(), + public_inputs.as_slice(), + key_hash + ); +} +``` + +You can see a full example of recursive proofs in [this example recursion demo repo](https://github.com/noir-lang/noir-examples/tree/master/recursion). + +## Parameters + +### `verification_key` + +The verification key for the zk program that is being verified. + +### `proof` + +The proof for the zk program that is being verified. + +### `public_inputs` + +These represent the public inputs of the proof we are verifying. + +### `key_hash` + +A key hash is used to check the validity of the verification key. The circuit implementing this opcode can use this hash to ensure that the key provided to the circuit matches the key produced by the circuit creator. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/traits.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/traits.md new file mode 100644 index 00000000000..ba9fa2ee841 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/traits.md @@ -0,0 +1,399 @@ +--- +title: Traits +description: Noir's stdlib provides a few commonly used traits. +keywords: [traits, trait, interface, protocol, default, add, eq] +--- + +## `std::default` + +### `std::default::Default` + +```rust title="default-trait" showLineNumbers +trait Default { + fn default() -> Self; +} +``` +> Source code: noir_stdlib/src/default.nr#L1-L5 + + +Constructs a default value of a type. + +Implementations: +```rust +impl Default for Field { .. } + +impl Default for i8 { .. } +impl Default for i16 { .. } +impl Default for i32 { .. } +impl Default for i64 { .. } + +impl Default for u8 { .. } +impl Default for u16 { .. } +impl Default for u32 { .. } +impl Default for u64 { .. } + +impl Default for () { .. } +impl Default for bool { .. } + +impl Default for [T; N] + where T: Default { .. } + +impl Default for (A, B) + where A: Default, B: Default { .. } + +impl Default for (A, B, C) + where A: Default, B: Default, C: Default { .. } + +impl Default for (A, B, C, D) + where A: Default, B: Default, C: Default, D: Default { .. } + +impl Default for (A, B, C, D, E) + where A: Default, B: Default, C: Default, D: Default, E: Default { .. } +``` + +For primitive integer types, the return value of `default` is `0`. Container +types such as arrays are filled with default values of their element type. + + +## `std::convert` + +### `std::convert::From` + +```rust title="from-trait" showLineNumbers +trait From { + fn from(input: T) -> Self; +} +``` +> Source code: noir_stdlib/src/convert.nr#L1-L5 + + +The `From` trait defines how to convert from a given type `T` to the type on which the trait is implemented. + +The Noir standard library provides a number of implementations of `From` between primitive types. +```rust title="from-impls" showLineNumbers +// Unsigned integers + +impl From for u32 { fn from(value: u8) -> u32 { value as u32 } } + +impl From for u64 { fn from(value: u8) -> u64 { value as u64 } } +impl From for u64 { fn from(value: u32) -> u64 { value as u64 } } + +impl From for Field { fn from(value: u8) -> Field { value as Field } } +impl From for Field { fn from(value: u32) -> Field { value as Field } } +impl From for Field { fn from(value: u64) -> Field { value as Field } } + +// Signed integers + +impl From for i32 { fn from(value: i8) -> i32 { value as i32 } } + +impl From for i64 { fn from(value: i8) -> i64 { value as i64 } } +impl From for i64 { fn from(value: i32) -> i64 { value as i64 } } + +// Booleans +impl From for u8 { fn from(value: bool) -> u8 { value as u8 } } +impl From for u32 { fn from(value: bool) -> u32 { value as u32 } } +impl From for u64 { fn from(value: bool) -> u64 { value as u64 } } +impl From for i8 { fn from(value: bool) -> i8 { value as i8 } } +impl From for i32 { fn from(value: bool) -> i32 { value as i32 } } +impl From for i64 { fn from(value: bool) -> i64 { value as i64 } } +impl From for Field { fn from(value: bool) -> Field { value as Field } } +``` +> Source code: noir_stdlib/src/convert.nr#L25-L52 + + +#### When to implement `From` + +As a general rule of thumb, `From` may be implemented in the [situations where it would be suitable in Rust](https://doc.rust-lang.org/std/convert/trait.From.html#when-to-implement-from): + +- The conversion is *infallible*: Noir does not provide an equivalent to Rust's `TryFrom`, if the conversion can fail then provide a named method instead. +- The conversion is *lossless*: semantically, it should not lose or discard information. For example, `u32: From` can losslessly convert any `u16` into a valid `u32` such that the original `u16` can be recovered. On the other hand, `u16: From` should not be implemented as `2**16` is a `u32` which cannot be losslessly converted into a `u16`. +- The conversion is *value-preserving*: the conceptual kind and meaning of the resulting value is the same, even though the Noir type and technical representation might be different. While it's possible to infallibly and losslessly convert a `u8` into a `str<2>` hex representation, `4u8` and `"04"` are too different for `str<2>: From` to be implemented. +- The conversion is *obvious*: it's the only reasonable conversion between the two types. If there's ambiguity on how to convert between them such that the same input could potentially map to two different values then a named method should be used. For instance rather than implementing `U128: From<[u8; 16]>`, the methods `U128::from_le_bytes` and `U128::from_be_bytes` are used as otherwise the endianness of the array would be ambiguous, resulting in two potential values of `U128` from the same byte array. + +One additional recommendation specific to Noir is: +- The conversion is *efficient*: it's relatively cheap to convert between the two types. Due to being a ZK DSL, it's more important to avoid unnecessary computation compared to Rust. If the implementation of `From` would encourage users to perform unnecessary conversion, resulting in additional proving time, then it may be preferable to expose functionality such that this conversion may be avoided. + +### `std::convert::Into` + +The `Into` trait is defined as the reciprocal of `From`. It should be easy to convince yourself that if we can convert to type `A` from type `B`, then it's possible to convert type `B` into type `A`. + +For this reason, implementing `From` on a type will automatically generate a matching `Into` implementation. One should always prefer implementing `From` over `Into` as implementing `Into` will not generate a matching `From` implementation. + +```rust title="into-trait" showLineNumbers +trait Into { + fn into(input: Self) -> T; +} + +impl Into for U where T: From { + fn into(input: U) -> T { + T::from(input) + } +} +``` +> Source code: noir_stdlib/src/convert.nr#L13-L23 + + +`Into` is most useful when passing function arguments where the types don't quite match up with what the function expects. In this case, the compiler has enough type information to perform the necessary conversion by just appending `.into()` onto the arguments in question. + + +## `std::cmp` + +### `std::cmp::Eq` + +```rust title="eq-trait" showLineNumbers +trait Eq { + fn eq(self, other: Self) -> bool; +} +``` +> Source code: noir_stdlib/src/cmp.nr#L1-L5 + + +Returns `true` if `self` is equal to `other`. Implementing this trait on a type +allows the type to be used with `==` and `!=`. + +Implementations: +```rust +impl Eq for Field { .. } + +impl Eq for i8 { .. } +impl Eq for i16 { .. } +impl Eq for i32 { .. } +impl Eq for i64 { .. } + +impl Eq for u8 { .. } +impl Eq for u16 { .. } +impl Eq for u32 { .. } +impl Eq for u64 { .. } + +impl Eq for () { .. } +impl Eq for bool { .. } + +impl Eq for [T; N] + where T: Eq { .. } + +impl Eq for (A, B) + where A: Eq, B: Eq { .. } + +impl Eq for (A, B, C) + where A: Eq, B: Eq, C: Eq { .. } + +impl Eq for (A, B, C, D) + where A: Eq, B: Eq, C: Eq, D: Eq { .. } + +impl Eq for (A, B, C, D, E) + where A: Eq, B: Eq, C: Eq, D: Eq, E: Eq { .. } +``` + +### `std::cmp::Ord` + +```rust title="ord-trait" showLineNumbers +trait Ord { + fn cmp(self, other: Self) -> Ordering; +} +``` +> Source code: noir_stdlib/src/cmp.nr#L92-L96 + + +`a.cmp(b)` compares two values returning `Ordering::less()` if `a < b`, +`Ordering::equal()` if `a == b`, or `Ordering::greater()` if `a > b`. +Implementing this trait on a type allows `<`, `<=`, `>`, and `>=` to be +used on values of the type. + +Implementations: + +```rust +impl Ord for u8 { .. } +impl Ord for u16 { .. } +impl Ord for u32 { .. } +impl Ord for u64 { .. } + +impl Ord for i8 { .. } +impl Ord for i16 { .. } +impl Ord for i32 { .. } + +impl Ord for i64 { .. } + +impl Ord for () { .. } +impl Ord for bool { .. } + +impl Ord for [T; N] + where T: Ord { .. } + +impl Ord for (A, B) + where A: Ord, B: Ord { .. } + +impl Ord for (A, B, C) + where A: Ord, B: Ord, C: Ord { .. } + +impl Ord for (A, B, C, D) + where A: Ord, B: Ord, C: Ord, D: Ord { .. } + +impl Ord for (A, B, C, D, E) + where A: Ord, B: Ord, C: Ord, D: Ord, E: Ord { .. } +``` + +## `std::ops` + +### `std::ops::Add`, `std::ops::Sub`, `std::ops::Mul`, and `std::ops::Div` + +These traits abstract over addition, subtraction, multiplication, and division respectively. +Implementing these traits for a given type will also allow that type to be used with the corresponding operator +for that trait (`+` for Add, etc) in addition to the normal method names. + +```rust title="add-trait" showLineNumbers +trait Add { + fn add(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops.nr#L1-L5 + +```rust title="sub-trait" showLineNumbers +trait Sub { + fn sub(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops.nr#L17-L21 + +```rust title="mul-trait" showLineNumbers +trait Mul { + fn mul(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops.nr#L33-L37 + +```rust title="div-trait" showLineNumbers +trait Div { + fn div(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops.nr#L49-L53 + + +The implementations block below is given for the `Add` trait, but the same types that implement +`Add` also implement `Sub`, `Mul`, and `Div`. + +Implementations: +```rust +impl Add for Field { .. } + +impl Add for i8 { .. } +impl Add for i16 { .. } +impl Add for i32 { .. } +impl Add for i64 { .. } + +impl Add for u8 { .. } +impl Add for u16 { .. } +impl Add for u32 { .. } +impl Add for u64 { .. } +``` + +### `std::ops::Rem` + +```rust title="rem-trait" showLineNumbers +trait Rem{ + fn rem(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops.nr#L65-L69 + + +`Rem::rem(a, b)` is the remainder function returning the result of what is +left after dividing `a` and `b`. Implementing `Rem` allows the `%` operator +to be used with the implementation type. + +Unlike other numeric traits, `Rem` is not implemented for `Field`. + +Implementations: +```rust +impl Rem for u8 { fn rem(self, other: u8) -> u8 { self % other } } +impl Rem for u16 { fn rem(self, other: u16) -> u16 { self % other } } +impl Rem for u32 { fn rem(self, other: u32) -> u32 { self % other } } +impl Rem for u64 { fn rem(self, other: u64) -> u64 { self % other } } + +impl Rem for i8 { fn rem(self, other: i8) -> i8 { self % other } } +impl Rem for i16 { fn rem(self, other: i16) -> i16 { self % other } } +impl Rem for i32 { fn rem(self, other: i32) -> i32 { self % other } } +impl Rem for i64 { fn rem(self, other: i64) -> i64 { self % other } } +``` + +### `std::ops::{ BitOr, BitAnd, BitXor }` + +```rust title="bitor-trait" showLineNumbers +trait BitOr { + fn bitor(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops.nr#L79-L83 + +```rust title="bitand-trait" showLineNumbers +trait BitAnd { + fn bitand(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops.nr#L95-L99 + +```rust title="bitxor-trait" showLineNumbers +trait BitXor { + fn bitxor(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops.nr#L111-L115 + + +Traits for the bitwise operations `|`, `&`, and `^`. + +Implementing `BitOr`, `BitAnd` or `BitXor` for a type allows the `|`, `&`, or `^` operator respectively +to be used with the type. + +The implementations block below is given for the `BitOr` trait, but the same types that implement +`BitOr` also implement `BitAnd` and `BitXor`. + +Implementations: +```rust +impl BitOr for bool { fn bitor(self, other: bool) -> bool { self | other } } + +impl BitOr for u8 { fn bitor(self, other: u8) -> u8 { self | other } } +impl BitOr for u16 { fn bitor(self, other: u16) -> u16 { self | other } } +impl BitOr for u32 { fn bitor(self, other: u32) -> u32 { self | other } } +impl BitOr for u64 { fn bitor(self, other: u64) -> u64 { self | other } } + +impl BitOr for i8 { fn bitor(self, other: i8) -> i8 { self | other } } +impl BitOr for i16 { fn bitor(self, other: i16) -> i16 { self | other } } +impl BitOr for i32 { fn bitor(self, other: i32) -> i32 { self | other } } +impl BitOr for i64 { fn bitor(self, other: i64) -> i64 { self | other } } +``` + +### `std::ops::{ Shl, Shr }` + +```rust title="shl-trait" showLineNumbers +trait Shl { + fn shl(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops.nr#L127-L131 + +```rust title="shr-trait" showLineNumbers +trait Shr { + fn shr(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops.nr#L142-L146 + + +Traits for a bit shift left and bit shift right. + +Implementing `Shl` for a type allows the left shift operator (`<<`) to be used with the implementation type. +Similarly, implementing `Shr` allows the right shift operator (`>>`) to be used with the type. + +Note that bit shifting is not currently implemented for signed types. + +The implementations block below is given for the `Shl` trait, but the same types that implement +`Shl` also implement `Shr`. + +Implementations: +```rust +impl Shl for u8 { fn shl(self, other: u8) -> u8 { self << other } } +impl Shl for u16 { fn shl(self, other: u16) -> u16 { self << other } } +impl Shl for u32 { fn shl(self, other: u32) -> u32 { self << other } } +impl Shl for u64 { fn shl(self, other: u64) -> u64 { self << other } } +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/zeroed.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/zeroed.md new file mode 100644 index 00000000000..97dab02dac2 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/noir/standard_library/zeroed.md @@ -0,0 +1,25 @@ +--- +title: Zeroed Function +description: + The zeroed function returns a zeroed value of any type. +keywords: + [ + zeroed + ] +--- + +Implements `fn zeroed() -> T` to return a zeroed value of any type. This function is generally unsafe to use as the zeroed bit pattern is not guaranteed to be valid for all types. It can however, be useful in cases when the value is guaranteed not to be used such as in a BoundedVec library implementing a growable vector, up to a certain length, backed by an array. The array can be initialized with zeroed values which are guaranteed to be inaccessible until the vector is pushed to. Similarly, enumerations in noir can be implemented using this method by providing zeroed values for the unused variants. + +You can access the function at `std::unsafe::zeroed`. + +This function currently supports the following types: + +- Field +- Bool +- Uint +- Array +- String +- Tuple +- Function + +Using it on other types could result in unexpected behavior. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/reference/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/reference/_category_.json new file mode 100644 index 00000000000..5b6a20a609a --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/reference/_category_.json @@ -0,0 +1,5 @@ +{ + "position": 4, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/reference/nargo_commands.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/reference/nargo_commands.md new file mode 100644 index 00000000000..8a309ef4e7e --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/reference/nargo_commands.md @@ -0,0 +1,380 @@ +--- +title: Nargo +description: + Noir CLI Commands for Noir Prover and Verifier to create, execute, prove and verify programs, + generate Solidity verifier smart contract and compile into JSON file containing ACIR + representation and ABI of circuit. +keywords: + [ + Nargo, + Noir CLI, + Noir Prover, + Noir Verifier, + generate Solidity verifier, + compile JSON file, + ACIR representation, + ABI of circuit, + TypeScript, + ] +sidebar_position: 0 +--- + +# Command-Line Help for `nargo` + +This document contains the help content for the `nargo` command-line program. + +**Command Overview:** + +* [`nargo`↴](#nargo) +* [`nargo backend`↴](#nargo-backend) +* [`nargo backend current`↴](#nargo-backend-current) +* [`nargo backend ls`↴](#nargo-backend-ls) +* [`nargo backend use`↴](#nargo-backend-use) +* [`nargo backend install`↴](#nargo-backend-install) +* [`nargo backend uninstall`↴](#nargo-backend-uninstall) +* [`nargo check`↴](#nargo-check) +* [`nargo fmt`↴](#nargo-fmt) +* [`nargo codegen-verifier`↴](#nargo-codegen-verifier) +* [`nargo compile`↴](#nargo-compile) +* [`nargo new`↴](#nargo-new) +* [`nargo init`↴](#nargo-init) +* [`nargo execute`↴](#nargo-execute) +* [`nargo prove`↴](#nargo-prove) +* [`nargo verify`↴](#nargo-verify) +* [`nargo test`↴](#nargo-test) +* [`nargo info`↴](#nargo-info) +* [`nargo lsp`↴](#nargo-lsp) + +## `nargo` + +Noir's package manager + +**Usage:** `nargo ` + +###### **Subcommands:** + +* `backend` — Install and select custom backends used to generate and verify proofs +* `check` — Checks the constraint system for errors +* `fmt` — Format the Noir files in a workspace +* `codegen-verifier` — Generates a Solidity verifier smart contract for the program +* `compile` — Compile the program and its secret execution trace into ACIR format +* `new` — Create a Noir project in a new directory +* `init` — Create a Noir project in the current directory +* `execute` — Executes a circuit to calculate its return value +* `prove` — Create proof for this program. The proof is returned as a hex encoded string +* `verify` — Given a proof and a program, verify whether the proof is valid +* `test` — Run the tests for this program +* `info` — Provides detailed information on a circuit +* `lsp` — Starts the Noir LSP server + +###### **Options:** + + + + +## `nargo backend` + +Install and select custom backends used to generate and verify proofs + +**Usage:** `nargo backend ` + +###### **Subcommands:** + +* `current` — Prints the name of the currently active backend +* `ls` — Prints the list of currently installed backends +* `use` — Select the backend to use +* `install` — Install a new backend from a URL +* `uninstall` — Uninstalls a backend + + + +## `nargo backend current` + +Prints the name of the currently active backend + +**Usage:** `nargo backend current` + + + +## `nargo backend ls` + +Prints the list of currently installed backends + +**Usage:** `nargo backend ls` + + + +## `nargo backend use` + +Select the backend to use + +**Usage:** `nargo backend use ` + +###### **Arguments:** + +* `` + + + +## `nargo backend install` + +Install a new backend from a URL + +**Usage:** `nargo backend install ` + +###### **Arguments:** + +* `` — The name of the backend to install +* `` — The URL from which to download the backend + + + +## `nargo backend uninstall` + +Uninstalls a backend + +**Usage:** `nargo backend uninstall ` + +###### **Arguments:** + +* `` — The name of the backend to uninstall + + + +## `nargo check` + +Checks the constraint system for errors + +**Usage:** `nargo check [OPTIONS]` + +###### **Options:** + +* `--package ` — The name of the package to check +* `--workspace` — Check all packages in the workspace +* `--expression-width ` — Override the expression width requested by the backend +* `--force` — Force a full recompilation +* `--print-acir` — Display the ACIR for compiled circuit +* `--deny-warnings` — Treat all warnings as errors +* `--silence-warnings` — Suppress warnings + + + +## `nargo fmt` + +Format the Noir files in a workspace + +**Usage:** `nargo fmt [OPTIONS]` + +###### **Options:** + +* `--check` — Run noirfmt in check mode + + + +## `nargo codegen-verifier` + +Generates a Solidity verifier smart contract for the program + +**Usage:** `nargo codegen-verifier [OPTIONS]` + +###### **Options:** + +* `--package ` — The name of the package to codegen +* `--workspace` — Codegen all packages in the workspace +* `--expression-width ` — Override the expression width requested by the backend +* `--force` — Force a full recompilation +* `--print-acir` — Display the ACIR for compiled circuit +* `--deny-warnings` — Treat all warnings as errors +* `--silence-warnings` — Suppress warnings + + + +## `nargo compile` + +Compile the program and its secret execution trace into ACIR format + +**Usage:** `nargo compile [OPTIONS]` + +###### **Options:** + +* `--package ` — The name of the package to compile +* `--workspace` — Compile all packages in the workspace +* `--expression-width ` — Override the expression width requested by the backend +* `--force` — Force a full recompilation +* `--print-acir` — Display the ACIR for compiled circuit +* `--deny-warnings` — Treat all warnings as errors +* `--silence-warnings` — Suppress warnings + + + +## `nargo new` + +Create a Noir project in a new directory + +**Usage:** `nargo new [OPTIONS] ` + +###### **Arguments:** + +* `` — The path to save the new project + +###### **Options:** + +* `--name ` — Name of the package [default: package directory name] +* `--lib` — Use a library template +* `--bin` — Use a binary template [default] +* `--contract` — Use a contract template + + + +## `nargo init` + +Create a Noir project in the current directory + +**Usage:** `nargo init [OPTIONS]` + +###### **Options:** + +* `--name ` — Name of the package [default: current directory name] +* `--lib` — Use a library template +* `--bin` — Use a binary template [default] +* `--contract` — Use a contract template + + + +## `nargo execute` + +Executes a circuit to calculate its return value + +**Usage:** `nargo execute [OPTIONS] [WITNESS_NAME]` + +###### **Arguments:** + +* `` — Write the execution witness to named file + +###### **Options:** + +* `-p`, `--prover-name ` — The name of the toml file which contains the inputs for the prover + + Default value: `Prover` +* `--package ` — The name of the package to execute +* `--workspace` — Execute all packages in the workspace +* `--expression-width ` — Override the expression width requested by the backend +* `--force` — Force a full recompilation +* `--print-acir` — Display the ACIR for compiled circuit +* `--deny-warnings` — Treat all warnings as errors +* `--silence-warnings` — Suppress warnings +* `--oracle-resolver ` — JSON RPC url to solve oracle calls + + + +## `nargo prove` + +Create proof for this program. The proof is returned as a hex encoded string + +**Usage:** `nargo prove [OPTIONS]` + +###### **Options:** + +* `-p`, `--prover-name ` — The name of the toml file which contains the inputs for the prover + + Default value: `Prover` +* `-v`, `--verifier-name ` — The name of the toml file which contains the inputs for the verifier + + Default value: `Verifier` +* `--verify` — Verify proof after proving +* `--package ` — The name of the package to prove +* `--workspace` — Prove all packages in the workspace +* `--expression-width ` — Override the expression width requested by the backend +* `--force` — Force a full recompilation +* `--print-acir` — Display the ACIR for compiled circuit +* `--deny-warnings` — Treat all warnings as errors +* `--silence-warnings` — Suppress warnings +* `--oracle-resolver ` — JSON RPC url to solve oracle calls + + + +## `nargo verify` + +Given a proof and a program, verify whether the proof is valid + +**Usage:** `nargo verify [OPTIONS]` + +###### **Options:** + +* `-v`, `--verifier-name ` — The name of the toml file which contains the inputs for the verifier + + Default value: `Verifier` +* `--package ` — The name of the package verify +* `--workspace` — Verify all packages in the workspace +* `--expression-width ` — Override the expression width requested by the backend +* `--force` — Force a full recompilation +* `--print-acir` — Display the ACIR for compiled circuit +* `--deny-warnings` — Treat all warnings as errors +* `--silence-warnings` — Suppress warnings + + + +## `nargo test` + +Run the tests for this program + +**Usage:** `nargo test [OPTIONS] [TEST_NAME]` + +###### **Arguments:** + +* `` — If given, only tests with names containing this string will be run + +###### **Options:** + +* `--show-output` — Display output of `println` statements +* `--exact` — Only run tests that match exactly +* `--package ` — The name of the package to test +* `--workspace` — Test all packages in the workspace +* `--expression-width ` — Override the expression width requested by the backend +* `--force` — Force a full recompilation +* `--print-acir` — Display the ACIR for compiled circuit +* `--deny-warnings` — Treat all warnings as errors +* `--silence-warnings` — Suppress warnings +* `--oracle-resolver ` — JSON RPC url to solve oracle calls + + + +## `nargo info` + +Provides detailed information on a circuit + +Current information provided: 1. The number of ACIR opcodes 2. Counts the final number gates in the circuit used by a backend + +**Usage:** `nargo info [OPTIONS]` + +###### **Options:** + +* `--package ` — The name of the package to detail +* `--workspace` — Detail all packages in the workspace +* `--expression-width ` — Override the expression width requested by the backend +* `--force` — Force a full recompilation +* `--print-acir` — Display the ACIR for compiled circuit +* `--deny-warnings` — Treat all warnings as errors +* `--silence-warnings` — Suppress warnings + + + +## `nargo lsp` + +Starts the Noir LSP server + +Starts an LSP server which allows IDEs such as VS Code to display diagnostics in Noir source. + +VS Code Noir Language Support: https://marketplace.visualstudio.com/items?itemName=noir-lang.vscode-noir + +**Usage:** `nargo lsp` + + + +
+ + + This document was generated automatically by + clap-markdown. + + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.25.0/tutorials/noirjs_app.md b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/tutorials/noirjs_app.md new file mode 100644 index 00000000000..ad76dd255cc --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.25.0/tutorials/noirjs_app.md @@ -0,0 +1,279 @@ +--- +title: Building a web app with NoirJS +description: Learn how to setup a new app that uses Noir to generate and verify zero-knowledge SNARK proofs in a typescript or javascript environment. +keywords: [how to, guide, javascript, typescript, noir, barretenberg, zero-knowledge, proofs, app] +sidebar_position: 0 +pagination_next: noir/concepts/data_types/index +--- + +NoirJS is a set of packages meant to work both in a browser and a server environment. In this tutorial, we will build a simple web app using them. From here, you should get an idea on how to proceed with your own Noir projects! + +You can find the complete app code for this guide [here](https://github.com/noir-lang/tiny-noirjs-app). + +## Setup + +:::note + +Feel free to use whatever versions, just keep in mind that Nargo and the NoirJS packages are meant to be in sync. For example, Nargo 0.19.x matches `noir_js@0.19.x`, etc. + +In this guide, we will be pinned to 0.19.4. + +::: + +Before we start, we want to make sure we have Node and Nargo installed. + +We start by opening a terminal and executing `node --version`. If we don't get an output like `v20.10.0`, that means node is not installed. Let's do that by following the handy [nvm guide](https://github.com/nvm-sh/nvm?tab=readme-ov-file#install--update-script). + +As for `Nargo`, we can follow the the [Nargo guide](../getting_started/installation/index.md) to install it. If you're lazy, just paste this on a terminal and run `noirup`: + +```sh +curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash +``` + +Easy enough. Onwards! + +## Our project + +ZK is a powerful technology. An app that doesn't reveal one of the inputs to *anyone* is almost unbelievable, yet Noir makes it as easy as a single line of code. + +In fact, it's so simple that it comes nicely packaged in `nargo`. Let's do that! + +### Nargo + +Run: + +```nargo new circuit``` + +And... That's about it. Your program is ready to be compiled and run. + +To compile, let's `cd` into the `circuit` folder to enter our project, and call: + +```nargo compile``` + +This compiles our circuit into `json` format and add it to a new `target` folder. + +:::info + +At this point in the tutorial, your folder structure should look like this: + +```tree +. +└── circuit <---- our working directory + ├── Nargo.toml + ├── src + │ └── main.nr + └── target + └── circuit.json +``` + +::: + +### Node and Vite + +If you want to explore Nargo, feel free to go on a side-quest now and follow the steps in the +[getting started](../getting_started/hello_noir/index.md) guide. However, we want our app to run on the browser, so we need Vite. + +Vite is a powerful tool to generate static websites. While it provides all kinds of features, let's just go barebones with some good old vanilla JS. + +To do this this, go back to the previous folder (`cd ..`) and create a new vite project by running `npm create vite` and choosing "Vanilla" and "Javascript". + +You should see `vite-project` appear in your root folder. This seems like a good time to `cd` into it and install our NoirJS packages: + +```bash +npm i @noir-lang/backend_barretenberg@0.19.4 @noir-lang/noir_js@0.19.4 +``` + +:::info + +At this point in the tutorial, your folder structure should look like this: + +```tree +. +└── circuit + └── ...etc... +└── vite-project <---- our working directory + └── ...etc... +``` + +::: + +#### Some cleanup + +`npx create vite` is amazing but it creates a bunch of files we don't really need for our simple example. Actually, let's just delete everything except for `index.html`, `main.js` and `package.json`. I feel lighter already. + +![my heart is ready for you, noir.js](@site/static/img/memes/titanic.jpeg) + +## HTML + +Our app won't run like this, of course. We need some working HTML, at least. Let's open our broken-hearted `index.html` and replace everything with this code snippet: + +```html + + + + + + +

Noir app

+
+ + +
+
+

Logs

+

Proof

+
+ + +``` + +It *could* be a beautiful UI... Depending on which universe you live in. + +## Some good old vanilla Javascript + +Our love for Noir needs undivided attention, so let's just open `main.js` and delete everything (this is where the romantic scenery becomes a bit creepy). + +Start by pasting in this boilerplate code: + +```js +const setup = async () => { + await Promise.all([ + import("@noir-lang/noirc_abi").then(module => + module.default(new URL("@noir-lang/noirc_abi/web/noirc_abi_wasm_bg.wasm", import.meta.url).toString()) + ), + import("@noir-lang/acvm_js").then(module => + module.default(new URL("@noir-lang/acvm_js/web/acvm_js_bg.wasm", import.meta.url).toString()) + ) + ]); +} + +function display(container, msg) { + const c = document.getElementById(container); + const p = document.createElement('p'); + p.textContent = msg; + c.appendChild(p); +} + +document.getElementById('submitGuess').addEventListener('click', async () => { + try { + // here's where love happens + } catch(err) { + display("logs", "Oh 💔 Wrong guess") + } +}); + +``` + +The display function doesn't do much. We're simply manipulating our website to see stuff happening. For example, if the proof fails, it will simply log a broken heart 😢 + +As for the `setup` function, it's just a sad reminder that dealing with `wasm` on the browser is not as easy as it should. Just copy, paste, and forget. + +:::info + +At this point in the tutorial, your folder structure should look like this: + +```tree +. +└── circuit + └── ...same as above +└── vite-project + ├── main.js + ├── package.json + └── index.html +``` + +You'll see other files and folders showing up (like `package-lock.json`, `node_modules`) but you shouldn't have to care about those. + +::: + +## Some NoirJS + +We're starting with the good stuff now. If you've compiled the circuit as described above, you should have a `json` file we want to import at the very top of our `main.js` file: + +```ts +import circuit from '../circuit/target/circuit.json'; +``` + +[Noir is backend-agnostic](../index.mdx#whats-new-about-noir). We write Noir, but we also need a proving backend. That's why we need to import and instantiate the two dependencies we installed above: `BarretenbergBackend` and `Noir`. Let's import them right below: + +```js +import { BarretenbergBackend } from '@noir-lang/backend_barretenberg'; +import { Noir } from '@noir-lang/noir_js'; +``` + +And instantiate them inside our try-catch block: + +```ts +// try { +const backend = new BarretenbergBackend(circuit); +const noir = new Noir(circuit, backend); +// } +``` + +:::note + +For the remainder of the tutorial, everything will be happening inside the `try` block + +::: + +## Our app + +Now for the app itself. We're capturing whatever is in the input when people press the submit button. Just add this: + +```js +const x = parseInt(document.getElementById('guessInput').value); +const input = { x, y: 2 }; +``` + +Now we're ready to prove stuff! Let's feed some inputs to our circuit and calculate the proof: + +```js +await setup(); // let's squeeze our wasm inits here + +display('logs', 'Generating proof... ⌛'); +const proof = await noir.generateFinalProof(input); +display('logs', 'Generating proof... ✅'); +display('results', proof.proof); +``` + +You're probably eager to see stuff happening, so go and run your app now! + +From your terminal, run `npm run dev`. If it doesn't open a browser for you, just visit `localhost:5173`. You should now see the worst UI ever, with an ugly input. + +![Getting Started 0](@site/static/img/noir_getting_started_1.png) + +Now, our circuit says `fn main(x: Field, y: pub Field)`. This means only the `y` value is public, and it's hardcoded above: `input = { x, y: 2 }`. In other words, you won't need to send your secret`x` to the verifier! + +By inputting any number other than 2 in the input box and clicking "submit", you should get a valid proof. Otherwise the proof won't even generate correctly. By the way, if you're human, you shouldn't be able to understand anything on the "proof" box. That's OK. We like you, human ❤️. + +## Verifying + +Time to celebrate, yes! But we shouldn't trust machines so blindly. Let's add these lines to see our proof being verified: + +```js +display('logs', 'Verifying proof... ⌛'); +const verification = await noir.verifyFinalProof(proof); +if (verification) display('logs', 'Verifying proof... ✅'); +``` + +You have successfully generated a client-side Noir web app! + +![coded app without math knowledge](@site/static/img/memes/flextape.jpeg) + +## Further Reading + +You can see how noirjs is used in a full stack Next.js hardhat application in the [noir-starter repo here](https://github.com/noir-lang/noir-starter/tree/main/vite-hardhat). The example shows how to calculate a proof in the browser and verify it with a deployed Solidity verifier contract from noirjs. + +You should also check out the more advanced examples in the [noir-examples repo](https://github.com/noir-lang/noir-examples), where you'll find reference usage for some cool apps. diff --git a/noir/noir-repo/docs/versioned_sidebars/version-v0.25.0-sidebars.json b/noir/noir-repo/docs/versioned_sidebars/version-v0.25.0-sidebars.json new file mode 100644 index 00000000000..b16f79cc176 --- /dev/null +++ b/noir/noir-repo/docs/versioned_sidebars/version-v0.25.0-sidebars.json @@ -0,0 +1,83 @@ +{ + "sidebar": [ + { + "type": "doc", + "id": "index" + }, + { + "type": "category", + "label": "Getting Started", + "items": [ + { + "type": "autogenerated", + "dirName": "getting_started" + } + ] + }, + { + "type": "category", + "label": "The Noir Language", + "items": [ + { + "type": "autogenerated", + "dirName": "noir" + } + ] + }, + { + "type": "html", + "value": "
", + "defaultStyle": true + }, + { + "type": "category", + "label": "How To Guides", + "items": [ + { + "type": "autogenerated", + "dirName": "how_to" + } + ] + }, + { + "type": "category", + "label": "Explainers", + "items": [ + { + "type": "autogenerated", + "dirName": "explainers" + } + ] + }, + { + "type": "category", + "label": "Tutorials", + "items": [ + { + "type": "autogenerated", + "dirName": "tutorials" + } + ] + }, + { + "type": "category", + "label": "Reference", + "items": [ + { + "type": "autogenerated", + "dirName": "reference" + } + ] + }, + { + "type": "html", + "value": "
", + "defaultStyle": true + }, + { + "type": "doc", + "id": "migration_notes", + "label": "Migration notes" + } + ] +} diff --git a/noir/noir-repo/flake.nix b/noir/noir-repo/flake.nix index 5125dad06be..785d5aead56 100644 --- a/noir/noir-repo/flake.nix +++ b/noir/noir-repo/flake.nix @@ -73,7 +73,7 @@ # Configuration shared between builds config = { # x-release-please-start-version - version = "0.24.0"; + version = "0.25.0"; # x-release-please-end src = pkgs.lib.cleanSourceWith { diff --git a/noir/noir-repo/noir_stdlib/src/bigint.nr b/noir/noir-repo/noir_stdlib/src/bigint.nr index 98237a54779..e7fc28ba39b 100644 --- a/noir/noir-repo/noir_stdlib/src/bigint.nr +++ b/noir/noir-repo/noir_stdlib/src/bigint.nr @@ -1,6 +1,7 @@ use crate::ops::{Add, Sub, Mul, Div}; use crate::cmp::Eq; +// docs:start:curve_order_base global bn254_fq = [0x47, 0xFD, 0x7C, 0xD8, 0x16, 0x8C, 0x20, 0x3C, 0x8d, 0xca, 0x71, 0x68, 0x91, 0x6a, 0x81, 0x97, 0x5d, 0x58, 0x81, 0x81, 0xb6, 0x45, 0x50, 0xb8, 0x29, 0xa0, 0x31, 0xe1, 0x72, 0x4e, 0x64, 0x30]; global bn254_fr = [0x01, 0x00, 0x00, 0x00, 0x3F, 0x59, 0x1F, 0x43, 0x09, 0x97, 0xB9, 0x79, 0x48, 0xE8, 0x33, 0x28, @@ -13,6 +14,7 @@ global secpr1_fq = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF]; global secpr1_fr = [0x51, 0x25, 0x63, 0xFC, 0xC2, 0xCA, 0xB9, 0xF3, 0x84, 0x9E, 0x17, 0xA7, 0xAD, 0xFA, 0xE6, 0xBC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,0xFF, 0xFF, 0xFF, 0xFF]; +// docs:end:curve_order_base struct BigInt { pointer: u32, diff --git a/noir/noir-repo/noir_stdlib/src/collections/map.nr b/noir/noir-repo/noir_stdlib/src/collections/map.nr index 056299b4238..2d76acf1f3a 100644 --- a/noir/noir-repo/noir_stdlib/src/collections/map.nr +++ b/noir/noir-repo/noir_stdlib/src/collections/map.nr @@ -3,6 +3,7 @@ use crate::collections::vec::Vec; use crate::option::Option; use crate::default::Default; use crate::hash::{Hash, Hasher, BuildHasher}; +use crate::collections::bounded_vec::BoundedVec; // We use load factor α_max = 0.75. // Upon exceeding it, assert will fail in order to inform the user @@ -78,21 +79,26 @@ impl Slot { // it is very unlikely to be after - performance will be heavily degraded. impl HashMap { // Creates a new instance of HashMap with specified BuildHasher. + // docs:start:with_hasher pub fn with_hasher(_build_hasher: B) -> Self where B: BuildHasher { + // docs:end:with_hasher let _table = [Slot::default(); N]; let _len = 0; Self { _table, _len, _build_hasher } } // Clears the map, removing all key-value entries. + // docs:start:clear pub fn clear(&mut self) { + // docs:end:clear self._table = [Slot::default(); N]; self._len = 0; } // Returns true if the map contains a value for the specified key. + // docs:start:contains_key pub fn contains_key( self, key: K @@ -101,89 +107,80 @@ impl HashMap { K: Hash + Eq, B: BuildHasher, H: Hasher { + // docs:end:contains_key self.get(key).is_some() } // Returns true if the map contains no elements. + // docs:start:is_empty pub fn is_empty(self) -> bool { + // docs:end:is_empty self._len == 0 } - // Get the Option<(K, V) array of valid entries - // with a length of map capacity. First len() elements - // are safe to unwrap_unchecked(), whilst remaining - // are guaranteed to be Option::none(). - // - // This design is reasoned by compile-time limitations and - // temporary nested slices ban. - pub fn entries(self) -> [Option<(K, V)>; N] { - let mut entries = [Option::none(); N]; - let mut valid_amount = 0; + // Returns a BoundedVec of all valid entries in this HashMap. + // The length of the returned vector will always match the length of this HashMap. + // docs:start:entries + pub fn entries(self) -> BoundedVec<(K, V), N> { + // docs:end:entries + let mut entries = BoundedVec::new(); for slot in self._table { if slot.is_valid() { - entries[valid_amount] = slot.key_value(); - valid_amount += 1; + // SAFETY: slot.is_valid() should ensure there is a valid key-value pairing here + let key_value = slot.key_value().unwrap_unchecked(); + entries.push(key_value); } } - let msg = f"Amount of valid elements should have been {self._len} times, but got {valid_amount}."; - assert(valid_amount == self._len, msg); + let msg = f"Amount of valid elements should have been {self._len} times, but got {entries.len()}."; + assert(entries.len() == self._len, msg); entries } - // Get the Option array of valid keys - // with a length of map capacity. First len() elements - // are safe to unwrap_unchecked(), whilst remaining - // are guaranteed to be Option::none(). - // - // This design is reasoned by compile-time limitations and - // temporary nested slices ban. - pub fn keys(self) -> [Option; N] { - let mut keys = [Option::none(); N]; - let mut valid_amount = 0; + // Returns a BoundedVec containing all the keys within this HashMap. + // The length of the returned vector will always match the length of this HashMap. + // docs:start:keys + pub fn keys(self) -> BoundedVec { + // docs:end:keys + let mut keys = BoundedVec::new(); for slot in self._table { if slot.is_valid() { let (key, _) = slot.key_value_unchecked(); - keys[valid_amount] = Option::some(key); - valid_amount += 1; + keys.push(key); } } - let msg = f"Amount of valid elements should have been {self._len} times, but got {valid_amount}."; - assert(valid_amount == self._len, msg); + let msg = f"Amount of valid elements should have been {self._len} times, but got {keys.len()}."; + assert(keys.len() == self._len, msg); keys } - // Get the Option array of valid values - // with a length of map capacity. First len() elements - // are safe to unwrap_unchecked(), whilst remaining - // are guaranteed to be Option::none(). - // - // This design is reasoned by compile-time limitations and - // temporary nested slices ban. - pub fn values(self) -> [Option; N] { - let mut values = [Option::none(); N]; - let mut valid_amount = 0; + // Returns a BoundedVec containing all the values within this HashMap. + // The length of the returned vector will always match the length of this HashMap. + // docs:start:values + pub fn values(self) -> BoundedVec { + // docs:end:values + let mut values = BoundedVec::new(); for slot in self._table { if slot.is_valid() { let (_, value) = slot.key_value_unchecked(); - values[valid_amount] = Option::some(value); - valid_amount += 1; + values.push(value); } } - let msg = f"Amount of valid elements should have been {self._len} times, but got {valid_amount}."; - assert(valid_amount == self._len, msg); + let msg = f"Amount of valid elements should have been {self._len} times, but got {values.len()}."; + assert(values.len() == self._len, msg); values } // For each key-value entry applies mutator function. + // docs:start:iter_mut pub fn iter_mut( &mut self, f: fn(K, V) -> (K, V) @@ -192,12 +189,13 @@ impl HashMap { K: Eq + Hash, B: BuildHasher, H: Hasher { + // docs:end:iter_mut let mut entries = self.entries(); let mut new_map = HashMap::with_hasher(self._build_hasher); for i in 0..N { if i < self._len { - let entry = entries[i].unwrap_unchecked(); + let entry = entries.get_unchecked(i); let (key, value) = f(entry.0, entry.1); new_map.insert(key, value); } @@ -207,6 +205,7 @@ impl HashMap { } // For each key applies mutator function. + // docs:start:iter_keys_mut pub fn iter_keys_mut( &mut self, f: fn(K) -> K @@ -215,12 +214,13 @@ impl HashMap { K: Eq + Hash, B: BuildHasher, H: Hasher { + // docs:end:iter_keys_mut let mut entries = self.entries(); let mut new_map = HashMap::with_hasher(self._build_hasher); for i in 0..N { if i < self._len { - let entry = entries[i].unwrap_unchecked(); + let entry = entries.get_unchecked(i); let (key, value) = (f(entry.0), entry.1); new_map.insert(key, value); } @@ -230,7 +230,9 @@ impl HashMap { } // For each value applies mutator function. + // docs:start:iter_values_mut pub fn iter_values_mut(&mut self, f: fn(V) -> V) { + // docs:end:iter_values_mut for i in 0..N { let mut slot = self._table[i]; if slot.is_valid() { @@ -242,7 +244,9 @@ impl HashMap { } // Retains only the elements specified by the predicate. + // docs:start:retain pub fn retain(&mut self, f: fn(K, V) -> bool) { + // docs:end:retain for index in 0..N { let mut slot = self._table[index]; if slot.is_valid() { @@ -257,16 +261,21 @@ impl HashMap { } // Amount of active key-value entries. + // docs:start:len pub fn len(self) -> u64 { + // docs:end:len self._len } // Get the compile-time map capacity. + // docs:start:capacity pub fn capacity(_self: Self) -> u64 { + // docs:end:capacity N } // Get the value by key. If it does not exist, returns none(). + // docs:start:get pub fn get( self, key: K @@ -275,6 +284,7 @@ impl HashMap { K: Eq + Hash, B: BuildHasher, H: Hasher { + // docs:end:get let mut result = Option::none(); let hash = self.hash(key); @@ -300,6 +310,7 @@ impl HashMap { } // Insert key-value entry. In case key was already present, value is overridden. + // docs:start:insert pub fn insert( &mut self, key: K, @@ -309,6 +320,7 @@ impl HashMap { K: Eq + Hash, B: BuildHasher, H: Hasher { + // docs:end:insert self.assert_load_factor(); let hash = self.hash(key); @@ -340,7 +352,8 @@ impl HashMap { } } - // Remove key-value entry. If key is not present, HashMap remains unchanged. + // Removes a key-value entry. If key is not present, HashMap remains unchanged. + // docs:start:remove pub fn remove( &mut self, key: K @@ -349,6 +362,7 @@ impl HashMap { K: Eq + Hash, B: BuildHasher, H: Hasher { + // docs:end:remove let hash = self.hash(key); let mut break = false; @@ -409,6 +423,7 @@ impl HashMap { // Equality class on HashMap has to test that they have // equal sets of key-value entries, // thus one is a subset of the other and vice versa. +// docs:start:eq impl Eq for HashMap where K: Eq + Hash, @@ -416,7 +431,8 @@ where B: BuildHasher, H: Hasher { - fn eq(self, other: HashMap) -> bool{ + fn eq(self, other: HashMap) -> bool { +// docs:end:eq let mut equal = false; if self.len() == other.len(){ @@ -443,12 +459,14 @@ where } } +// docs:start:default impl Default for HashMap where B: BuildHasher + Default, H: Hasher + Default { - fn default() -> Self{ + fn default() -> Self { +// docs:end:default let _build_hasher = B::default(); let map: HashMap = HashMap::with_hasher(_build_hasher); map diff --git a/noir/noir-repo/noir_stdlib/src/eddsa.nr b/noir/noir-repo/noir_stdlib/src/eddsa.nr index 966bc1da2a1..3aff6043ffd 100644 --- a/noir/noir-repo/noir_stdlib/src/eddsa.nr +++ b/noir/noir-repo/noir_stdlib/src/eddsa.nr @@ -1,6 +1,8 @@ use crate::hash::poseidon; use crate::ec::consts::te::baby_jubjub; use crate::ec::tecurve::affine::Point as TEPoint; +use crate::hash::{Hash, Hasher, BuildHasher, BuildHasherDefault}; +use crate::hash::poseidon::PoseidonHasher; // Returns true if signature is valid pub fn eddsa_poseidon_verify( @@ -11,6 +13,28 @@ pub fn eddsa_poseidon_verify( signature_r8_y: Field, message: Field ) -> bool { + let mut hasher = PoseidonHasher::default(); + eddsa_verify_with_hasher( + pub_key_x, + pub_key_y, + signature_s, + signature_r8_x, + signature_r8_y, + message, + &mut hasher + ) +} + +pub fn eddsa_verify_with_hasher( + pub_key_x: Field, + pub_key_y: Field, + signature_s: Field, + signature_r8_x: Field, + signature_r8_y: Field, + message: Field, + hasher: &mut H +) -> bool +where H: Hasher { // Verifies by testing: // S * B8 = R8 + H(R8, A, m) * A8 let bjj = baby_jubjub(); @@ -23,7 +47,12 @@ pub fn eddsa_poseidon_verify( // Ensure S < Subgroup Order assert(signature_s.lt(bjj.suborder)); // Calculate the h = H(R, A, msg) - let hash: Field = poseidon::bn254::hash_5([signature_r8_x, signature_r8_y, pub_key_x, pub_key_y, message]); + signature_r8_x.hash(hasher); + signature_r8_y.hash(hasher); + pub_key_x.hash(hasher); + pub_key_y.hash(hasher); + message.hash(hasher); + let hash: Field = (*hasher).finish(); // Calculate second part of the right side: right2 = h*8*A // Multiply by 8 by doubling 3 times. This also ensures that the result is in the subgroup. let pub_key_mul_2 = bjj.curve.add(pub_key, pub_key); diff --git a/noir/noir-repo/noir_stdlib/src/hash/mimc.nr b/noir/noir-repo/noir_stdlib/src/hash/mimc.nr index 10c0a48917c..db8a32d7909 100644 --- a/noir/noir-repo/noir_stdlib/src/hash/mimc.nr +++ b/noir/noir-repo/noir_stdlib/src/hash/mimc.nr @@ -1,3 +1,6 @@ +use crate::hash::Hasher; +use crate::default::Default; + // mimc-p/p implementation // constants are (publicly generated) random numbers, for instance using keccak as a ROM. // You must use constants generated for the native field @@ -16,13 +19,8 @@ fn mimc(x: Field, k: Field, constants: [Field; N], exp: Field) -> Field { } global MIMC_BN254_ROUNDS = 91; -//mimc implementation with hardcoded parameters for BN254 curve. -#[field(bn254)] -pub fn mimc_bn254(array: [Field; N]) -> Field { - //mimc parameters - let exponent = 7; - //generated from seed "mimc" using keccak256 - let constants: [Field; MIMC_BN254_ROUNDS] = [ +//generated from seed "mimc" using keccak256 +global MIMC_BN254_CONSTANTS: [Field; MIMC_BN254_ROUNDS] = [ 0, 20888961410941983456478427210666206549300505294776164667214940546594746570981, 15265126113435022738560151911929040668591755459209400716467504685752745317193, @@ -116,10 +114,46 @@ pub fn mimc_bn254(array: [Field; N]) -> Field { 13602139229813231349386885113156901793661719180900395818909719758150455500533 ]; +//mimc implementation with hardcoded parameters for BN254 curve. +#[field(bn254)] +pub fn mimc_bn254(array: [Field; N]) -> Field { + let exponent = 7; let mut r = 0; for elem in array { - let h = mimc(elem, r, constants, exponent); + let h = mimc(elem, r, MIMC_BN254_CONSTANTS, exponent); r = r + elem + h; } r } + +struct MimcHasher{ + _state: [Field], + _len: u64, +} + +impl Hasher for MimcHasher { + #[field(bn254)] + fn finish(self) -> Field { + let exponent = 7; + let mut r = 0; + for i in 0..self._len { + let h = mimc(self._state[i], r, MIMC_BN254_CONSTANTS, exponent); + r = r + self._state[i] + h; + } + r + } + + fn write(&mut self, input: [Field]){ + self._state = self._state.append(input); + self._len += input.len(); + } +} + +impl Default for MimcHasher{ + fn default() -> Self{ + MimcHasher{ + _state: [], + _len: 0, + } + } +} diff --git a/noir/noir-repo/noir_stdlib/src/hash/poseidon.nr b/noir/noir-repo/noir_stdlib/src/hash/poseidon.nr index b1a7c4a2367..7f99ad36316 100644 --- a/noir/noir-repo/noir_stdlib/src/hash/poseidon.nr +++ b/noir/noir-repo/noir_stdlib/src/hash/poseidon.nr @@ -1,5 +1,7 @@ mod bn254; // Instantiations of Poseidon for prime field of the same order as BN254 use crate::field::modulus_num_bits; +use crate::hash::Hasher; +use crate::default::Default; struct PoseidonConfig { t: Field, // Width, i.e. state size @@ -100,3 +102,77 @@ fn apply_matrix(a: [Field; M], x: [Field; N]) -> [Field; N] { y } + +struct PoseidonHasher{ + _state: [Field], + _len: u64, +} + +impl Hasher for PoseidonHasher { + #[field(bn254)] + fn finish(self) -> Field { + let mut result = 0; + assert(self._len < 16); + if self._len == 1 { + result = bn254::hash_1([self._state[0]]); + } + if self._len == 2 { + result = bn254::hash_2([self._state[0],self._state[1]]); + } + if self._len == 3 { + result = bn254::hash_3([self._state[0],self._state[1],self._state[2]]); + } + if self._len == 4 { + result = bn254::hash_4([self._state[0],self._state[1],self._state[2],self._state[3]]); + } + if self._len == 5 { + result = bn254::hash_5([self._state[0],self._state[1],self._state[2],self._state[3],self._state[4]]); + } + if self._len == 6 { + result = bn254::hash_6([self._state[0],self._state[1],self._state[2],self._state[3],self._state[4], self._state[5]]); + } + if self._len == 7 { + result = bn254::hash_7([self._state[0],self._state[1],self._state[2],self._state[3],self._state[4], self._state[5], self._state[6]]); + } + if self._len == 8 { + result = bn254::hash_8([self._state[0],self._state[1],self._state[2],self._state[3],self._state[4], self._state[5], self._state[6], self._state[7]]); + } + if self._len == 9 { + result = bn254::hash_9([self._state[0],self._state[1],self._state[2],self._state[3],self._state[4], self._state[5], self._state[6], self._state[7], self._state[8]]); + } + if self._len == 10 { + result = bn254::hash_10([self._state[0],self._state[1],self._state[2],self._state[3],self._state[4], self._state[5], self._state[6], self._state[7], self._state[8], self._state[9]]); + } + if self._len == 11 { + result = bn254::hash_11([self._state[0],self._state[1],self._state[2],self._state[3],self._state[4], self._state[5], self._state[6], self._state[7], self._state[8], self._state[9], self._state[10]]); + } + if self._len == 12 { + result = bn254::hash_12([self._state[0],self._state[1],self._state[2],self._state[3],self._state[4], self._state[5], self._state[6], self._state[7], self._state[8], self._state[9], self._state[10], self._state[11]]); + } + if self._len == 13 { + result = bn254::hash_13([self._state[0],self._state[1],self._state[2],self._state[3],self._state[4], self._state[5], self._state[6], self._state[7], self._state[8], self._state[9], self._state[10], self._state[11], self._state[12]]); + } + if self._len == 14 { + result = bn254::hash_14([self._state[0],self._state[1],self._state[2],self._state[3],self._state[4], self._state[5], self._state[6], self._state[7], self._state[8], self._state[9], self._state[10], self._state[11], self._state[12], self._state[13]]); + } + if self._len == 15 { + result = bn254::hash_15([self._state[0],self._state[1],self._state[2],self._state[3],self._state[4], self._state[5], self._state[6], self._state[7], self._state[8], self._state[9], self._state[10], self._state[11], self._state[12], self._state[13], self._state[14]]); + } + + result + } + + fn write(&mut self, input: [Field]){ + self._state = self._state.append(input); + self._len += input.len(); + } +} + +impl Default for PoseidonHasher{ + fn default() -> Self{ + PoseidonHasher{ + _state: [], + _len: 0, + } + } +} diff --git a/noir/noir-repo/noir_stdlib/src/hash/poseidon2.nr b/noir/noir-repo/noir_stdlib/src/hash/poseidon2.nr index 40eea029e82..52229f18dbd 100644 --- a/noir/noir-repo/noir_stdlib/src/hash/poseidon2.nr +++ b/noir/noir-repo/noir_stdlib/src/hash/poseidon2.nr @@ -1,3 +1,6 @@ +use crate::hash::Hasher; +use crate::default::Default; + global RATE = 3; struct Poseidon2 { @@ -9,7 +12,7 @@ struct Poseidon2 { impl Poseidon2 { - pub fn hash(input: [Field; N], message_size: u32) -> Field { + pub fn hash(input: [Field; N], message_size: u64) -> Field { if message_size == N { Poseidon2::hash_internal(input, N, false) } else { @@ -92,12 +95,12 @@ impl Poseidon2 { result } - fn hash_internal(input: [Field; N], in_len: u32, is_variable_length: bool) -> Field { + fn hash_internal(input: [Field; N], in_len: u64, is_variable_length: bool) -> Field { let two_pow_64 = 18446744073709551616; let iv : Field = (in_len as Field) * two_pow_64; let mut sponge = Poseidon2::new(iv); for i in 0..input.len() { - if i as u32 < in_len { + if i < in_len { sponge.absorb(input[i]); } } @@ -111,3 +114,33 @@ impl Poseidon2 { sponge.squeeze() } } + +struct Poseidon2Hasher{ + _state: [Field], + _len: u64, +} + +impl Hasher for Poseidon2Hasher { + fn finish(self) -> Field { + let iv : Field = (self._state.len() as Field)*18446744073709551616; // iv = (self._state.len() << 64) + let mut sponge = Poseidon2::new(iv); + for i in 0..self._len { + sponge.absorb(self._state[i]); + } + sponge.squeeze() + } + + fn write(&mut self, input: [Field]){ + self._state = self._state.append(input); + self._len += input.len(); + } +} + +impl Default for Poseidon2Hasher{ + fn default() -> Self{ + Poseidon2Hasher{ + _state: [], + _len: 0, + } + } +} diff --git a/noir/noir-repo/noir_stdlib/src/internal.nr b/noir/noir-repo/noir_stdlib/src/internal.nr new file mode 100644 index 00000000000..8d5c01dda7f --- /dev/null +++ b/noir/noir-repo/noir_stdlib/src/internal.nr @@ -0,0 +1,12 @@ +// This file contains functions which should only be used in calls injected by the Noir compiler. +// These functions should not be called manually in user code. +// +// Changes to this file will not be considered breaking. + +#[oracle(assert_message)] +unconstrained fn assert_message_oracle(_input: T) {} +unconstrained pub fn resolve_assert_message(input: T, condition: bool) { + if !condition { + assert_message_oracle(input); + } +} diff --git a/noir/noir-repo/noir_stdlib/src/lib.nr b/noir/noir-repo/noir_stdlib/src/lib.nr index ebde4b88858..90c04472066 100644 --- a/noir/noir-repo/noir_stdlib/src/lib.nr +++ b/noir/noir-repo/noir_stdlib/src/lib.nr @@ -26,6 +26,7 @@ mod default; mod prelude; mod uint128; mod bigint; +mod internal; // Oracle calls are required to be wrapped in an unconstrained function // Thus, the only argument to the `println` oracle is expected to always be an ident diff --git a/noir/noir-repo/noirc_macros/Cargo.toml b/noir/noir-repo/noirc_macros/Cargo.toml deleted file mode 100644 index 699e6b01cae..00000000000 --- a/noir/noir-repo/noirc_macros/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "noirc_macros" -version.workspace = true -authors.workspace = true -edition.workspace = true -rust-version.workspace = true -license.workspace = true -repository.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -noirc_frontend.workspace = true -iter-extended.workspace = true \ No newline at end of file diff --git a/noir/noir-repo/noirc_macros/src/lib.rs b/noir/noir-repo/noirc_macros/src/lib.rs deleted file mode 100644 index 4b22b553d94..00000000000 --- a/noir/noir-repo/noirc_macros/src/lib.rs +++ /dev/null @@ -1,73 +0,0 @@ -use noirc_frontend::hir::def_collector::dc_crate::UnresolvedFunctions; -use noirc_frontend::hir::def_collector::dc_crate::UnresolvedTraitImpl; -use noirc_frontend::macros_api::parse_program; -use noirc_frontend::macros_api::HirContext; -use noirc_frontend::macros_api::SortedModule; -use noirc_frontend::macros_api::{CrateId, FileId}; -use noirc_frontend::macros_api::{MacroError, MacroProcessor}; - -pub struct AssertMessageMacro; - -impl MacroProcessor for AssertMessageMacro { - fn process_untyped_ast( - &self, - ast: SortedModule, - crate_id: &CrateId, - _context: &HirContext, - ) -> Result { - transform(ast, crate_id) - } - - fn process_collected_defs( - &self, - _crate_id: &CrateId, - _context: &mut HirContext, - _collected_trait_impls: &[UnresolvedTraitImpl], - _collected_functions: &mut [UnresolvedFunctions], - ) -> Result<(), (MacroError, FileId)> { - Ok(()) - } - - // This macro does not need to process any information after name resolution - fn process_typed_ast( - &self, - _crate_id: &CrateId, - _context: &mut HirContext, - ) -> Result<(), (MacroError, FileId)> { - Ok(()) - } -} - -fn transform(ast: SortedModule, crate_id: &CrateId) -> Result { - let ast = add_resolve_assert_message_funcs(ast, crate_id)?; - - Ok(ast) -} - -fn add_resolve_assert_message_funcs( - mut ast: SortedModule, - crate_id: &CrateId, -) -> Result { - if !crate_id.is_stdlib() { - return Ok(ast); - } - let assert_message_oracles = " - #[oracle(assert_message)] - unconstrained fn assert_message_oracle(_input: T) {} - unconstrained pub fn resolve_assert_message(input: T, condition: bool) { - if !condition { - assert_message_oracle(input); - } - }"; - - let (assert_msg_funcs_ast, errors) = parse_program(assert_message_oracles); - assert_eq!(errors.len(), 0, "Failed to parse Noir macro code. This is either a bug in the compiler or the Noir macro code"); - - let assert_msg_funcs_ast = assert_msg_funcs_ast.into_sorted(); - - for func in assert_msg_funcs_ast.functions { - ast.functions.push(func) - } - - Ok(ast) -} diff --git a/noir/noir-repo/test_programs/execution_success/bigint/src/main.nr b/noir/noir-repo/test_programs/execution_success/bigint/src/main.nr index b93fec370e5..b6c23276c15 100644 --- a/noir/noir-repo/test_programs/execution_success/bigint/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/bigint/src/main.nr @@ -1,4 +1,5 @@ use dep::std::bigint; +use dep::std::{bigint::Secpk1Fq, println}; fn main(mut x: [u8; 5], y: [u8; 5]) { let a = bigint::Secpk1Fq::from_le_bytes([x[0], x[1], x[2], x[3], x[4]]); @@ -13,4 +14,15 @@ fn main(mut x: [u8; 5], y: [u8; 5]) { let d = a * b - b; let d1 = bigint::Secpk1Fq::from_le_bytes(597243850900842442924.to_le_bytes(10)); assert(d1 == d); + // big_int_example(x[0], x[1]); } + +// docs:start:big_int_example +fn big_int_example(x: u8, y: u8) { + let a = Secpk1Fq::from_le_bytes([x, y, 0, 45, 2]); + let b = Secpk1Fq::from_le_bytes([y, x, 9]); + let c = (a + b) * b / a; + let d = c.to_le_bytes(); + println(d[0]); +} +// docs:end:big_int_example diff --git a/noir/noir-repo/test_programs/execution_success/brillig_cow_assign/Nargo.toml b/noir/noir-repo/test_programs/execution_success/brillig_cow_assign/Nargo.toml new file mode 100644 index 00000000000..a878566a372 --- /dev/null +++ b/noir/noir-repo/test_programs/execution_success/brillig_cow_assign/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "brillig_cow_assign" +type = "bin" +authors = [""] +compiler_version = ">=0.23.0" + +[dependencies] diff --git a/noir/noir-repo/test_programs/execution_success/brillig_cow_assign/Prover.toml b/noir/noir-repo/test_programs/execution_success/brillig_cow_assign/Prover.toml new file mode 100644 index 00000000000..882c73b83f8 --- /dev/null +++ b/noir/noir-repo/test_programs/execution_success/brillig_cow_assign/Prover.toml @@ -0,0 +1,2 @@ +items_to_update = 10 +index = 6 diff --git a/noir/noir-repo/test_programs/execution_success/brillig_cow_assign/src/main.nr b/noir/noir-repo/test_programs/execution_success/brillig_cow_assign/src/main.nr new file mode 100644 index 00000000000..e5c3e2bd2f5 --- /dev/null +++ b/noir/noir-repo/test_programs/execution_success/brillig_cow_assign/src/main.nr @@ -0,0 +1,23 @@ +global N = 10; + +unconstrained fn main() { + let mut arr = [0; N]; + let mut mid_change = arr; + + for i in 0..N { + if i == N / 2 { + mid_change = arr; + } + arr[i] = 27; + } + + // Expect: + // arr = [27, 27, 27, 27, 27, 27, 27, 27, 27, 27] + // mid_change = [27, 27, 27, 27, 27, 0, 0, 0, 0, 0] + + let modified_i = N / 2 + 1; + assert_eq(arr[modified_i], 27); + + // Fail here! + assert(mid_change[modified_i] != 27); +} diff --git a/noir/noir-repo/test_programs/execution_success/eddsa/src/main.nr b/noir/noir-repo/test_programs/execution_success/eddsa/src/main.nr index 4404ffe75f7..fd1a95ee5fb 100644 --- a/noir/noir-repo/test_programs/execution_success/eddsa/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/eddsa/src/main.nr @@ -2,7 +2,9 @@ use dep::std::compat; use dep::std::ec::consts::te::baby_jubjub; use dep::std::ec::tecurve::affine::Point as TEPoint; use dep::std::hash; -use dep::std::eddsa::{eddsa_to_pub, eddsa_poseidon_verify}; +use dep::std::eddsa::{eddsa_to_pub, eddsa_poseidon_verify, eddsa_verify_with_hasher}; +use dep::std::hash::poseidon2::Poseidon2Hasher; +use dep::std::hash::pedersen::PedersenHasher; fn main(msg: pub Field, _priv_key_a: Field, _priv_key_b: Field) { // Skip this test for non-bn254 backends @@ -48,5 +50,11 @@ fn main(msg: pub Field, _priv_key_a: Field, _priv_key_b: Field) { assert(!eddsa_poseidon_verify(pub_key_a.x, pub_key_a.y, s_b, r8_b.x, r8_b.y, msg)); // User A's signature over the message can't be used with another message assert(!eddsa_poseidon_verify(pub_key_a.x, pub_key_a.y, s_a, r8_a.x, r8_a.y, msg + 1)); + // Using a different hash should fail + let mut hasher = Poseidon2Hasher::default(); + assert(!eddsa_verify_with_hasher(pub_key_a.x, pub_key_a.y, s_a, r8_a.x, r8_a.y, msg, &mut hasher)); + // Using a different hash should fail + let mut hasher = PedersenHasher::default(); + assert(!eddsa_verify_with_hasher(pub_key_a.x, pub_key_a.y, s_a, r8_a.x, r8_a.y, msg, &mut hasher)); } } diff --git a/noir/noir-repo/test_programs/execution_success/hashmap/src/main.nr b/noir/noir-repo/test_programs/execution_success/hashmap/src/main.nr index 597a5c0b7de..4d2cbd45993 100644 --- a/noir/noir-repo/test_programs/execution_success/hashmap/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/hashmap/src/main.nr @@ -37,6 +37,8 @@ fn main(input: [Entry; HASHMAP_LEN]) { test_retain(); test_iterators(); test_mut_iterators(); + + doc_tests(); } // Insert, get, remove. @@ -154,9 +156,9 @@ fn test_iterators() { hashmap.insert(5, 7); hashmap.insert(11, 13); - let keys: [K; 3] = cut(hashmap.keys()).map(|k: Option| k.unwrap_unchecked()).sort_via(K_CMP); - let values: [V; 3] = cut(hashmap.values()).map(|v: Option| v.unwrap_unchecked()).sort_via(V_CMP); - let entries: [(K, V); 3] = cut(hashmap.entries()).map(|e: Option<(K, V)>| e.unwrap_unchecked()).sort_via(KV_CMP); + let keys: [K; 3] = cut(hashmap.keys()).sort_via(K_CMP); + let values: [V; 3] = cut(hashmap.values()).sort_via(V_CMP); + let entries: [(K, V); 3] = cut(hashmap.entries()).sort_via(KV_CMP); assert(keys == [2, 5, 11], "Got incorrect iteration of keys."); assert(values == [3, 7, 13], "Got incorrect iteration of values."); @@ -177,8 +179,8 @@ fn test_mut_iterators() { let f = |v: V| -> V{ v * 5}; hashmap.iter_values_mut(f); - let keys: [K; 3] = cut(hashmap.keys()).map(|k: Option| k.unwrap_unchecked()).sort_via(K_CMP); - let values: [V; 3] = cut(hashmap.values()).map(|v: Option| v.unwrap_unchecked()).sort_via(V_CMP); + let keys: [K; 3] = cut(hashmap.keys()).sort_via(K_CMP); + let values: [V; 3] = cut(hashmap.values()).sort_via(V_CMP); assert(keys == [6, 15, 33], f"Got incorrect iteration of keys: {keys}"); assert(values == [15, 35, 65], "Got incorrect iteration of values."); @@ -186,7 +188,175 @@ fn test_mut_iterators() { let f = |k: K, v: V| -> (K, V){(k * 2, v * 2)}; hashmap.iter_mut(f); - let entries: [(K, V); 3] = cut(hashmap.entries()).map(|e: Option<(K, V)>| e.unwrap_unchecked()).sort_via(KV_CMP); + let entries: [(K, V); 3] = cut(hashmap.entries()).sort_via(KV_CMP); assert(entries == [(12, 30), (30, 70), (66, 130)], "Got incorrect iteration of entries."); } + +// docs:start:type_alias +type MyMap = HashMap>; +// docs:end:type_alias + +/// Tests examples from the stdlib hashmap documentation +fn doc_tests() { + // docs:start:default_example + let hashmap: HashMap> = HashMap::default(); + assert(hashmap.is_empty()); + // docs:end:default_example + + // docs:start:with_hasher_example + let my_hasher: BuildHasherDefault = Default::default(); + let hashmap: HashMap> = HashMap::with_hasher(my_hasher); + assert(hashmap.is_empty()); + // docs:end:with_hasher_example + + // docs:start:insert_example + let mut map: HashMap> = HashMap::default(); + map.insert(12, 42); + assert(map.len() == 1); + // docs:end:insert_example + + get_example(map); + + // docs:start:remove_example + map.remove(12); + assert(map.is_empty()); + + // If a key was not present in the map, remove does nothing + map.remove(12); + assert(map.is_empty()); + // docs:end:remove_example + + // docs:start:is_empty_example + assert(map.is_empty()); + + map.insert(1, 2); + assert(!map.is_empty()); + + map.remove(1); + assert(map.is_empty()); + // docs:end:is_empty_example + + // docs:start:len_example + // This is equivalent to checking map.is_empty() + assert(map.len() == 0); + + map.insert(1, 2); + map.insert(3, 4); + map.insert(5, 6); + assert(map.len() == 3); + + // 3 was already present as a key in the hash map, so the length is unchanged + map.insert(3, 7); + assert(map.len() == 3); + + map.remove(1); + assert(map.len() == 2); + // docs:end:len_example + + // docs:start:capacity_example + let empty_map: HashMap> = HashMap::default(); + assert(empty_map.len() == 0); + assert(empty_map.capacity() == 42); + // docs:end:capacity_example + + // docs:start:clear_example + assert(!map.is_empty()); + map.clear(); + assert(map.is_empty()); + // docs:end:clear_example + + // docs:start:contains_key_example + if map.contains_key(7) { + let value = map.get(7); + assert(value.is_some()); + } else { + println("No value for key 7!"); + } + // docs:end:contains_key_example + + entries_examples(map); + iter_examples(map); + + // docs:start:retain_example + map.retain(|k, v| (k != 0) & (v != 0)); + // docs:end:retain_example + + // docs:start:eq_example + let mut map1: HashMap> = HashMap::default(); + let mut map2: HashMap> = HashMap::default(); + + map1.insert(1, 2); + map1.insert(3, 4); + + map2.insert(3, 4); + map2.insert(1, 2); + + assert(map1 == map2); + // docs:end:eq_example +} + +// docs:start:get_example +fn get_example(map: HashMap>) { + let x = map.get(12); + + if x.is_some() { + assert(x.unwrap() == 42); + } +} +// docs:end:get_example + +fn entries_examples(map: HashMap>) { + // docs:start:entries_example + let entries = map.entries(); + + // The length of a hashmap may not be compile-time known, so we + // need to loop over its capacity instead + for i in 0..map.capacity() { + if i < entries.len() { + let (key, value) = entries.get(i); + println(f"{key} -> {value}"); + } + } + // docs:end:entries_example + + // docs:start:keys_example + let keys = map.keys(); + + for i in 0..keys.max_len() { + if i < keys.len() { + let key = keys.get_unchecked(i); + let value = map.get(key).unwrap_unchecked(); + println(f"{key} -> {value}"); + } + } + // docs:end:keys_example + + // docs:start:values_example + let values = map.values(); + + for i in 0..values.max_len() { + if i < values.len() { + let value = values.get_unchecked(i); + println(f"Found value {value}"); + } + } + // docs:end:values_example +} + +fn iter_examples(mut map: HashMap>) { + // docs:start:iter_mut_example + // Add 1 to each key in the map, and double the value associated with that key. + map.iter_mut(|k, v| (k + 1, v * 2)); + // docs:end:iter_mut_example + + // docs:start:iter_keys_mut_example + // Double each key, leaving the value associated with that key untouched + map.iter_keys_mut(|k| k * 2); + // docs:end:iter_keys_mut_example + + // docs:start:iter_values_mut_example + // Halve each value + map.iter_values_mut(|v| v / 2); + // docs:end:iter_values_mut_example +} diff --git a/noir/noir-repo/test_programs/execution_success/hashmap/src/utils.nr b/noir/noir-repo/test_programs/execution_success/hashmap/src/utils.nr index 45c9ca9bbf7..ee73245a902 100644 --- a/noir/noir-repo/test_programs/execution_success/hashmap/src/utils.nr +++ b/noir/noir-repo/test_programs/execution_success/hashmap/src/utils.nr @@ -1,10 +1,10 @@ -// Compile-time: cuts the M first elements from the [T; N] array. -pub(crate) fn cut(input: [T; N]) -> [T; M] { - assert(M as u64 < N as u64, "M should be less than N."); +// Compile-time: cuts the M first elements from the BoundedVec. +pub(crate) fn cut(input: BoundedVec) -> [T; M] { + assert(M < N, "M should be less than N."); - let mut new = [dep::std::unsafe::zeroed(); M]; + let mut new = BoundedVec::new(); for i in 0..M { - new[i] = input[i]; + new.push(input.get(i)); } - new + new.storage() } diff --git a/noir/noir-repo/test_programs/execution_success/poseidon_bn254_hash/src/main.nr b/noir/noir-repo/test_programs/execution_success/poseidon_bn254_hash/src/main.nr index 939b99595c7..a1607956190 100644 --- a/noir/noir-repo/test_programs/execution_success/poseidon_bn254_hash/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/poseidon_bn254_hash/src/main.nr @@ -9,7 +9,7 @@ fn main(x1: [Field; 2], y1: pub Field, x2: [Field; 4], y2: pub Field, x3: [Field let hash2 = poseidon::bn254::hash_4(x2); assert(hash2 == y2); - let hash3 = poseidon2::Poseidon2::hash(x3, x3.len() as u32); + let hash3 = poseidon2::Poseidon2::hash(x3, x3.len()); assert(hash3 == y3); } // docs:end:poseidon diff --git a/noir/noir-repo/test_programs/execution_success/regression_4449/Nargo.toml b/noir/noir-repo/test_programs/execution_success/regression_4449/Nargo.toml new file mode 100644 index 00000000000..925420a03a8 --- /dev/null +++ b/noir/noir-repo/test_programs/execution_success/regression_4449/Nargo.toml @@ -0,0 +1,6 @@ +[package] +name = "regression_4449" +type = "bin" +authors = [""] + +[dependencies] diff --git a/noir/noir-repo/test_programs/execution_success/regression_4449/Prover.toml b/noir/noir-repo/test_programs/execution_success/regression_4449/Prover.toml new file mode 100644 index 00000000000..81af476bcc9 --- /dev/null +++ b/noir/noir-repo/test_programs/execution_success/regression_4449/Prover.toml @@ -0,0 +1,3 @@ + +x = 0xbd +result = [204, 59, 83, 197, 18, 1, 128, 43, 247, 28, 104, 225, 106, 13, 20, 187, 42, 26, 67, 150, 48, 75, 238, 168, 121, 247, 142, 160, 71, 222, 97, 188] \ No newline at end of file diff --git a/noir/noir-repo/test_programs/execution_success/regression_4449/src/main.nr b/noir/noir-repo/test_programs/execution_success/regression_4449/src/main.nr new file mode 100644 index 00000000000..454a93f5d1a --- /dev/null +++ b/noir/noir-repo/test_programs/execution_success/regression_4449/src/main.nr @@ -0,0 +1,14 @@ +// Regression test for issue #4449 +use dep::std; + +fn main(x: u8, result: [u8; 32]) { + let x = x % 31; + let mut digest = [0; 32]; + for i in 0..70 { + let y = x + i; + let a = [y, x, 32, 0, y + 1, y - 1, y - 2, 5]; + digest = std::sha256::digest(a); + } + + assert(digest == result); +} diff --git a/noir/noir-repo/test_programs/execution_success/slices/src/main.nr b/noir/noir-repo/test_programs/execution_success/slices/src/main.nr index eca42a660c4..e44edf872a4 100644 --- a/noir/noir-repo/test_programs/execution_success/slices/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/slices/src/main.nr @@ -50,6 +50,10 @@ fn main(x: Field, y: pub Field) { // The parameters to this function must come from witness values (inputs to main) regression_merge_slices(x, y); regression_2370(); + + regression_4418(x); + regression_slice_call_result(x, y); + regression_4506(); } // Ensure that slices of struct/tuple values work. fn regression_2083() { @@ -297,3 +301,32 @@ fn regression_2370() { let mut slice = []; slice = [1, 2, 3]; } + +fn regression_4418(x: Field) { + let mut crash = x.to_be_bytes(32); + + if x != 0 { + crash[0] = 10; + } +} + +fn regression_slice_call_result(x: Field, y: Field) { + let mut slice = merge_slices_return(x, y); + if x != 0 { + slice = slice.push_back(5); + slice = slice.push_back(10); + } else { + slice = slice.push_back(5); + } + assert(slice.len() == 5); + assert(slice[0] == 0); + assert(slice[1] == 0); + assert(slice[2] == 10); + assert(slice[3] == 5); + assert(slice[4] == 10); +} + +fn regression_4506() { + let slice: [Field] = [1, 2, 3]; + assert(slice == slice); +} diff --git a/noir/noir-repo/tooling/bb_abstraction_leaks/build.rs b/noir/noir-repo/tooling/bb_abstraction_leaks/build.rs index f9effd5d991..0bd2b1c076a 100644 --- a/noir/noir-repo/tooling/bb_abstraction_leaks/build.rs +++ b/noir/noir-repo/tooling/bb_abstraction_leaks/build.rs @@ -10,7 +10,7 @@ use const_format::formatcp; const USERNAME: &str = "AztecProtocol"; const REPO: &str = "aztec-packages"; -const VERSION: &str = "0.24.0"; +const VERSION: &str = "0.26.3"; const TAG: &str = formatcp!("aztec-packages-v{}", VERSION); const API_URL: &str = diff --git a/noir/noir-repo/tooling/debugger/ignored-tests.txt b/noir/noir-repo/tooling/debugger/ignored-tests.txt index c472e828739..231d4d897a9 100644 --- a/noir/noir-repo/tooling/debugger/ignored-tests.txt +++ b/noir/noir-repo/tooling/debugger/ignored-tests.txt @@ -1,21 +1,13 @@ array_dynamic_blackbox_input -array_sort -assign_ex +bigint bit_shifts_comptime -brillig_cow -brillig_nested_arrays brillig_references brillig_to_bytes_integration debug_logs double_verify_nested_proof double_verify_proof modulus -nested_array_dynamic -nested_array_in_slice -nested_arrays_from_brillig references scalar_mul signed_comparison -simple_2d_array to_bytes_integration -bigint diff --git a/noir/noir-repo/tooling/debugger/src/context.rs b/noir/noir-repo/tooling/debugger/src/context.rs index 515edf0bb06..a3ee89263a4 100644 --- a/noir/noir-repo/tooling/debugger/src/context.rs +++ b/noir/noir-repo/tooling/debugger/src/context.rs @@ -8,11 +8,14 @@ use acvm::pwg::{ }; use acvm::{BlackBoxFunctionSolver, FieldElement}; -use nargo::artifacts::debug::DebugArtifact; +use codespan_reporting::files::{Files, SimpleFile}; +use fm::FileId; +use nargo::artifacts::debug::{DebugArtifact, StackFrame}; use nargo::errors::{ExecutionError, Location}; use nargo::NargoError; -use noirc_printable_type::{PrintableType, PrintableValue}; +use noirc_driver::DebugFile; +use std::collections::BTreeMap; use std::collections::{hash_set::Iter, HashSet}; #[derive(Debug)] @@ -29,6 +32,7 @@ pub(super) struct DebugContext<'a, B: BlackBoxFunctionSolver> { foreign_call_executor: Box, debug_artifact: &'a DebugArtifact, breakpoints: HashSet, + source_to_opcodes: BTreeMap>, } impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { @@ -39,12 +43,14 @@ impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { initial_witness: WitnessMap, foreign_call_executor: Box, ) -> Self { + let source_to_opcodes = build_source_to_opcode_debug_mappings(debug_artifact); Self { acvm: ACVM::new(blackbox_solver, &circuit.opcodes, initial_witness), brillig_solver: None, foreign_call_executor, debug_artifact, breakpoints: HashSet::new(), + source_to_opcodes, } } @@ -100,10 +106,50 @@ impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { self.debug_artifact .file_map .get(&location.file) - .map(|file| file.path.starts_with("__debug/")) + .map(is_debug_file_in_debug_crate) .unwrap_or(false) } + /// Find an opcode location matching a source code location + // We apply some heuristics here, and there are four possibilities for the + // return value of this function: + // 1. the source location is not found -> None + // 2. an exact unique location is found (very rare) -> Some(opcode_location) + // 3. an exact but not unique location is found, ie. a source location may + // be mapped to multiple opcodes, and those may be disjoint, for example for + // functions called multiple times throughout the program + // -> return the first opcode in program order that matches the source location + // 4. exact location is not found, so an opcode for a nearby source location + // is returned (this again could actually be more than one opcodes) + // -> return the opcode for the next source line that is mapped + pub(super) fn find_opcode_for_source_location( + &self, + file_id: &FileId, + line: i64, + ) -> Option { + let line = line as usize; + let Some(line_to_opcodes) = self.source_to_opcodes.get(file_id) else { + return None; + }; + let found_index = match line_to_opcodes.binary_search_by(|x| x.0.cmp(&line)) { + Ok(index) => { + // move backwards to find the first opcode which matches the line + let mut index = index; + while index > 0 && line_to_opcodes[index - 1].0 == line { + index -= 1; + } + line_to_opcodes[index].1 + } + Err(index) => { + if index >= line_to_opcodes.len() { + return None; + } + line_to_opcodes[index].1 + } + }; + Some(found_index) + } + /// Returns the callstack in source code locations for the currently /// executing opcode. This can be `None` if the execution finished (and /// `get_current_opcode_location()` returns `None`) or if the opcode is not @@ -128,6 +174,9 @@ impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { &self, opcode_location: &OpcodeLocation, ) -> Vec { + // TODO: this assumes we're debugging a program (ie. the DebugArtifact + // will contain a single DebugInfo), but this assumption doesn't hold + // for contracts self.debug_artifact.debug_symbols[0] .opcode_location(opcode_location) .map(|source_locations| { @@ -467,10 +516,14 @@ impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { } } - pub(super) fn get_variables(&self) -> Vec<(&str, &PrintableValue, &PrintableType)> { + pub(super) fn get_variables(&self) -> Vec { return self.foreign_call_executor.get_variables(); } + pub(super) fn current_stack_frame(&self) -> Option { + return self.foreign_call_executor.current_stack_frame(); + } + fn breakpoint_reached(&self) -> bool { if let Some(location) = self.get_current_opcode_location() { self.breakpoints.contains(&location) @@ -526,6 +579,52 @@ impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { } } +fn is_debug_file_in_debug_crate(debug_file: &DebugFile) -> bool { + debug_file.path.starts_with("__debug/") +} + +/// Builds a map from FileId to an ordered vector of tuples with line +/// numbers and opcode locations corresponding to those line numbers +fn build_source_to_opcode_debug_mappings( + debug_artifact: &DebugArtifact, +) -> BTreeMap> { + if debug_artifact.debug_symbols.is_empty() { + return BTreeMap::new(); + } + let locations = &debug_artifact.debug_symbols[0].locations; + let simple_files: BTreeMap<_, _> = debug_artifact + .file_map + .iter() + .filter(|(_, debug_file)| !is_debug_file_in_debug_crate(debug_file)) + .map(|(file_id, debug_file)| { + ( + file_id, + SimpleFile::new(debug_file.path.to_str().unwrap(), debug_file.source.as_str()), + ) + }) + .collect(); + + let mut result: BTreeMap> = BTreeMap::new(); + locations.iter().for_each(|(opcode_location, source_locations)| { + source_locations.iter().for_each(|source_location| { + let span = source_location.span; + let file_id = source_location.file; + let Some(file) = simple_files.get(&file_id) else { + return; + }; + let Ok(line_index) = file.line_index((), span.start() as usize) else { + return; + }; + let line_number = line_index + 1; + + result.entry(file_id).or_default().push((line_number, *opcode_location)); + }); + }); + result.iter_mut().for_each(|(_, file_locations)| file_locations.sort_by_key(|x| (x.0, x.1))); + + result +} + #[cfg(test)] mod tests { use super::*; diff --git a/noir/noir-repo/tooling/debugger/src/dap.rs b/noir/noir-repo/tooling/debugger/src/dap.rs index 7e67a26b257..7c722ed0a61 100644 --- a/noir/noir-repo/tooling/debugger/src/dap.rs +++ b/noir/noir-repo/tooling/debugger/src/dap.rs @@ -5,7 +5,6 @@ use std::str::FromStr; use acvm::acir::circuit::{Circuit, OpcodeLocation}; use acvm::acir::native_types::WitnessMap; use acvm::BlackBoxFunctionSolver; -use codespan_reporting::files::{Files, SimpleFile}; use crate::context::DebugCommandResult; use crate::context::DebugContext; @@ -30,15 +29,16 @@ use nargo::artifacts::debug::DebugArtifact; use fm::FileId; use noirc_driver::CompiledProgram; +type BreakpointId = i64; + pub struct DapSession<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> { server: Server, context: DebugContext<'a, B>, debug_artifact: &'a DebugArtifact, running: bool, - source_to_opcodes: BTreeMap>, - next_breakpoint_id: i64, - instruction_breakpoints: Vec<(OpcodeLocation, i64)>, - source_breakpoints: BTreeMap>, + next_breakpoint_id: BreakpointId, + instruction_breakpoints: Vec<(OpcodeLocation, BreakpointId)>, + source_breakpoints: BTreeMap>, } enum ScopeReferences { @@ -57,8 +57,6 @@ impl From for ScopeReferences { } } -// BTreeMap - impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { pub fn new( server: Server, @@ -67,7 +65,6 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { debug_artifact: &'a DebugArtifact, initial_witness: WitnessMap, ) -> Self { - let source_to_opcodes = Self::build_source_to_opcode_debug_mappings(debug_artifact); let context = DebugContext::new( solver, circuit, @@ -79,7 +76,6 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { server, context, debug_artifact, - source_to_opcodes, running: false, next_breakpoint_id: 1, instruction_breakpoints: vec![], @@ -87,46 +83,6 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { } } - /// Builds a map from FileId to an ordered vector of tuples with line - /// numbers and opcode locations corresponding to those line numbers - fn build_source_to_opcode_debug_mappings( - debug_artifact: &'a DebugArtifact, - ) -> BTreeMap> { - if debug_artifact.debug_symbols.is_empty() { - return BTreeMap::new(); - } - let locations = &debug_artifact.debug_symbols[0].locations; - let simple_files: BTreeMap<_, _> = debug_artifact - .file_map - .iter() - .map(|(file_id, debug_file)| { - ( - file_id, - SimpleFile::new(debug_file.path.to_str().unwrap(), debug_file.source.as_str()), - ) - }) - .collect(); - - let mut result: BTreeMap> = BTreeMap::new(); - locations.iter().for_each(|(opcode_location, source_locations)| { - if source_locations.is_empty() { - return; - } - let source_location = source_locations[0]; - let span = source_location.span; - let file_id = source_location.file; - let Ok(line_index) = &simple_files[&file_id].line_index((), span.start() as usize) - else { - return; - }; - let line_number = line_index + 1; - - result.entry(file_id).or_default().push((line_number, *opcode_location)); - }); - result.iter_mut().for_each(|(_, file_locations)| file_locations.sort_by_key(|x| x.0)); - result - } - fn send_stopped_event(&mut self, reason: StoppedEventReason) -> Result<(), ServerError> { let description = format!("{:?}", &reason); self.server.send_event(Event::Stopped(StoppedEventBody { @@ -230,6 +186,8 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { } fn build_stack_trace(&self) -> Vec { + let stack_frames = self.context.get_variables(); + self.context .get_source_call_stack() .iter() @@ -239,9 +197,15 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { self.debug_artifact.location_line_number(*source_location).unwrap(); let column_number = self.debug_artifact.location_column_number(*source_location).unwrap(); + + let name = match stack_frames.get(index) { + Some(frame) => format!("{} {}", frame.function_name, index), + None => format!("frame #{index}"), + }; + StackFrame { id: index as i64, - name: format!("frame #{index}"), + name, source: Some(Source { path: self.debug_artifact.file_map[&source_location.file] .path @@ -422,7 +386,7 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { Ok(()) } - fn get_next_breakpoint_id(&mut self) -> i64 { + fn get_next_breakpoint_id(&mut self) -> BreakpointId { let id = self.next_breakpoint_id; self.next_breakpoint_id += 1; id @@ -493,36 +457,6 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { found.map(|iter| *iter.0) } - // TODO: there are four possibilities for the return value of this function: - // 1. the source location is not found -> None - // 2. an exact unique location is found -> Some(opcode_location) - // 3. an exact but not unique location is found (ie. a source location may - // be mapped to multiple opcodes, and those may be disjoint, for example for - // functions called multiple times throughout the program) - // 4. exact location is not found, so an opcode for a nearby source location - // is returned (this again could actually be more than one opcodes) - // Case 3 is not supported yet, and 4 is not correctly handled. - fn find_opcode_for_source_location( - &self, - file_id: &FileId, - line: i64, - ) -> Option { - let line = line as usize; - let Some(line_to_opcodes) = self.source_to_opcodes.get(file_id) else { - return None; - }; - let found_index = match line_to_opcodes.binary_search_by(|x| x.0.cmp(&line)) { - Ok(index) => line_to_opcodes[index].1, - Err(index) => { - if index >= line_to_opcodes.len() { - return None; - } - line_to_opcodes[index].1 - } - }; - Some(found_index) - } - fn map_source_breakpoints(&mut self, args: &SetBreakpointsArguments) -> Vec { let Some(ref source) = &args.source.path else { return vec![]; @@ -539,7 +473,8 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { .iter() .map(|breakpoint| { let line = breakpoint.line; - let Some(location) = self.find_opcode_for_source_location(&file_id, line) else { + let Some(location) = self.context.find_opcode_for_source_location(&file_id, line) + else { return Breakpoint { verified: false, message: Some(String::from( @@ -608,16 +543,20 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { } fn build_local_variables(&self) -> Vec { - let mut variables: Vec<_> = self - .context - .get_variables() + let Some(current_stack_frame) = self.context.current_stack_frame() else { + return vec![]; + }; + + let mut variables = current_stack_frame + .variables .iter() .map(|(name, value, _var_type)| Variable { name: String::from(*name), value: format!("{:?}", *value), ..Variable::default() }) - .collect(); + .collect::>(); + variables.sort_by(|a, b| a.name.partial_cmp(&b.name).unwrap()); variables } diff --git a/noir/noir-repo/tooling/debugger/src/foreign_calls.rs b/noir/noir-repo/tooling/debugger/src/foreign_calls.rs index 68c4d3947b0..25f126ff490 100644 --- a/noir/noir-repo/tooling/debugger/src/foreign_calls.rs +++ b/noir/noir-repo/tooling/debugger/src/foreign_calls.rs @@ -3,17 +3,19 @@ use acvm::{ pwg::ForeignCallWaitInfo, }; use nargo::{ - artifacts::debug::{DebugArtifact, DebugVars}, + artifacts::debug::{DebugArtifact, DebugVars, StackFrame}, ops::{DefaultForeignCallExecutor, ForeignCallExecutor, NargoForeignCallResult}, }; -use noirc_errors::debug_info::DebugVarId; -use noirc_printable_type::{ForeignCallError, PrintableType, PrintableValue}; +use noirc_errors::debug_info::{DebugFnId, DebugVarId}; +use noirc_printable_type::ForeignCallError; pub(crate) enum DebugForeignCall { VarAssign, VarDrop, MemberAssign(u32), DerefAssign, + FnEnter, + FnExit, } impl DebugForeignCall { @@ -28,13 +30,16 @@ impl DebugForeignCall { "__debug_var_assign" => Some(DebugForeignCall::VarAssign), "__debug_var_drop" => Some(DebugForeignCall::VarDrop), "__debug_deref_assign" => Some(DebugForeignCall::DerefAssign), + "__debug_fn_enter" => Some(DebugForeignCall::FnEnter), + "__debug_fn_exit" => Some(DebugForeignCall::FnExit), _ => None, } } } pub trait DebugForeignCallExecutor: ForeignCallExecutor { - fn get_variables(&self) -> Vec<(&str, &PrintableValue, &PrintableType)>; + fn get_variables(&self) -> Vec; + fn current_stack_frame(&self) -> Option; } pub struct DefaultDebugForeignCallExecutor { @@ -57,23 +62,33 @@ impl DefaultDebugForeignCallExecutor { } pub fn load_artifact(&mut self, artifact: &DebugArtifact) { - artifact.debug_symbols.iter().for_each(|info| { - self.debug_vars.insert_variables(&info.variables); - self.debug_vars.insert_types(&info.types); - }); + // TODO: handle loading from the correct DebugInfo when we support + // debugging contracts + let Some(info) = artifact.debug_symbols.get(0) else { + return; + }; + self.debug_vars.insert_debug_info(info); } } impl DebugForeignCallExecutor for DefaultDebugForeignCallExecutor { - fn get_variables(&self) -> Vec<(&str, &PrintableValue, &PrintableType)> { + fn get_variables(&self) -> Vec { self.debug_vars.get_variables() } + + fn current_stack_frame(&self) -> Option { + self.debug_vars.current_stack_frame() + } } fn debug_var_id(value: &Value) -> DebugVarId { DebugVarId(value.to_u128() as u32) } +fn debug_fn_id(value: &Value) -> DebugFnId { + DebugFnId(value.to_u128() as u32) +} + impl ForeignCallExecutor for DefaultDebugForeignCallExecutor { fn execute( &mut self, @@ -136,6 +151,19 @@ impl ForeignCallExecutor for DefaultDebugForeignCallExecutor { } Ok(ForeignCallResult::default().into()) } + Some(DebugForeignCall::FnEnter) => { + let fcp_fn_id = &foreign_call.inputs[0]; + let ForeignCallParam::Single(fn_id_value) = fcp_fn_id else { + panic!("unexpected foreign call parameter in fn enter: {fcp_fn_id:?}") + }; + let fn_id = debug_fn_id(fn_id_value); + self.debug_vars.push_fn(fn_id); + Ok(ForeignCallResult::default().into()) + } + Some(DebugForeignCall::FnExit) => { + self.debug_vars.pop_fn(); + Ok(ForeignCallResult::default().into()) + } None => self.executor.execute(foreign_call), } } diff --git a/noir/noir-repo/tooling/debugger/src/repl.rs b/noir/noir-repo/tooling/debugger/src/repl.rs index 8441dbde9be..41dbf604f99 100644 --- a/noir/noir-repo/tooling/debugger/src/repl.rs +++ b/noir/noir-repo/tooling/debugger/src/repl.rs @@ -337,11 +337,13 @@ impl<'a, B: BlackBoxFunctionSolver> ReplDebugger<'a, B> { } pub fn show_vars(&self) { - let vars = self.context.get_variables(); - for (var_name, value, var_type) in vars.iter() { - let printable_value = - PrintableValueDisplay::Plain((*value).clone(), (*var_type).clone()); - println!("{var_name}:{var_type:?} = {}", printable_value); + for frame in self.context.get_variables() { + println!("{}({})", frame.function_name, frame.function_params.join(", ")); + for (var_name, value, var_type) in frame.variables.iter() { + let printable_value = + PrintableValueDisplay::Plain((*value).clone(), (*var_type).clone()); + println!(" {var_name}:{var_type:?} = {}", printable_value); + } } } @@ -530,7 +532,7 @@ pub fn run( .add( "vars", command! { - "show variable values available at this point in execution", + "show variables for each function scope available at this point in execution", () => || { ref_context.borrow_mut().show_vars(); Ok(CommandStatus::Done) diff --git a/noir/noir-repo/tooling/debugger/src/source_code_printer.rs b/noir/noir-repo/tooling/debugger/src/source_code_printer.rs index b5ffdb12d01..e298eb8aadd 100644 --- a/noir/noir-repo/tooling/debugger/src/source_code_printer.rs +++ b/noir/noir-repo/tooling/debugger/src/source_code_printer.rs @@ -30,7 +30,7 @@ struct LocationPrintContext { // Given a DebugArtifact and an OpcodeLocation, prints all the source code // locations the OpcodeLocation maps to, with some surrounding context and // visual aids to highlight the location itself. -pub(crate) fn print_source_code_location(debug_artifact: &DebugArtifact, locations: &[Location]) { +pub(super) fn print_source_code_location(debug_artifact: &DebugArtifact, locations: &[Location]) { let locations = locations.iter(); for loc in locations { @@ -269,8 +269,12 @@ mod tests { let mut opcode_locations = BTreeMap::>::new(); opcode_locations.insert(OpcodeLocation::Acir(42), vec![loc]); - let debug_symbols = - vec![DebugInfo::new(opcode_locations, BTreeMap::default(), BTreeMap::default())]; + let debug_symbols = vec![DebugInfo::new( + opcode_locations, + BTreeMap::default(), + BTreeMap::default(), + BTreeMap::default(), + )]; let debug_artifact = DebugArtifact::new(debug_symbols, &fm); let location_rendered: Vec<_> = render_location(&debug_artifact, &loc).collect(); diff --git a/noir/noir-repo/tooling/debugger/tests/debug.rs b/noir/noir-repo/tooling/debugger/tests/debug.rs index 4cb678192b8..143ee7987f8 100644 --- a/noir/noir-repo/tooling/debugger/tests/debug.rs +++ b/noir/noir-repo/tooling/debugger/tests/debug.rs @@ -12,7 +12,7 @@ mod tests { let nargo_bin = cargo_bin("nargo").into_os_string().into_string().expect("Cannot parse nargo path"); - let mut dbg_session = spawn_bash(Some(10000)).expect("Could not start bash session"); + let mut dbg_session = spawn_bash(Some(15000)).expect("Could not start bash session"); // Set backend to `/dev/null` to force an error if nargo tries to speak to a backend. dbg_session diff --git a/noir/noir-repo/tooling/lsp/src/requests/test_run.rs b/noir/noir-repo/tooling/lsp/src/requests/test_run.rs index 0b88d814265..1844a3d9bf0 100644 --- a/noir/noir-repo/tooling/lsp/src/requests/test_run.rs +++ b/noir/noir-repo/tooling/lsp/src/requests/test_run.rs @@ -84,7 +84,7 @@ fn on_test_run_request_inner( let test_result = run_test( &state.solver, &mut context, - test_function, + &test_function, false, None, &CompileOptions::default(), diff --git a/noir/noir-repo/tooling/nargo/src/artifacts/debug.rs b/noir/noir-repo/tooling/nargo/src/artifacts/debug.rs index a249ecb03ad..fbdf59805c9 100644 --- a/noir/noir-repo/tooling/nargo/src/artifacts/debug.rs +++ b/noir/noir-repo/tooling/nargo/src/artifacts/debug.rs @@ -8,7 +8,7 @@ use std::{ ops::Range, }; -pub use super::debug_vars::DebugVars; +pub use super::debug_vars::{DebugVars, StackFrame}; use fm::{FileId, FileManager, PathString}; /// A Debug Artifact stores, for a given program, the debug info for every function @@ -231,8 +231,12 @@ mod tests { let mut opcode_locations = BTreeMap::>::new(); opcode_locations.insert(OpcodeLocation::Acir(42), vec![loc]); - let debug_symbols = - vec![DebugInfo::new(opcode_locations, BTreeMap::default(), BTreeMap::default())]; + let debug_symbols = vec![DebugInfo::new( + opcode_locations, + BTreeMap::default(), + BTreeMap::default(), + BTreeMap::default(), + )]; let debug_artifact = DebugArtifact::new(debug_symbols, &fm); let location_in_line = debug_artifact.location_in_line(loc).expect("Expected a range"); diff --git a/noir/noir-repo/tooling/nargo/src/artifacts/debug_vars.rs b/noir/noir-repo/tooling/nargo/src/artifacts/debug_vars.rs index 20f2637f7d6..66568bec833 100644 --- a/noir/noir-repo/tooling/nargo/src/artifacts/debug_vars.rs +++ b/noir/noir-repo/tooling/nargo/src/artifacts/debug_vars.rs @@ -1,54 +1,85 @@ use acvm::brillig_vm::brillig::Value; use noirc_errors::debug_info::{ - DebugTypeId, DebugTypes, DebugVarId, DebugVariable, DebugVariables, + DebugFnId, DebugFunction, DebugInfo, DebugTypeId, DebugVarId, DebugVariable, }; use noirc_printable_type::{decode_value, PrintableType, PrintableValue}; -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; #[derive(Debug, Default, Clone)] pub struct DebugVars { variables: HashMap, + functions: HashMap, types: HashMap, - active: HashSet, - values: HashMap, + frames: Vec<(DebugFnId, HashMap)>, +} + +pub struct StackFrame<'a> { + pub function_name: &'a str, + pub function_params: Vec<&'a str>, + pub variables: Vec<(&'a str, &'a PrintableValue, &'a PrintableType)>, } impl DebugVars { - pub fn get_variables(&self) -> Vec<(&str, &PrintableValue, &PrintableType)> { - self.active - .iter() - .filter_map(|var_id| { - self.variables.get(var_id).and_then(|debug_var| { - let Some(value) = self.values.get(var_id) else { - return None; - }; - let Some(ptype) = self.types.get(&debug_var.debug_type_id) else { - return None; - }; - Some((debug_var.name.as_str(), value, ptype)) - }) - }) - .collect() + pub fn insert_debug_info(&mut self, info: &DebugInfo) { + self.variables.extend(info.variables.clone()); + self.types.extend(info.types.clone()); + self.functions.extend(info.functions.clone()); + } + + pub fn get_variables(&self) -> Vec { + self.frames.iter().map(|(fn_id, frame)| self.build_stack_frame(fn_id, frame)).collect() } - pub fn insert_variables(&mut self, vars: &DebugVariables) { - self.variables.extend(vars.clone()); + pub fn current_stack_frame(&self) -> Option { + self.frames.last().map(|(fn_id, frame)| self.build_stack_frame(fn_id, frame)) } - pub fn insert_types(&mut self, types: &DebugTypes) { - self.types.extend(types.clone()); + fn lookup_var(&self, var_id: DebugVarId) -> Option<(&str, &PrintableType)> { + self.variables.get(&var_id).and_then(|debug_var| { + let Some(ptype) = self.types.get(&debug_var.debug_type_id) else { + return None; + }; + Some((debug_var.name.as_str(), ptype)) + }) + } + + fn build_stack_frame<'a>( + &'a self, + fn_id: &DebugFnId, + frame: &'a HashMap, + ) -> StackFrame { + let debug_fn = &self.functions.get(fn_id).expect("failed to find function metadata"); + + let params: Vec<&str> = + debug_fn.arg_names.iter().map(|arg_name| arg_name.as_str()).collect(); + let vars: Vec<(&str, &PrintableValue, &PrintableType)> = frame + .iter() + .filter_map(|(var_id, var_value)| { + self.lookup_var(*var_id).map(|(name, typ)| (name, var_value, typ)) + }) + .collect(); + + StackFrame { + function_name: debug_fn.name.as_str(), + function_params: params, + variables: vars, + } } pub fn assign_var(&mut self, var_id: DebugVarId, values: &[Value]) { - self.active.insert(var_id); let type_id = &self.variables.get(&var_id).unwrap().debug_type_id; let ptype = self.types.get(type_id).unwrap(); - self.values.insert(var_id, decode_value(&mut values.iter().map(|v| v.to_field()), ptype)); + + self.frames + .last_mut() + .expect("unexpected empty stack frames") + .1 + .insert(var_id, decode_value(&mut values.iter().map(|v| v.to_field()), ptype)); } pub fn assign_field(&mut self, var_id: DebugVarId, indexes: Vec, values: &[Value]) { - let mut cursor: &mut PrintableValue = self - .values + let current_frame = &mut self.frames.last_mut().expect("unexpected empty stack frames").1; + let mut cursor: &mut PrintableValue = current_frame .get_mut(&var_id) .unwrap_or_else(|| panic!("value unavailable for var_id {var_id:?}")); let cursor_type_id = &self @@ -102,7 +133,6 @@ impl DebugVars { }; } *cursor = decode_value(&mut values.iter().map(|v| v.to_field()), cursor_type); - self.active.insert(var_id); } pub fn assign_deref(&mut self, _var_id: DebugVarId, _values: &[Value]) { @@ -114,6 +144,14 @@ impl DebugVars { } pub fn drop_var(&mut self, var_id: DebugVarId) { - self.active.remove(&var_id); + self.frames.last_mut().expect("unexpected empty stack frames").1.remove(&var_id); + } + + pub fn push_fn(&mut self, fn_id: DebugFnId) { + self.frames.push((fn_id, HashMap::default())); + } + + pub fn pop_fn(&mut self) { + self.frames.pop(); } } diff --git a/noir/noir-repo/tooling/nargo/src/ops/test.rs b/noir/noir-repo/tooling/nargo/src/ops/test.rs index 92c09ec889e..8ddcb5cf8d2 100644 --- a/noir/noir-repo/tooling/nargo/src/ops/test.rs +++ b/noir/noir-repo/tooling/nargo/src/ops/test.rs @@ -14,10 +14,16 @@ pub enum TestStatus { CompileError(FileDiagnostic), } +impl TestStatus { + pub fn failed(&self) -> bool { + !matches!(self, TestStatus::Pass) + } +} + pub fn run_test( blackbox_solver: &B, context: &mut Context, - test_function: TestFunction, + test_function: &TestFunction, show_output: bool, foreign_call_resolver_url: Option<&str>, config: &CompileOptions, @@ -45,7 +51,7 @@ pub fn run_test( /// that a constraint was never satisfiable. /// An example of this is the program `assert(false)` /// In that case, we check if the test function should fail, and if so, we return `TestStatus::Pass`. -fn test_status_program_compile_fail(err: CompileError, test_function: TestFunction) -> TestStatus { +fn test_status_program_compile_fail(err: CompileError, test_function: &TestFunction) -> TestStatus { // The test has failed compilation, but it should never fail. Report error. if !test_function.should_fail() { return TestStatus::CompileError(err.into()); @@ -70,7 +76,7 @@ fn test_status_program_compile_fail(err: CompileError, test_function: TestFuncti /// We now check whether execution passed/failed and whether it should have /// passed/failed to determine the test status. fn test_status_program_compile_pass( - test_function: TestFunction, + test_function: &TestFunction, debug: DebugInfo, circuit_execution: Result, ) -> TestStatus { @@ -109,7 +115,7 @@ fn test_status_program_compile_pass( } fn check_expected_failure_message( - test_function: TestFunction, + test_function: &TestFunction, failed_assertion: Option, error_diagnostic: Option, ) -> TestStatus { diff --git a/noir/noir-repo/tooling/nargo_cli/src/cli/test_cmd.rs b/noir/noir-repo/tooling/nargo_cli/src/cli/test_cmd.rs index 68660d62d23..2828aaf01eb 100644 --- a/noir/noir-repo/tooling/nargo_cli/src/cli/test_cmd.rs +++ b/noir/noir-repo/tooling/nargo_cli/src/cli/test_cmd.rs @@ -5,17 +5,18 @@ use bn254_blackbox_solver::Bn254BlackBoxSolver; use clap::Args; use fm::FileManager; use nargo::{ - insert_all_files_for_workspace_into_file_manager, - ops::{run_test, TestStatus}, - package::Package, - parse_all, prepare_package, + insert_all_files_for_workspace_into_file_manager, ops::TestStatus, package::Package, parse_all, + prepare_package, }; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; -use noirc_driver::{file_manager_with_stdlib, CompileOptions, NOIR_ARTIFACT_VERSION_STRING}; +use noirc_driver::{ + check_crate, file_manager_with_stdlib, CompileOptions, NOIR_ARTIFACT_VERSION_STRING, +}; use noirc_frontend::{ graph::CrateName, hir::{FunctionNameMatch, ParsedFiles}, }; +use rayon::prelude::{IntoParallelIterator, ParallelBridge, ParallelIterator}; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; use crate::{backends::Backend, cli::check_cmd::check_crate_and_report_errors, errors::CliError}; @@ -82,15 +83,13 @@ pub(crate) fn run( None => FunctionNameMatch::Anything, }; - let blackbox_solver = Bn254BlackBoxSolver::new(); - let test_reports: Vec> = workspace .into_iter() + .par_bridge() .map(|package| { - run_tests( + run_tests::( &workspace_file_manager, &parsed_files, - &blackbox_solver, package, pattern, args.show_output, @@ -116,24 +115,95 @@ pub(crate) fn run( }; } - if test_report.iter().any(|(_, status)| matches!(status, TestStatus::Fail { .. })) { + if test_report.iter().any(|(_, status)| status.failed()) { Err(CliError::Generic(String::new())) } else { Ok(()) } } -#[allow(clippy::too_many_arguments)] -fn run_tests( +fn run_tests( file_manager: &FileManager, parsed_files: &ParsedFiles, - blackbox_solver: &S, package: &Package, fn_name: FunctionNameMatch, show_output: bool, foreign_call_resolver_url: Option<&str>, compile_options: &CompileOptions, ) -> Result, CliError> { + let test_functions = + get_tests_in_package(file_manager, parsed_files, package, fn_name, compile_options)?; + + let count_all = test_functions.len(); + + let plural = if count_all == 1 { "" } else { "s" }; + println!("[{}] Running {count_all} test function{plural}", package.name); + + let test_report: Vec<(String, TestStatus)> = test_functions + .into_par_iter() + .map(|test_name| { + let status = run_test::( + file_manager, + parsed_files, + package, + &test_name, + show_output, + foreign_call_resolver_url, + compile_options, + ); + + (test_name, status) + }) + .collect(); + + display_test_report(file_manager, package, compile_options, &test_report)?; + Ok(test_report) +} + +fn run_test( + file_manager: &FileManager, + parsed_files: &ParsedFiles, + package: &Package, + fn_name: &str, + show_output: bool, + foreign_call_resolver_url: Option<&str>, + compile_options: &CompileOptions, +) -> TestStatus { + // This is really hacky but we can't share `Context` or `S` across threads. + // We then need to construct a separate copy for each test. + + let (mut context, crate_id) = prepare_package(file_manager, parsed_files, package); + check_crate( + &mut context, + crate_id, + compile_options.deny_warnings, + compile_options.disable_macros, + ) + .expect("Any errors should have occurred when collecting test functions"); + + let test_functions = context + .get_all_test_functions_in_crate_matching(&crate_id, FunctionNameMatch::Exact(fn_name)); + let (_, test_function) = test_functions.first().expect("Test function should exist"); + + let blackbox_solver = S::default(); + + nargo::ops::run_test( + &blackbox_solver, + &mut context, + test_function, + show_output, + foreign_call_resolver_url, + compile_options, + ) +} + +fn get_tests_in_package( + file_manager: &FileManager, + parsed_files: &ParsedFiles, + package: &Package, + fn_name: FunctionNameMatch, + compile_options: &CompileOptions, +) -> Result, CliError> { let (mut context, crate_id) = prepare_package(file_manager, parsed_files, package); check_crate_and_report_errors( &mut context, @@ -143,30 +213,27 @@ fn run_tests( compile_options.silence_warnings, )?; - let test_functions = context.get_all_test_functions_in_crate_matching(&crate_id, fn_name); - let count_all = test_functions.len(); - - let plural = if count_all == 1 { "" } else { "s" }; - println!("[{}] Running {count_all} test function{plural}", package.name); + Ok(context + .get_all_test_functions_in_crate_matching(&crate_id, fn_name) + .into_iter() + .map(|(test_name, _)| test_name) + .collect()) +} +fn display_test_report( + file_manager: &FileManager, + package: &Package, + compile_options: &CompileOptions, + test_report: &[(String, TestStatus)], +) -> Result<(), CliError> { let writer = StandardStream::stderr(ColorChoice::Always); let mut writer = writer.lock(); - let mut test_report: Vec<(String, TestStatus)> = Vec::new(); - for (test_name, test_function) in test_functions { + for (test_name, test_status) in test_report { write!(writer, "[{}] Testing {test_name}... ", package.name) .expect("Failed to write to stderr"); writer.flush().expect("Failed to flush writer"); - let test_status = run_test( - blackbox_solver, - &mut context, - test_function, - show_output, - foreign_call_resolver_url, - compile_options, - ); - match &test_status { TestStatus::Pass { .. } => { writer @@ -181,7 +248,7 @@ fn run_tests( writeln!(writer, "FAIL\n{message}\n").expect("Failed to write to stderr"); if let Some(diag) = error_diagnostic { noirc_errors::reporter::report_all( - context.file_manager.as_file_map(), + file_manager.as_file_map(), &[diag.clone()], compile_options.deny_warnings, compile_options.silence_warnings, @@ -190,23 +257,21 @@ fn run_tests( } TestStatus::CompileError(err) => { noirc_errors::reporter::report_all( - context.file_manager.as_file_map(), + file_manager.as_file_map(), &[err.clone()], compile_options.deny_warnings, compile_options.silence_warnings, ); } } - - test_report.push((test_name, test_status)); - writer.reset().expect("Failed to reset writer"); } write!(writer, "[{}] ", package.name).expect("Failed to write to stderr"); - let count_failed = - test_report.iter().filter(|(_, status)| !matches!(status, TestStatus::Pass)).count(); + let count_all = test_report.len(); + let count_failed = test_report.iter().filter(|(_, status)| status.failed()).count(); + let plural = if count_all == 1 { "" } else { "s" }; if count_failed == 0 { writer.set_color(ColorSpec::new().set_fg(Some(Color::Green))).expect("Failed to set color"); write!(writer, "{count_all} test{plural} passed").expect("Failed to write to stderr"); @@ -231,5 +296,5 @@ fn run_tests( writer.reset().expect("Failed to reset writer"); } - Ok(test_report) + Ok(()) } diff --git a/noir/noir-repo/tooling/noir_codegen/package.json b/noir/noir-repo/tooling/noir_codegen/package.json index 6bb9d06f718..68ee7184928 100644 --- a/noir/noir-repo/tooling/noir_codegen/package.json +++ b/noir/noir-repo/tooling/noir_codegen/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.24.0", + "version": "0.25.0", "packageManager": "yarn@3.5.1", "license": "(MIT OR Apache-2.0)", "type": "module", diff --git a/noir/noir-repo/tooling/noir_js/package.json b/noir/noir-repo/tooling/noir_js/package.json index 6f1899fae52..0a40d300ea4 100644 --- a/noir/noir-repo/tooling/noir_js/package.json +++ b/noir/noir-repo/tooling/noir_js/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.24.0", + "version": "0.25.0", "packageManager": "yarn@3.5.1", "license": "(MIT OR Apache-2.0)", "type": "module", diff --git a/noir/noir-repo/tooling/noir_js_backend_barretenberg/package.json b/noir/noir-repo/tooling/noir_js_backend_barretenberg/package.json index 28c3609fd14..d94999f324b 100644 --- a/noir/noir-repo/tooling/noir_js_backend_barretenberg/package.json +++ b/noir/noir-repo/tooling/noir_js_backend_barretenberg/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.24.0", + "version": "0.25.0", "packageManager": "yarn@3.5.1", "license": "(MIT OR Apache-2.0)", "type": "module", @@ -42,7 +42,7 @@ "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0" }, "dependencies": { - "@aztec/bb.js": "0.24.0", + "@aztec/bb.js": "0.26.3", "@noir-lang/types": "workspace:*", "fflate": "^0.8.0" }, diff --git a/noir/noir-repo/tooling/noir_js_types/package.json b/noir/noir-repo/tooling/noir_js_types/package.json index a3b5c85897a..d853813303d 100644 --- a/noir/noir-repo/tooling/noir_js_types/package.json +++ b/noir/noir-repo/tooling/noir_js_types/package.json @@ -4,7 +4,7 @@ "The Noir Team " ], "packageManager": "yarn@3.5.1", - "version": "0.24.0", + "version": "0.25.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://noir-lang.org/", "repository": { diff --git a/noir/noir-repo/tooling/noirc_abi_wasm/package.json b/noir/noir-repo/tooling/noirc_abi_wasm/package.json index 05fcc270402..8fb9eb314a5 100644 --- a/noir/noir-repo/tooling/noirc_abi_wasm/package.json +++ b/noir/noir-repo/tooling/noirc_abi_wasm/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.24.0", + "version": "0.25.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://noir-lang.org/", "repository": { diff --git a/noir/noir-repo/yarn.lock b/noir/noir-repo/yarn.lock index f5f3a29f08a..49485193532 100644 --- a/noir/noir-repo/yarn.lock +++ b/noir/noir-repo/yarn.lock @@ -221,9 +221,9 @@ __metadata: languageName: node linkType: hard -"@aztec/bb.js@npm:0.24.0": - version: 0.24.0 - resolution: "@aztec/bb.js@npm:0.24.0" +"@aztec/bb.js@npm:0.26.3": + version: 0.26.3 + resolution: "@aztec/bb.js@npm:0.26.3" dependencies: comlink: ^4.4.1 commander: ^10.0.1 @@ -231,7 +231,7 @@ __metadata: tslib: ^2.4.0 bin: bb.js: dest/node/main.js - checksum: a086dabf30084cfa526e512148b9c02f0a0770dcc19b7dca4af9a3e98612b716acc7eaac6b52c0f12d985932e866d1cb9e534ded6ac9d747f3dd021afe25de27 + checksum: 74c2b7ef5405f56472cf7c41d1c13261df07b1d5019e3ede9b63d218378e0fb73ccf5c52f1cc524505efad5799b347b497349d7c9b6fe82286014b1574f12309 languageName: node linkType: hard @@ -4396,7 +4396,7 @@ __metadata: version: 0.0.0-use.local resolution: "@noir-lang/backend_barretenberg@workspace:tooling/noir_js_backend_barretenberg" dependencies: - "@aztec/bb.js": 0.24.0 + "@aztec/bb.js": 0.26.3 "@noir-lang/types": "workspace:*" "@types/node": ^20.6.2 "@types/prettier": ^3 diff --git a/yarn-project/circuits.js/src/contract/__snapshots__/contract_class.test.ts.snap b/yarn-project/circuits.js/src/contract/__snapshots__/contract_class.test.ts.snap index b400f769558..0c8262f95ee 100644 --- a/yarn-project/circuits.js/src/contract/__snapshots__/contract_class.test.ts.snap +++ b/yarn-project/circuits.js/src/contract/__snapshots__/contract_class.test.ts.snap @@ -9,18 +9,18 @@ exports[`ContractClass creates a contract class from a contract compilation arti "selector": { "value": 2381782501 }, - "bytecode": "0x1f8b08000000000000ffed9d67941cc775ef7b76177176b058820824181624080220c2ec6c405884418e14b0244082020572810540805880041639e79cb34831283948b22d4759b26c59b26c39c8966c45cb564e94c40fef9df74defd0ae9aa9abfda3503d9a59740def00b7cfb93bd577abebfeeeedeaea50d55d6f0741100bb24bb99287839b17fa7fdafc266f6da98db0aca44fce58897096950867798970569408679712e1ec5a229cdd4a84b37b8970f6889053b39505372e51f3f6f410d7a819e32516d3ca128869a2c462daab04625a1594461bd5bb4438ab4b84f3ae12e1ec53229c77970867df12e1ec57229cfd4b8473408970de53229cf79608e7c012e1bcaf4438ef2f11ce074a84f3c112e1ac2911ce4125c2f95089703e5c229c834b84f39108398701e710f3fba8f91d6a7e29cf70f3fb98f91d617e471a1f2bccfa2825a3359b925aeb7f2925754aea953458ff6b543246c95825e3ccff6accffc62b69523241c9442593944c367198a264aa92694aa62b99a164a692594a662b99a364ae92794ae62b795cc97b942c50b25049b39227943ca9649192c54a9e52f2b492254a9eb158deab64a9926795bc4fc93225cf29795e498b92e54a56286955b252c92a25ab95bca0648d92b54a5e54b24e499b92f54a36287949c9cb4a362ad9a4a45dc966255b946c55b24dc9762b663b94ec54b24bc96e8b738f92bd4af629d9afe48092834a0e2939ace48892a34a8e2939aee48492934a4e2939ade48c92b34ace2939afe482928b4a2e29b9ace48a92ab4aae29b9aee4fd4a5e51f2aa920f18163a105e53f2ba923794bca9e4834a3ea4e4c34a3ea2e4a34a7e47c9ef2af93d25bfafe4634a3eaee4134afe40c91f2af923259f54f2c74afe44c99f2af933257faee42f947c4ac95f2af9b492cf28f92b259f55f2d74afe46c9e794fcad92cf2bf98292bf53f245257fafe41f947c49c93f2af92725fface45f947cd98af9bf2af937255f51f255f33f7a0ef6ef4afec3a4bf667ebf6e7ebf617ebf696df32d25dfb674ffa9e43b96eebf94fcb7497fd7fc7ecffc7edffcfec0fcfed0fcfec8fcfed8fcfec4fcfed4fcfeccfcfedcfcbe657e7f617e7f697e7f657edf56f2eb01d974f7a063490711b549f52b57ea3e140af690e0c645c7a2dcfc8f7e6b8cbec2acd32fc5ae8b59ef62e9bb9af5ae5639ddcd7a774b5f6dd6ab2d7d1fb3dec7d2f735eb7d2d7d7fb3de1ff4f1009ea51abdd6951b550c74540fcb40d725b831265ad7958a035db7e0c658681dedc7aea0eb6174dd40d7d3e8ba832e6e743d28664a2a8d2e1d445527922dbadc44d4e59afea55ed1f3aed0e55679e2ed1d3def4a5d6eb5075e5d3fee3265f5867ad3c7e8aa4177b7d1dd05babe46d70774fd8cee6ed0f537babea033cd54d00f74f7185d7fd0dd6b74034037d0e8ee01dd7d46772fe8ee37ba81a07bc0e8ee03dd8346773fe86a8cee01d00d32ba0741f790d1d5808ec6ae0c02dd60a37b08748f18ddc3a0a3367530e8e89aef11a3d3ed4497186c63f4d44665b6a176187443a90d06dd306a7f41379cda5ed03d06b6493702da15d28d343a6aa3f4ffc69a743a88ea9848658e89715197ab4ad6e536455f6ea63f6e42d011d734d81907b19a68d2118ef9a945db31236487f415909e0d79291fc583ce33c4aecf27e34d7a628eedc65adb2520cf7887ffe9205aff9b2c9e268bb90ba4fdd4d9ba94d4d9bc9782ebec5390d7ae7b74cd733bd6d979c0e1a1ce364a9dcd7b29b8ceb6425ebbeed175efed58679f010e0f75b6c54f9d4d25a5ce669f7f0581bbeed1bdcfed5867570347f475b641ea6cfe4bc175761fe4b5eb1eddffde8e75763370445f67c7b4c8b541de4bc175f60ce4b5eb1e3d8bb91debec41e0f05067574a3b9bf752709d7d15f2da758f9e0bde8e75f63c70445f67c779aab3755267836c5f6610b8eb1e3da3be1debecebc0117d9d5d21cf67f35f0aaeb39f82bc76dda3fe92dbb1ce7e0238a2afb3adbe9ecfa6a4ce66c7700481bbee51dfdded58673f63d2ba6fec6ba66fec01d07ddde81e04dd3760ec01e9be697483c02f0fc7c0583906f25e0a3e06be0579edbafc9049df8ec7c09781c3439d6d913a9bf752709dfd29e4b5eb1e8d69b81debec7780c3439d5d217536efa5e03afbff20af5df7687ccded5867697ca8be5ef8aeb95e180abaef19dd30d07ddfe88683ee0746f718e87e68742340f723a31b09ba1f1bdd28d0fdc4e84683eea7469704ddcf8cae16743f37ba14e8de32ba3ad0fdc2e8ea41f74ba36b00ddaf8cae11746f1bdd18a3d3fd5834a6ea4b46d71db8d24174fb360e31a02566ada7215deb972799001eb45517bdad3aed7b2ac8dff73ae0a9f7e07b1c6ce4c3530f3c0dd1f364c69336465f6e661fa7ac98c6c1560afc1ae3c1af18d8a2b2699dec254087c7f4180763e4e767751e8d812d2a9bd6c70223e9b08da136978e1fdd36df1febe0f5702c65cecf682f0d1c64af02f25c1ed091779061ab84ff531b5009db631bcca9ae6846aa238dc5674ce5cbd860317a3abe33316bb0785cb6c77bb26dc782ead4f822d81e6bd9aeb76c631b424bae367e2c307bb85eaf7d37aed7f1bcc5e17a3d1debc86b5f7753db53e8f5fa186b3b8ed7eb0d704ef0703c64eac0788b83d6eb21764d21b11b0fb1a33c8f828ece118da0a3b696cac0eb5b6c877d5c2fc5821bafa5d3b0dee0e01e0b8c0d0e460fd798a95c6d733d30920eefad539e6236cee219e788c59d6adb433dcd1c976483aed5e818227b1590e7b1f28ebc4ba0cdf0513ff158a025df7ba0e8f7532a734f565f000fee3b0fd7d9b59eea6312efe7df09a2ad6b769b586fc52aec9e3fe9217e58f7a96c5a277bc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc2cc9f19fbb2701c0fe56b60c2688f87f2f59c3ff3cd355316f601bde5757c502ad30f40f1a7f100c32c9f2b20cfaf631d6c6fc3f820fa3f8e7772ed4b1f632573ed4bb2e71aafe4b3bfb9cee2a973c48283ed9ac86ca756f8d9bfa9a4fee691fe6e60bdb54fedbef9ccf7082d9daea7a3ca3bfcf6d1f757685f24b625948eb26f2f013c68cbc7bec163af2cb8b1fdc0f38caf712cd456537ff978cb7605e4e95116fc66df34c1ffd3c1cded05e6a1b2697d186cdb64955de5cfdf9c6313c60337a5bb5abe350237e5e955d6e1e3274ddad3392e55e8386a6ca7a3bf06c88e214815c093041e1fe7314fd73a49ac8f518f21b0c788b9aea1280f8eaff330b631e7382fb227ccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccfc99358feb1b1494af8e096391c65d64fa33e87b4dd82ff67a59875ddf7d80d4e734dcf219df5bfd7e5907db874cba32b879ac45d8bef4d5b716b62fc99eeb3b28befa9463608bcaae75c48283ed9ac86c67c71044bf7f3bc610a4ac7d5a67ed4fec3bc763e893504fedf114f1e0e631099e8ef19cfb86ece1b184e35f288def66fb88359e4bec3145640ffbce3f63624b7de7d1b7d5a9a4cf7683be5742e304520e5f29cfe7a0edfbbc49e3f8913a28ebab8effd392ab9f9ae2a77d9e14bdcf99fd3bd99445fb7792c3761a5823b25d8bb66356d9a4af80f457ca6e66a07850ac895d1f23f8dd97b0edeaaded129067a2c3ff74c4fe4fb278701feb45d79d2f423dfb2a9cff7db549134362340c6244793c7f3fd0391ed01ed388ed68372b0f6d8bdf45fb36b4516163575de780df7ccb2828ce3980ec25829bcf0bf98c31bdd3c788bd05ed4513fc3f1ddcfa18b1b7a00ee138adc02a7f38944f5cdd82f0730be579db3a8f7a18c395d7f7715cf703c48b63d028cfff85b66ab019ab59c8fdc0bb756fe7ba1fc0edc27cc77621ea7323d64764c1efab519eff6fd5c7a610eeb18e6dff27645b8a95fdadb0cae0e6f8f9f9ce5ab6bd9964f942c7d444f085f27429eff0c5cf3553f6fad3d737e5e85a87daa05a87af94a7277c33aad2a4e3b09ff0bc30d0f17f5a725d7f52fcb4cf53a2f739b37fa79ab268ff4e71d89e06ac11d9ae45db74fd4976485f01e97bcb3bf2523e8a07c59ad82b8113d9ededc65bdb25204fdae17f3a62ffa7583c532c665d77aaa09e0d84f1f7bedaea74e08ed17088d16fec818ece23f81d50d7b30e5fe7d2b0eb387c6f8b74d8b60f869816eb9d1afb999eebfa64b8c58fd727c3a09d8d3bf2dacf2a69bb28c72ce33b22785d88ef88f8ba474a0437c6336171f8b45d65d9ae2aa2ed6acb7675116d4bcc25e69c62ce69ae08ec9b2a03461fe73a3cafe6c3e83aff9503a3aff7f8520530d601239eef88d1c377586b3b3b17055eeb7401461fefa016fabc1abfc18cef2213a38f6fe117fa3d5bfc96356dd70d187dcc71807315e4c3e89a23a33bfc7a980fa3b6b3dfcdc739327a00a38f6fe9c7831bbfffffdb18c701236dd713187df423c5831b9fabfd3646fc063b6d17f7cc98ebdcee793c48aad0671038fe029f41519c5ce3587c3dabb79f8dd13a3eab47dec05f1c735e2335f98d450ae34e4bae7de88a4f2ff31b87fffb7d9e78631f2f954deb13819174557ee398f35a7382df58a430eeb4e4da87aef8f436bff1e0e6f93f3cf5593bfb28691dfb714957ed99276ef1fcb638ba18ef02c6c99e182715c038191869bb3ec098f6c438b900c63430d2767703a387e7d519c674018cf85c97f47d8171aa27c62905304e0546daae1f30fa78f61c07bbf9304e0346daae3f304ef7c438ad00c6e9c048db0d00c6199e18a717c038031869bb7b8071a627c6190530ce0446daee5e609ce5897166018cb38091b61b088cb33d31ce2a80713630d276f701e31c4f8cb30b609c038cb4ddfdc038d713e39c0218e702236df70030cef3c438b700c679c048db3d088cf33d31ce2b80713e30d2763525c038a804181f2a01c6874b80717009303e52028cdd4b80f131607c3c7ac6ccfdf5fc02181f079e05d1f3d4c7c1463e3c0b80e73dd1f3d47af233333e6ba1292bea6fa4355bb17adc8a5502f22c84f8357b885f0cec52d9b44ef6845998c398350fb54fc41a877cf3993092ee3d9e79e2168f5e72b58fcd7e799209473cb4ad27a2b7952ad4f727806751f43c9973d51305f02c029e27a3e7a9f5e467e69cb2d8f2e909cba704e4c17663b1073f636097caa6f5c50edb3541b4b1782a8f583ce5e079aac8b1207b85322f2c41660e71c6b69058e3906f011346d23de999276ef1e82557fbe8626cf6cb98ea2ca3e659123d4fe69cf254013c4b80e7e9e8796a3df99969479fb17c7acaf2290179b04d7ac6839f31b04b65d3fa33b01f0a615e5c82cc12e7ce31639b45ac71c8b7880923e99ef6cc13b778f492ab1d733136fb654c759651f32c8d9c273b3fc03305f02c059ef746ce936dfba3f733dbf63f6bf9f48ce55302f2609bf4ac073f636097caa6f567613f08b3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300b336f66ec6320d638e45bc2849174eff5cc13b778f492abdfc1c5d8ec9731d55946cdb32c729e6c5fcdb305f02c039ef745ce93edab89decf6c5fcd73964fcf5a3e25200f1edfcf79f0330676a96c5a7f0ef683300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb330f366c63e06628d43bea54c1849f73ecf3c718b472fb9fa1d5c8ccd7e19539d65d43c2dd1f364dea97cae009e16e0793e7a9e5a4f7e66fa6a965b3e3d67f994803c787c2ff7e0670cec52d9b4be1cf683300bb38b19db2c628d43be654c1849f7bc679eb8c5a3975ced988bb1d92f63aab38c9aa735729e6c3ffdf202785a816745e43cd9b63f7a3fb36dff4acba7e5964f09c883c7f74a0f7ec6c02e954deb2b613f14c2bcb8049925ce12e7306689b3c4398c59e22c710e6396384b9cc39825ce12e7306689b3c4398c59e22c710e6396384b9cc39825ce12e7306689f39d1367ec6320d638e46b61c248ba159e79e2168f5e72f53bb8189bfd32a63acba8795647ce5397e9ab595900cf6ae05915394fb6af267a3fb37d352f583eadb47c4a401e6c935ef0e0670cec52d9b4fe02ec87db9d797109324bdd280eb3d40d610e6396ba21cc61cc523784398c59ea863087314bdd10e63066a91bc21cc62c754398c398a56e087318b3d40d610e6396ba21cc61cc523784398c59ea863087314bdd10e63066a91bc21cc6cca16ee0181d628d43be56268ca45be599276ef1e825d7b81d1763b35fc654671935cfdae87932df2479a1009eb5c0b3267a9e5a4f7e66c63abd68f9f482e55302f2609bf4a2073f636097caa6f517613f08b330bb98b1cd22d638e45bcd8491746b3cf3c42d1ebde46ac75c8ccd7e19539d65d43c6d9e785e2c80a70d78d645cf53ebc9cf4cdbbfdef2e945cba704e4c1e37bbd073f636097caa6f5f5b01f4a8d198f25628d43beb54c1849b70e783cd4bb82dba436471c9b4b8071610930f62801c69e25c01807460fd7e999633861f1d0fa5abff14945119f4a8813d7762f013cbef66195c553e58805d77dd8cbfc72de8755c0e36b1f565b3cd58e5870dd87bdcd2fe77d58ed378e91b4f7779500639f1260bcbb0418fb960063bf1260ec5f028c034a80f19e1260bcb70418079600e37d25c0787f09303e50028c0f9600a3ef671ab9ee73db8a603becfeac18b6c3ee2b8a615b622e3197984bcc25e612f35bb52d3197984bccdffd98fb78968bcf8d69c9750fe17abeebbb4f5e18f9302e66ca883cb1e87892e83bdadac0c077622835c6c525c0b8b00418258ed93ed4ce306a9e973df16c2880e765e079297a9e5a4f7e66c61a6eb47cda60f994803c580f367af0330676a96c5adf08fba1d498f15822d638e46b63c248ba9780c7d7f155c8f18ec7d7264f3c2f17c0b309787cec2f4f7e668ef776cba7972d9f1290078f9d760f7ec6c02e954debedb01f4a8d198f77628d43be36268ca4db083cbe8eaf428e773cbe367be2d95400cf66e0f1b1bf3cf99939deb7583e6db27c4a401e3c76b678f0330676a96c5adf02fba1d498f17827d638e46b63c248ba76e0f150ef0abee7d8ec88e3c212605c5c028c12478923274689e39d13476114466114c67783b114da7039cf14fe6c00efc5b746cf538ff76df9f06c051e1ff7769efccc3c1bd866f9b4d9f2290179b01e6cf3e0670cec52d9b4be0df683300bb38b19db2c628d43be36268ca4db023c1e8eef82dbfead8e3836fb654c759651f36c8f9ca73e89f5251f9eedc0e3a34ef9f133dbf6efb07cda6af994803c787ceff0e0670cec52d9b4be03f64321cc8b4b9059e22c710e6396384b9cc39825ce12e7306689b3c4398c59e22c710e6396384b9cc39825ce12e7306689b3c4398c59e22c710e6396384b9cc39825ce12e7306689b3c4398c59e22c710e6396384b9cc39825ce12e7306689b3c4398c59e22c710e6396384b9cc39825ce12e7306689b3c4398c59e2dc39661ce34eac71c8d7c6849174db8067bb079e42c7e16f77c4b1d92f63aab38c9a6767f43cf5585ff2e1d9093c3eea94273f33ef0aecb27cda6ef994803cd826edf2e0670cec52d9b4be0bf64321cc8b4b9059e2dc39666cb388350ef9da9830926e07f07838be0b6efb773ae2d8ec9731d55946cdb33b7a9e7aac2ff9f0ec061e1f75ca939f99b67f8fe5d34ecba704e4c136698f073f636097caa6f53db01f8459985dccd866116b1cf2b5316124dd2ee0f1707c17dcf6ef76c4b1d92f63aab38c9a676fe43ca924d6977c78f6028f8f3ae5c7cf6cdbbfcff269b7e55302f2e0f1bdcf839f31b04b65d3fa3ed80ffb0a605e5c82cc1267897318b3c459e21cc62c71963887314b9c25ce61cc1267897318b3c459e21cc62c71963887314b9c25ce61cc1267897318b3c4f9ce8933f631106b1cf2b5316124dd1ee0f1f03cbee0be9abd8e3836fb654c759651f3ec8f9ca72e89f5251f9efdc0b32f729e6c5f4df47e66fb6a0e583eedb57c4a401e6c930e78f0330676a96c5a3f00fbe176675e5c82cc52378ac32c754398c398a56e087318b3d40d610e6396ba21cc61cc52376e5a84d9a4a56e087318b3d40d610e6396ba21cc61cc523784398c59ea863087314bdd10e63066a91bc21cc62c754398c398a56e0873183387ba81637488350ef9da9830926e1ff0ecf7c053e838a2fd8e3836fb654c759651f31c8c9ea71eeb4b3e3c0781c7479df2e46766acd321cba7fd964f09c8836dd2210f7ec6c02e954deb87603f08b330bb98b1cd22d638e46b63c248ba03c0e3e1f82eb8ed3fe88863b35fc654671935cfe1e879eab1bee4c37318787cd4294f7e66dafe23964f072d9f1290078fef231efc8c815d2a9bd68fc07e1066617631639b45ac71c8d7c68491748780c7c3f15d70db7fd811c766bf8ca9ce326a9ea3d1f3d4637dc987e728f0f8a8539efcccb4fdc72c9f0e5b3e25200f1edfc73cf81903bb5436ad1f83fd20ccc2ec62c6368b58e390af8d0923e98e008f87e3bbe0b6ffa8238ecd25c0b8b00418179700a3e738a63acba8798e7be2395a00cf71e0f1d17e78f233739e3f61f974d4f2290179b01e9cf0e0670cec52d9b47e02f643a931e3b144ac71c8d7c6849174c780c7d7f155c8f18ec7d7494f3cc70be039093c3ef697273f33c7fb29cba7e3964f09c883c7ce290f7ec6c02e954deba7603f941a331eefc41a877c6d4c18497702787c1d5f851cef787c9df6c473b2009ed3c0e3637f79f23373bc9fb17c3a69f994803c78ec9cf1e0670cec52d9b47e06f643a931e3f14eac71c8d7c6849174a780c743bd2bf89ee3b4238e0b4b80717109304a1c258e9c18258e774e1c85511885b130c6f525c028fb5a18b932b679608c197bc843eb6d45b05d65d9ae2aa2ed6acb7675116d4bcc25e6127389b9c45c627eabb625e6127389b9c45c622e31bf55db127389b9c45c622e319798dfaa6d89b9c45c622e3197984bcc6fd5b6c45c626edbf630deb4e0f1dc6780e7b4875878f233a9cb3d6bca7a27c2f8e9589db362d566c52a0179ce42fcce79889f6bcc35ad93bd4299873060f6643bd54b95d103fc271b8bad7868fbe73df91ed6e69d2f82edb036af18b6c3dabc62d896984bcc25e6776ecc315d11dcfc0e922ee382497731eb947f3d6c4779deaaccfe5605b23f7dd8966348622e319798bf1b31c7b88c2f024f60f10439786632e3a967c6d3c28c6709339ee1cc784633e399cf8c6716339e29cc78ca99f13431e36960c6338219cf6c663c5399f14c60c6d3c88c27c98c6728339e91cc785a99f10c61c6b39419cf02663cc5e81f2a84670e339e51cc782632e399c68c670c339e5a663c8f32e399cb8ca792194f8219cf74663c9398f18c65c69362c6b39a19cf32663c8b98f1f462c653c58c6706339ec9cc78d632e319c78ca78e19cf3c663cbd99f15433e319c68c27cd8c27c680271edc3c263d0eff3f03ba326bdb6e4abe35a0e3ff178dbe0cb6b964d2e58eb22f828ec67a5d726c8b71ba08bea44d3a796b4b264e682b0deb64af12382e31e14933e319c68ca79a194f6f663cf398f1d431e319c78c672d339ec9cc786630e3a962c6d38b19cf22663ccb98f1ac66c69362c6339619cf24663cd399f12498f15432e399cb8ce751663cb5cc78c630e399c68c6722339e51cc78e630e339c38c6701339ea5cc788630e36965c6339219cf50663c49663c8dcc782630e399ca8c6736339e11cc781a98f13431e32967c6338519cf2c663cf399f18c66c6339c19cf12663c2dcc78ea99f1cc64c633dec1e36b5e66eaffa7b269fd0c13db1ef643e6bb79973df974c594d5d5944bfc64af02f2ac301d43babf0ab7252e7bbc063e2bb80231bae0c997b06f675c2882edb06f6714c376d8b7338a615b621e1ef32bd1db4ee118285a62d67a1ad278dcf9183be6c9cf1bdabca8bf157ad58ad5052b5609c87319e277d543fc5ced28ad93bd4299873060c67a5113445b2fae45efd36fbe414a71bd66c517fdbaee29a6616de9f522d80e6b4b8b613bac2d2d866d89b9c45c627e67c7fcfd261de17546126de87b283a7fbc1fecbe6ad2b108edeab25e3165d1375389e355e0a13c6fc03d9dd43f39e6ef8498db697a4681df15f0f50c296c9f14e3f955d83e2986edb07d520cdb12f3f0987fc083ed7870e35c127ac9f58ce203c0f38a071e4f7e66ceb5af593e9db17c4a401e6cfb5ef3e0670cec52d9b4fe1af0d082dfd1f5510ff2d9e761dfd1e5c053cf8ca78519cf12663cc399f18c66c6339f19cf2c663c5398f19433e36962c6d3c08c6704339eabcc786633e399ca8c6702339e46663c49663c4399f18c64c6d3ca8c6708339ea5cc781630e399c38c6714339e89cc78a631e319c38ca79619cf5c663c95cc7812cc78a633e399c48c672c339e14339ed5cc789631e359c48ce73a339e5ecc78aa98f1cc60c6339919cf5a663ce398f1d431e399c78ca737339e6a663cc398f1a499f1c418f0847d4797fe7f1574d4678fdfd67ddda45f015d99c306f51dbd06ba0a93a632f477797f34e0e6b2314ebec629a0ad34ac933dfc8eeeeb4c78d2cc788631e3a966c6d39b19cf3c663c75cc78c631e359cb8c6732339e19cc78aa98f1f462c6739d19cf22663ccb98f1ac66c69362c6339619cf24663cd399f12498f15432e399cb8ca79619cf18663cd398f14c64c6338a19cf1c663c0b98f12c65c63384194f2b339e91cc788632e34932e36964c6338119cf54663cb399f15c65c63382194f03339e26663ce5cc78a630e399c58c673e339ed1cc788633e359c28ca785194f3d339e99cc78c63b78e4db30d1da96eff1f08cb987ef5466be958adff9d18b3df6260d69cfefcbd6c7831bbfe3f9db78f0bb283eda254f7e66bed1f906b04755ae8ed59b56acae5ab14a401e6478d343fc6241f8f756c89e300b7318b3e6a1f609c7fd51beeb4c1849f71af0f86837b4eff44c81cad7df309cddbbc3ae87f344bd8e037def97be833fc2da2f1590e7b3fd3bd8e61bb64af83fed37edcf154ba77df0fd2d7f2a9bd6c91e3e43c2ef82fb3aefdbdfacbeea88c5bb69dbc377cb6b0bbde6b8e2e079273a9e24b63168eb9227df2f07f9fb7ec9c113a1efb509e0f13c574aa6eda2fe182a5fb70fcb7b7b8d793d1ef7d476d9f319e21c1ed7a1ed5a95a3ed2a0b3a8e19fa5f8dd1dbe7ac778cde2ea32690fb291fb6e51e56ee61038b8716bc878dfe3a23952cf41e16e7cff071bef5743d95f4744ecadcc35eb46265cf3592803cc598e3ebb2c543eb644f98855998855998855998855998855998855998855998855998855998855998f933878d39a17cd79930920efbac7d3ce7d7bed37baa54beee1bed56dd6137fa7e8b5412c72850bfed28cb679c377455bf0eb6b861c3f11c38e6c4b52f7df4f7e7da9764af32b8791c8acf7ebab03130c5e8232cc4764d64b6532bfcecdf5492e644bf6aedd3eb8efde9a3adc0f153b4e4ea6bbc083c3ee6bdf7357644fb74c1f2e98ae55302f2e03c16173cf8e93aafd1fa05e0a105e711f475ce082c9ec0111f5aca98f1d433e3e9ce8ca78519cf12663c8399f1cc67c6f300339e01cc784633e399c58ce72e663c5398f1f460c653ce8ca789194f03339ee1cc784630e3b9c68ce711663c0f32e3b98719cf63cc786633e3e9c38c672a339e9ecc782630e3a960c6d3c88c27c98c6728339e91cc785a99f10c61c6b38019cf52663c35cc78ee65c6338719cfddcc78a631e319c58c6722339e38339e31cc78ba30e3a965c6f328339e41cc780632e399cb8ca72f339ee9cc782a99f12498f14c62c6d39519cf58663c29663cab99f12c63c6b38819cf43cc78ee63c6d38f19cf0c663cbd98f15431e399cc8c672d339e71cc78ba31e3a963c6e37b1c73a13c0f33e399c78ce77e663cfd99f1cc64c6338c194f9a194f6f663cd5cc78620c78e2c1cdef9ec4e1ff574047ef48e0fb75658ef2681c23e5d7e7e95f0eb8b9ec3247d9171d0c18a7f3e04bdaa493b7b6dcf05e48cc944beb64af12382e32e1a966c6d39b194f9a19cf30663c3399f1f467c6733f339e79cc781e66c67399194f1d339e6ecc78c631e359cb8c6732339e2a663cbd98f1cc60c6d38f19cf7dcc781e62c6b38819cf32663cab99f1a498f18c65c6d39519cf24663c09663c95cc78a633e3e9cb8c672e339e81cc780631e37994194f2d339e2ecc78c630e38933e399c88c6714339e69cc78ee66c6338719cfbdcc786a98f12c65c6b38019cf10663cadcc784632e319ca8c27c98ca791194f05339e09cc787a32e399ca8ca70f339ed9cc781e63c6730f339e0799f13cc28ce71a339e11cc788633e36960c6d3c48ca79c194f0f663c5398f1dcc58c6716339ed1cc780630e3798019cf7c663c8399f12c61c6d3c28ca73b339e7a663c65cc78c65b3cf87ffdec83c6b75e001dfdbfb14ff6b7caf871c1b217811fc9b0b9317cc50c97b4232661736370e0a967c6d39d194f0b339e25cc780633e399cf8ce701663c0398f18c66c6338b19cf5dcc78a630e3e9c18ca79c194f13339e06663cc399f18c60c6738d19cf23cc781e64c6730f339ec798f1cc66c6d38719cf54663c3d99f14c60c653c18ca791194f9219cf50663c2399f1b432e359c08c6729339e1a663cf732e399c38ce76e663cd398f18c62c63391194f9c19cf18663c5d98f1d432e3799419cf20663c0399f1cc65c6d39719cf74663c95cc7812cc782631e3e9ca8c672c339e14339ed5cc789631e359c48ce721663cf731e3e9c78c6706339e5ecc78aa98f14c66c6b39619cf38663cdd98f1d431e3b9cc8ce761663cf398f1dccf8ca73f339e99cc788631e34933e3e9cd8ca79a194f8c014fd85c14f4ff72d09d33e96ba03b6bd2974177c6a42f80eeb44357e660217be74047e302ce828e9e4d9f011d3d7f205bfafae0ff0cb899b5cce153b983f5acc3a7738e6d713fd236e920dafd88b6d2b04ef670ae8c734c78aa99f1f466c69366c6338c19cf4c663cfd99f1dccf8c671e339e8799f15c66c653c78ca71b339e71cc78d632e399cc8ca78a194f2f663c3398f1f463c6731f339e8798f12c62c6b38c19cf6a663c29663c6399f17465c63389194f82194f25339ee9cc78fa32e399cb8c6720339e41cc781e65c653cb8ca70b339e31cc78e2cc782632e319c58c671a339ebb99f1cc61c6732f339e1a663c4b99f12c60c6d3ca8c6724339ea1cc7892cc781a99f15430e399c08ca727339ea9cc78fa30e399cd8ce731663cf730e3799019cf23cc78ae31e319c18c6738339e06663c4dcc78ca99f1f460c6338519cf5dcc786631e319cd8c6700339e0798f1cc67c6339819cf12663c2dcc78ba33e3a967c653c68c67bcc583634893a0a3742de8289d021da5eb4047e97ad051ba0174946e041da5c7808ed2634147e971a0a334f988ef6714639e0bb24565d3fa7960a4fb17d73e6902eef3964e739ff2c47ddee2a6f553c0e8f285d82600f7294ba7b94f7ae23e6571d3fa496074f9426c134147e949a0a3f464d04d067ba4a3f414d0517a2ae8283d0d74949e0e3a4acf001da5e9fd057c976116e8283d1b74949e033a4acf051da5e7818ed2f3cdafdec7272d9ddec7274c3a1d44bb8fc916954deb2780d1b5df896d01709fb0749afbb827ee131637ad1f0746972fc4b608b88f5b3acd7dcc13f7718b9bd68f01a3cb17625b02dcc72c9de63eea89fb98c54deb4781d1e50bb12d05eea3964e731ff1c47dd4e2a6f523c0e8f285d89601f7114ba7b90f7be23e6271d3fa616074f9426c2dc07dd8d269ee439eb80f5bdcb47e08185dbe105b2b701fb2749afba027ee431637ad1f0446972fc4b61ab80f5a3acd7dc013f7418b9bd60f00a3cb1762c3ef95acf5c478cd62bc5644db61d78cc5b01d76dd570cdb61d76ec5b01d764d510cdb61d705c5b01d766e2f86edb0f373316c879d638b613bec3c590cdb61e7ba62d80e3b5fc9f12dc777d4b6dfcd73c99d7a7cbf9b6deabbd9b6c8b5a25c2b16cbb69c4be45ab158b6efd46b4569cfc3db730fcf845271b0414bcc5a4f43fa00f0f878b6e6c9cfa42e77bf29eb9d08cbd5b1da67c56aad15ab04e4d90ff1dbe7217e31b04b65d33ad92b4566ac17b1e86c27e36003bf6fb897ca07dd1e93ae05dd6e934e816e9749d7816ea749d7836e874937806ebb49cf05dd36939e07baad267d0a745b4c1afb06379bf449d0b59b34f6c56d32e913a0db68d2d8f7f5b2491f07dd4b268d7d4d1b4cfa18e8d69b34f6edb499f451d0ad3369ec4b79d1a48f806e8d49b780ee05933e0cba55268d7d052b4dfa10e85698f45ad02d37e983a07bdea4f783ee39936e04ddfb4c7a0ce89e35e9b1a07baf498f03dd33268ddfe17cdaa4713cc553267d16748b4d1ac72f3c69d2f81dce274c1ac70b349bf444d02d34e949a07b8f494f06dde3269d06ddfb4d7a0ae85e31e9a9a07bd5a4a781ee03263d1d74af99f40cd0bd6ed23341f78649cf02dd9b263d1b741f34e939a0fb9049631fcd874dfa00e8ca4c7a1fe868fcf05ed0d13b4c7b4047ef99ef061d7dab6417e8e87b693b414763bc76808ec6096f075d4f93de06bab8496f055da5496f011d7d176433e8e85b57eda0ab32e94da0eb6dd21b4147df097d19743476f725d0d1fb3a1b4047ef0caf071d7d07a30d74f4ada975a0a3ef39be083a1a83ba0674f4dec90ba0a3777157818ebe2fb11274f44da915a0a3ef362e071d8d357d1e74f47ec973a0ab31e9f7816e90493f0bba874cfabda0a3ef213e033a1ac3f934e8e83d92a74037c4a417838ebe17f124e8869af413a0a3ef8a36836eb8492f04dd6326fd1ed08d30e9c74147ef8dbe1f74f46efd2ba0a3f1cdaf828eced91f001d9db35f031d9db35f071d9db3df001d9db3df041d9db33f083a6afb3f043a6afba9fdd0c7a93e7eaf98f57410dd7594b67735b871c9752d4f0cc813e5b5710278d0d6a5c87d4f65aec3e9faadcc944bf5e512d8be10b9edec3dc04553561753ee05cb7605e469efd7b16fcec3ffd3e0036d8779a86c5a1f05db9eb7caae32fe5ef4e4ef058b89b82f0213e5d9d6af23ef40d32077876d2264cbdccf525d0b2086b8a4218df367441fab54e6fee272013c178127fae3247b7feda34ee0b115f5fdb5fd6cc4ae6b09c87301e2e76b5cf1458b87d6c99e300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb330f367d63cd49f80e38328df15268ca4c3be2e1fcff9b1cf15fbbc7a40bf8eeffebdaea6dcd196cf1590676eff0eb68449e3b75568bf85ed4b0ffd8439f725d9ab047fb02fc8477f710c6c51d9971cb1e060bb2632dba9157ef66f2aa9c7c7e8fefdcbd63ebd62ed4fec17c7636820d453dae6baf98d437cae437c3c1ce339f70dd9c363e912e8287d15187dc41acf25d41e507f38d9c37ef1474c6ca95f3cfab63a95f4d96ed0f7a1ecfe76f495f20c87b66f8449e3d8902b505693e3ffb4e4eaa7a6f8699fcf44ef7366ff9e3665d1fe3de3b07d0a5823b25d8bb66346c80ee92b203dbe7f475efbdd288a35b1e3b79b90dddeeeaab55d02f29c75f89f0ea2f5ff8cc573c662d6756734d4b32638fffb6a93ce86c46814c488f2e07590877126ce369238c89ece43fbbf9b9507af5928cf3468a3b42fd4ce939f38b605cf01e73cf977c5f28fd6c91e5e1b5f0446db475d3fba5577f0dee9e3bf9e84f6e23cfc3f1ddcfaf8af27a10ee138adc02a7f34944f5cdd82f0730be579da3a8ffab8c7c07d69c713c797519ea5d00e5de8c4b5febb75df1676adefe37b94f1e0c67b6fbde43abfe339c647fbe2c9cfa4ebdc75def229017986809f1eae6372be5778066cfbfa0629d9a06ba80b562c2a204f9bd57684c511ef552f16c59794f37a70b4c317cab3c96aa74e7b60f2b9dff03a4b977bc9e12be5d906eddf0eb89ea7fd846de971c7ff69c9d51e50fcb4cf27a2f739b37fe99d32dabf271cb68f016b44b66f78bf9eaef7c90ee92b207d0ccedf948fe241b1c66f489ea4ed82f0ed2e58db2520cf4987ffe9205affc3be6d40f674ddd90df5ec385ceffb6a374f86c46834c488f2e0b3153ab753feb0f3be8ff1d5b9cefb9780d16e37f1dac527db658bcd7e86eaba1ea43cb42d5e0f5e857636eec8ebffd970f6daa69031ff9e9f91d7c7ac78a6c1ce48d053fda438d3fff01a97f2bce9fdf955b67e5cb0b8c90fecc33967719fb7e28acfa23e6addd3dac7a6eb59a7a76bce7abc16b3af87ce013be5f9b8753d645fc75d73f8629fa7cb829bef05dfb1f2e231996b3b3b7dc5da069f19b89ec9e2bb2e6781256dd2c95b596a9349642a73c42211dc7c4fe67ace40c701d6392acb3e5668db0ac8f319ab4db2f3ea366979ef8ef8d07ec467edae3ae9eb3952d87316b2a7195defd145df76dd99ef2b758facdc71cb4bb18fbbbb958ec676aa15cf15b96271cec1e3eb9966582cce396c47178bc615aef3872b16671d3cbeee31c36271d6613bc258ac723d5b70c5e28c83c7d7bd46582cce386c47178b31373cd7c8158bd30e9ee89f69e48e05f68915c27c960173772b1d8dedfae5aebe3b572c4e39787cf5dd85c5e294c37674b1a86d74ddb3bb6271d2c173b2c8b138e9b01d5d2cc68e733d5371c5e28483c7c3f3b59cb138e1b01d61bd5889cfd772c5e2b883c7d77c3061b138eeb01de1f56163ae6786188b630e1e5fcffec26271cc613bc258b468db47f388c551078faf796bc26271d4613bba582c6fd0b68fe4118b230e1e5f73e184c5e288c37674b16819ab6d1fce2316871d3cbee6d7098bc56187ed08efa132f5e2501eb138e4e0f135674f582c0e396c47178bd6ccb5d6c13c6271d0c1e36b1ea0b0581c74d88e2e16c9cc39f5401eb138e0e03950e4581c70d88eb05e64ee27f7e7118bfd0e9efd458ec57e87ed08cf23997ab12f8f58ec73f0ec2b722cf6396c47178b5599e74f7bf388c55e07cfde22c762afc37684cf5c32f5624f1eb1d8e3e0d953e458ec71d88e2e16759973eaee3c62b1dbc1b3bbc8b1d8edb01d5d2c5666fac476e5118b5d0e9e5d458ec52e87ed08af3b33edc5ce3c62b1d3c1b3b3c8b1d8e9b01de17567e6f9c58e3c62b1c3c1b3a3c8b1d8e1b01d61db99b9eedc9e472cb63b78b6173916db1db623bceeccc4625b1eb1d8e6e0d956e4586c73d88ef0ba33731ed99a472cb63a78b61639165b1db623ac1799b6734b1eb1d8e2e0d952e4586c71d88ef0b956a6eddc9c472c363b78361739169b1db623bc1fc93ce36bcf2316ed0e9ef622c7a2dd613bc2bea2cc35f8a63c62b1c9c1b3a9c8b1d804b67d8c33c158d058ac11562c2a20cf5af3d1761a8b1516472a03c795a12f1b23f7253baeece5105f36822f94e725f0a53be8a364f2e46ba6ced0f7fa696cfa5587af9467f3808ebc5b4d3a0efbe41a9475c4f17f5a728d41a2f8699fd747ef73a6aeb699b268ffae77d85e07ac11d9ae45db34369dec90be02d2870774e4a57c140f8a35b1eb6364834923bbbddd266bbb04e4d9e0f03f1d44ebff7a8b67bdc59c79ef01ea19d5233f6d57966943488c46408c280f8ed9bbea89c71e43481c644fe7a1fddfcdca83632829cf1968a3705c29f9190f6e1e37a9fd7bc9937f61f3c291bd04e82e02a3eda3ae1fb361ec672d31061dba3a934e41398d964efb3ac693af648bcaa6f531c0586fd28dc5674ce5cbd860316a9e711e6286f36cd092eb7c310e78c67ae0f1e467e63c34def2698ce55302f2e0bb8de33df81903bb5436ad8f07db3ef639c682cec943ad5854409e8f5bd78f6171a43274fd6d74f8e22b8e0d164f83c3f644cf71a4b2a94d9c5804db4d96ed7acbb63eb6b18ee925d7b1dd04cc133c30eb7227455f6ee6d8a6b9d4a83e939d7af0290d3188ca27b41db3ca267d05a4bf30e066068a079d3b895d1f475877c2b61b676d97803c131dfea723f67f92c583fb582ffabae153705de9e178c8d481891607add743ec2685c46e22c48ef234828eae71c6838eae1570ee41fa3f5e473444efafb3eda1f50660241dce67d8e060ac8f9e3195ab6dae0746d24d009e264f319b60f10cb5e283e7e56e561edab602f27c03ce8d71475e5df7ef8f75f845731c4638cf4fa65dedea215e38ff6200f109ac18d2420cdd838e391aa3e4e91974ccc1b8a97dc3c696d52b9f5899ed7a24b40a0b137f630e37ca4087e972872e086e9c6ab2027434d56417d0955961c1292e293f4d69e7235c180f2abbc2e2ec0e2c51dac6693a69c95575ba018f8faaacab0e4dd569aaced31bd7b4afc4fad1c5e2ec4cddd1ff2bcf912fac2caa07151e7c47262a9bd6c99e8e4fc2a45f6a59f1e2948dab37b7ad5cdfbe0961ed830bd3312b08f6af6b1bac24783051395dace0f4883e38f578f0da7c01d80b8025303cdda3e7c954d4bb4c592b5ad6ad5bb879f9ba352b666e5ebfa27dcd86f518d16e56e4c2a26d1ff27a71357598d7cedfd5a1b3179c49b71be86826ddeea023fb3d40471c3de17ff69ef0724c0c81f2a91aebff551887bb1a87a80ad26948b727fa98d19f2ed5a77ffd644c7fa94defbe3e4176eaddbe41766a5dfd56b5be52d053e5eaa971f554b87aea5b3dd5ad9eda564f655b1364a7aa7d28c84e453b38e8986a562f5f025e3db5acbed4d053c7eaa9621f0bb28feb4606d94f9be94f49e84b567d3baa2ff3f4ad85bee4d2975afab256dfb2ebc737fa32465f22eacb1f7dc9a22f83f5e5ef6413eb294176aa693db5f4f4203b75b49e2a5a4f0d3d3bc84efdaca75b9f1764a74e7f3cc84e4fbb20c84e5ddb1c64a7ba7d32c84e85be38c84e9bfb74909df25c4fb5aba7e0d5d39aebe979f5b4bd7aea723da5eff341767af2e541767ae0d6203b75b09e52584f2ffd42909d86584f39fe62907da4ad1fe5eb47dcfaf1b17ebca9bb1874d78a7ef4aabb047517a9ee32d65de87a48811e62a1879ce821387a48921ea2a587ace9217cfb82ec10cf03417608b01e12ad8788eb21f3fa15826341f61513fdca8d7e0549bf92753ac8be66a85fdbd3afa1ead772f56bcafab1aa7ec55b77b5e9c7a9fad1b27ee4aa1fffea697af5b4bc7a1a5e3dedae9e66574fabfb46909d36f78341765adc0f2bf988928f2af91d25bfabe4f794fcbe928f29f9b8924f28f903257fa8e48f947c52c91f2bf913257faae4cf94fcb992bf50f229257fa9e4d34a3ea3e4af947c56c95f2bf91b259f53f2b74a3eafe40b4afe4ec91795fcbd927f08b2f5f11f95fc93927f56f22f4abeace45f95fc9b92af28f9aa927f57f21f4abea6e4eb4abea1e49b4abea5e4db4afe53c97794fc9792ff56f25d25df53f27d253f50f243253f52f263253f51f253253f53f273256f29f985925f2af99592b7838ee9a3b1f1e86e5a9c4166bda5bd7d65db4bed35ed1b6ada36af6b5ff3d2baed355bd7b4bf50b361cbca8dabd66dd88a1b7fda6c4cf35c4fd9b8b1657bcd9af5ad2bb7d56cd8dc5eb36155cdf20d9bd7b7de70b2fc96d9e8be9b2db6b4b6861bfbf9ad90feaa93467f6db6eb63d6e7e4f6ed9dce04a4a2bc131b0d2def6414cdc51edd863d99bde6abd9b46e437b4db266bdfaab4eae1bb6ae6c1d5583ffdba482bca9bd66537bcbc6f69a551b37b4d5d48ec27297f7ea8413aff7f203b3a95ff6b753556570ff4e7832b57fe776c713fd6f81f4a94e1a5dd7190f377666a32b9d247c233c2c9b362f6fdfd8b2a23d7ce38fdccac61feb8c9b9feea49b6b0674c2d886ce6c747a40e7083fd619635f2fc058f0bf713e55c3fca20400", + "bytecode": "0x1f8b08000000000000ffed9d0774154796f75b4280f0d3b3088e045b3860c004e9492449c023679325030e801019e3210c382272c618b0c946e0999d4db339cfe69c739cd9303bb333bb3b3b73ce37bb5ffecef1f9aafad51dfd55543ff4e4aec77dd2ed734aaffaaabaefaffe7dab3a55777f270882a22033f550e9e9e0ee89fe9f36bf959f6eaa8a715d953e398b0a84b3b840387b140867498170f62c10ce5e05c2d9bb40384b0b84b34f8c9c9aad38683fc5cdfb80075de3664c1498a66505a069b2c0347db000342d0f0aa38fea5b209cfd0a84b37f81700e2810ce870a84f3e102e17ca440381f2d10cec70a84f3f102e11c58209c830a84737081700e2910ce270a84f3c902e1ac2810cea105c2f95481703e5d209ccf1408e7b331728e00ce61e6f739f33bdcfc529991e6f779f33bcafc8e36752c31f363541aabd954aab2fe9752a95aa51a95c659ff1bafd2049526aa34c9fcafc2fcaf56a53a95ea559aacd21495a61a1da6a9345da5192acd5469964ab3559aa3d25c95e6a9345fa5052a2d5469914a2fa8b458a5252a2d5569994acb555aa1d24a951a546a54e9459556592cab555aa3d24b2abdacd22b2abdaad25a95d6a9b45ea5269536a8d4acd2469536a9b459a52d2a6d55699b4adb55daa1d26b2aed54e975953ea3d22e9576abb447a5bd2a7d56a57d2aed57e90d4bb337557a4ba5b7557ac7e27c57a5032ab5a87450a5432a1d56e9884a47553aa6d271954ea87452a5532a9d56e98c4a67553aa7d27b2a9d57e97d952ea87451a54b2a7da0d2872a5d56e98a4a5755baa6d275956ea874d3b05043f848a55b2ab5aa745ba53b2a7dacd2e754fabc4adfa7d21754fa7e957e40a51f54e98754fa6195bea8d28fa8f4a32afd984a3faed24fa8f4932afd944a3fadd2cfa8f4b32afd9c4a3fafd22fa8f425957e51a55f52e99755fa15957e55a55f53e9d755fa0d957e53a5df52e9b755fa1d957e57a5df53e9f755fa0395fe50a53fb234ff6395fe44a53f55e9cfccffe83ad89fabf41726ff97e6f7afccef5f9bdfbfb196f95b95feceb27d59a5af58b6bf57e91f4cfe1fcdef3f99dfaf9adf7f36bf5f33bf5f37bfff627ebf617ebf697effd5fcfe9bf9fd77f3fb2df3fb1fe6f7dbe6f73b2add1c9cc997066d533a88a94faa696ed6f75048ec6141fb496bd1c3fc8f7e2b8cbdc4ccd32f69d7d3ccf7b4ecbdcc7c2f6b3da566bed4b2f733f3fd2cfb00333fc0b23f6ce61fb6ec8f9af947c19e08e05aaab16b5b0f632a021bc56131d87a06ed35d1b65eb43ab0f50eda6ba16db41d7b81ad8fb1f506db03c6560ab684b1f521cd542a33b67410574c54aed3eb4dc6bd5e737fe9c1f8799bf47acb3df1f68d9fb759afb79f075e1d1ffdcdbafa42dc0c30b67e607bc8d8fa83ed61631b00b6478ced21b03d6a6c0f83ed31637b046c8f1bdba3601b686c8f816d90b13d0e36d3ed0503c136c4d80681ed09631b0cb6278d6d08d82a8ced09b00d35b627c1f694b155808dc6ae0c05db33c6f614d89e35b6a7c1467dea3360a363be678d4df7133d8b601963a73e2a5c86fa61b00da73e186c23a8ff05db48ea7bc1f63cf826db28e857c836dad8a88fd2ff9b68f2e920ae36910adbc4a4b8d7abd6acd75b17ff7ac3fb71f5419bae69f03309b49a6cf2318ef9a942df4526911fb297407e2e94a572a407ed67885def4f6a4d7e7296e5265acb25a14cada3fee920defad7593c7516734fc8fb89d9ea94c46c87a79c63b601cadab147c73c5d316617008787981d2f31dbe129e798dd0065edd8a3e3deae18b3ab80c343ccaef313b3a94a89d9ccf5af2070c71e9dfb74c598dd041cf1c7ec3889d98e4f39c76c0b94b5638fce7fbb62ccee058ef86376c23a3936e8f09473cc9e83b276ecd1b598ae18b38781c343cc364b3fdbe129e798bd0165edd8a3eb825d3166df078ef8637692a798ad96980d32f73283c01d7b748dba2bc6ec2de0883f669be4fa6cc7a79c63f6e7a0ac1d7b74bfa42bc6ec178123fe98dde0ebfa6c4a623633862308dcb147f7eeba62cc7ec9e4f5bdb1bf34f7c69e00db5f19db9360fb6b187b40b6bf31b6a1502f0f6d60a2b4810e4f39b781bf85b2762c3f65f25db10dfc11707888d97512b31d9e728ed96f42593bf6684c43578cd9af008787986d9298edf09473ccfe77286bc71e8dafe98a314be343f5f1c23f9ae385e160fb27631b01b6af1adb48b0fdb3b13d0fb6af19db28b07dddd84683ed5f8c6d0cd8be616c63c1f64d63ab04dbbf1a5b15d8fecdd85260fb7763ab06dbb78cad066cff616ce3c0f66d631b0fb6ef18db0463d3f7b1684cd5ef1a5b2970a583f8b66d0234a0a9c89a4f43beca2f4f651278d05775fcbeaa75dd5341c7eb5e0d3c351eea9e001f1de1a9019e71f1f384e349c7c7bfde701ba72c4d13e02b05f59ae0a15e45e08bd64df3e42f09366cd3131c8cb1ef9fd57eb4087cd1ba697e2230920dfb18ea73a9fde8be7948511baf87b614ee9fd15f1a38c85f09941937b8adec50c35606ffc7fe769c65f31497615c902f5a37cd93bf32a8cfb8fc33a63aca586331faea238ac017addbf65d06f94abffa64e519cfc477ad27df769f469ad7e6c1f744cb77b5e51bfb4e9ab2eddb2602b387f394aafb719e82c70f1cce536616b595b5cf37a81fcef53c6582b51cc7f39449b02ff4d01ec218a8b53868be1ab4ab8bd0ae16b4a332cf8176befaf149160fcd8f031eeabfb13fabcc334f2503df780c4bdb0dcfa5f038c0d7f6aab41869deb5bd2602a3eb58c5c3f94cd663951a60241b5ec74979d22c6abba698f8f6102b617f443ee8d89cda2ff92b81320b7ab4955d0b7da58f18c178a4a9a3e7bcf16fa754780e5e93030f6e3b0fe755559ee2b112afdf7c12c41b6b76bf54636915758dc7575f9eb278689efc09b3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300b337f66bc9f84e3b6a8dc38268cf6f8375fd7f9c377ec9975e13da0ef7a1d0f96aac4b130340e628455e71228535edcc6f63f603c983d96286a5bfa181b9b6d5b923f1c0f968f7b88d5168fedbbcca10fde9746cd7c8d81b2fb0c9ac7f169a45f25f0f86a8f55168fed1bfb8c1453cda2fa595f630ba2e2cc359eb02236dfa9265ff775f5fbccf43b41edfdd7384bd3f05da3964df7492ff468abb78ffbbcb9de77c6fd06e5e3bc8f9b041ef4157f3f9b6a373ea13868bfafc058f735568bda158d8da8b57c97409921c56ddba60efe9f0eeede3760195a37cd8f8065ebac7597fbab6fd67128b5c04df95e56ddc6033795790af6dd7f66f29ef681a95c9f91c07d72fcfb97cc7891540e3cb8bff371cce2693f5a89f118f778117b1ca4eb7899cae018520fe377b3ee8bc99f300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb330f367d63cf63d74bcf75bcd84314f636cc2fb19f42e36bc2ff693c56d7e7ddf03a47b4e23ad3ae333ca013ca3fcb3860dc73ee07ba55cdbd2d7bdb5a86d49feb88d7d2873e8a335ab736856ef89d1ee3368be1e1849bf3ae0f1d51ea3dedde1ea332a996a16d5cffa18bb902dce5ce3142a62f39d192fe2e3be2e8d17b1f75ff67b8d709c04d9f03e78d4fbc2aa2cdbfdee035ce3da288fef5c88bfdf4cb5bb076c8f15247f384ee22b465b1a27117f3f90aaf4b98fa0364a6342528eba5299af16b795fd9ac9e358a16a58d7771dffa729db9804ec53a7c45fe770fb4e35eba2ed3bc5e13b0dac31f9ae42df45d6bac95e02f9ff567c3703e9415a13bb6e23f81eaba8e56aace5925066b2a3fee998eb3fc5e2c16dac271d3bdf8038fb2e1cebf9ea93264768340234a2329edf03eb1ce76b8f55c67eb4b7558696c5f75bfe1fe8a3a2c6a4bbf601be8e17a2f60178bc60ef173a3276bcbb8f07ec63ce437c8c07a4759707edc7e405d6fa47c2fa89ab7710bd6ff9deb938acdfe798f57bbdf7ca75ee47bc38de90caf48773bf99269fcbb9dffd3a8f779dfbe1725175c77e21ee7d23c623b2e0fb22a9cc602b1eeb22b8273a967d326259d2ca7ef7219e97e23142fcef8dccf43753acba509b9a0c75a132cf5aed26fe63a6ccf1a7af7764d2b10ef541558eba529991d0d646997c02b613ee17ea1cffa729dbf127e9a7eb3c2dfe3a87db77ba59176ddf690edf33803526df55e89b8e3fc90fd94b205f0bfb132a477a90d6c45e069cc86e2f576b2d9784326947fdd331d77f9ac533cd62d6b13316e2ac0e9eb5f0d557a703b7462341a3eff9039bebbdc6ae7d8cafe7d1a2f63155c068f79bb89fcce7b372f6f55bd7f10995c163682a330ffad984a3ac7d5d9a968b737c3a3e0f84c785f83c90af73a464d05ecfa4c5e1d377b9e5bb3c8fbefb59befbe5d1b7682e9a73d29cd3377f70df520c8c3ece1bf1fa484718f17d04b45c0f60f4f5cc662a07c66a60c4fd1d317a78bf725567bf2984c73a3d81d1c7f3c6b95eafc6f79be33b0688d1c733dab9bea71a9fdba6e57a03a38fef1ae137943ac2e8fad65129fc7af8ae515567bf0382df3aea038c3ebe0d9208da7fcfe45e8c938091967b00187ddc474a04edafabdd8b11ef57d27209cf8cd9f6ed9ec7fea472bd06918f710551c71ae8dbc3f5ff148e4de88816f57e79b21efba06f0fd7bf422dea838e6b81f7e73cdc1b0ddbf1e41c78f01e222dd71f18a77a629c9203e35460a4e5060063da13e3d41c18d3c048cb3d048c1eae43868ce91c18f17a1dd91f06c6e99e18a7e5c0381d1869b94780d1c735c504f8ed08e30c60a4e51e05c6999e1867e4c038131869b9c780719627c6993930ce02465aee71609ced8971560e8cb38191961b088c733c31cece81710e30d272838071ae27c6393930ce05465a6e3030cef3c4383707c679c048cb0d01c6f99e18e7e5c0381f1869b92780718127c6f939302e00465aee49605ce88971410e8c0b819196ab2800c6a105c0f85401303e5d008ccf1400e3b305c0585a008ccf03e3a2f819c3f3d48539302e029e17e2e709355b9403cf0b7e79c2f7132e72f85a1cbfaf54ae755f0c3c4be2e709b7c5e21c78882109cbbde09731d55946cdb3347e9e50b32539f02c05cd963834f3c098ea2ca3e659163f4fa8d9d21c789681664b1d9a79604c759651f32c8f9f27d46c590e3ccb41b3650ecd3c30a63acba87956c4cf136ab63c079e15a0d97287661e18539d65d43c2be3e709355b9103cf4ad06c8543330f8ca9ce326a9e86f87942cd56e6c0d3009aad7468e68131d55946cdd3183f4fa859430e3c8da0598343330f8ca9ce326a9e17e3e709356bcc81e745d0acd1a1192746e489fb7de38d0e5fab18d49d1890b14f01303e50008c3806c147ff956d0c42a35f7d529dd5c7d7f6ca3606017daff6a4c5aaa0e35aacf6cb93750c02fa5ee3498bd541c7b558033c2f79d022013e3ac2430c4958ae7f01300e2800c6870a80f1e102607ca400181f2d00c6c70a80f1f102601c58008c830a80717001300e2900c6270a80f1c902607cd13363b6f39797bab8efa87395aeee3beabca4abfb96389738ef0ebe25ce25cebb836f897389f3eee05be25ce2bc3bf896389738ef0ebe25ce25cebb836f897389734ebe5ff6e03b013e68ca768d9f1892b0dc8bc2d8a51991a7223e9e4aac3bfa7a8541dd5f71f01479aa3bfa7a9541dd89a1d0185f2e00c6170b805174cc8c41ec0ca3e659eb89e7d51c78d602cf3a4f3c6b73e059073cebe3e709636a5d0e3cc49084e55e2c00c6970b805174141d39318a8edd47476114466114c6fbc158087db8ec6732e72e9d61d43c4df1f3849aadcf81a70934a3e55ef0cb98ea2ca3e6d9103f4fa859530e3c1b40b32687661e18539d65d43ccdf1f3849a6dc881a71934dbe0d0cc0363aab38c9a6763fc3ca166cd39f06c04cd9a1d9a79604c759651f36c8a9f27d46c630e3c9b40b38d0ecd3c30a63acba87936c7cf136ab629079ecda0d92687661e18539d65d43c5be2e70935db9c03cf16d06cb343330f8ca9ce326a9eadf1f3849a6dc981672b68b6c5a19907c654671935cfb6f87942cdb6e6c0b30d34dbead08c2be38b05c0f87201307ad631d55946cdb3dd13cfb61c78b603cf0e4f3cdb73e0d9013cafc5cf13c6d48e1c78882109cbbd58008c2f1700a3e8283a7262141dbb8f8ec2288cc2981be32b05c028db5a18b9327a38bfcafa7cca8e2eee3beaf994aeee3beaf994aeee5be25ce2bc3bf896389738ef0ebe25ce25cebb836f897389f3eee05be25ce2bc3bf896389738ef0ebe25ce25cebb836f897389f3eee05be25ce2bc3bf896389738ef0ebe25ce25cebb836f897389f3eee05be25ce2bc3bf896389738ef0ebe25ce25cebb836f897389f3eee05be25ce2bc3bf896389738ef0ebe25ce25ce39f9de19bfef54aecfb0ee041e1fcfd47aaa67a55eefeb665d9fc4a89fd6ea3396563b2cad9250e675d0ef331ef42b02bfb46e9a277fb9320f63c0ecc977ea41b58e3e507ff2f1b2a587f6bfcb53dda3fafa5d5ddc77545fdfd57d47f5f55dddb7c4b9c47977f02d712e71de1d7c4b9c4b9c73f18df992a0edb89ddeafa4d7b1dbe47b9a792aff0a2c4765e6f5cefc9607d2867cf8963624fb8aeee05be25ce2bc3bf896389738ef0ebe25cef9c539c6c3bc3cf004164f9085271ff70f72e119c38c6706339ec9cc782630e3a962c6339219cf66663ccdcc78d633e3e9c18c673e339e99cc785e62c6338519cf44663c29663c5b99f1ac64c6b38c19cf68663c8b99f1bcca8c6716339ea9cc78d630e399c48ca79a19cf36663c5b98f10c63c6b391194f13339e05cc78d632e399cd8c27cd8ca79619cf70663c35cc78b633e3798e194f23339e06663ccb99f12c61c653c68c27c98c6721339e39cc78a631e3a963c6338e19cf2a663c9b98f16c60c6b38e19cf08663c0f32e32967c6339619cf5c663cd399f1d433e319cf8ca79219cf6a663c2b98f12c65c6d397194f3f663c8b98f18c62c653c4802711dcfd8e9304fc7f27d88aad65f563616f0e6efbff1e632f8665f69a7c0fc7baf7808d9e35dbeb581675da0375499b7ce5a79b429dd0571ae6c95f1970ec65c2338a19cf22663cfd98f1f465c6b39419cf0a663cab99f15432e319cf8ca79e19cf74663c7399f18c65c653ce8ce741663c2398f1ac63c6b38119cf26663cab98f18c63c653c78c671a339e39cc781632e34932e32963c6b38419cf72663c0dcc781a99f13cc78c673b339e1a663cc399f1d432e34933e399cd8c672d339e05cc789a98f16c64c6338c19cf16663cdb98f15433e399c48c670d339ea9cc786631e3799519cf62663ca399f12c63c6b39219cf56663c29663c1399f14c61c6f312339e99cc78e633e3e9c18c673d339e66663c9b99f18c64c653c58c6702339ec9cc786630e319c38c6727339e790e1e0fdfcf0b7968bc2aad9be67732f1ed613b84df0dfcaca73aed33ebea65d64bfce4af04ca2cea93f9d5e3757059e2b2c71763acee038d767baa4bd43b99777771df51ef64eeeabea3dec9dcd57d4b9c4b9c73f2bd2f7edf297c3685a6226b3e0d79dcbff878a6c7533ddbeddbe3fe26f07e4babdd96564928f359d06fbf07fd5cc70b344ffe72651ec68019e3a22288372ede88bf4edffbd630e9fa86a52fd6eb4d4f9a46ed43deece2bea3f6215ddd77d43ea4abfb96389738ef0ebe25ce25cebb836f897389734ebedf32f918cf1b2bd187bef64be7036f81df774cbe2846bf7a5d6f9b75d1b79189e31de0a1323f02d7a2a5cd4b9b8fcbb7ecdb24cebb836fce716ee7e91e22beb7dbd73ddea858ccc7fde5fbe93b2a16bbbaefa858eceabe25ce25ce39f97e377edfe13dc49d41fb29db3dc47781e76d0f5a78aa6778ee74c0aad34eab4e492883e772073cd4b308fcd2ba69fe006c874263d63c34961ddfcf48e55e62c248b6b7fdf284edeba5a0fd94ad7d1d001e0feda0ca533dc3f6d562d5e92587ee540663b5c5433d5d6d87e65b603bb41418b3e6a167e7883501e55e65c248b677fdf284edebd5a0fd94ad7db5008f8ffec7533dc3f675d0aad3ab0edda90cc6ea410ff574b51d9a277f85c8ac79d69a3cb126a0dc5a268c643be097a7260175a6295bfb3a083c2d1ef4f154cfb07d1db2eab436b85b772a83b17ac8433d5d6d87e60fc17610666176316b9e7526bfd6fc26a0dc3a268c646bf1ca535399803ad394ad1f3b043c3efa794fba87fdd861ab4eeb1cba53198cd5c31eeae96a3b347f18b6432eccfb0a905974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974ee1cb3e6596ff2c49a8072eb993092eda05f9ef0f99df541fba9c89a4f43fe30f01cf2a08fa77a86e3de8f58755aefd09dca60fb3ae2a19eaeb643f347603be4c2bcaf009945e7ce316b9e269327d604946b62c248b6437e79c27eac29683f65ebc78e008f8f7ede533dc37eeca855a72687ee5406dbd7510ff574b51d9a3f0adb419885d9c5ac7936983cb126a0dc06268c643bec9527153e87b821683f65ebc78e028f8f7ede93ee613f76ccaad30687ee540663f598877abada0ecd1f83ed900bf3be0264169d45e72866d159748e62169d45e72866d159748e62169d45e72866d159748e62169d45e72866d159748e62169d45e72866d1b9fbe8ac799a4d9e581350ae990923d98e78e5a90eef3b3407eda76cf71d8e018f8ffb329e740fef3b1cb7ead4ecd09dca60fb3aeea19eaeb643f3c7613b7475e67d05c82cb1911f66890d618e6296d810e62866890d618e6296d810e62866890d618e6296d810e62866890d618e6296d810e62866890d618e6296d810e62866890d618e6296d810e62866890d618e6296d810e628660eb1a179369a3cb126a0dc46268c643bea97277cefc1c6a0fd946ddcce71e039e6411f4ff50cc7ed9cb0eab4d1a13b95c1f675c2433d5d6d87e64fc07610666176316b9e4d264fac0928b7890923d98ef9e509fbb14d41fb295b3f7602787cf4f39eea19f66327ad3a6d72e84e6530564f7aa8a7abedd0fc49d80ec22ccc2e66cdb3d9e4893501e536336124db71bf3c613fb639683f65ebc74e028f8f7ede533dc37eec9455a7cd0edda90cc6ea290ff574b51d9a3f05db419885d9c5ac79b6983cb126a0dc16268c643be1972795803ad394ad1f3b053c3efa794ff50cfbb1d3569db63874a73218aba73dd4d3d57668fe346c874263d63c5b4d9e5813506e2b1346b29df4cb13b6afad41fb295bfb3a0d3c3efa1f4ff50cdbd719ab4e5b1dba53198cd5331eeae96a3b347f06b643a1316b9e6d264fac0928b78d0923d94ef9e509dbd7b6a0fd94ad7d9d011e1ffd8fa77a86edebac55a76d0edda90cc6ea590ff574b51d9a3f0bdba1d09835cf769327d60494dbce84916ca73df324a0ce34656b5f6781c747ffe3a99e61fb3a67d569bb43772af326d4f39c877abada0ecd9f031e9ae6018fafb80c2c9ec0a10f4d6398f1cc60c6339919cf04663c55cc784632e3e9c18c673e339e99cc78a630e399c88c27c58c6725339e65cc784633e3799319cf62663cb398f14c65c6b38619cf24663cd5cc788631e359c08c6736339e34339e5a663cc399f1d430e36964c6d3c08c6739339e25cc78ca98f12499f12c64c6338719cf34663c75cc78c631e359c58c6704339e0799f19433e319cb8c673f339eb9cc78a633e3a967c6339e194f25339ed5cc785630e359ca8ca72f339e7ecc781631e319c58ca788014f22b87b2c4d02febf1f6c34e6633bd8de33f933602b76f8a07bc5e7c05662f2b48ede2a1d1d7cf7ba51275fe35cd0571ae6c95f1970bcc7846714339e45cc78fa31e3e9cb8c6729339e15cc785633e3a964c6339e194f3d339ee9cc78e632e3d9cf8c672c339e72663c0f32e319c18c6715339e71cc78ea98f14c63c6338719cf42663c49663c65cc789630e359ce8ca781194f23339e1a663cc399f1d432e34933e399cd8c6701339e61cc78aa99f14c62c6b38619cf54663cb398f12c66c6f326339ed1cc789631e359c98c27c58c6722339e29cc786632e399cf8ca707339e91cc78aa98f14c60c6339919cf0c663c6398f1cc73f0ecf7c4633fe745f3fb19f8d6f3b5a08b9e12f07f7c0eec4d4f8cfb2d469a7f131891d7b766e5164fb9a5d9fdf4adeb4ff72a1e34bfb8bdf0b9070edbab3c0f9af5b378fa599add4fdf5a0bbaf74f636c707be138680edb0bc7697ae89f6b12168f9e8aacf934e4cf79d6c7533d2b71dce42731ae576b75ded26abfa55512ca9c05fdce7bd0af08fcd2ba699efc09b33047316b1eba97eb1acfbb900923d9f03d2aefc7cf5393b078f494ad7f7cdfb33e9eea19f6631702b7eeef83ee540663f582877a16815f5a37cd5f70f8ae08e2d5e26207b4b8e8e0b998672dc85faecc670b909983ce9a87c6ae136b02ca2d62c248b6f3c073297e9e9a84c5a3a76cfde325cffa78aa67d8277c10b875bf04ba53196c5f1f78a86711f8a575d3fc07b01d7261be5080cca273e79835cf629327d604945bcc84916c1781e7c3d8795295098b474fd9fab10f3debe3a79e997eec72e0d6fd43d09dca60fbbaeca19e45e097d64df397613b08b3300bb3300bb3300bb3300bb3300bb3300bb330eb32c22cccc22cccc22cccc2cc9759f3d0b3e7c49a80724b983092ed03e0b9123b4fe6be03f2e829db7d872b9ef5f153cfcc7d87ab815bf72ba03b95c158bdeaa19e45e097d64df357613b08b3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300b336f66cd43dfb020d604945bca84916c9781e75afc3c35098b474fd9ee3b5cf3ac8fa77a86f71dae076eddaf81ee540663f5ba877a16815f5a37cd5f87ed20ccc2ec62d63cf42e44624d40b9654c18c97615786ec4ce93b97f8a3c7acad68fddf0ac8f9f7a66fab19b815bf71ba03b95c158bde9a19e45e097d64df337613be4c27ca100994567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974ee3e3a6b1efa4627b126a0dc72268c64bb0e3c1fc5ce535d99b078f494edbec3479ef5f153cfcc7d875b815bf78f40772a83edeb96877a16815f5a37cddf82edd0d5992f1420b3c4467e98253684398a59624398a398253684398a59624398a398253684398a59624398a398253684398a59624398a398253684398a59624398a398253684398a59624398a398253684398a59624398a39839c486e65961f2c49a80722b983092ed26f0b4c6cf5393b078f4946ddc4eab677d3cd5331cb7733b70ebde0aba53196c5fb73dd4b308fcd2ba699efc09b33047316b9e95264fac0928b7920923d96e01cf9df87952098b474fd9fab13b9ef5f154cfb01ffb3870eb7e0774a73218ab1f7ba86711f8a575d3fcc7b01d0a8d59f334987cabf94d40b906268c64bb0d3c1ee22ee4495a3c347f87816f3ddf68f265e617b757233072d85ec93c68566ef1945b9add4fdfbafeab4cfe41f38bdb6b153072d85ee579d0ac9fc5d3cfd2ec7efad65aac36f9bee617b7d76a60e4b0bdfaf9e549252c1e3d653bdef818783e1f3f4f781ef7710e3c9f079ecfc5cf53e5a99e957abddf07ec71ad576bf5054bab8f2dad92500619bee041bf22f04beba679f227ccc21cc58c7d21b126a0dc1d268c64fb1cf0f8e83774dd479975d1fa7baaf450ff36bfadf1fbadc16b0bbdcc7a8983fc9540999707b5b13d66d8cae0ffb4dd747d6e59364fcfbc55b9aef3d23cf92b0bdce7fabeaea1b65a3cb6ef32873e5ab39b0ecd6e7862b49f69a5f91bc0e8baceebeb79d1a8ebcef8bce81d4b476e9ae173c01f018fafe3e2568ba7d5a1858f3697ebf1e5470e9e4fe2e3a9c4d8405f3e6215fbb68ed4ddd57662ac7b15dec3425f1eda40b89f1a6dd645ebd7fb82dafe5e35afc1fe81f653a3ad3a97409949b09f9a92653f551cdc7d5db8c2d8a90cfdff1363b7d75111dcdf6b4b6590af35bf18a36493fd6ffb7b98b5968edc34c376dd0a3cad9e78a2ae89913fdc86750ecdea1868866d211f7176c7e2b17d27419756a69a619ce17183affeec5ed7f2701bd63b34ab67a019c7feacded2919b66aefe0c755ce8e05ec8809b639fb2d0d2919b66ae3e05755ce4e05ec4809b63bb5e64e9c84db37bb5ebc50eeec50cb839b6ebc5968edc34bb57bb5ee2e05ec2809b63bb5e62e9c84db37bb5eba50eeea50cb839b6eba5968edc34bb57bb5ee6e05ec6809b63bb5e66e9c84db37bb5ebe50eeee50cb839b6ebe5968edc34bb57bb5ee1e05ec1809b63bb5e61e9c84db37bb5eb950eee950cb839b6eb95968edc34bb57bb6e70703730e0e6d8ae1b2c1db96996effb0051f79bc81f6ec34687668d0c34e3d8a7345a3a72d32cdff701ee35061bb7e12a8766ab1868c6b13f5b65e9c84db37cf76751f79bc81f6ec3d50ecd5633d08c637fb6dad2919b6651fd596bfc3c398fb76ff5aa4fe63bcbad39f0e098291f31e5290e2a3d8da90ac7dbdbdfaf68b5b44a06777fd3c2e7d8c3a8f191e44f98855998855998855998855998855998855998855998855998855998855998f933e3f3ccade617df857a870923d9f09e948febfcbaee63ccba68fdfad9de5b03dafcc67fdf225589f75ce9b9e331569d4ba0ccff7dbc8ded63c386f71769bb456dcbfbf56e057c1f05de0bba9ff73b3f726876c3a1d9754f8c769f41f3d781d17effc3fd7ef7c41d4b476e9a45f5b3773cf144c5d91d87ef8ad87ca79a7cddd7d5ef22ec13dcbdffbae3d0d4471ce6faee0b6c17ad1e787cbde742d7e9ba55a75b569d92506618d4f37eb62d9ae6018faffe28b07802873e341533e399c18c670c339ec9cc784a99f14c60c653c58c6724339e6798f13cc18ce731663cfd99f1f461c6d38319cf7c663c3399f14c61c63391194f8a19cfb3cc785632e3799219cf32663c8f33e359cc8c6700339e0798f18c66c653c28ce779663cb398f14c65c6b38619cf24663cd5cc78f2710f34179e61cc782a98f10c64c6f310339e05cc7812cc787a32e399cd8c27cd8ca79619cf70663c35cc781a99f13cc78ca78119cf50663ccb99f10c62c6b38419cfc3cc781632e32963c69364c6d38b19cf1c663cd398f1d431e319c78c6715339ea798f10c66c6f308339e11cc781e64c653ce8c672c339edecc78e632e399ce8ca79e19cf78663c95cc785633e3799a19cf0a663c4398f1dc66c6b39419cf22663c8f32e3e9cb8ca71f339e51cc788a18f02482bb9f5dc2e7e56e818d9eb169055bb1637d342e97caebe3ceb383ef5e77b163dd371c0ca8d335a84bdae42b3fddd4eeb9a222b35e9a277f65c0718309cf28663cfd98f1f465c6f328339e45cc789632e3b9cd8c6708339e15cc789e66c6b39a194f25339ef1cc78ea99f14c67c63397194f6f663c6399f19433e3799019cf08663c8f30e319cc8ce729663cab98f18c63c653c78c671a339e39cc787a31e34932e32963c6b39019cfc3cc789630e319c48c6739339ea1cc781a98f13cc78ca791194f0d339ee1cc786a99f1a499f1cc66c6d393194f8219cf02663c0f31e319c88ca78219cf30663c3799f15433e399c48c670d339ea9cc786631e3799e194f09339ed1cc781e60c6338019cf62663c8f33e359c68ce749663c2b99f13ccb8c27c58c6722339e29cc786632e399cf8ca707339e3ecc78fa33e3798c19cf13cc789e61c63392194f15339e09cc784a99f14c66c6338619cf0c663cc5cc78e6593cf87f7dad81ae2f5e071bfdff3fcdcdfb72538feb96bf18ea5119f56d1e5f9ae194766812f56d1e0e3c3398f18c61c63399194f29339e09cc78aa98f18c64c6f30c339e2798f13cc68ca73f339e3ecc787a30e399cf8c6726339e29cc782632e34931e3799619cf4a663c4f32e359c68ce771663c8b99f10c60c6f300339ed1cc784a98f13ccf8c6716339ea9cc78d630e399c48ca79a19cf4d663c15cc780632e3798819cf02663c09663c3d99f1cc66c69366c653cb8c6738339e1a663c8dcc789e63c6d3c08c6728339ee5cc780631e359c28ce761663c0b99f19431e34932e3e9c58c670e339e69cc78ea98f18c63c6b38a19cf53cc780633e3798419cf08663c0f32e32967c63396194f6f663c7399f14c67c653cf8c673c339e4a663cab99f13ccd8c6705339e21cc786e33e359ca8c6711339e4799f1f465c6d38f19cf28663c450c78a2be8543ffef01b6ab267f1b6c574cfe26d82e9bfc75b07de8b0153b58c8df55b0d138972b60a37b7597c146d78bc8973edebd38f86ed662479d7a3858af38ea74d5b12c6e475a261dc4bb1dd1571ae6c91f7eabe72a139e51cc78fa31e3e9cb8ce751663c8b98f12c65c6739b19cf10663c2b98f13ccd8c6735339e4a663ce399f1d433e399ce8c672e339edecc78c632e32967c6f320339e11cc781e61c6339819cf53cc785631e319c78ca78e19cf34663c7398f1f462c69364c653c68c6721339e8799f12c61c6338819cf72663c4399f13430e3798e194f23339e1a663cc399f1d432e34933e399cd8ca727339e04339e05cc781e62c63390194f05339e9bcc78aa99f14c62c6b38619cf54663cb398f13ccf8ca78419cf68663c0f30e319c08c6731339ec799f12c63c6f324339e95cc789e65c69362c6339119cf14663c3399f1cc67c6d383194f1f663cfd99f13cc68ce709663ccf30e319c98ca78a19cf04663ca5cc782633e319c38c6706339e62663cf32c1ebca6580936ca57818df229b051be1a6c94af011be5c7818df2e3c146f90960a3fc44b0517e12d8284ff78cf0f99e7cbc178e7cd1ba69fe1a30de3679dc2694af03ee0f2c9be6bee489fb038b9be62f0123d5e103b051be1eb82f5a36cd7dc113f7458b9be62f0023d5e122d8283f196c949f0236ca4f05db54f04736ca4f031be5a7838df233c046f99960a3fc2cb0517e36d8283f076c949f0b36cacf031be5e7838df20bc046f985e6576fe3f72d9bdec6e74d3e1dc4bb8dc917ad9be6cf03236deff7c146f945c0fd9e65d3dce73c71bf6771d3fc3960a43abc0736ca2f06eeb3964d739ff1c47dd6e2a6f933c04875380b36ca2f01eed3964d739ff2c47ddae2a6f953c04875380d36ca2f05ee93964d739ff0c47dd2e2a6f913c04875380936ca2f03eee3964d731ff3c47ddce2a6f963c04875380e36ca2f07eea3964d731ff1c47dd4e2a6f923c04875380a36caaf00eec3964d731ff2c47dd8e2a6f943c04875380c36caaf04ee83964d73b778e23e6871d37c0b30521d0e828df2f83efa359e186f5b8cb72ddf781f178f2d0f5836cdf8ae27c6031623cdbf0b8c2d267f00780e78e269b1786cdf49d0650d53cd92606b019e5a4f3cd72c9e6b961638de0dcf05d658369fdb758dc548f30780b1c5e4f3d1365b2c1edb771274a965aa59126c2dc053e789e792c573c9d2029f73c173b75acbe673bbd65a8c765f8171867d85afb6d962f1d8be93a04b1d53cdb0cf6d019e7a4f3c172c9e0b96166590c7f3c73acbe673bbd6598c765f8171867d85afb6d962f1d8be93a04b3d53cdb0cf6d019e164f3ce72d9ef3966fdc8678bebfd0b2f9dcae0b2d469ac73ed76e0ba5908f9ba7dee2b17d27419716a69ab9da82cffeec9cc573cef28ddb10afcf2cb26c3eb7eb228b91e61702638bc9e3365ce489a7c5e2b17d2741977aa69ab9da4229b0c5cd73c6e239636981e3f6f07a5abd65f3b95da3fa8f45c0d862f2f9689b2d168fed3b09ba2c66aa191e43b6004f8b279e5316cf29cb376e43bcfeb9c4b2f9dcae4b2c469ac73ed76e0ba5908f9b67b1c563fb4e822e2d4c3573b5059ffdd9098be784e51bb7215eaf5e6ad97c6ed7a51623cd2f01c61693c76db8d4134f8bc563fb4e822e8b996ae66a0b3efbb36316cf31cb376e43bcbfb0ccb2f9dcaecb2c469a5f0a8c765b28857cdc3c51fd19f94b822e2d4c3573b58552608b9be788c573c4d2a20cf2783fa8c5b2f9dcae2d1623cd2f0346d2aa05785a3cf144c519f94b822ecb996a96045b3ef69b872c9e43966fdc8678ff6e8565f3b95d57588c34df028c765b28857cdc3ccb2d1edb77127459cc5433575b401d1b807ba565f3a9ed4a8b9be65700e362878e2b3df144f5292b41c7064b476e9ab9e211756c04ee06cbe653db068bbbc1d2d6158fa5908f9b27aa5d37808e8d968edc3473c56319b0ad02eec596cda7b651eda80118975bdafadcef456debc5a023e9d2c85433bcae89db9ad8560377a365f3a96da3c56db719dcd6d8661a3df1446deb46d0917459c55433ec7bf07cc8d7f947d4fdae7cf88eba07920fdf51d7c5f3e13bea5a693e7c47dd47cf87efa86b2af9f07daff36c9fbea3ae59e6c377d4795f3e7cdfb67cdfcea3efa8f16ff9f01d3526aaabb76fd99774af7dc9fdecd7baebbe44fa739efdf9eaf87da71241fb731a3d1559f369c8e3f9cb2a0f5a78aa67259e137e12e37a5de7d6cb2dadf0dc1acf517d9dffadb678689efc152233c645517cbe2bf13a0c7edf91ae8b54828dae8b55818dae8ba6c0d662f2d560a37b323560a3fb81e3c046f7a2e7838dc6412c001b8dc1b900361afff53ed868ece179b0d1b8d7f7c04663aecf818dc6fb9f051b3d6b72066cef98fc69b0bd6df2a7c0f696c99f04db9b267f026c6f98fc71b0ed37f96360db67f247c1f659933f02b6bd267f186c7b4cfe10d8769b3c5e7bdf65f2782de733268fd7f25e37f9f160db69f213c0f69ac94f04db0e939f04b6ed267f1b6cdb4cfe0ad8b69a3c7e5f748bc97f00b6cd267f096c9b4cfe22d8369afc64b0359bfc14b06d30f9a9606b32f934d8d69bfc34b0ad33f9e9605b6bf233c0f6aac9cf04db2b263f0b6c2f9bfc6cb0bd64f273c0f6a2c9cf05db0b263f0f6c1f9bfc41b07dcee4f13a68b1c9e3f57b7adf14def3a2775ee23d4f7aaf34de6fa76f7fb4808dbeaf85e38c4a4d1ec7b8d17ba5707c25bd4b12c7a9264c1ec79597993c3ed340dffdc06743e8db51f85c52b9c9e33371f4cdcf0360a3ef92be0b367af7d43b601b60f26f838ddee9fc16d8e83b176f828dbeddf406d8e87b9ffbc146ef98da07b6c74dfeb3601b68f27bc136c8e4f7808dbed1b41b6cf49dc85d60a377497d066cf47ec4d7c15661f23bc136d4e45f03db5326bf036cf4fdc5ed60a377466d031bbd77702bd88699fc16b0d1f70e36836db8c96f021b7dc76b23d8e8dd50cd607bdee437806d94c937816db4c9af071bbd9b671dd8c69afc5ab0d13efb55b0d13efb15b0d13efb65b0d13efb25b0d13efb45b0d13efb05b051dfff31d8a8efa7fe43b753dd7e6f99f97410df7194f6d71ab49fb21dcb1303f2c4796c9c041ef47533f6baa7c2e3f08fccba8acd7a295e6e82efebb1fbce9c03dc30ebea69d67bddf25d02654a07b66d9b6bf0ff34d48196c332b46e9a1f03cb5eb3d65d6eea7bc3537daf5b4cc47d0398a84cd9c0b6b25f32f952582646b6f07c96622d000d714a439e18fc68950acf2f3eca81e706f0c4df4e32e7d73e6202db56dce7d7f675193bd69250e63ae8e7ebbd58372c1e9a277fc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc2cc9f59f3d0fd04624d40b95b4c18c986f7ba7c5ce7c77bae78cfebe6c036bfbeefeff532eb1d6bd5b904ca7c6b601bdb6d932f83ffd3768bda961eee1366dd96dfbb5706f5c17b411eb665c873d3e2b17d9739f4d19a5d736876d513a3dd67d03c7ef385f4bb063cbedae3758bc7f68d7dc60da69a45f5b33ec625648b33d718848ad87ca79a7cddd7d563a1f4580e7bff75cbd214c740e03df32f419f44cbdc31bf09d0e70ee8733ffb007b5c02f653adc0187fbf996a770f98fafe3196a63806e2b78cb6340622fe7e2055e9731f416dd41e5b8175a532bf0ffbb93f34791c07740bd6f515c7ff69ca362601fbd4cbf1d739dcbe1f9a75d1f6bdecf0fd01b0c6e4bb0a7d1799447ec85e02f92f0f6c2b6b7f678ab42676fc1616b2dbcbb55acb25a1cc1547fdd341bcf5bf6cf15cb69875ecfc09c4d957e058cf579f742542a331a01195c1635e5ffbaf8f2c1ee2207fd88ff6b6cad0b22550e6ebd047e9ba503fdf6a7ea3f601be8e17a2f60178bc60ef17128e3aeaf8b835a08db7bb8ff5fb2fe82faec1ffd3c1a71febf75f1043aee3525aff58583f71f50ea2f72d54e67f59fb511fe793b82d6d3d712c2195f97fd00fa50665f2b99cd7ddaf73f4a8f33a1fdfcec4730d9ab2eddf711fe3a37ff154cf4ad7beeb9a55a724941906f5f4701ce3dc6fd1fc65f0edeb7ba9e4838ea1ae5b5a944099a4693bd47744e988d7256ee4a52e29e7f1e058475da8cc00a84b29d8e364f2b9ddf0384baff7a6a3ae54e6b1416d65079a7c02b613f6a5231cffa7295b7f40fae93a5f8cbfcee1f6a5e71669fb5e74f87e1f5863f2ddeefd1574bc4f7ec85e02f9e183dacadadfee24adf15bacf47c1db2dbcb5db7964b42994b8efaa78378eb1ff59d59f2a7636708c419c591cf7ef35284466341232a83f70aeceb2d51fb7d1f63e9b3edf76f02a3dd6fe2b18b4f36fb9cc5be5eee3a1ea43278ce426526403f9b7094f57f1f20736c83f5a27a04565d03abae9e8e5f6b8a2c3dd3e06734d8293e4967fa1f1ee3529969d6feccf7756ce2a67ae0fdbaab16f7354b57bc16351bb875dcdbe716789ceef99cb6068fc5ece3a1abc04e65165ac743f671dc6d475decfd747170f7b9e02756597c3629db7276fe236b19bc66e0ba268b7ddf1560499b7ce5a799aa2a2b91a9d8a185ebbea9ab4fa2768031675f47196dad07afa3acb1fa24bbacee936afbb7e943db11afb5dbd7df3d3d9b16b6b95b56fd6d8d3463abc9e336f4710fa33b3e9b561adb7a27ad2fc4f10ca5563e1edfa90db8afc8a6c555078faf6b9a515a5c75f88e4f8bf14daefd874b8b2b0e1e5fe798515a5c71f88e518b8dae6b0b2e2d2e3b787c9d6b446971d9e13b3e2d26b4bbae914d8b0f1d3cf15fd3c8ae05de13cb85f90a03e6522b1f8fef9af5ae7b772e2d3e70f0f8ba7717a5c5070edff1695135de75ceeed2e29283e7529eb5b8e4f01d9f161327b9aea9b8b4b8e8e0f1707d2dab16171dbe638c8b66bcbe964d8b0b0e9e0b79d6e282c3778cc787e3b35d33442dde77f0f8baf617a5c5fb0edf316ab14efb3edf012dce3b78cee7598bf30edff169b17e9cf6fd5e07b478cfc1f35e9eb578cfe13b3e2dd64dd4becf75408b730e9e7379d6e29cc3778ce750615c9ced8016671d3c67f3acc55987eff8b4d8101e6b9de98016671c3c67f2acc51987eff8b4a80cf7a9a73ba0c56907cfe93c6b71dae13bc6b808cf274f75408b530e9e5379d6e294c3778cfb91302e4e76408b930e9e9379d6e2a4c3777c5a6c0caf3f9de88016271c3c27f2acc50987ef18afb9847171bc035a1c77f01ccfb316c71dbee3d3a23adca71eeb8016c71c3cc7f2acc53187eff8b4680eef891ded8016471d3c47f3acc55187ef188f3bc3fee24807b438e2e03992672d8e387cc778dc195ebf38dc012d0e3b780ee7598bc30edf31f69de171e7a10e6871c8c17328cf5a1c72f88ef1b833d4e26007b438e8e03998672d0e3a7cc778dc19ee475a3aa0458b83a725cf5ab4387cc7181761df79a0035a1c70f01cc8b316071cbe63bcae15f69def76408b771d3cefe6598b771dbe633c1f09aff1bdd3012dde71f0bc93672dde71f88ef15e51780cfe7607b478dbc1f3769eb5781b7cfb1867825ad058ac5196162550e681c1995f1a8b15a523ad039fa1c5babc157b5d32e3cade8ca8cb5b50172ad317ea520af638993cd5358c19fa96028d4d6f75d495ca3c3cb8adeca3269f806d721bd635ccf17f9ab28d4122fd749df7c55fe73056e91b10b47df7397cef05d6987c57a16f1a9b4e7ec85e02f96707b795a572a407694decba8dd0373090dd5eee6d6bb92494d9efa87f3a88b7fefb2c9e7d1673f8dc03c419c5919fbe2bc3b43f42a351a01195c1317bad9e78ec3184c441fe7419dafebdad32b46c099419037d148e2ba57a2682bbc74deafabde1a97ee48bd64df3e42f09b61bc068d751c7c74330f693be0142df07d136fade077ebf6bbc65d3759de0a9aee48bd64df3138091be3f323eff8ca98e328eb31835cf240f9ae1375568cab6bf98043c133df078aa67b81faab5ea34c1aa5312cae0b38db51eea59047e69dd345f0bbe7d6c73d482f6c9c32d2d4aa0cc42ebf8314a475a878edff18ebaf8d2719cc533cee17bb2671d69ddd4274ece83ef3acb778de55bb76d8c313d656bdb75c05cef8159af774afceb0ddbf654b32e8a67f25303754a830671d5097d1759eb267b09e49b06dfcd407ad0be93d8753bc2d8895a6e92b55c12ca4c76d43f1d73fda7583cb88df5a48f1b5e84e34a0fed218c81c91607cdd780765322b49b0cda5119dcf75679d2aedee2a1f92ae0a1e3ab5ab0d1710a7ee392fe9fca03b7ddefd53ab8c986df3cac72308e8f9f313cceaab218697e3c3092ad1e78ea3c69666febe1963e784cd0db2a43cb964099fdb05f4e38ca86cf1d17b5d58bbea5f9498cf5d2ebede5412ffcce6700fa04968634114369d0f62dd038791e08dabef5b97bcfce5deb36352f6bcedcf624b4120b137f8b1cd528061be67b386c41d0fe93a62560a34f9af6045bb1250b7e4a95cad3a7137dc8857ad0ba4b2cce526089d3377e0e96a66ca1d31b787c84b20e1dfa24ac099dc65d5bf634637cf4b4383b133bfa7f3db2948b5a17c5418987ba2313ad9be6c99fd6873e8ffbfabaa66dd3766ddabba3f9b53dbb11d66e5c982fb244b07f5dcb60906063a2f5f4b4c4e913bf3835d8786dbe00fc05c012189ed2f879c240a56f0837addbbe7dc9def5dbb734cddefb5ad39e2d3b5f43457b5bca45a96d37793db9ba3a2c6b97efe5b0d9137eb1b937d8e88bcda56023ff7dc0461c0fc0ffec2de1a54d0c83f55318ebff95980af73215a210a4dd90ee4f749bd1af4dd5bb7ffd8968fd4968bdf9f4dbe2f4279ef5279df5279cf5279bf5279af52799f5db24f413defac8614890f984f29341e615b14383cc2790f5278f9f09da3e69aca7df055efd09637da8a13f51ac3f49fc7c90b954383ac8bc564dbfc6421fb2ea432b7d98a74f6bf421b83e2dd7875efa7281be74a40f63f421a23efcd1872cfa105c1f7a4f355a4f0b329f34d79f309f19643e51ae3f49ae3f413e37c87c627cbe4a0b82cca7b6170599cf07ebcf87ebcf76ebcf79ebcf7cebcfcfebcf82ebcf85ebcf88ebcfcceb4f0feb4fd0af0e329fda7e29c87cb6f89520f399e3b541e6b3c8eb83cc6794370499cf2eebcf31ebcf346f0e329f75d69f7bde16643e0fbd23c87c4e5a7f665a7f7e5a7f965a7fae5a7fc65a7fde5a5f72d7b71af425787d795b5f7ed5b740f4ad1f7d6958dfb2d4b770f52ded962033e4e150901912a38708e921537a08991e527722c80cb9d44350f5905c3d44590fd9d643d8f5907efd88837ee4433f02a31f09d28f48e947c6f42374fa3148fd58a17e4c563f36ac1fa3d6977df523e8fa56a0bedcdb1a642e09df09329f5ffe9c4a9f57e9fb54fa824adfafd20fa8f4832afd904a3facd21755fa11957e54a51f53e9c755fa09957e52a59f52e9a755fa19957e56a59f53e9e755fa0595bea4d22faaf44b2afdb24abfa2d2afaaf46b2afdba4abfa1d26faaf45b2afdb64abf1364e2f1f754fa7d95fe40a53f54e98f54fa6395fe44a53f55e9cf54fa7395fe42a5bf54e9af54fa6b95fe46a5bf55e9ef54fab24a5f51e9ef55fa0795fe51a57f52e9ab2afdb34a5f53e9eb2afd8b4adf50e99b2afdab4affa6d2bfabf42d95fe43a56fabf49da0ed33e5d8790c363dce5033bf6ecf9ee61dafefa9d8b3b362c7deed7bb6bcbefd8d8a7d5bf66caed8f9d9e65d1bb7efdc870b7fd92cfcb8999fb66bd7ba372ab6bcb6a1797fc5cebd7b2a766eac58bf73ef6b1bdaed2cffb75968f0dd1ed76dd810edacb4c7a7202debd139a783cc72f4a5fa79d9ebf6448f4e08f24c67169adbc90acd357b203a0d5b9e39e6abd8bd7de79e8aca8ad7d45fb573ddb9af79c3980afcdf6e25f2ee3d15bbf7acdbb5a762e3ae9d3b2aaac6e07a17f6e94425bed8c70f4c6ff35ea24e85ca6f0eec444dbe36b0739be33f3f0de9ffeca4d3b2419da861ffce2c347e50e708d3832265d9bd77fd9e5deb9af6442f3cebd32cbca033d55cddc96af619dc0967e59d5968f4e0ce112ee88cb37d39380bfe3f4095c818d4550500", "isInternal": false }, { "selector": { "value": 2603445359 }, - "bytecode": "0x1f8b08000000000000ffed9d77741cd5f5c767654996bd5acb927b17d5658db45a49b6856d9069a677530dd896646370015bf44e1a0921210d924008e924815448ef0909a47712d220014280ff7ee7fcf21fe777dfeebb475f3fcfec6f479ebb7e23df3de76adf5cbd9dfbb9dfb9f376f6cdccee6b41106482f2631cd9c1c1de0ffe7fbf7d2eecdba32bc1751524393329e1ac4b09e7b89470d6a784b321259c8d29e11c9f12cea694704e4890d3b0d5057b3e92e69d28a06bd28cd99469da9c024d7329d374520a346d09d231464d4e09676b4a38db52c23925259c5353c2392d259cd353c23923259c3353c2392b259cb353c23927259c7353c2392f259cf353c2b920259ced29e13c28259c07a784f39094701e9a20e762e03ccc3e1f6e9f17dae745f699fb2eb1cf79fbbcd4e6586f978f20eb20eb347cceffcc8986225937598ff3bf5eb26564cbc956d8ffb5dbfff5911d49b6926c15d96ab2a3c88eb65aac213b86ec58b2e3c88e273b816c2dd9896427919d4c760ad9a964a7919d4e7606d9996467919d4d760ed9b964ebc8ce233b9fec0287e542b28bc82e265b4f7609d9a56497916d20db48b6896c806c906c886c33d916b2cbc9b6925d417625d936b2ed643bc876925d457635d92eb2dd64c364d7905d4b761dd9f58e663790dd487613d9cd0ee72d64b792dd46763bd91d647792bd81ec8d646f227b33d95bc8ee227b2bd9dbc8ee267b3bd93d64ef207b27d9bd64ef227b37d97bc8de4bf63eb2fbc8ee277b3fd907c83e48f600d983968577840f913d44f661b287c93e42f651b28f917d9cec13649f24fb14d923649f26fb0cd967c91e257b8cec73649f27fb02d917c9be44f665b2c7c99e20fb0ad957c9be46f675b26f907d93ec5b64df26fb0ed977c9be47f67db21f90fd90ec47644f92fd98ec27644f913d4df653b29f91fddcd1fc1764bf24fb15d9afedff787ee93764bfb5eddfd9e7dfdbe73fd8e73f3aaf7986ec4f8eefcf64cf3abebf90fdd5b6ff669fff6e9fff619f9fb3cfcfdbe77fdae77fd9e717ecf38bf6f925fbfc6ffbfcb27dfe8f7d7ec53ebf6a9f5f23bba9addc6e0a461efd41426352cfd0a03937c1621f16ecf9305a8cb3ffe3e776ebafb7cbfcccda35d8e506c7df68971b9df534d9e526c7df6a975b1dff14bb3cc5f14fb3cbd31cff0cbb3c03fcd900e628addff8c65957067c5c8775e06b08f6d4c4f81a7975e01b1feca985f1f1766c04df04eb1b0fbe89d6d704beacf54d60cdc89aadaf3f48aa260a1bcd7a7349afd79eb799943cef80596f8b10efe4e47987cc7a5b05784d7dd8e122980c7533c5fa5ac137d5fadac037cdfaa6806fbaf54d05df0ceb9b06be99d6371d7cb3ac6f06f8665bdf4cf0cdb1be59e09b6b7db3c137cffae6806fbef5cd05df02eb9b07be76eb9b0fbe83ac6f01f80eb6be76f01d627d0781ef50eb3b187c3c7e1e023e3ebe3bd4facc98509f81d7583f8f47a5d7f0980bbe853cde826f118fb5e05bcce32cf896406cf6e5610c61df52ebe3f1c8fc6f856df70749d57f71d0acb72fe9f5d29acd7a5726bfded239ad55c188aefd10a70fb45a6ddb095e37d385b133d6380efbeba1bd16fa723fd683df5398ddbc771c69dbab2bbc6e85f3ba1cf4393224fffe20d9fc573a3c2b1de606c85fa666bbbbb466ab7ec4aed975d0d7ad3d3ebe198b357b327008d46cafd66cd58fd8353b007ddddae363dcb158b317008740cdf6c9d46cb1a0355b9eeb0a82f0dae3cf3963b166370347f235dbab355bfd2376cdde067ddddae3cfba63b166878123f99a5ddea7c706553f62d7ec3dd0d7ad3d9e77198b357b277008d4eca08eb3553f62d7ec03d0d7ad3d9e031c8b357b2f70245fb37d4235dbad351b94cf5b064178edf17cf458acd9878023f99a1dd0f9d9ea1fb16bf6abd0d7ad3d3e3732166bf651e048be6607a5e6678b5ab3e5eb358220bcf6f83cdd58acd96fd8b63937f63b7b6e6c3ef87e6f7d0bc0f707b8ce807d7fb4be83202f817d60b9ee03553f62ef03cf405fb7960fb6edb1b80ffc1c38046ab64f6bb6ea47ec9a7d11fabab5c7d72f8cc59a7d1638046a7693d66cd58fd835fb3fd0d7ad3dbe96662cd6eccbb66d8e17fe668f171681efefd6b7187cffb0be25e07bcefaf2e07bdefa9682ef9fd67704f8fe657d1de07bc1fa3ac1f7a2f515c0f792f57581efdfd65704dfcbd6d70dbeff585f0ff85eb1be5ef0bd6a7dcbc0f79af52db73e731e8bafa97acafa9a20f7fe20b96d5bba8e2ad8f3917196fba1bd5496a7900bf6bc4f806375241fabdbe47e44507dee1dc0d329907b166254c3d3093c85e4794a9f47bb925f6f691b1fe1689a855847405e4581bc32108bd7cdcb1c2f073e1c378a218cddc9331633108bd7cdcbddc0c83e1cc7f83e1cde7fccd83c3733c22bb02f95de9f315e3f7070bc7ae833ab6da46fbb656b86fff318d00c6d1ce70b8e4fa8564bb5823767f5c3721730728e85da3316ab65ec74189b802d419e92669d0e4f678816076a6c81b1bab4ff710cdeff785fe278f5d067fcb891be3d1951b662dcf759accfe4c7ff6201f7cd6a788ac02331c608bdcf15f0bde9f520d95aeb71b42a385ae5a04f37e8d723a05fa5f74a8ea7cccaaccccaaccccaaccccaaccccaaccccaaccccaaccccaaccccaaccccaacccfe33e3f9633cdf16766e767f32b2af0b7824e6f94bdfa363d7c5eb37e7759e84f33ac99fb72816f0bc235f93b5c8c9b91efa3c9319617b3ae49c2f9edfed707c42d75c94b6255e73d10fcb1c0fcf41e3352052e710f30e4f3e440b1f62b72716bb3820b37d8b05f33d16e6bba0963adb34ecfa93258ecfd4e9c47123794b9cfb8b7b2e12c7126e27796e2f17ec7ded80cc352ee5f183c7abba60cff103df677a138fbde7394c3e5fdeebc4ae873e2f6646b6cd32f87f7fb0f77539d887d7cdcb8be0b5cb9c75b7c8e55bf1da845ee0e676a393db52e0e63eafc0787e4f5db92df41e57c4ebc302e00d9c9cf881e7ec933f06285f43508cc1d3033c02d78b75091deb14b01e93be866099a355d83114f7e905fd9609e817761ccccb1c4f99955999955999955999955999955999955999955999955999955999955999fd67c6fbbb99350bfdba3c61acd17517a5f319fcbd1c785eeca6ba91b8d2e700f99cd36227e77ae8f3adba11b6db6cbb39d8fb5a8ba86d29756e2d6a5b72bc66c807cf0549ddb3deedf0748768e143ecf6c46297af21487efb8e5c435074b66997b33df1dc39ee43f7409dbadf7191057d6a71dd52d4b6e178b82f75838fdb786fb684d6f85ee25e53c4f1f0dcf9fd565b3e779efc585d2c488e1bfc9d3f7c9d40312457eef3208c7d0fd9365e3fd205eb7a2ce4fffca8749e9af513fa7eb0d2f6e5efabe2eddb17127b25b02614bb0b6367ac711cf6d743fbd1ba91beeef75fb1d6cc6ef611f73bbac25e57705e97833e2b42f2ef0f92cdbfcfe1e973984ded7c04eaec3178ff971a935604e11a2d028db80f1e07095c67123a46bad7569a3ebcfdc73b7df09885fb3c016354d4b5ab61df7db45c28bfa8ef3ee278786cdc038c6e8eee35a607fa35624fc278b10cfedf1fecfb35624f420de1755a81b3fec5b07ee61a1f44bfb7709fa79df751a97d2bea1a34dcb7dccf03cc8bd7a0719f5fc258c53f36da1cec7dec8fd76bd5e2b35dd4f5e11c0f8fa9e2e48ee342d2ef8d588fc8c2f1b01effe4d4e3b208ee8e90d7fe25e2b5ac155f738c9f9d5cfd8c0e897f2faa1d6ffa9c5c789f5a01b9709fe79dfd46eab75d92cf75cfe3211e83ba4372e53e2fc1bef6321c5ff276c2b1f2bf21ffe747a5e34ffc2ed755c9e75cdabefc9da5bc7d5785c43e0a58138add85b1f9f893e3b0bf1edaff0bef27dc8ff560ad99ddec237c0c87eceeeb7a9dd7e5a0cfca90fcfb8364f35fe5f0ac72984dedbc0a75f65f38fe941aab574668b41834e23e784f14bf8fe0f7bb86bdc7485cef5be93d26ecfb21716c0fc6d59ecd9dd30b3b3ee13efc5a3c3e69b0cc669ccd86f475e72af93d24c96b96f11e913cc4c57b44f2427ae6823df5cc391c92b15b9cd82d358cddeac46ead616cd55c35f749739fbeff1bbfa7bb2e058ce352c0589f02c686143036a680717c0a189b52c03821058c1353c09805c6fdf9de2ea04f31097d9a41a7a521dc52f7e32f7518ddef4ac839bcccb33f8f917cdd8693ecb3cfdbb00578c6d8b16622db70b27df6791bb6caea98c878df9602c62929609c9a02c66929609c9e02c61929609c9902c65929609c9d02c63929609c9b02c67929609c9f02c60529606c4f01e34129603c38058c87a480f1d014301e9602c634cc552e91651cf5e76bc323f09b903df819bd1a1ee9efd614cab3747d165fc798f477a4b9bfebb8d4d10aef3991fe3dd84c10fd5da91c4f9995398a19c742fc1d6fee97f78431ecbb8705c68dd8ef291db23c7bfcf67687ecb688fd5e25fb9ba0e5f7aa03e13741c3ee6f09fbbe77ee83e3c6feba8e1163b707c96ad153851635ba075be4fbfa3b53c8eccb6f0cf0f814f61b03794f186bf41b03b1dfab8a213a76c8321647cb2874ff580fd64b353cf8bd18123525799f5cd4f77f703cfcfe0f1c93a4aee977ef8fe3e56abeb3248cb93b85ccaaf3e89871ccc2ef86e17e794f18ddfbae84f6efd8637f6f888e1db28cc5d132cadc675dfe7d8038f7bd2d071e899a92c9b33cf6bbf7eff73a39e1fdfb382649ddd3b8dce1e1e515b01d94599995599995599995599995599995599995599995599995599995599995d96f663cc780dfc3c5fdf29e30b20fbfbf50e2fb5de39e07591ea263872c6371b48c8647e2fb15b15eaae1c1ef0994a829993cf7fcee6d5ef77227a71cf4c1fdfb48813c3341f4f751e3f7742bb3322bb3322bb3322bb3322bb3322bb3322bb3322bb3322bb3322bb3322bb3dfcc788e8159b3d02fef0923fb56008fc07c7cec73357d213a76c8321647cb6878047ec3b207eba51a1efc4d23899a12cab374aec6fdad24f7b73a73d007f76f81dfcd0afd9d245e5e05db419995398c19c72c66cd42bfbc278ceeef010beddfb1c7fe95213a76c8321647cb68785627ce533e4fbf3206cf6ae091a829993ccb63bffbbb7d2b9d9c72d007f76fa9dfed5bedf0f072a5df1aacc4dc9d4266d559758e62569d55e72866d559758e62569d55e72866d559758e62569d55e72866d559758e62569d55e72866d559758e62569d0f1c9df11c03b366a15fde1346f6ad021e81f9f8d8e76a5687e8d821cb581c2da3e1393a719eee02d64b353c47038f444dc9e4593e57d3efe4b4dac929077d704cea17c833037179dd987760b743ff1867ee4e21b3d6466d98b53694398a596b4399a398b53694398a596b4399a398b53694398a596b4399a398b53694398a596b4399a398b53694398a596b4399a398b53694398a596b4399a398b53694398a596b4399a3987da80dbc468759b3d02fef0923fb8e029ea30578e25e477474888e1db28cc5d1321a9e35c9f3f460bd54c3b30678fa93e7e912cab374add3314e4e473b39e5a00f8e49c708e49981b8bc6e5e3e06b683322b7318338e59cc9a857e794f18715f661e81fd3bf6d8bf2644c70e59c6e268190dcfb1423c6b62f01c0b3c123525946769ec3fcec9698d93530efae0fe7d9c409e1988cbebe6e5e3603ba48d19f72566cd42bfbc278cec3b067804ea2ef698746c888e1d2960ec4c01e38414304e4c01631618f3028c191b0f7978392fab4f31097d9a41275fc7bd1cf0486dc31687a725440b5fb7e124fbecf3366c011ea96dd8eaf0b48668e1eb369c6c9f7dde86adb23a2632deb7a580714a0a18a7a680715a0a18a7a78071460a1867a68071560a1867a780714e0a18e7a680715e0a18e7a78071410a18714e637f7ecedd9f9fcff6e7e70ad55c352fecdb433557cd5573d55c350f54f3c2be3d54738f354fc36708651cdb8cdd9e32224f26399e02e68eb124ceabc4cd3dec7a94343076a78051fa3a23d53111c6e268190dcf09423cc7c5e03901788e4f9ea74b28cfd2b5866b9d9c8e7372ca411fac83b5027966202eaf9b97d7c276481b33ee4bcc9a857e794f18d9773cf048ed5f71f677dcbf4e14e2392106cf89c023b1bd84f22cedef2739399de0e494833eb8ef9c24906706e2f2ba79f924d80e6963c6fd9d59b3d02fef0923fbd6028fd4fe15677fc7fdeb64219e1363f09c0c3c12db4b28cfd2fe7e8a93d3894e4e39e883fbce29027966202eaf9b974f81ed903666dcdf99350bfdf29e30b2ef24e011a8bbd89f394e0ed1b133058cdd2960541d55479f1855c70347476554466554c6fdc19886315cdf67e2cf0de067f15393e7e9c1cf6dd5f09c0a3ca724cfd3259467696ee03427a7939d9c72d007ebe034813c331097d7cdcba7c1765066650e63c6318b59b3d02fef0923fb4e011e81fd3bf6d87f6a888e1db28cc5d1321a9ed313e7e92960bd54c3733af048d4944c9ee5b1ff0c27a7539d9c72d007f7ef3304f2cc405c5e372f9f01db210e73770a995567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da39855e7d131e335eecc9a857e794f18d9771af09c2ec013f73afcd34374ec90652c8e96d1f09c993c4f0fd64b353c67028f444d09e559ba57e02c27a7d39d9c72d007c7a4b304f2cc405c5e372f9f05db210e73770a9955e7d131e398c5ac59e897f784917d67008fc0fe1d7bec3f3344c70e59c6e268190dcfd9c9f3f460bd54c37336f048d494509ea5b1ff1c27a7339d9c72d007c7a47304f2cc405c5e372f9f03db419995398c19c72c66cd42bfbc278cec3b0b7804f6efd863ffd9213a76c8321647cb6878ce4d9ca758c07aa986e75ce091a829993ccb63ff3a27a7b39d9c72d007f7ef75027966202eaf9b97d7c17688c3dc9d4266d559758e62569d55e72866d559758e62569d55e72866d559758e62569d55e72866d559758e62569d55e72866d559758e62569d0f1c9df11c03b366a15fde1346f69d033c02f3f1b1cfd59c1ba263872c6371b48c86e7bcc479ba0b582fd5f09c073c1235259367f95ccdf94e4ee73a39e5a00f8e49e70be49981b8bc6e5e3e1fb6c35867ee4e21b3d6466d98b53694398a596b4399a398b53694398a596b4399a398b53694398a596b4399a398b53694398a596b63af8732dbb6d6863247316b6d287314b3d6863247316b6d287314b3d6863247316b6d287314b30fb581d7e8306b16fae53d6164df3ae0394f8027ee7544e785e8d821cb581c2da3e1b920799e1eac976a782e001e899a12cab374add3854e4ee73939e5a00f8e49170ae49981b8bc6e5ebe10b683322b7318338e59cc9a857e794f18d9773ef008ecdfb1c7fe0b4274ec90652c8e96d1f05c943c4f0fd64b353c17018f444d09e5591afb2f7672bac0c929077d70ffbe5820cf0cc4e575f3f2c5b01d945999c39871cc62d62cf4cb7bc2c8be0b814760ff8e3df65f14a263872c6371b48c86677df23c3d582fd5f0ac071e899a12cab334f65fe2e4749193530efae0fe7d89409e1988cbebe6e54b603b28b3328731e398c5ac59e897f784917d17038fc0fe1d7bec5f1fa263470a183b53c0d89d0246611d8ba365343c970af1ac8fc17329f0488c1f427996dee72f73725aefe494833e58079709e49981b8bc6e5ebe0cb643da98715f62d62cf4cb7bc2c8be4b80476aff8ab3bfe3feb54188e7d2183c1b8047627b09e559dadf373a395deae494833eb8ef6c14c833037179ddbcccf1d2c88cfb3bb366a15fde1346f65d063c1b92e789bdbf6f009e4d423c1b62f06c021e89ed259467697f1f7072dae0e494833eb8ef0c08e49981b8bc6e5e1e80ed903666dcdf37d8e72cf4cb7bc2c8be8dc0235077b13f736c0ad1b133058cdd2960541d55479f1855c7034747655446658cc7786c0a18755b2ba3af8c7901c68c8d873cbc9caf41ec1627764b0d63b73ab15b6b185b3557cd5573d55c3557cdf735b66aae9aabe6aab96aae9aef6b6cd55c3557cd5573d55c35dfd7d8aab96aae9aabe6aab96abeafb15573d5dc8d2d70bd69ecebb9078067938016427916cc7a07edba5e4f503fa3d590a355ded12a077d0641bf2101fdc2aeb9e6658e1797f9700f9885621727d13a2640fe1ca3dbd1c3c4df2c947bd498b7b906b1a3c6bc5ac48e1af36a115b3557cd55f30357736cd7077bdf8364d6b1c5b61bec32f73f165ec77d9e6c2e3fb704ba3d2562eb3ea49aabe6aaf9fed01c75a9ab014fe0f00415786af1f9240ecf7ccf78667ac6d3e619cf04cf78c679c6b3d0339e059ef1ccf28c678a673c133de3a9f78c67b6673c533de3c97ac6d3e019cf22cf78e678c6b3d8339e699ef1347bc693f38ca7d1339eb99ef14cf78c6792673c2d9ef12cf18c67bc673cf33ce399e119cf64cf785a3de369f28c27e3014f36d8fb9a9a2cfc7f007c75ce6bcdf8b0be6de4ff975b7f1dbc66ab6d8f0b59f7e5e0e373555b435e8b3a5d0eb9f4db7661df1e259d30563f2c73bc66e0d8ea094f93673cad9ef14cf68c6786673cf33ce319ef19cf12cf785a3ce399e419cf74cf78e67ac6d3e8194fce339e66cf78a679c6b3d8339e399ef12cf28ca7c1339eac673c533de399ed194fbd673c133de399e219cf2ccf781678c6b3d0339e719ef14cf08ca7cd339e999ef1ccf78c67c0339eba101ea9dfc5e0f94b5e372f0f78125b603b94ee5bbc4228a72bedba1aed7a999fe3d5439f9fd80f92667e045fcb5cee7c33d6ea95a0d116a15ca2ae5dde5283d851d72ed72276d4b5cbb588ad9aabe6aab96a6e1e09de53dfebf3fd167a7f43651ebdbfa1328fdedf509947ef6fa8cca3f73754e6d1fb1b2af3e8fd0d9579f4fe86ca3c7a7f43651ebdbfa1328fdedf5099c7b7fbb9f57e8bca3c7abf45651ebddfa2328fde6f519947efb7a8ccd3e4194fc6039effef7e0bbc4f82cf4d6d011f9fffaa745f4616d67325f8f8f327afc38c375bdaf666a883d76c0be1ba22241ec7d916f2da5ae88eb1fa6199e3e1fd1bdb3ce169f28ca7d5339ec99ef1ccf08c679e673ce33de359e2194f8b673c933ce399ee19cf5ccf78063ce369f48c27e7194fb3673cd33ce359ec19cf1ccf781679c6d3e0194fd6339ea99ef1ccf68ca7de339e899ef14cf18c6796673c0b3ce359e819cf38cf782678c6d3e619cf4ccf78e67bc65317c223750f45d475b4b5b87f23ea3ada5ac48eba8eb616b15573d55c353fb035df9e7cec9e6cb0e76fb69947a57373db8147e2fd4e28cfd2fd773becba12bcc7a160b4dae96835e06895833e3b40bf9d02fa65202eaf9b97399e322b7314b3897d55f2b14be30cc6667d0287871f57096b219467693cb83a08d798e3e5a00f6ef3ab05f2cc405c5e372f5f1d12bb3d48568b5d5568b12b8467578db5e078719977a490d9079d4decddc9c72e8d33189bf5091c1e7eec16d64228cfd2be351c846bccf172d007eb745820cf0cc4e575f3f2306c8738cc57a79059751e1db3897d4de2b18b85ac139bf5091c1e7e5c23ac854c9ee5f1e0da205c638e97833e58a7d70ae49981b8bc6e5ebe16b683322bb3322bb3322bb3322bb3322bb3322bb3322bb3322bb3322bb3322bb332fbcd6c625f9778ecf2fc3dc6667d0287871fd7096b21936779fefefa205c638e97833eb8cdaf17c833037179ddbc7c3d6c0765566665566665566665566665566665566665566665566665566665566665f69bd9c4be21f9d8a5fb713036eb13383cfcb841580ba13c4bf3f73706e11a73bc1cf4c16d7ea3409e1988cbebe6e51b613b28b33287319bd837251ebb7c3e0f63b33e81c3c38f9b84b590c9b33c1edc1c846bccf172d007b7f9cd027966202eaf9b976f86ed1087f9ea1432abceaa7314b3eaac3a4731abceaa7314b3eaac3a4731abceaa7314b3eaac3a4731abceaa7314b3eaac3a4731abceaa7314b3ea7ce0e86c62df9278eceed2fc3dc6667d0287871fb7086b21936779fefed6205c638e97833e58a7b70ae49981b8bc6e5ebe15b6c35867be3a85cc5a1bb561d6da50e62866ad0d658e62d6da50e62866ad0d658e62d6da50e62866ad0d658e62d6da50e62866ad0d658e62d6da50e62866ad0d658e62d6da50e62866ad0d658e62d6da50e62866ad0d658e62f6a1364cecdb928f5dba9f1d63b33e81c3c38fdb84b510cab374fdcbed41b8c61c2f077db04e6f17c833037179ddbc7c3b6c87db95599943984dec3b928f5dcc3ab1599fc0e1e1c71dc25a08e5591a0fee0cc235e67839e883dbfc4e813c331097d7cdcb77c276481b336ebf4c72b14bd76d728c3afb6c7c6fb0ed71e07ba36dd783ef4db6dd00be37db7623f8de62dbe3c17717e4c6beb7daf612f0bdcdb607c077b76d6f06dfdb6d7b3bf8eeb1ed9de07b876d5f05be77daf62ef0dd6bdbbbc1f72edb1e06dfbb6dfb1af0bdc7b6af05df7b6dfb3af0bdcfb6af07df7db67d03f8eeb7ed1bc1f77edbbe097c1fb0ed9bc1f741dbbe057c0fd8f6ade07bd0b66f03df876cfb76f03d64db3bc0f761db9e00be876d7b22f83e026d7efea86d3783ef63b69d03dfc76d7b12f83e61db2de0fba46d4f06dfa76cbb157c8fd8761bf83e6ddb53c0f719db9e0abecfdaf634f03d6adbd3c1f7986dcf00dfe76c7b26f83e6fdbb3c0f705db9e0dbe2fdaf61cf07dc9b6e782efcbb63d0f7c8fdbf67cf03d61db0bc0f715dbc6edfb55dbbe037c3c5edc093e1e2fde003e1e2fde083e1e2fde043e1e2fde0c3e1e2fde023e1e2fee021fd7dd5bc1c775f736f071dddd0d3eaebbb7838febee1ef071ddbd037c5c77ef041fd7ddbde0e3ba7b17f8b8eede0d3eaebbf7808febeebde0e3ba7b1ff8b8eeee031fd7ddfde0e3ba7b3ff8b8ee3e003eaebb0f828febee01f071dd3d083eaebb0f818febee21f071dd7d187cedb6fd30f80eb26d1c3f0eb6ed8f82ef10dbfe18f80eb5ed8f83ef30dbfe04f80eb7ed4f826fa16d7f0a7c8b6cfb11f02db6ed4f838fdfc33e03bebc6d7f167c4b6dfb51f01d61db8f81afc3b63f07be4edbfe3cf80ab6fd05f075d9f617c157b4ed2f81afdbb6bf0cbe1edb7e1c7cbdb6fd04f896d9f657c0b7dcb679fc30fba9d9df3867d6a319f23b22849b7d4dc0dd1f247b0cc6b178ddbc5c0446d6bbabf68cc56a190b0ea3e1e911d00c6b881f953ee3f4004fb7008f509ea5cf38bd4e4e4527a71cf4391cf2ec15c833037179ddbcdc0bb125b6396ad168d7bbd0d1a21efa14ec9b9c799faca423afc3d46f57482e523a161c9e4248ec15c23af2ba794c5c5183d8cb9cd89d4e6c1cf7f95169df5e06cccb0598cd7afb925f6f69df3ed2ae8beb99e374424e2b4183a472c2d8196b1c87fdf5d05edb36d297fbb11efcdec9ec663fe26d89eceeeb7a9cd7e5a0cf8a90fcfb8364f3ef7378fa1c66f3396155db0887c0fe50aa81150e072f7782767d11daad00edb84f17f8f818a7177c7cacc0ebc0632a3c8ee84a3edfd0b1a737849b7dcb8031ec58a7903c63c5639d0230b26f39f02c13d26cb9c3b3d0d107df97c73b7df8b5f5d0e722786fcc86f435b53f373392177fb67e3d48765c6d14d00b3ff707a04fe068c80f66680a46e60692e499188c7cf6df3dbc73d7c62d43670f6d1ccc005abd8389cf999034eac087ed7121be20d8738a03a750798a03a750eb1c59706a85fb9b8f52262d9e4618dabe7578dd8ea11d03bb6eb86a7868f0d49d5b90bac1a147d2a80c90147dfc680a462663fa83644f9e343ab12a154f133c8f4f9ea74b28cfd21bcf0427a74627a71cf46980ff4d10c833037179ddbc3c212476820351498b89556831318467628db5c0096df6e19ecaffc7931d754e2eb847634e6e9d279a10073c0cd69fb170e67f66676fb0c98c0f4636368f9ee6a8d26c0433136adeb5cc4ca799d934439099b93433956666d2cc449a994733d3686616cd4ca299393433856666d0cc049a99bff6a03cb36766f2ccccdda1c0f514b09a4fd4e6ddd1ccbc99993633b3668eaacc27267324628e7ecd919a3932304704e653a5996130efb4e628c6bc439b775573a4668ed0cc11b539c25c45b69aec28b2a3add66bc88e213b96ec38b2e3c94e205b4b7622d9496427939d42762ad96964a7939d417626d9596467939d43762ed93ab2f3c8ce27bb80ec42b28bc82e265b4f7609d9a56497916d20db48b629289fed1a241b0aca67b9b6905d4eb695ec0ab22bc9b605e5b35d66a6de9ce13267b4cc5536e62c96396b65ce5299b352e62c9439eb64ce3299b34ae62c92396b64ce1299b342e62c9039eb737b509ee13733fa6606dfccd89b197a33236f66e0ef0aca33ec6646fdeea03c636e66c8cd8cb899013733de6686dbcc689b196c33636d66a8cd8cb499813633ce6686d9cc289b196433636c6688cd8cb099017e3828cff09a195d33836b666ccd0cad99913533b08f04e5195633a36a6650cd8ca999213533a26606d4cc789a194e33a3696630cd8ca599a13433926606f26b645f27fb06d937c9be45f66db2ef907d97ec7b64df27fb01d90fc97e44f624d98fc97e12946bf269b29f92fd8cece764bf20fb25d9afc87e4df61bb2df92fd8eecf7647f20fb23d933647f22fb33d9b3647f21fb2bd9dfc8fe4ef60fb2e7c89e27fb27d9bfc85e207b91ec25b27f93bd4cf61fb257c85e257b2d1839538103c70b768167cd370e0f0f6dbf6ab87d7867fbf66bb60d6fbd6adb0dedd76d1dbebc7de7b543bb366fdb791dbef83e3b54f1298135bb766dbca17deb8ec1a1ebdb775e33dcbe7373fba69dd7ec18dc8d2f7adcbe68eede11370e0e4607fb51dd3e903e35caa0cfd8d7f1c996932ae7f6ec6804796e342faa1f374a15ed29ac5576f99cf2116efbee6d3b87db0bed3be8efc66df49aa1c18e76fcdf6e1279f770fbeee18dbb86db37efdab9bdbdab03d7fbe3dc2892e86c1bc58b2e6cab3ef3e0ff009826ecb5716c0300", + "bytecode": "0x1f8b08000000000000ffed9d69741cc5b5c77b24595e46832d5bde37b1056fb246a3dd968d8cf70dcc8e018317c960b02d638b7d271b092121fb4202bcac2421fbbeef09d9f7852424908484247c7839efbdf3ce791f38afaa5537fa4f51dd6886be72b5e6f639d7537d55d3f7776fdfaaeea9aa6e3f1304412618daaa959c143c77a3bff79acffc0bdb5a123c569e93339312ceaa947056a784b326259ce352c2599b12cef129e19c9012ce8909726ab6aaa0784b9a7712435c9366cca62ca6752988692e65313d2105319d1ca4a38f9a9212cefa94704e4d09e7b4947036a484737a4a3867a48473664a3867a58473764a38e7a484736e4a38e7a584737e4a3817a48473614a381b53c279624a384f4a09e7c929e13c2541cec5c079aaf97c91f93ccd7c2e329f547789f95c6a3e97191f6bcc7e9392e54a9a359ff5373dd15050d2aaa4cdfa5bbb920e259d4abaccdf1acddfba95ac50b252498f92554a562b39ddc4628d923394ac55b24ec97a251b946c54b249c966255b946c55b24dc97625672a394bc90e25672b3947c9b94ace5372be920b945ca8e4228b65a7928b955ca2e45225bb945ca6e47225bb95ec51b257c93e257d4afa95ec577285922b951c50729592ab951c547248c96125034a8e28b946c95125c7940c2ab956c9754aae57728315b31b95dca4e46625b7589cb72ab94dc9ed4aee5072a792bb94bc58c94b94bc54c9cb94bc5cc9dd4a5ea1e4954aee51f22a25f72a79b592d728b94fc96b95bc4ec9eb95bc41c91b95bc49c99b95bc45c95b95bc4dc9fd4ade6e58a821bc43c9034a1e54f29092ff50f24e25ef52f26e25ef51f25e25ef53f2b092f72bf980920f2a7944c987947c58c947947c54c9c7947c5cc927947c52c9a7947c5ac967947c56c9e7947c5ec917947c51c997947c59c957947c55c9d7947c5dc937947c53c9b7947c5bc977943caae4bb4abea7e4fb4a7e60c5fc874a7ea4e4c74a7e62fe46e34b3f55f23353feb9f9fc85f9fca5f9fc95f59d5f2bf98da57b4cc96f2dddef94fcde941f379f7f309f7f349f4f98cf27cde79fcce79fcde75fcce753e6f3afe6f36fe6f369f3f977f3f90ff3f94ff3f98c92fe86a1f2846078eb0d12ea93dafafbf4dc0405fbd4a078d3b1a8367fa3cf46a3af31fbf449b11b67f6c759fa5ab35f6b1d6782d99f60e9ebcd7ebda59f66f6a759fae9667fbaa59f69f667823e1bc018a5d16b5db551654047795805ba7141714cb4ae960e07baf141712cb48ece632de8261add78d04d32ba09a0cb1add448a99923aa3eb0d92ca89fc1e7ddc5cd2c735f3362724cfbb4f1f773213ef94e479fbf571eb1978757e4c35c79a027933cde8ea4167ba95602ae8a61bdd34d0cd30ba06d0cd34bae9a09b6574334037dbe866826e8ed1cd02dd5ca39b0dba7946370774f38d6e2ee81618dd3cd02d34baf9a06b34ba05a03bd1e81682ee24a36b04ddc9467722e84e31ba934047fde7c9a0a3fbbb538c4ef7093519f88ed1537f147e87fa5cd09d46fd2de816515f0bbac5d4cf826e09d826dd52e84348b7cce8a83fd27feb32e5de20a9fc2ff4e9e376277d5c75647ddc95c91f379cd3ea0986e3da0b76ba2156ab4c39c175332d683b6384ec90be06ca1ba12ed5a378d03585d8f5b5638529af8af95e97f5bd1cd459e1f0bf3748d6ff9516cf4a8b791cf8cf93b3ad2d92b323de4aced9f3a1ae9d7b747f331673760b7030e46cbbe4ec88b79273761fd4b5738fee71c762ce5e041c0c39dbcd93b385bce4ecd0585710b8738f7ee78cc59cdd0f1cc9e76cbbe4ecc8b79273f676a86be71efdd61d8b393b081cc9e76c67b7dc1b8c782b3967ef85ba76eed1b8cb58ccd9bb80832167fba49f1df15672cede0f75eddca331c0b198b3f70147f239dbcd94b3ad92b3c1d0bc6510b8738fc6a3c762ce3e001cc9e7ec3e199f1df95672ce7e06eadab94773236331671f018ee473b68f6b7cb620393bb45e2308dcb947f3746331673f6fca7a6eece7666e6c01e87e61740b41f74b586740ba5f19dd89e017431be8943630e2ade436f06ba86be7f249a63c16dbc00f80832167bb256747bc959cb34f415d3bf768fdc258ccd9df020743ceee959c1df15672cefe17d4b5738fd6d28cc59c7dda94f5fdc2e3e67e6111e8fe60748b41f747a35b02ba278c6e29e89e34ba65a0fb93d13581eecf46b71c747f31ba66d03d657479d0fdd5e85a40f737a32b80ee69a36b05dddf8dae0d74ff30ba76d0fdd3e83a40f78cd1751a9d9ec7a235558f1add04f0bd3748eedc86eba882e22d63edf74279192f4f3e17143f2740b696276fab55fbde148cdcf7e5c0d3cce07b166c8c84a71978f2c9f384bf475b923f6e788e9bac9866c15613f85560f02b03b6e8d8b44ff672a0c37ea3e0606c4d9eb190015b746cda6f0546d2613f46cfe150fbd17df3bccc302f435b0aafcf68af1738c85e0dd4c9340cd76d346c75f077ea03eaa08cfd7cded231e56a982bf870562fecb70023f9981f7dc6c248199b2d46ae7e2303b6e8d8b6ed3a477c74cc5a1d316b63626cb51869bf0d18297eada3cf581829a3dd2f30f5492d23ed93282ef9d18fd988ce6b0e7478afd7e6606c4f9e313caf6d1623edb70323e90ac0c3753d8c6aafbed8e6b80fc17ca66b165d7fc85e0dd469ad1eaebb09aea70c7d68a1d47b53ecd3933f4f853c5ecf46c2c37cee5a98f2318f7de7b341b2b966b7f9bc152b6cf3d89773f593517d39d91366611666611666611666611666611666611666611666611666611666611666ff99a3e6e55ceb198e2723e95a8087639c3f7cf7943916ce013d06f33ac9cf5b14f238574feb1817593ed7409dffcd0cb33dee58278173e7cb2d1dd33aa5f05ce23aa55ed8277bb86e03d74d31ac3d0979965a3cb6ed3a477c7c5c47e2d31a8da8755a3ec52c073a5c0fd7c4c41395674d0edb8d89d92eece3693b85bc7ecf8f7e571ef527761bc1b56f4b2c9dee933aaa87fde6c88152e79df1ba41e524e77131dfd056f2eb6d0a45eb13aa82e26b05de5330ac51299aafa6b511ed96ed1aac5315fcfbdc74c0df7b83e7ae11c23a746cda5f04dfedb08e3d99cfdfd8feb01db8a95c6bf9b60cb8a9cea4aa611f3f67ca4cf733055c3f1b006f60f9441baecf48fe7e6f68bd48a1049e36e0e158bbc6745f9bc77c4c7abd4887152bd7fd32d56987f87530c42f6ecd1ad91366611666611666611666611666611666611666611666611666611666611666ff99f1fd17c48acf48b778c2384a6b6cc2f90c7a6f11ce8bdd5f356c977b0e90e69c165b3ee333ca4f570db33d68caf88e00d7f3ee782eb9e6d6a2ce25d9ab0b9efb9c3ed3b91cf1bb1fda1c31eb70c4ac9389d1ee3368bf1318297e1dc0c3d51edb2d1edb36f6196d9ec62caa9fe55abf129567ae750a8d89d91e5a2fc231af4beb45eceb578b15535c27413a9c07c777abe07a2cdfdeff62af5dc07e0ad76825df6f168ae680edb582640fd7497cc3c496d64924df0f14f29cd7086aa3b426a4e0f095ea3c0ad7b9ef9932ae156a81633de6f83b6d716b12b04f65785766787ee9dd8d747ebb1db657026b42b65bd076c608d9217d0d947f53355cd77e1724c59ad8751bb1df57e9fa5edefa5e0eea7439fcef0d92f5bfdbe2e9b69875eefc10f2ec31b8d7e3ea93ba02778c16418ca80edef332ac2972f691f69a695d87ceff78ab0ede9f529d27a18f8a5a93ee7a0f20d7fd42d47b00f17ec1754f63fb68af1daff4f580ff82fea203fede1bbcf0f580ff821c72dd97d2f117c3f1896b7c107d6da13aff635d47b9dad6f3bdf7caf5db8f7871bd21d5f93fe8ab969975b951bf635ccf5970fd6e887aee83ece13d5529be63bf90f4b511f31159c81ee6638d8935e5634704f772c777c7477c976245ebcbf177b21d3f1d87c4df116efa9b6ecb176a535de0cbbfafdfe00bcf3dd3d0fd67f2be16df0f511fd4eaf095ea4c8577c135987216ce13f695273bfe4e5bdcfd27bed7bc27799fc3f34befefa6f3dbe3b0bd1a5813b2dd82b6e9fe93ec90be06ca27550fd7a57a140f8a35b1eb3642f770c86e7fafddfa5e0eeaac74f8df1b24eb7f8fc5d36331ebdc99097976323c6bc1d557af8c88d1628811d5c1671deddffff85b1eaf31c7ebb73cbef313fbf66510d3d17a67aa3d7eebba3f596cc518ef4f5aa09fcd3aeadae3d2740d49727d3a3e0fb414ece2f3404b99e2990b8ae399b338386d4fb66c4f1e45dbf596edfa51b42d319798fb14739ffe2f0cfc3f2baa52c0589d02c69a14308e4b01636d0a18c7a78071420a1827a68071520a18b3c0783cafed0cf12978f6ff3dc5de6ba06d86f73984b158168c3c164dbc3cb1f73e689be11d2a25ff7f03ccff17564bb9ff17560ebe3735058cd352c0d89002c6e929609c9102c69929609c9502c6d929609c9302c6b929609c9702c6f929605c9002c68529606c4c01e38929603c29058c27a780f19414309e9a02c60929605cc2cb58289751f370bc47331b14afe37a3e1ee6f77a86ef2774bd4394e3ff9d2dd577e677fab694fb0e3c5cbfc0fbff28beb0f7f471ac4f28f53d7d71fff7341363a15c46aef526b8b665243cae3528795ec642b98c5ccf77e0f38623e171fd3fb8bccfdb0cc5ac1c46aef558a5ae17c4e7f0da1d3163602c94cbc8b5a61f9f371c098febb9c03c2f63a15c46aeb5af59b031129e2e8859a723660c8c857219999edd0a63d655020f3ee3d4e588190363a15c46cdb3822966dd25f0ac8098753b62e61323f224fdbef16e872d8e67e24af59d189071620a1827a58011d72070f45f716b10ba79e35328373e5ce72b6e0d02da667806238c05aeb97fbe58f4f0f2c4ae4140dbab986281cf443c5f2c56010fc7331a59b031121e62c8c1f7a6a680715a0a181b52c0383d058c3352c03833058cb352c0383b058c7352c03837058cf352c0383f058c0b52c0b830058cf85b95e15e31f6f7cbaa316e3beab7ca58b71df5bb64acdb963c973caf04db92e792e795605bf25cf2bc126c4b9e4b9e57826dc973c9f34ab02d792e795e09b625cf25cf7db29d86317e611c7b8cc8d3981c4f1e7d475ba77be0fbe90e9e0c93ef68abd703dfa99c36c6d529605c91024689e3d01ac4721835cf1a269ede1278d600cf194c3c6b4ae0390378d626cf13e6d41925f010430ebeb722058cab53c028719438fac42871ac9c380aa3300aa3301e0fc634f4e1729d19faed520ea3e659973c4f18b3b525f0ac8398d1f7f2bc8c85721935cffae479c298ad2b81673dc46c9d23660c8c85721935cf86e479c298ad2f816703c46cbd23660c8c85721935cfc6e479c2986d28816723c46c8323660c8c85721935cfa6e479c2986d2c816713c46ca323660c8c85721935cfe6e479c2986d2a816733c46c9323660c8c85721935cf96e479c2986d2e81670bc46cb323660c8c85721935cfd6e479c2986d2981672bc46c8b23660c8c85721935cfb6e479c2986d2d81671bc46cab2366be32ae4801e3ea143032c7b1502ea3e6d9cec4b3ad049eedc0732613cff61278ce049eb392e70973eacc1278882107df5b9102c6d5296094384a1c7d629438564e1c85511885b134c6d353c028e75a187d6564f87d15fb7cca9963dc76d4f32963dd76d4f32963ddb6e4b9e47925d8963c973caf04db92e792e795605bf25cf2bc126c4b9e4b9e57826dc973c9f34ab02d792e795e09b625cf25cf2bc1b6e4b9e47925d8963c973caf04db92e792e795605bf25cf2bc126c4b9e4b9e57826dc973c9f34ab02d792e795e09b625cf25cf2bc1b6e4b9e47925d8963c973caf04db92e792e73ed9de91bced42a9cfb0ee009eb31862c1e4675e1ff76c73ac67138c9f8ed53956acceb46295833a6743fcce61885f06ecd2b1699fec95cafc220f98996c174e50c79808fe938dd5563cb4fd73997c8feaebcf1de3b6a3fafab16e3baaaf1febb625cf25cf2bc1b6e4b9e47925d8963c973cf7c536966b82e1fb767abf923ec679a63cceec53fdd3e17b54a765fcd0e7e440da10876d694372ada804db92e792e795605bf25cf2bc126c4b9efb99e7e7276f3b9c1bc3df177a8b9b1b3b1f78ce638805939f79edd305964fe75a3ee5a00ebeb3f602063f3360978e4dfb17c079481bb3e65965cac49a857aab3c6124dd79bc3c61fb5a15146f71edeb02e06168072d4c7e86edeb42cba7558eb8531dccd50b19fc74b51ddabf10ce43da9873608f58b341f139f5819174e7f3f284edab3728dee2dad785c0c3d1ff30f919b6af8b2c9f7a1d71a73a98ab1731f8e96a3bb47f119c87b4316b9e35f077bd65a1de1a4f184977012f4f5b167ca62dae7d5d043c1cfd0f939f61fbda69f9b4c61177aa83b9ba93c14f57dba1fd9d701e8459985dcc9ae70c5326d62cd43bc31346d25dc8cad396cf82cfb4c5f5633b8187a39f678a7bd88f5d6cf9748623ee540773f562063f5d6d87f62f86f3500af3ea14324b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9ccb63d63c6b4d9958b3506fad278ca4bb8897277c7e676d50bc65acfd5e285f0c3c3b19e2c3e467b8eefd12cba7b58eb8531d6c5f9730f8e96a3bb47f099c87529857a79059e25c1eb3e65967cac49a857aeb3c6124dd4e5e9eb01f5b17146f71fdd825c0c3d1cf33f919f663975a3ead73c49dea60fbba94c14f57dba1fd4be13c08b330bb9835cf7a5326d62cd45bef0923e92e66e52984cf21ae0f8ab7b87eec52e0e1e8e799e21ef663bb2c9fd63be24e7530577731f8e96a3bb4bf0bce4329ccab53c82c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c2b27ce9a678329136b16ea6df084917497b0f2b486f30e1b82e22d6ede6117f070cccb30c53d9c77b8ccf2698323ee5407dbd7650c7ebada0eed5f06e761ac33af4e21b3e4c6e8304b6e087314b3e4863047314b6e087314b3e4863047314b6e087314b3e4863047314b6e087314b3e4863047314b6e087314b3e4863047314b6e087314b3e4863047314b6e087314b3e486304731fb901b9a67a329136b16ea6df484917497f2f284ef3dd818146f71eb762e039e5d0cf161f2335cb773b9e5d34647dca90eb6afcb19fc74b51ddabf1cce83300bb38b59f36c326562cd42bd4d9e30926e172f4fd88f6d0a8ab7b87eec72e0e1e8e799fc0cfbb1dd964f9b1c71a73a98abbb19fc74b51ddadf0de761b7300bb38359f36c366562cd42bdcd9e3092ee325e9eb01fdb1c146f71fdd86ee0e1e8e799fc0cfbb13d964f9b1d71a73a98ab7b18fc74b51dda277bc22ccc51cc9a678b29136b16ea6df184917497f3f214b2e0336d71fdd81ee0d9cd101f263fc37e6cafe5d31647dca90ee6ea5e063f5d6d87f6f7c279481bb3e6d96acac49a857a5b3d6124dd6e5e9eb07d6d0d8ab7b8f6b5177838fa1f263fc3f6b5cff269ab23ee540773751f839faeb643fbfbe03ca48d59f36c336562cd42bd6d9e30926e0f2f4fd8beb605c55b5cfbda073c1cfd0f939f61fbeab37cdae6883bd5c15ced63f0d3d57668bf0fce43da9835cf765326d62cd4dbee0923e9b09fa2ad0a18b7333106166360c507791678c633cb339ea99ef14cf48ca7da339ea59ef1747bc6d3e519cf42cf78167bc633db339e82673cd33ce359ee19cf24cf78da3de3a9f18c6799673ca779c6b3d2339e399ef13478c6b3c4339eac673ce33ce369f28ca7c7339e0ecf78e67ac6d3ea19cf74cf789a3de3a9f38c27e7194fad673c3b3ce399e719cf0ccf784ef08c67b2673ce33de3e9f48c67be673c6d9ef1ccf48ca7c5339e299ef1d47bc633c1339e459ef1643ce0c906cf5d379085bfef005d95f55d7d7dd9d030fc779aa7ad82eff49b72b5e3d87da0a379dd7ec777314e5c73cf68ab17f6c95e1d70f47bc2b3c8339e099ef1d47bc633c5339e16cf78667ac6d3e619cf7ccf783a3de319ef19cf64cf784ef08c6786673cf33ce3d9e1194fad673c39cf78ea3ce369f68c67ba673cad9ef1ccf58ca7c3339e1ecf789a3ce319e7194fd6339e259ef13478c633c7339e959ef19ce619cf32cf786a3ce369f78c6792673ccb3de399e6194fc1339ed99ef12cf68c67a1673c5d9ef1747bc6b3d4339e6acf78267ac633d5339e599ef12cf08ca7cac1b3838927ead9dd1d9ed866380f797ddcfd4c3e5d618e556b8e4bfc64af06ead49b81473ddf80df252e7bbe1dc796af801871bd372167f1d0febe316e7bb2657b7285d8aeb76cd757886dc973c9f34ab02d792e795e09b625cf25cf7db4fd6c72b6db31cfaac0960feba3e5fd49f13cf2fea4789e6acf78e4fd49f13cf2fea4781e797f523c8fbc3f299e47de9f14cf23ef4f8ae7f1edf978799f533c8fbccf299e47dee714cf23ef738ae769f28c47dee714cf23ef738ae791f739c5f3d479c693f38cc7b7f739c9fb93e279e4fd49f13cf2fea4781e797f523c8fbc3f299e47de9f14cf33c1339e459ef1643ce079bef727e17b8f68ade53ed0d17aceb8f72c65e13857808ec607e918fa7a7576c37319aae03b573ab8f63bec919d2b1ddf1d8db8a3ad5ed8277bf83ea62b3de159e419cf04cf78ea3de399e2194f8b673c333de369f38c67be673c9d9ef18cf78c67b2673c2778c633c3339e799ef1d47ac693f38ca7ce339e66cf78a67bc6d3ea19cf5ccf783a3ce3e9f18ca7c9339e719ef1643de359e2194f83673c733ce359e919cf699ef12cf38c6787673c359ef1b47bc633c9339ee59ef14cf38ca7e019cf6ccf78167bc6b3d0339e2ecf78ba3de359ea194fb5673c133de399ea19cf2ccf781678c653e5e0e17a27522e18de7a617f34dec7f47cb6f5fe52888bdeb2f0f7d1784e7287c548fbb8ce0079896729134fd473ef4b3db0adfda7df5a34679185bfe373385c39b5d462a47d574ee13ac2654c3c51cfeb2ff3c0b68e459329d31c7716fede048c5c39b5cc62a47d574ed5f3f2b465c167dae2d6f6609be338874c7ee6b1fd25f88e88bc8ed5762b564d56ac725067349e138cea0fc89e300b7314b3e6a1b11662c5ebd9683c273d1246d7f5958127ec1f9707c55b5cffb81d7838ae1f4c7e86fdd801cba7e58eb8531dccd5030c7ebada0eed1f70d86e0c928dc5552388c5550e9eab46391664af54e61d2964f621ce9a87d64e102bae276ef68491744b7979c2feb13928dee2fac7ab8087e3fac1e467d8275c6df9d4ec883bd5c1f67535839faeb643fb57c3792885f9400a9925cee5316b1e5a534dac59a8d7e20923e9b6b3f214f259f099b6b87eec6ae0e1e8e799e21ef663072d9f5a1c71a73ad8be0e32f8e96a3bb47f10ce83300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb330fbcdac79e8591562cd42bd82278ca4bb8a956768dea110146f71f30e078187635e8629eee1bcc321cba78223ee540773f510839faeb643fb87e03c08b3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3dfcc9a87dee94aac59a8d7ea0923e9aee6e5099fdb6a0d8ab7b8798743c0c3312fc3e46738ef70d8f2a9d51177aa83b97a98c14f57dba1fdc3701e8459985dcc9a87feaf0762cd42bd364f18497790956768feb42d28dee2fab1c3c0c3d1cf33c53decc7062c9fda1c71a73a98ab030c7ebada0eed0fc0792885f9400a9925ce12e7286689b3c4398a59e22c718e6296384b9ca39825ce12e7286689b3c4398a59e22c718e6296384b9ca39825ce12e728668973e5c459f3d0ff5145ac59a8d7ee0923e90eb1f2b486f30eed41f11637ef30003c1cf3324c710fe71d8e583eb53be24e75b07d1d61f0d3d57668ff089c87b1ce7c2085cc921ba3c32cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc5ec436e689e0e5326d62cd4ebf0849174877979c2f71e7404c55bdcba9d23c033c0101f263fc3753bd7583e7538e24e75b07d5dc3e0a7abedd0fe35701e8459985dcc9aa7d39489350bf53a3d6124dd002f4f210b3ed316d78f5d033c1cfd3c939f613f76d4f2a9d31177aa83b97a94c14f57dba1fda3701ed2c6ac79ba4c9958b350afcb1346d2e175b98b892767f1e41cb1385eb6f57eb729d799cf2cfcbd1b18b9fac32e8b91f631c7919778ba9978265b3c931db1385eb6b5ff2b4df904f39985bfaf0446ae9ceab61869df955393816725134fbdc553ef88c5f1b2ad63d163ca53cc6716fede038c5c39b5d262a47d574ed5034f0f134f549fd4330ab6a3dad768d88eca95d1b02d318f8e3943bb0bc7077a82e22deebe1aaf2d1c7d15939f79d7f5bbc7f209afdf788f7abcae4fc22ccc51cc4cf7b96d59cb36c527b07868bb863916a3f93bbbdbf2290dbfb3e3980fa49059e25c1eb3b67d2c79db6d59cb36c527b078683bc61c0b263fc3fe603070c798ece5a00ee6e920839f19b04bc7a6fd41380fa5301f4821b3c4b93c666dfbdac46d0fbd7f186d537c028b87b66b9963c1e3e7507f705de08e31d9cb411dccd3eb18fccc805d3a36ed5f07e74198855998855998855998855998855998855998855998855998855998855998fd66d6b6af4fdcf6d0f83ddaa6f804160f6dd733c782c7cfa1f1fb1b02778cc95e0eeae039bf81c1cf0cd8a563d3fe0d701e84599885599885599885599885599885599885599885599885599885599885d96f666dfbc6e46d87cfe3a06d8a4f60f1d07623732c98fc0cc7ef6f0adc31267b39a883e7fc26063f3360978e4dfb37c17910666176316bdb37276e7b683e0f6d537c028b87b69b9963c1e3e7507f704be08e31d9cb411d3ce7b730f89901bb746cdabf05ce4329cc0752c82c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c2b27cedaf6ad89db6e0dc7efd136c527b07868bb9539163c7e0e8ddfdf16b8634cf6725007f3f436063f3360978e4dfbb7c17918ebcc0752c82cb9313acc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc3ee486b67d7bf2b6c3e7d9d136c527b07868bb9d39164c7e86eb5fee08dc31267b39a883797a07839f19b04bc7a6fd3be03cdc21ccc2ec60d6b6ef4cde76216bd9a6f804160f6d7732c782c9cfb03fb82b70c798ece5a00e9ef3bb18fccc805d3a36eddf05e7216dcc78fe32c9d90ed76d928d2af3a9752f36e56ad0bdc4946b40f752531e07ba9799722de85e6ecae3417737f846ba5798f212d0bdd2947b40778f29af04ddab4cb91b74f79a7217e85e6dcad780ee35a67c1474f799f231d0bdd6940741f73a53be1674af37e5eb40f70653be1e746f34e51b40f72653be11746f36e59b40f71653be19746f35e55b40f73653be1574f79bf26da07bbb29df0eba7798f21da07bc0947780ee41539e08ba874c7912e8fe03caf4f94e53ae03ddbb4c3907ba779bf209a07b8f294f06dd7b4d790ae8de67caf5a07bd894a782eefda63c0d741f30e506d07dd094a783ee11539e01ba0f99f24cd07dd8946781ee23a63c1b741f35e539a0fb9829cf05ddc74d791ee83e61caf341f749535e00ba4f99f242d07dda94f1fc7ec694ef041df51777818efa8b17838efa8b97808efa8b97828efa8b97818efa8b97838efa8bbb414779f70ad051debd12749477f7808ef2ee55a0a3bcbb17749477af061de5dd6b404779771fe828ef5e0b3acabbd7818ef2eef5a0a3bc7b03e828efde083acabb37818ef2eecda0a3bc7b0be828efde0a3acabbb7818ef2ee7ed051debd1d749477ef001de5dd03a0a3bc7b10748da6fc10e84e3465ec3f4e32e57782ee64537e17e84e31e57783ee54537e0fe85e64caef05dd69a6fc3ed02d32e58741b7d894df0f3aba867d00744b4df983a05b66ca8f80aec9943f04bae5a6fc61d0359bf247409737e58f82aec5943f06ba82297f1c74ada6fc09d0b599f22741d76eca9f025d87297f1a749da64cfd876ea7babd91cf148f3af0afc9c14dba09c0dd1b247b0f46b6e8d8b45f00468a77cbe8331646ca98b718354f1b43cc3087688bfb8dd3063cad0c3c4c7e86bf71da2d9f0a964f39a8f322f0b39dc1cf0cd8a563d37e3bd8e638e7188b5a73dcd3ac58d4409d59e6e2a5af937171a463e8fc6d71f8c215c7bcc59377d8ee628e231d9bfac4ae51b0dd61d96eb66c63bf4f5b5cdbee00e64e06667ddceee48f1bb6ed15e65894cf64a7197c5a093148ca27b49d314276485f03e5e686e1ba548fe241d74e62d7ed88ce25b2dbdf6bb3be97833a5d0eff7b8364fdefb678ba2d66fd3be19486610e86f610e64097c541fbcd10bbee88d87541eca80e5e7bf34cb1ebb478683f0f3c747fd50e3aba4f217ebc9f6b1a056ebbdf6b777093ae0318f30ec6e6e4190b71d7856660245d27f07430c5cc3ed7a759f1c17b82f1561dfa6e0dd45907d7e5aca3ae6e77f332c37ed1effa678364fbf45a8678e1984300f109ac18d2460c1382e1718924792605c3e30ec706078eeeb9a2ff9cfe3d7d1940abb130f133e370a30a7458ae76e882a0787805876f697805876fabacb0e0b00ed5d73fe3b45b3484d17fe8c0e0f987fb0fef3b7ae391c1febe6d035720f5388b1e49a33c4052d4d13621181e08ea0d929db8a9b56cc525cf04f81c9f3c4f0b939fe1456fa2e553ade5530eea8c83bf4d64f0330376e9d8b43fd1613bc18e288cc5a411c462928367d228c70207d349872d95fe8e132d55962fd8a2d1273bcf1375880c9e0ac7cf1838fd37ddd8c71967c607c3279b7a4f7d47ab4f821e85d5572d3dcaaa47557517a4474df5054d8f8aea51503deaa94739f5a8a61ec5d4a3967a94528f4aea51483dead8180c8d2aea51443d6a780a703d0aacfad7bcbe3aea513f3dcaa747f5f45d95feb5a6ef44f49db7be2bd07703faae4fffa2d5a31bfa4aabef62f4155a5f55f55da2be3bd477f3faee56cf66ad52b25ac9e926d66b949ca164ad92754ad62bd9a064a3924d4a362bd9a264ab926d4ab62b3953c959c1d068fdd94ace5172ae92f3949cafe40225172ab948c94e25172bb944c9a54a7629b94cc9e54a762bd9a364af927d4afa94f42bd9afe40a255706432b78ae5272b592834a0e2939ac6440c9916068464dcfa0e919333d43a667c4f40c989ef1d2335c7a464bcf60e9192b3d43a567a4f40c949e71ba23189a5dd0b3097af640cf16e8d9013d1ba047ffef0e8646f7f568fe3dc1d068bd1e9dd7a3f17af45d8fb6ebd1753d9aae47cff568b91e1dd7a3e17af45b8f76ebd16d3d9aad47aff568b51e9dd6a3d17af4f9a1606874598f26ebd1633d5aac4787f568b01efd7d38181addd5a3b97af4568fd6ead1593d1aab475ff568ab1e5dd5a3a97af4548f96ead1513d1aaa473f3fabe4734a3eafe40b4abea8e44b4abeace42b4abeaae46b4abeaee41b4abea9e45b4abeade43bc1504e7e57c9f7947c5fc90f94fc50c98f94fc58c94f94fc54c9cf94fc5cc92f94fc52c9af94fc5ac96f943ca6e4b74a7ea7e4f74a1e57f207257f54f284922795fc49c99f95fc45c9534afeaae46f4a9e56f27725ff50f24f25cf04c3b324d871d498de8646ecf70c0ef61f3a32d83838d078e8da8383078e1cbcb1f1fa038357360e5cd77f74ffc181ebf1cb5f375fa6e98835478feeb9b1f1c0e1befe1b1a07ae1d6c1cd8dfb877e0dac37dc7f04b4f982fcd7baec53d7d7dd1c6fef38590fe779946ab4d3f48133d9be37dabad2e232075e57c295f5d9e437973a5a1d9f97387ee701b8f1d1c186ccc371e56ffee39a8bed3dfb7bc11ff764c05f9d860e3b1c13d47071bf71f1d38d4d8b21c8f3ba5ae0c27663694f1a5b50d23f73cf87f8198955c01d50300", "isInternal": false } ], - "packedBytecode": "0x000000028df71de500000036cb1f8b08000000000000ffed9d67941cc775ef7b76177176b058820824181624080220c2ec6c405884418e14b0244082020572810540805880041639e79cb34831283948b22d4759b26c59b26c39c8966c45cb564e94c40fef9df74defd0ae9aa9abfda3503d9a59740def00b7cfb93bd577abebfeeeedeaea50d55d6f0741100bb24bb99287839b17fa7fdafc266f6da98db0aca44fce58897096950867798970569408679712e1ec5a229cdd4a84b37b8970f6889053b39505372e51f3f6f410d7a819e32516d3ca128869a2c462daab04625a1594461bd5bb4438ab4b84f3ae12e1ec53229c77970867df12e1ec57229cfd4b8473408970de53229cf79608e7c012e1bcaf4438ef2f11ce074a84f3c112e1ac2911ce4125c2f95089703e5c229c834b84f39108398701e710f3fba8f91d6a7e29cf70f3fb98f91d617e471a1f2bccfa2825a3359b925aeb7f2925754aea953458ff6b543246c95825e3ccff6accffc62b69523241c9442593944c367198a264aa92694aa62b99a164a692594a662b99a364ae92794ae62b795cc97b942c50b25049b39227943ca9649192c54a9e52f2b492254a9eb158deab64a9926795bc4fc93225cf29795e498b92e54a56286955b252c92a25ab95bca0648d92b54a5e54b24e499b92f54a36287949c9cb4a362ad9a4a45dc966255b946c55b24dc9762b663b94ec54b24bc96e8b738f92bd4af629d9afe48092834a0e2939ace48892a34a8e2939aee48492934a4e2939ade48c92b34ace2939afe482928b4a2e29b9ace48a92ab4aae29b9aee4fd4a5e51f2aa920f18163a105e53f2ba923794bca9e4834a3ea4e4c34a3ea2e4a34a7e47c9ef2af93d25bfafe4634a3eaee4134afe40c91f2af923259f54f2c74afe44c99f2af933257faee42f947c4ac95f2af9b492cf28f92b259f55f2d74afe46c9e794fcad92cf2bf98292bf53f245257fafe41f947c49c93f2af92725fface45f947cd98af9bf2af937255f51f255f33f7a0ef6ef4afec3a4bf667ebf6e7ebf617ebf696df32d25dfb674ffa9e43b96eebf94fcb7497fd7fc7ecffc7edffcfec0fcfed0fcfec8fcfed8fcfec4fcfed4fcfeccfcfedcfcbe657e7f617e7f697e7f657edf56f2eb01d974f7a063490711b549f52b57ea3e140af690e0c645c7a2dcfc8f7e6b8cbec2acd32fc5ae8b59ef62e9bb9af5ae5639ddcd7a774b5f6dd6ab2d7d1fb3dec7d2f735eb7d2d7d7fb3de1ff4f1009ea51abdd6951b550c74540fcb40d725b831265ad7958a035db7e0c658681dedc7aea0eb6174dd40d7d3e8ba832e6e743d28664a2a8d2e1d445527922dbadc44d4e59afea55ed1f3aed0e55679e2ed1d3def4a5d6eb5075e5d3fee3265f5867ad3c7e8aa4177b7d1dd05babe46d70774fd8cee6ed0f537babea033cd54d00f74f7185d7fd0dd6b74034037d0e8ee01dd7d46772fe8ee37ba81a07bc0e8ee03dd8346773fe86a8cee01d00d32ba0741f790d1d5808ec6ae0c02dd60a37b08748f18ddc3a0a3367530e8e89aef11a3d3ed4497186c63f4d44665b6a176187443a90d06dd306a7f41379cda5ed03d06b6493702da15d28d343a6aa3f4ffc69a743a88ea9848658e89715197ab4ad6e536455f6ea63f6e42d011d734d81907b19a68d2118ef9a945db31236487f415909e0d79291fc583ce33c4aecf27e34d7a628eedc65adb2520cf7887ffe9205aff9b2c9e268bb90ba4fdd4d9ba94d4d9bc9782ebec5390d7ae7b74cd733bd6d979c0e1a1ce364a9dcd7b29b8ceb6425ebbeed175efed58679f010e0f75b6c54f9d4d25a5ce669f7f0581bbeed1bdcfed5867570347f475b641ea6cfe4bc175761fe4b5eb1eddffde8e75763370445f67c7b4c8b541de4bc175f60ce4b5eb1e3d8bb91debec41e0f05067574a3b9bf752709d7d15f2da758f9e0bde8e75f63c70445f67c779aab3755267836c5f6610b8eb1e3da3be1debecebc0117d9d5d21cf67f35f0aaeb39f82bc76dda3fe92dbb1ce7e0238a2afb3adbe9ecfa6a4ce66c7700481bbee51dfdded58673f63d2ba6fec6ba66fec01d07ddde81e04dd3760ec01e9be697483c02f0fc7c0583906f25e0a3e06be0579edbafc9049df8ec7c09781c3439d6d913a9bf752709dfd29e4b5eb1e8d69b81debec7780c3439d5d217536efa5e03afbff20af5df7687ccded5867697ca8be5ef8aeb95e180abaef19dd30d07ddfe88683ee0746f718e87e68742340f723a31b09ba1f1bdd28d0fdc4e84683eea7469704ddcf8cae16743f37ba14e8de32ba3ad0fdc2e8ea41f74ba36b00ddaf8cae11746f1bdd18a3d3fd5834a6ea4b46d71db8d24174fb360e31a02566ada7215deb972799001eb45517bdad3aed7b2ac8dff73ae0a9f7e07b1c6ce4c3530f3c0dd1f364c69336465f6e661fa7ac98c6c1560afc1ae3c1af18d8a2b2699dec254087c7f4180763e4e767751e8d812d2a9bd6c70223e9b08da136978e1fdd36df1febe0f5702c65cecf682f0d1c64af02f25c1ed091779061ab84ff531b5009db631bcca9ae6846aa238dc5674ce5cbd860317a3abe33316bb0785cb6c77bb26dc782ead4f822d81e6bd9aeb76c631b424bae367e2c307bb85eaf7d37aed7f1bcc5e17a3d1debc86b5f7753db53e8f5fa186b3b8ed7eb0d704ef0703c64eac0788b83d6eb21764d21b11b0fb1a33c8f828ece118da0a3b696cac0eb5b6c877d5c2fc5821bafa5d3b0dee0e01e0b8c0d0e460fd798a95c6d733d30920eefad539e6236cee219e788c59d6adb433dcd1c976483aed5e818227b1590e7b1f28ebc4ba0cdf0513ff158a025df7ba0e8f7532a734f565f000fee3b0fd7d9b59eea6312efe7df09a2ad6b769b586fc52aec9e3fe9217e58f7a96c5a277bc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc2cc9f19fbb2701c0fe56b60c2688f87f2f59c3ff3cd355316f601bde5757c502ad30f40f1a7f100c32c9f2b20cfaf631d6c6fc3f820fa3f8e7772ed4b1f632573ed4bb2e71aafe4b3bfb9cee2a973c48283ed9ac86ca756f8d9bfa9a4fee691fe6e60bdb54fedbef9ccf7082d9daea7a3ca3bfcf6d1f757685f24b625948eb26f2f013c68cbc7bec163af2cb8b1fdc0f38caf712cd456537ff978cb7605e4e95116fc66df34c1ffd3c1cded05e6a1b2697d186cdb64955de5cfdf9c6313c60337a5bb5abe350237e5e955d6e1e3274ddad3392e55e8386a6ca7a3bf06c88e214815c093041e1fe7314fd73a49ac8f518f21b0c788b9aea1280f8eaff330b631e7382fb227ccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccfc99358feb1b1494af8e096391c65d64fa33e87b4dd82ff67a59875ddf7d80d4e734dcf219df5bfd7e5907db874cba32b879ac45d8bef4d5b716b62fc99eeb3b28befa9463608bcaae75c48283ed9ac86c67c71044bf7f3bc610a4ac7d5a67ed4fec3bc763e893504fedf114f1e0e631099e8ef19cfb86ece1b184e35f288def66fb88359e4bec3145640ffbce3f63624b7de7d1b7d5a9a4cf7683be5742e304520e5f29cfe7a0edfbbc49e3f8913a28ebab8effd392ab9f9ae2a77d9e14bdcf99fd3bd99445fb7792c3761a5823b25d8bb66356d9a4af80f457ca6e66a07850ac895d1f23f8dd97b0edeaaded129067a2c3ff74c4fe4fb278701feb45d79d2f423dfb2a9cff7db549134362340c6244793c7f3fd0391ed01ed388ed68372b0f6d8bdf45fb36b4516163575de780df7ccb2828ce3980ec25829bcf0bf98c31bdd3c788bd05ed4513fc3f1ddcfa18b1b7a00ee138adc02a7f38944f5cdd82f0730be579db3a8f7a18c395d7f7715cf703c48b63d028cfff85b66ab019ab59c8fdc0bb756fe7ba1fc0edc27cc77621ea7323d64764c1efab519eff6fd5c7a610eeb18e6dff27645b8a95fdadb0cae0e6f8f9f9ce5ab6bd9964f942c7d444f085f27429eff0c5cf3553f6fad3d737e5e85a87daa05a87af94a7277c33aad2a4e3b09ff0bc30d0f17f5a725d7f52fcb4cf53a2f739b37fa79ab268ff4e71d89e06ac11d9ae45db74fd4976485f01e97bcb3bf2523e8a07c59ad82b8113d9ededc65bdb25204fdae17f3a62ffa7583c532c665d77aaa09e0d84f1f7bedaea74e08ed17088d16fec818ece23f81d50d7b30e5fe7d2b0eb387c6f8b74d8b60f869816eb9d1afb999eebfa64b8c58fd727c3a09d8d3bf2dacf2a69bb28c72ce33b22785d88ef88f8ba474a0437c6336171f8b45d65d9ae2aa2ed6acb7675116d4bcc25e69c62ce69ae08ec9b2a03461fe73a3cafe6c3e83aff9503a3aff7f8520530d601239eef88d1c377586b3b3b17055eeb7401461fefa016fabc1abfc18cef2213a38f6fe117fa3d5bfc96356dd70d187dcc71807315e4c3e89a23a33bfc7a980fa3b6b3dfcdc739327a00a38f6fe9c7831bbfffffdb18c701236dd713187df423c5831b9fabfd3646fc063b6d17f7cc98ebdcee793c48aad0671038fe029f41519c5ce3587c3dabb79f8dd13a3eab47dec05f1c735e2335f98d450ae34e4bae7de88a4f2ff31b87fffb7d9e78631f2f954deb13819174557ee398f35a7382df58a430eeb4e4da87aef8f436bff1e0e6f93f3cf5593bfb28691dfb714957ed99276ef1fcb638ba18ef02c6c99e182715c038191869bb3ec098f6c438b900c63430d2767703a387e7d519c674018cf85c97f47d8171aa27c62905304e0546daae1f30fa78f61c07bbf9304e0346daae3f304ef7c438ad00c6e9c048db0d00c6199e18a717c038031869bb7b8071a627c6190530ce0446daee5e609ce5897166018cb38091b61b088cb33d31ce2a80713630d276f701e31c4f8cb30b609c038cb4ddfdc038d713e39c0218e702236df70030cef3c438b700c679c048db3d088cf33d31ce2b80713e30d2763525c038a804181f2a01c6874b80717009303e52028cdd4b80f131607c3c7ac6ccfdf5fc02181f079e05d1f3d4c7c1463e3c0b80e73dd1f3d47af233333e6ba1292bea6fa4355bb17adc8a5502f22c84f8357b885f0cec52d9b44ef6845998c398350fb54fc41a877cf3993092ee3d9e79e2168f5e72b58fcd7e799209473cb4ad27a2b7952ad4f727806751f43c9973d51305f02c029e27a3e7a9f5e467e69cb2d8f2e909cba704e4c17663b1073f636097caa6f5c50edb3541b4b1782a8f583ce5e079aac8b1207b85322f2c41660e71c6b69058e3906f011346d23de999276ef1e82557fbe8626cf6cb98ea2ca3e659123d4fe69cf254013c4b80e7e9e8796a3df99969479fb17c7acaf2290179b04d7ac6839f31b04b65d3fa33b01f0a615e5c82cc12e7ce31639b45ac71c8b7880923e99ef6cc13b778f492ab1d733136fb654c759651f32c8d9c273b3fc03305f02c059ef746ce936dfba3f733dbf63f6bf9f48ce55302f2609bf4ac073f636097caa6f567613f08b3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300b336f66ec6320d638e45bc2849174eff5cc13b778f492abdfc1c5d8ec9731d55946cdb32c729e6c5fcdb305f02c039ef745ce93edab89decf6c5fcd73964fcf5a3e25200f1edfcf79f0330676a96c5a7f0ef683300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb330f366c63e06628d43bea54c1849f73ecf3c718b472fb9fa1d5c8ccd7e19539d65d43c2dd1f364dea97cae009e16e0793e7a9e5a4f7e66fa6a965b3e3d67f994803c787c2ff7e0670cec52d9b4be1cf683300bb38b19db2c628d43be654c1849f7bc679eb8c5a3975ced988bb1d92f63aab38c9aa735729e6c3ffdf202785a816745e43cd9b63f7a3fb36dff4acba7e5964f09c883c7f74a0f7ec6c02e954deb2b613f14c2bcb8049925ce12e7306689b3c4398c59e22c710e6396384b9cc39825ce12e7306689b3c4398c59e22c710e6396384b9cc39825ce12e7306689f39d1367ec6320d638e46b61c248ba159e79e2168f5e72f53bb8189bfd32a63acba8795647ce5397e9ab595900cf6ae05915394fb6af267a3fb37d352f583eadb47c4a401e6c935ef0e0670cec52d9b4fe02ec87db9d797109324bdd280eb3d40d610e6396ba21cc61cc523784398c59ea863087314bdd10e63066a91bc21cc62c754398c398a56e087318b3d40d610e6396ba21cc61cc523784398c59ea863087314bdd10e63066a91bc21cc6cca16ee0181d628d43be56268ca45be599276ef1e825d7b81d1763b35fc654671935cfdae87932df2479a1009eb5c0b3267a9e5a4f7e66c63abd68f9f482e55302f2609bf4a2073f636097caa6f517613f08b330bb98b1cd22d638e45bcd8491746b3cf3c42d1ebde46ac75c8ccd7e19539d65d43c6d9e785e2c80a70d78d645cf53ebc9cf4cdbbfdef2e945cba704e4c1e37bbd073f636097caa6f5f5b01f4a8d198f25628d43beb54c1849b70e783cd4bb82dba436471c9b4b8071610930f62801c69e25c01807460fd7e999633861f1d0fa5abff14945119f4a8813d7762f013cbef66195c553e58805d77dd8cbfc72de8755c0e36b1f565b3cd58e5870dd87bdcd2fe77d58ed378e91b4f7779500639f1260bcbb0418fb960063bf1260ec5f028c034a80f19e1260bcb70418079600e37d25c0787f09303e50028c0f9600a3ef671ab9ee73db8a603becfeac18b6c3ee2b8a615b622e3197984bcc25e612f35bb52d3197984bccdffd98fb78968bcf8d69c9750fe17abeebbb4f5e18f9302e66ca883cb1e87892e83bdadac0c077622835c6c525c0b8b00418258ed93ed4ce306a9e973df16c2880e765e079297a9e5a4f7e66c61a6eb47cda60f994803c580f367af0330676a96c5adf08fba1d498f15822d638e46b63c248ba9780c7d7f155c8f18ec7d7264f3c2f17c0b309787cec2f4f7e668ef776cba7972d9f1290078f9d760f7ec6c02e954debedb01f4a8d198f77628d43be36268ca4db083cbe8eaf428e773cbe367be2d95400cf66e0f1b1bf3cf99939deb7583e6db27c4a401e3c76b678f0330676a96c5adf02fba1d498f17827d638e46b63c248ba76e0f150ef0abee7d8ec88e3c212605c5c028c12478923274689e39d13476114466114c67783b114da7039cf14fe6c00efc5b746cf538ff76df9f06c051e1ff7769efccc3c1bd866f9b4d9f2290179b01e6cf3e0670cec52d9b4be0df683300bb38b19db2c628d43be36268ca4db023c1e8eef82dbfead8e3836fb654c759651f36c8f9ca73e89f5251f9eedc0e3a34ef9f133dbf6efb07cda6af994803c787ceff0e0670cec52d9b4be03f64321cc8b4b9059e22c710e6396384b9cc39825ce12e7306689b3c4398c59e22c710e6396384b9cc39825ce12e7306689b3c4398c59e22c710e6396384b9cc39825ce12e7306689b3c4398c59e22c710e6396384b9cc39825ce12e7306689b3c4398c59e22c710e6396384b9cc39825ce12e7306689b3c4398c59e2dc39661ce34eac71c8d7c6849174db8067bb079e42c7e16f77c4b1d92f63aab38c9a6767f43cf5585ff2e1d9093c3eea94273f33ef0aecb27cda6ef994803cd826edf2e0670cec52d9b4be0bf64321cc8b4b9059e2dc39666cb388350ef9da9830926e07f07838be0b6efb773ae2d8ec9731d55946cdb33b7a9e7aac2ff9f0ec061e1f75ca939f99b67f8fe5d34ecba704e4c136698f073f636097caa6f53db01f8459985dccd866116b1cf2b5316124dd2ee0f1707c17dcf6ef76c4b1d92f63aab38c9a676fe43ca924d6977c78f6028f8f3ae5c7cf6cdbbfcff269b7e55302f2e0f1bdcf839f31b04b65d3fa3ed80ffb0a605e5c82cc1267897318b3c459e21cc62c71963887314b9c25ce61cc1267897318b3c459e21cc62c71963887314b9c25ce61cc1267897318b3c4f9ce8933f631106b1cf2b5316124dd1ee0f1f03cbee0be9abd8e3836fb654c759651f3ec8f9ca72e89f5251f9efdc0b32f729e6c5f4df47e66fb6a0e583eedb57c4a401e6c930e78f0330676a96c5a3f00fbe176675e5c82cc52378ac32c754398c398a56e087318b3d40d610e6396ba21cc61cc52376e5a84d9a4a56e087318b3d40d610e6396ba21cc61cc523784398c59ea863087314bdd10e63066a91bc21cc62c754398c398a56e0873183387ba81637488350ef9da9830926e1ff0ecf7c053e838a2fd8e3836fb654c759651f31c8c9ea71eeb4b3e3c0781c7479df2e46766acd321cba7fd964f09c8836dd2210f7ec6c02e954deb87603f08b330bb98b1cd22d638e46b63c248ba03c0e3e1f82eb8ed3fe88863b35fc654671935cfe1e879eab1bee4c37318787cd4294f7e66dafe23964f072d9f1290078fef231efc8c815d2a9bd68fc07e1066617631639b45ac71c8d7c68491748780c7c3f15d70db7fd811c766bf8ca9ce326a9ea3d1f3d4637dc987e728f0f8a8539efcccb4fdc72c9f0e5b3e25200f1edfc73cf81903bb5436ad1f83fd20ccc2ec62c6368b58e390af8d0923e98e008f87e3bbe0b6ffa8238ecd25c0b8b00418179700a3e738a63acba8798e7be2395a00cf71e0f1d17e78f233739e3f61f974d4f2290179b01e9cf0e0670cec52d9b47e02f643a931e3b144ac71c8d7c6849174c780c7d7f155c8f18ec7d7494f3cc70be039093c3ef697273f33c7fb29cba7e3964f09c883c7ce290f7ec6c02e954deba7603f941a331eefc41a877c6d4c18497702787c1d5f851cef787c9df6c473b2009ed3c0e3637f79f23373bc9fb17c3a69f994803c78ec9cf1e0670cec52d9b47e06f643a931e3f14eac71c8d7c6849174a780c743bd2bf89ee3b4238e0b4b80717109304a1c258e9c18258e774e1c85511885b130c6f525c028fb5a18b932b679608c197bc843eb6d45b05d65d9ae2aa2ed6acb7675116d4bcc25e6127389b9c45c627eabb625e6127389b9c45c622e31bf55db127389b9c45c622e319798dfaa6d89b9c45c622e3197984bcc6fd5b6c45c626edbf630deb4e0f1dc6780e7b4875878f233a9cb3d6bca7a27c2f8e9589db362d566c52a0179ce42fcce79889f6bcc35ad93bd4299873060f6643bd54b95d103fc271b8bad7868fbe73df91ed6e69d2f82edb036af18b6c3dabc62d896984bcc25e6776ecc315d11dcfc0e922ee382497731eb947f3d6c4779deaaccfe5605b23f7dd8966348622e319798bf1b31c7b88c2f024f60f10439786632e3a967c6d3c28c6709339ee1cc784633e399cf8c6716339e29cc78ca99f13431e36960c6338219cf6c663c5399f14c60c6d3c88c27c98c6728339e91cc785a99f10c61c6b39419cf02663cc5e81f2a84670e339e51cc782632e399c68c670c339e5a663c8f32e399cb8ca792194f8219cf74663c9398f18c65c69362c6b39a19cf32663c8b98f1f462c653c58c6706339ec9cc78d632e319c78ca78e19cf3c663cbd99f15433e319c68c27cd8c27c680271edc3c263d0eff3f03ba326bdb6e4abe35a0e3ff178dbe0cb6b964d2e58eb22f828ec67a5d726c8b71ba08bea44d3a796b4b264e682b0deb64af12382e31e14933e319c68ca79a194f6f663cf398f1d431e319c78c672d339ec9cc786630e3a962c6d38b19cf22663ccb98f1ac66c69362c6339619cf24663cd399f12498f15432e399cb8ce751663cb5cc78c630e399c68c6722339e51cc78e630e339c38c6701339ea5cc788630e36965c6339219cf50663c49663c8dcc782630e399ca8c6736339e11cc781a98f13431e32967c6338519cf2c663cf399f18c66c6339c19cf12663c2dcc78ea99f1cc64c633dec1e36b5e66eaffa7b269fd0c13db1ef643e6bb79973df974c594d5d5944bfc64af02f2ac301d43babf0ab7252e7bbc063e2bb80231bae0c997b06f675c2882edb06f6714c376d8b7338a615b621e1ef32bd1db4ee118285a62d67a1ad278dcf9183be6c9cf1bdabca8bf157ad58ad5052b5609c87319e277d543fc5ced28ad93bd4299873060c67a5113445b2fae45efd36fbe414a71bd66c517fdbaee29a6616de9f522d80e6b4b8b613bac2d2d866d89b9c45c627e67c7fcfd261de17546126de87b283a7fbc1fecbe6ad2b108edeab25e3165d1375389e355e0a13c6fc03d9dd43f39e6ef8498db697a4681df15f0f50c296c9f14e3f955d83e2986edb07d520cdb12f3f0987fc083ed7870e35c127ac9f58ce203c0f38a071e4f7e66ceb5af593e9db17c4a401e6cfb5ef3e0670cec52d9b4fe1af0d082dfd1f5510ff2d9e761dfd1e5c053cf8ca78519cf12663cc399f18c66c6339f19cf2c663c5398f19433e36962c6d3c08c6704339eabcc786633e399ca8c6702339e46663c49663c4399f18c64c6d3ca8c6708339ea5cc781630e399c38c6714339e89cc78a631e319c38ca79619cf5c663c95cc7812cc78a633e399c48c672c339e14339ed5cc789631e359c48ce73a339e5ecc78aa98f1cc60c6339919cf5a663ce398f1d431e399c78ca737339e6a663cc398f1a499f1c418f0847d4797fe7f1574d4678fdfd67ddda45f015d99c306f51dbd06ba0a93a632f477797f34e0e6b2314ebec629a0ad34ac933dfc8eeeeb4c78d2cc788631e3a966c6d39b19cf3c663c75cc78c631e359cb8c6732339e19cc78aa98f1f462c6739d19cf22663ccb98f1ac66c69362c6339619cf24663cd399f12498f15432e399cb8ca79619cf18663cd398f14c64c6338a19cf1c663c0b98f12c65c63384194f2b339e91cc788632e34932e36964c6338119cf54663cb399f15c65c63382194f03339e26663ce5cc78a630e399c58c673e339ed1cc788633e359c28ca785194f3d339e99cc78c63b78e4db30d1da96eff1f08cb987ef5466be958adff9d18b3df6260d69cfefcbd6c7831bbfe3f9db78f0bb283eda254f7e66bed1f906b04755ae8ed59b56acae5ab14a401e6478d343fc6241f8f756c89e300b7318b3e6a1f609c7fd51beeb4c1849f71af0f86837b4eff44c81cad7df309cddbbc3ae87f344bd8e037def97be833fc2da2f1590e7b3fd3bd8e61bb64af83fed37edcf154ba77df0fd2d7f2a9bd6c91e3e43c2ef82fb3aefdbdfacbeea88c5bb69dbc377cb6b0bbde6b8e2e079273a9e24b63168eb9227df2f07f9fb7ec9c113a1efb509e0f13c574aa6eda2fe182a5fb70fcb7b7b8d793d1ef7d476d9f319e21c1ed7a1ed5a95a3ed2a0b3a8e19fa5f8dd1dbe7ac778cde2ea32690fb291fb6e51e56ee61038b8716bc878dfe3a23952cf41e16e7cff071bef5743d95f4744ecadcc35eb46265cf3592803cc598e3ebb2c543eb644f98855998855998855998855998855998855998855998855998855998855998f933878d39a17cd79930920efbac7d3ce7d7bed37baa54beee1bed56dd6137fa7e8b5412c72850bfed28cb679c377455bf0eb6b861c3f11c38e6c4b52f7df4f7e7da9764af32b8791c8acf7ebab03130c5e8232cc4764d64b6532bfcecdf5492e644bf6aedd3eb8efde9a3adc0f153b4e4ea6bbc083c3ee6bdf7357644fb74c1f2e98ae55302f2e03c16173cf8e93aafd1fa05e0a105e711f475ce082c9ec0111f5aca98f1d433e3e9ce8ca78519cf12663c8399f1cc67c6f300339e01cc784633e399c58ce72e663c5398f1f460c653ce8ca789194f03339ee1cc784630e3b9c68ce711663c0f32e3b98719cf63cc786633e3e9c38c672a339e9ecc782630e3a960c6d3c88c27c98c6728339e91cc785a99f10c61c6b38019cf52663c35cc78ee65c6338719cfddcc78a631e319c58c6722339e38339e31cc78ba30e3a965c6f328339e41cc780632e399cb8ca72f339ee9cc782a99f12498f14c62c6d39519cf58663c29663cab99f12c63c6b38819cf43cc78ee63c6d38f19cf0c663cbd98f15431e399cc8c672d339e71cc78ba31e3a963c6e37b1c73a13c0f33e399c78ce77e663cfd99f1cc64c6338c194f9a194f6f663cd5cc78620c78e2c1cdef9ec4e1ff574047ef48e0fb75658ef2681c23e5d7e7e95f0eb8b9ec3247d9171d0c18a7f3e04bdaa493b7b6dcf05e48cc944beb64af12382e32e1a966c6d39b194f9a19cf30663c3399f1f467c6733f339e79cc781e66c67399194f1d339e6ecc78c631e359cb8c6732339e2a663cbd98f1cc60c6d38f19cf7dcc781e62c6b38819cf32663cab99f1a498f18c65c6d39519cf24663c09663c95cc78a633e3e9cb8c672e339e81cc780631e37994194f2d339e2ecc78c630e38933e399c88c6714339e69cc78ee66c6338719cfbdcc786a98f12c65c6b38019cf10663cadcc784632e319ca8c27c98ca791194f05339e09cc787a32e399ca8ca70f339ed9cc781e63c6730f339e0799f13cc28ce71a339e11cc788633e36960c6d3c48ca79c194f0f663c5398f1dcc58c6716339ed1cc780630e3798019cf7c663c8399f12c61c6d3c28ca73b339e7a663c65cc78c65b3cf87ffdec83c6b75e001dfdbfb14ff6b7caf871c1b217811fc9b0b9317cc50c97b4232661736370e0a967c6d39d194f0b339e25cc780633e399cf8ce701663c0398f18c66c6338b19cf5dcc78a630e3e9c18ca79c194f13339e06663cc399f18c60c6738d19cf23cc781e64c6730f339ec798f1cc66c6d38719cf54663c3d99f14c60c653c18ca791194f9219cf50663c2399f1b432e359c08c6729339e1a663cf732e399c38ce76e663cd398f18c62c63391194f9c19cf18663c5d98f1d432e3799419cf20663c0399f1cc65c6d39719cf74663c95cc7812cc782631e3e9ca8c672c339e14339ed5cc789631e359c48ce721663cf731e3e9c78c6706339e5ecc78aa98f14c66c6b39619cf38663cdd98f1d431e3b9cc8ce761663cf398f1dccf8ca73f339e99cc788631e34933e3e9cd8ca79a194f8c014fd85c14f4ff72d09d33e96ba03b6bd2974177c6a42f80eeb44357e660217be74047e302ce828e9e4d9f011d3d7f205bfafae0ff0cb899b5cce153b983f5acc3a7738e6d713fd236e920dafd88b6d2b04ef670ae8c734c78aa99f1f466c69366c6338c19cf4c663cfd99f1dccf8c671e339e8799f15c66c653c78ca71b339e71cc78d632e399cc8ca78a194f2f663c3398f1f463c6731f339e8798f12c62c6b38c19cf6a663c29663c6399f17465c63389194f82194f25339ee9cc78fa32e399cb8c6720339e41cc781e65c653cb8ca70b339e31cc78e2cc782632e319c58c671a339ebb99f1cc61c6732f339e1a663c4b99f12c60c6d3ca8c6724339ea1cc7892cc781a99f15430e399c08ca727339ea9cc78fa30e399cd8ce731663cf730e3799019cf23cc78ae31e319c18c6738339e06663c4dcc78ca99f1f460c6338519cf5dcc786631e319cd8c6700339e0798f1cc67c6339819cf12663c2dcc78ba33e3a967c653c68c67bcc583634893a0a3742de8289d021da5eb4047e97ad051ba0174946e041da5c7808ed2634147e971a0a334f988ef6714639e0bb24565d3fa7960a4fb17d73e6902eef3964e739ff2c47ddee2a6f553c0e8f285d82600f7294ba7b94f7ae23e6571d3fa496074f9426c134147e949a0a3f464d04d067ba4a3f414d0517a2ae8283d0d74949e0e3a4acf001da5e9fd057c976116e8283d1b74949e033a4acf051da5e7818ed2f3cdafdec7272d9ddec7274c3a1d44bb8fc916954deb2780d1b5df896d01709fb0749afbb827ee131637ad1f0746972fc4b608b88f5b3acd7dcc13f7718b9bd68f01a3cb17625b02dcc72c9de63eea89fb98c54deb4781d1e50bb12d05eea3964e731ff1c47dd4e2a6f523c0e8f285d89601f7114ba7b90f7be23e6271d3fa616074f9426c2dc07dd8d269ee439eb80f5bdcb47e08185dbe105b2b701fb2749afba027ee431637ad1f0446972fc4b61ab80f5a3acd7dc013f7418b9bd60f00a3cb1762c3ef95acf5c478cd62bc5644db61d78cc5b01d76dd570cdb61d76ec5b01d764d510cdb61d705c5b01d766e2f86edb0f373316c879d638b613bec3c590cdb61e7ba62d80e3b5fc9f12dc777d4b6dfcd73c99d7a7cbf9b6deabbd9b6c8b5a25c2b16cbb69c4be45ab158b6efd46b4569cfc3db730fcf845271b0414bcc5a4f43fa00f0f878b6e6c9cfa42e77bf29eb9d08cbd5b1da67c56aad15ab04e4d90ff1dbe7217e31b04b65d33ad92b4566ac17b1e86c27e36003bf6fb897ca07dd1e93ae05dd6e934e816e9749d7816ea749d7836e874937806ebb49cf05dd36939e07baad267d0a745b4c1afb06379bf449d0b59b34f6c56d32e913a0db68d2d8f7f5b2491f07dd4b268d7d4d1b4cfa18e8d69b34f6edb499f451d0ad3369ec4b79d1a48f806e8d49b780ee05933e0cba55268d7d052b4dfa10e85698f45ad02d37e983a07bdea4f783ee39936e04ddfb4c7a0ce89e35e9b1a07baf498f03dd33268ddfe17cdaa4713cc553267d16748b4d1ac72f3c69d2f81dce274c1ac70b349bf444d02d34e949a07b8f494f06dde3269d06ddfb4d7a0ae85e31e9a9a07bd5a4a781ee03263d1d74af99f40cd0bd6ed23341f78649cf02dd9b263d1b741f34e939a0fb9049631fcd874dfa00e8ca4c7a1fe868fcf05ed0d13b4c7b4047ef99ef061d7dab6417e8e87b693b414763bc76808ec6096f075d4f93de06bab8496f055da5496f011d7d176433e8e85b57eda0ab32e94da0eb6dd21b4147df097d19743476f725d0d1fb3a1b4047ef0caf071d7d07a30d74f4ada975a0a3ef39be083a1a83ba0674f4dec90ba0a3777157818ebe2fb11274f44da915a0a3ef362e071d8d357d1e74f47ec973a0ab31e9f7816e90493f0bba874cfabda0a3ef213e033a1ac3f934e8e83d92a74037c4a417838ebe17f124e8869af413a0a3ef8a36836eb8492f04dd6326fd1ed08d30e9c74147ef8dbe1f74f46efd2ba0a3f1cdaf828eced91f001d9db35f031d9db35f071d9db3df001d9db3df041d9db33f083a6afb3f043a6afba9fdd0c7a93e7eaf98f57410dd7594b67735b871c9752d4f0cc813e5b5710278d0d6a5c87d4f65aec3e9faadcc944bf5e512d8be10b9edec3dc04553561753ee05cb7605e469efd7b16fcec3ffd3e0036d8779a86c5a1f05db9eb7caae32fe5ef4e4ef058b89b82f0213e5d9d6af23ef40d32077876d2264cbdccf525d0b2086b8a4218df367441fab54e6fee272013c178127fae3247b7feda34ee0b115f5fdb5fd6cc4ae6b09c87301e2e76b5cf1458b87d6c99e300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb330f367d63cd49f80e38328df15268ca4c3be2e1fcff9b1cf15fbbc7a40bf8eeffebdaea6dcd196cf1590676eff0eb68449e3b75568bf85ed4b0ffd8439f725d9ab047fb02fc8477f710c6c51d9971cb1e060bb2632dba9157ef66f2aa9c7c7e8fefdcbd63ebd62ed4fec17c7636820d453dae6baf98d437cae437c3c1ce339f70dd9c363e912e8287d15187dc41acf25d41e507f38d9c37ef1474c6ca95f3cfab63a95f4d96ed0f7a1ecfe76f495f20c87b66f8449e3d8902b505693e3ffb4e4eaa7a6f8699fcf44ef7366ff9e3665d1fe3de3b07d0a5823b25d8bb66346c80ee92b203dbe7f475efbdd288a35b1e3b79b90dddeeeaab55d02f29c75f89f0ea2f5ff8cc573c662d6756734d4b32638fffb6a93ce86c46814c488f2e07590877126ce369238c89ece43fbbf9b9507af5928cf3468a3b42fd4ce939f38b605cf01e73cf977c5f28fd6c91e5e1b5f0446db475d3fba5577f0dee9e3bf9e84f6e23cfc3f1ddcfaf8af27a10ee138adc02a7f34944f5cdd82f0730be579da3a8ffab8c7c07d69c713c797519ea5d00e5de8c4b5febb75df1676adefe37b94f1e0c67b6fbde43abfe339c647fbe2c9cfa4ebdc75def229017986809f1eae6372be5778066cfbfa0629d9a06ba80b562c2a204f9bd57684c511ef552f16c59794f37a70b4c317cab3c96aa74e7b60f2b9dff03a4b977bc9e12be5d906eddf0eb89ea7fd846de971c7ff69c9d51e50fcb4cf27a2f739b37fe99d32dabf271cb68f016b44b66f78bf9eaef7c90ee92b207d0ccedf948fe241b1c66f489ea4ed82f0ed2e58db2520cf4987ffe9205affc3be6d40f674ddd90df5ec385ceffb6a374f86c46834c488f2e0b3153ab753feb0f3be8ff1d5b9cefb9780d16e37f1dac527db658bcd7e86eaba1ea43cb42d5e0f5e857636eec8ebffd970f6daa69031ff9e9f91d7c7ac78a6c1ce48d053fda438d3fff01a97f2bce9fdf955b67e5cb0b8c90fecc33967719fb7e28acfa23e6addd3dac7a6eb59a7a76bce7abc16b3af87ce013be5f9b8753d645fc75d73f8629fa7cb829bef05dfb1f2e231996b3b3b7dc5da069f19b89ec9e2bb2e6781256dd2c95b596a9349642a73c42211dc7c4fe67ace40c701d6392acb3e5668db0ac8f319ab4db2f3ea366979ef8ef8d07ec467edae3ae9eb3952d87316b2a7195defd145df76dd99ef2b758facdc71cb4bb18fbbbb958ec676aa15cf15b96271cec1e3eb9966582cce396c47178bc615aef3872b16671d3cbeee31c36271d6613bc258ac723d5b70c5e28c83c7d7bd46582cce386c47178b31373cd7c8158bd30e9ee89f69e48e05f68915c27c960173772b1d8dedfae5aebe3b572c4e39787cf5dd85c5e294c37674b1a86d74ddb3bb6271d2c173b2c8b138e9b01d5d2cc68e733d5371c5e28483c7c3f3b59cb138e1b01d61bd5889cfd772c5e2b883c7d77c3061b138eeb01de1f56163ae6786188b630e1e5fcffec26271cc613bc258b468db47f388c551078faf796bc26271d4613bba582c6fd0b68fe4118b230e1e5f73e184c5e288c37674b16819ab6d1fce2316871d3cbee6d7098bc56187ed08efa132f5e2501eb138e4e0f135674f582c0e396c47178bd6ccb5d6c13c6271d0c1e36b1ea0b0581c74d88e2e16c9cc39f5401eb138e0e03950e4581c70d88eb05e64ee27f7e7118bfd0e9efd458ec57e87ed08cf23997ab12f8f58ec73f0ec2b722cf6396c47178b5599e74f7bf388c55e07cfde22c762afc37684cf5c32f5624f1eb1d8e3e0d953e458ec71d88e2e16759973eaee3c62b1dbc1b3bbc8b1d8edb01d5d2c5666fac476e5118b5d0e9e5d458ec52e87ed08af3b33edc5ce3c62b1d3c1b3b3c8b1d8e9b01de17567e6f9c58e3c62b1c3c1b3a3c8b1d8e1b01d61db99b9eedc9e472cb63b78b6173916db1db623bceeccc4625b1eb1d8e6e0d956e4586c73d88ef0ba33731ed99a472cb63a78b61639165b1db623ac1799b6734b1eb1d8e2e0d952e4586c71d88ef0b956a6eddc9c472c363b78361739169b1db623bc1fc93ce36bcf2316ed0e9ef622c7a2dd613bc2bea2cc35f8a63c62b1c9c1b3a9c8b1d804b67d8c33c158d058ac11562c2a20cf5af3d1761a8b1516472a03c795a12f1b23f7253baeece5105f36822f94e725f0a53be8a364f2e46ba6ced0f7fa696cfa5587af9467f3808ebc5b4d3a0efbe41a9475c4f17f5a728d41a2f8699fd747ef73a6aeb699b268ffae77d85e07ac11d9ae45db34369dec90be02d2870774e4a57c140f8a35b1eb6364834923bbbddd266bbb04e4d9e0f03f1d44ebff7a8b67bdc59c79ef01ea19d5233f6d57966943488c46408c280f8ed9bbea89c71e43481c644fe7a1fddfcdca83632829cf1968a3705c29f9190f6e1e37a9fd7bc9937f61f3c291bd04e82e02a3eda3ae1fb361ec672d31061dba3a934e41398d964efb3ac693af648bcaa6f531c0586fd28dc5674ce5cbd860316a9e711e6286f36cd092eb7c310e78c67ae0f1e467e63c34def2698ce55302f2e0bb8de33df81903bb5436ad8f07db3ef639c682cec943ad5854409e8f5bd78f6171a43274fd6d74f8e22b8e0d164f83c3f644cf71a4b2a94d9c5804db4d96ed7acbb63eb6b18ee925d7b1dd04cc133c30eb7227455f6ee6d8a6b9d4a83e939d7af0290d3188ca27b41db3ca267d05a4bf30e066068a079d3b895d1f475877c2b61b676d97803c131dfea723f67f92c583fb582ffabae153705de9e178c8d481891607add743ec2685c46e22c48ef234828eae71c6838eae1570ee41fa3f5e473444efafb3eda1f50660241dce67d8e060ac8f9e3195ab6dae0746d24d009e264f319b60f10cb5e283e7e56e561edab602f27c03ce8d71475e5df7ef8f75f845731c4638cf4fa65dedea215e38ff6200f109ac18d2420cdd838e391aa3e4e91974ccc1b8a97dc3c696d52b9f5899ed7a24b40a0b137f630e37ca4087e972872e086e9c6ab2027434d56417d0955961c1292e293f4d69e7235c180f2abbc2e2ec0e2c51dac6693a69c95575ba018f8faaacab0e4dd569aaced31bd7b4afc4fad1c5e2ec4cddd1ff2bcf912fac2caa07151e7c47262a9bd6c99e8e4fc2a45f6a59f1e2948dab37b7ad5cdfbe0961ed830bd3312b08f6af6b1bac24783051395dace0f4883e38f578f0da7c01d80b8025303cdda3e7c954d4bb4c592b5ad6ad5bb879f9ba352b666e5ebfa27dcd86f518d16e56e4c2a26d1ff27a71357598d7cedfd5a1b3179c49b71be86826ddeea023fb3d40471c3de17ff69ef0724c0c81f2a91aebff551887bb1a87a80ad26948b727fa98d19f2ed5a77ffd644c7fa94defbe3e4176eaddbe41766a5dfd56b5be52d053e5eaa971f554b87aea5b3dd5ad9eda564f655b1364a7aa7d28c84e453b38e8986a562f5f025e3db5acbed4d053c7eaa9621f0bb28feb4606d94f9be94f49e84b567d3baa2ff3f4ad85bee4d2975afab256dfb2ebc737fa32465f22eacb1f7dc9a22f83f5e5ef6413eb294176aa693db5f4f4203b75b49e2a5a4f0d3d3bc84efdaca75b9f1764a74e7f3cc84e4fbb20c84e5ddb1c64a7ba7d32c84e85be38c84e9bfb74909df25c4fb5aba7e0d5d39aebe979f5b4bd7aea723da5eff341767af2e541767ae0d6203b75b09e52584f2ffd42909d86584f39fe62907da4ad1fe5eb47dcfaf1b17ebca9bb1874d78a7ef4aabb047517a9ee32d65de87a48811e62a1879ce821387a48921ea2a587ace9217cfb82ec10cf03417608b01e12ad8788eb21f3fa15826341f61513fdca8d7e0549bf92753ac8be66a85fdbd3afa1ead772f56bcafab1aa7ec55b77b5e9c7a9fad1b27ee4aa1fffea697af5b4bc7a1a5e3dedae9e66574fabfb46909d36f78341765adc0f2bf988928f2af91d25bfabe4f794fcbe928f29f9b8924f28f903257fa8e48f947c52c91f2bf913257faae4cf94fcb992bf50f229257fa9e4d34a3ea3e4af947c56c95f2bf91b259f53f2b74a3eafe40b4afe4ec91795fcbd927f08b2f5f11f95fc93927f56f22f4abeace45f95fc9b92af28f9aa927f57f21f4abea6e4eb4abea1e49b4abea5e4db4afe53c97794fc9792ff56f25d25df53f27d253f50f243253f52f263253f51f253253f53f273256f29f985925f2af99592b7838ee9a3b1f1e86e5a9c4166bda5bd7d65db4bed35ed1b6ada36af6b5ff3d2baed355bd7b4bf50b361cbca8dabd66dd88a1b7fda6c4cf35c4fd9b8b1657bcd9af5ad2bb7d56cd8dc5eb36155cdf20d9bd7b7de70b2fc96d9e8be9b2db6b4b6861bfbf9ad90feaa93467f6db6eb63d6e7e4f6ed9dce04a4a2bc131b0d2def6414cdc51edd863d99bde6abd9b46e437b4db266bdfaab4eae1bb6ae6c1d5583ffdba482bca9bd66537bcbc6f69a551b37b4d5d48ec27297f7ea8413aff7f203b3a95ff6b753556570ff4e7832b57fe776c713fd6f81f4a94e1a5dd7190f377666a32b9d247c233c2c9b362f6fdfd8b2a23d7ce38fdccac61feb8c9b9feea49b6b0674c2d886ce6c747a40e7083fd619635f2fc058f0bf713e55c3fca204009b2d6c6f000000243c1f8b08000000000000ffed9d77741cd5f5c767654996bd5acb927b17d5658db45a49b6856d9069a677530dd896646370015bf44e1a0921210d924008e924815448ef0909a47712d220014280ff7ee7fcf21fe777dfeebb475f3fcfec6f479ebb7e23df3de76adf5cbd9dfbb9dfb9f376f6cdccee6b41106482f2631cd9c1c1de0ffe7fbf7d2eecdba32bc1751524393329e1ac4b09e7b89470d6a784b321259c8d29e11c9f12cea694704e4890d3b0d5057b3e92e69d28a06bd28cd99469da9c024d7329d374520a346d09d231464d4e09676b4a38db52c23925259c5353c2392d259cd353c23923259c3353c2392b259cb353c23927259c7353c2392f259cf353c2b920259ced29e13c28259c07a784f39094701e9a20e762e03ccc3e1f6e9f17dae745f699fb2eb1cf79fbbcd4e6586f978f20eb20eb347cceffcc8986225937598ff3bf5eb26564cbc956d8ffb5dbfff5911d49b6926c15d96ab2a3c88eb65aac213b86ec58b2e3c88e273b816c2dd9896427919d4c760ad9a964a7919d4e7606d9996467919d4d760ed9b964ebc8ce233b9fec0287e542b28bc82e265b4f7609d9a56497916d20db48b6896c806c906c886c33d916b2cbc9b6925d417625d936b2ed643bc876925d457635d92eb2dd64c364d7905d4b761dd9f58e663790dd487613d9cd0ee72d64b792dd46763bd91d647792bd81ec8d646f227b33d95bc8ee227b2bd9dbc8ee267b3bd93d64ef207b27d9bd64ef227b37d97bc8de4bf63eb2fbc8ee277b3fd907c83e48f600d983968577840f913d44f661b287c93e42f651b28f917d9cec13649f24fb14d923649f26fb0cd967c91e257b8cec73649f27fb02d917c9be44f665b2c7c99e20fb0ad957c9be46f675b26f907d93ec5b64df26fb0ed977c9be47f67db21f90fd90ec47644f92fd98ec27644f913d4df653b29f91fddcd1fc1764bf24fb15d9afedff787ee93764bfb5eddfd9e7dfdbe73fd8e73f3aaf7986ec4f8eefcf64cf3abebf90fdd5b6ff669fff6e9fff619f9fb3cfcfdbe77fdae77fd9e717ecf38bf6f925fbfc6ffbfcb27dfe8f7d7ec53ebf6a9f5f23bba9addc6e0a461efd41426352cfd0a03937c1621f16ecf9305a8cb3ffe3e776ebafb7cbfcccda35d8e506c7df68971b9df534d9e526c7df6a975b1dff14bb3cc5f14fb3cbd31cff0cbb3c03fcd900e628addff8c65957067c5c8775e06b08f6d4c4f81a7975e01b1feca985f1f1766c04df04eb1b0fbe89d6d704beacf54d60cdc89aadaf3f48aa260a1bcd7a7349afd79eb799943cef80596f8b10efe4e47987cc7a5b05784d7dd8e122980c7533c5fa5ac137d5fadac037cdfaa6806fbaf54d05df0ceb9b06be99d6371d7cb3ac6f06f8665bdf4cf0cdb1be59e09b6b7db3c137cffae6806fbef5cd05df02eb9b07be76eb9b0fbe83ac6f01f80eb6be76f01d627d0781ef50eb3b187c3c7e1e023e3ebe3bd4facc98509f81d7583f8f47a5d7f0980bbe853cde826f118fb5e05bcce32cf896406cf6e5610c61df52ebe3f1c8fc6f856df70749d57f71d0acb72fe9f5d29acd7a5726bfded239ad55c188aefd10a70fb45a6ddb095e37d385b133d6380efbeba1bd16fa723fd683df5398ddbc771c69dbab2bbc6e85f3ba1cf4393224fffe20d9fc573a3c2b1de606c85fa666bbbbb466ab7ec4aed975d0d7ad3d3ebe198b357b327008d46cafd66cd58fd8353b007ddddae363dcb158b317008740cdf6c9d46cb1a0355b9eeb0a82f0dae3cf3963b166370347f235dbab355bfd2376cdde067ddddae3cfba63b166878123f99a5ddea7c706553f62d7ec3dd0d7ad3d9e77198b357b277008d4eca08eb3553f62d7ec03d0d7ad3d9e031c8b357b2f70245fb37d4235dbad351b94cf5b064178edf17cf458acd9878023f99a1dd0f9d9ea1fb16bf6abd0d7ad3d3e3732166bf651e048be6607a5e6678b5ab3e5eb358220bcf6f83cdd58acd96fd8b63937f63b7b6e6c3ef87e6f7d0bc0f707b8ce807d7fb4be83202f817d60b9ee03553f62ef03cf405fb7960fb6edb1b80ffc1c38046ab64f6bb6ea47ec9a7d11fabab5c7d72f8cc59a7d1638046a7693d66cd58fd835fb3fd0d7ad3dbe96662cd6eccbb66d8e17fe668f171681efefd6b7187cffb0be25e07bcefaf2e07bdefa9682ef9fd67704f8fe657d1de07bc1fa3ac1f7a2f515c0f792f57581efdfd65704dfcbd6d70dbeff585f0ff85eb1be5ef0bd6a7dcbc0f79af52db73e731e8bafa97acafa9a20f7fe20b96d5bba8e2ad8f3917196fba1bd5496a7900bf6bc4f806375241fabdbe47e44507dee1dc0d329907b166254c3d3093c85e4794a9f47bb925f6f691b1fe1689a855847405e4581bc32108bd7cdcb1c2f073e1c378a218cddc9331633108bd7cdcbddc0c83e1cc7f83e1cde7fccd83c3733c22bb02f95de9f315e3f7070bc7ae833ab6da46fbb656b86fff318d00c6d1ce70b8e4fa8564bb5823767f5c3721730728e85da3316ab65ec74189b802d419e92669d0e4f678816076a6c81b1bab4ff710cdeff785fe278f5d067fcb891be3d1951b662dcf759accfe4c7ff6201f7cd6a788ac02331c608bdcf15f0bde9f520d95aeb71b42a385ae5a04f37e8d723a05fa5f74a8ea7cccaaccccaaccccaaccccaaccccaaccccaaccccaaccccaaccccaaccccaacccfe33e3f9633cdf16766e767f32b2af0b7824e6f94bdfa363d7c5eb37e7759e84f33ac99fb72816f0bc235f93b5c8c9b91efa3c9319617b3ae49c2f9edfed707c42d75c94b6255e73d10fcb1c0fcf41e3352052e710f30e4f3e440b1f62b72716bb3820b37d8b05f33d16e6bba0963adb34ecfa93258ecfd4e9c47123794b9cfb8b7b2e12c7126e27796e2f17ec7ded80cc352ee5f183c7abba60cff103df677a138fbde7394c3e5fdeebc4ae873e2f6646b6cd32f87f7fb0f77539d887d7cdcb8be0b5cb9c75b7c8e55bf1da845ee0e676a393db52e0e63eafc0787e4f5db92df41e57c4ebc302e00d9c9cf881e7ec933f06285f43508cc1d3033c02d78b75091deb14b01e93be866099a355d83114f7e905fd9609e817761ccccb1c4f99955999955999955999955999955999955999955999955999955999955999fd67c6fbbb99350bfdba3c61acd17517a5f319fcbd1c785eeca6ba91b8d2e700f99cd36227e77ae8f3adba11b6db6cbb39d8fb5a8ba86d29756e2d6a5b72bc66c807cf0549ddb3deedf0748768e143ecf6c46297af21487efb8e5c435074b66997b33df1dc39ee43f7409dbadf7191057d6a71dd52d4b6e178b82f75838fdb786fb684d6f85ee25e53c4f1f0dcf9fd565b3e779efc585d2c488e1bfc9d3f7c9d40312457eef3208c7d0fd9365e3fd205eb7a2ce4fffca8749e9af513fa7eb0d2f6e5efabe2eddb17127b25b02614bb0b6367ac711cf6d743fbd1ba91beeef75fb1d6cc6ef611f73bbac25e57705e97833e2b42f2ef0f92cdbfcfe1e973984ded7c04eaec3178ff971a935604e11a2d028db80f1e07095c67123a46bad7569a3ebcfdc73b7df09885fb3c016354d4b5ab61df7db45c28bfa8ef3ee278786cdc038c6e8eee35a607fa35624fc278b10cfedf1fecfb35624f420de1755a81b3fec5b07ee61a1f44bfb7709fa79df751a97d2bea1a34dcb7dccf03cc8bd7a0719f5fc258c53f36da1cec7dec8fd76bd5e2b35dd4f5e11c0f8fa9e2e48ee342d2ef8d588fc8c2f1b01effe4d4e3b208ee8e90d7fe25e2b5ac155f738c9f9d5cfd8c0e897f2faa1d6ffa9c5c789f5a01b9709fe79dfd46eab75d92cf75cfe3211e83ba4372e53e2fc1bef6321c5ff276c2b1f2bf21ffe747a5e34ffc2ed755c9e75cdabefc9da5bc7d5785c43e0a58138add85b1f9f893e3b0bf1edaff0bef27dc8ff560ad99ddec237c0c87eceeeb7a9dd7e5a0cfca90fcfb8364f35fe5f0ac72984dedbc0a75f65f38fe941aab574668b41834e23e784f14bf8fe0f7bb86bdc7485cef5be93d26ecfb21716c0fc6d59ecd9dd30b3b3ee13efc5a3c3e69b0cc669ccd86f475e72af93d24c96b96f11e913cc4c57b44f2427ae6823df5cc391c92b15b9cd82d358cddeac46ead616cd55c35f749739fbeff1bbfa7bb2e058ce352c0589f02c686143036a680717c0a189b52c03821058c1353c09805c6fdf9de2ea04f31097d9a41a7a521dc52f7e32f7518ddef4ac839bcccb33f8f917cdd8693ecb3cfdbb00578c6d8b16622db70b27df6791bb6caea98c878df9602c62929609c9a02c66929609c9e02c61929609c9902c65929609c9d02c63929609c9b02c67929609c9f02c60529606c4f01e34129603c38058c87a480f1d014301e9602c634cc552e91651cf5e76bc323f09b903df819bd1a1ee9efd614cab3747d165fc798f477a4b9bfebb8d4d10aef3991fe3dd84c10fd5da91c4f9995398a19c742fc1d6fee97f78431ecbb8705c68dd8ef291db23c7bfcf67687ecb688fd5e25fb9ba0e5f7aa03e13741c3ee6f09fbbe77ee83e3c6feba8e1163b707c96ad153851635ba075be4fbfa3b53c8eccb6f0cf0f814f61b03794f186bf41b03b1dfab8a213a76c8321647cb2874ff580fd64b353cf8bd18123525799f5cd4f77f703cfcfe0f1c93a4aee977ef8fe3e56abeb3248cb93b85ccaaf3e89871ccc2ef86e17e794f18ddfbae84f6efd8637f6f888e1db28cc5d132cadc675dfe7d8038f7bd2d071e899a92c9b33cf6bbf7eff73a39e1fdfb382649ddd3b8dce1e1e515b01d94599995599995599995599995599995599995599995599995599995599995d96f663cc780dfc3c5fdf29e30b20fbfbf50e2fb5de39e07591ea263872c6371b48c8647e2fb15b15eaae1c1ef0994a829993cf7fcee6d5ef77227a71cf4c1fdfb48813c3341f4f751e3f7742bb3322bb3322bb3322bb3322bb3322bb3322bb3322bb3322bb3322bb3322bb3dfcc788e8159b3d02fef0923fb56008fc07c7cec73357d213a76c8321647cb6878047ec3b207eba51a1efc4d23899a12cab374aec6fdad24f7b73a73d007f76f81dfcd0afd9d245e5e05db419995398c19c72c66cd42bfbc278ceeef010beddfb1c7fe95213a76c8321647cb68785627ce533e4fbf3206cf6ae091a829993ccb63bffbbb7d2b9d9c72d007f76fa9dfed5bedf0f072a5df1aacc4dc9d4266d559758e62569d55e72866d559758e62569d55e72866d559758e62569d55e72866d559758e62569d55e72866d559758e62569d0f1c9df11c03b366a15fde1346f6ad021e81f9f8d8e76a5687e8d821cb581c2da3e1393a719eee02d64b353c47038f444dc9e4593e57d3efe4b4dac929077d704cea17c833037179dd987760b743ff1867ee4e21b3d6466d98b53694398a596b4399a398b53694398a596b4399a398b53694398a596b4399a398b53694398a596b4399a398b53694398a596b4399a398b53694398a596b4399a398b53694398a596b4399a3987da80dbc468759b3d02fef0923fb8e029ea30578e25e477474888e1db28cc5d1321a9e35c9f3f460bd54c3b30678fa93e7e912cab374add3314e4e473b39e5a00f8e49c708e49981b8bc6e5e3e06b683322b7318338e59cc9a857e794f18715f661e81fd3bf6d8bf2644c70e59c6e268190dcfb1423c6b62f01c0b3c123525946769ec3fcec9698d93530efae0fe7d9c409e1988cbebe6e5e3603ba48d19f72566cd42bfbc278cec3b067804ea2ef698746c888e1d2960ec4c01e38414304e4c01631618f3028c191b0f7978392fab4f31097d9a41275fc7bd1cf0486dc31687a725440b5fb7e124fbecf3366c011ea96dd8eaf0b48668e1eb369c6c9f7dde86adb23a2632deb7a580714a0a18a7a680715a0a18a7a78071460a1867a68071560a1867a780714e0a18e7a680715e0a18e7a78071410a18714e637f7ecedd9f9fcff6e7e70ad55c352fecdb433557cd5573d55c350f54f3c2be3d54738f354fc36708651cdb8cdd9e32224f26399e02e68eb124ceabc4cd3dec7a94343076a78051fa3a23d53111c6e268190dcf09423cc7c5e03901788e4f9ea74b28cfd2b5866b9d9c8e7372ca411fac83b5027966202eaf9b97d7c276481b33ee4bcc9a857e794f18d9773cf048ed5f71f677dcbf4e14e2392106cf89c023b1bd84f22cedef2739399de0e494833eb8ef9c24906706e2f2ba79f924d80e6963c6fd9d59b3d02fef0923fbd6028fd4fe15677fc7fdeb64219e1363f09c0c3c12db4b28cfd2fe7e8a93d3894e4e39e883fbce29027966202eaf9b974f81ed903666dcdf99350bfdf29e30b2ef24e011a8bbd89f394e0ed1b133058cdd2960541d55479f1855c70347476554466554c6fdc19886315cdf67e2cf0de067f15393e7e9c1cf6dd5f09c0a3ca724cfd3259467696ee03427a7939d9c72d007ebe034813c331097d7cdcba7c1765066650e63c6318b59b3d02fef0923fb4e011e81fd3bf6d87f6a888e1db28cc5d1321a9ed313e7e92960bd54c3733af048d4944c9ee5b1ff0c27a7539d9c72d007f7ef3304f2cc405c5e372f9f01db210e73770a995567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da3985567d5398a5975569da39855e7d131e335eecc9a857e794f18d9771af09c2ec013f73afcd34374ec90652c8e96d1f09c993c4f0fd64b353c67028f444d09e559ba57e02c27a7d39d9c72d007c7a4b304f2cc405c5e372f9f05db210e73770a9955e7d131e398c5ac59e897f784917d67008fc0fe1d7bec3f3344c70e59c6e268190dcfd9c9f3f460bd54c37336f048d494509ea5b1ff1c27a7339d9c72d007c7a47304f2cc405c5e372f9f03db419995398c19c72c66cd42bfbc278cec3b0b7804f6efd863ffd9213a76c8321647cb6878ce4d9ca758c07aa986e75ce091a829993ccb63ff3a27a7b39d9c72d007f7ef75027966202eaf9b97d7c17688c3dc9d4266d559758e62569d55e72866d559758e62569d55e72866d559758e62569d55e72866d559758e62569d55e72866d559758e62569d0f1c9df11c03b366a15fde1346f69d033c02f3f1b1cfd59c1ba263872c6371b48c86e7bcc479ba0b582fd5f09c073c1235259367f95ccdf94e4ee73a39e5a00f8e49e70be49981b8bc6e5e3e1fb6c35867ee4e21b3d6466d98b53694398a596b4399a398b53694398a596b4399a398b53694398a596b4399a398b53694398a596b63af8732dbb6d6863247316b6d287314b3d6863247316b6d287314b3d6863247316b6d287314b30fb581d7e8306b16fae53d6164df3ae0394f8027ee7544e785e8d821cb581c2da3e1b920799e1eac976a782e001e899a12cab374add3854e4ee73939e5a00f8e49170ae49981b8bc6e5ebe10b683322b7318338e59cc9a857e794f18d9773ef008ecdfb1c7fe0b4274ec90652c8e96d1f05c943c4f0fd64b353c17018f444d09e5591afb2f7672bac0c929077d70ffbe5820cf0cc4e575f3f2c5b01d945999c39871cc62d62cf4cb7bc2c8be0b814760ff8e3df65f14a263872c6371b48c86677df23c3d582fd5f0ac071e899a12cab334f65fe2e4749193530efae0fe7d89409e1988cbebe6e54b603b28b3328731e398c5ac59e897f784917d17038fc0fe1d7bec5f1fa263470a183b53c0d89d0246611d8ba365343c970af1ac8fc17329f0488c1f427996dee72f73725aefe494833e58079709e49981b8bc6e5ebe0cb643da98715f62d62cf4cb7bc2c8be4b80476aff8ab3bfe3feb54188e7d2183c1b8047627b09e559dadf373a395deae494833eb8ef6c14c833037179ddbcccf1d2c88cfb3bb366a15fde1346f65d063c1b92e789bdbf6f009e4d423c1b62f06c021e89ed259467697f1f7072dae0e494833eb8ef0c08e49981b8bc6e5e1e80ed903666dcdf37d8e72cf4cb7bc2c8be8dc0235077b13f736c0ad1b133058cdd2960541d55479f1855c7034747655446658cc7786c0a18755b2ba3af8c7901c68c8d873cbc9caf41ec1627764b0d63b73ab15b6b185b3557cd5573d55c3557cdf735b66aae9aabe6aab96aae9aef6b6cd55c3557cd5573d55c35dfd7d8aab96aae9aabe6aab96abeafb15573d5dc8d2d70bd69ecebb9078067938016427916cc7a07edba5e4f503fa3d590a355ded12a077d0641bf2101fdc2aeb9e6658e1797f9700f9885621727d13a2640fe1ca3dbd1c3c4df2c947bd498b7b906b1a3c6bc5ac48e1af36a115b3557cd55f30357736cd7077bdf8364d6b1c5b61bec32f73f165ec77d9e6c2e3fb704ba3d2562eb3ea49aabe6aaf9fed01c75a9ab014fe0f00415786af1f9240ecf7ccf78667ac6d3e619cf04cf78c679c6b3d0339e059ef1ccf28c678a673c133de3a9f78c67b6673c533de3c97ac6d3e019cf22cf78e678c6b3d8339e699ef1347bc693f38ca7d1339eb99ef14cf78c6792673c2d9ef12cf18c67bc673cf33ce399e119cf64cf785a3de369f28c27e3014f36d8fb9a9a2cfc7f007c75ce6bcdf8b0be6de4ff975b7f1dbc66ab6d8f0b59f7e5e0e373555b435e8b3a5d0eb9f4db7661df1e259d30563f2c73bc66e0d8ea094f93673cad9ef14cf68c6786673cf33ce319ef19cf12cf785a3ce399e419cf74cf78e67ac6d3e8194fce339e66cf78a679c6b3d8339e399ef12cf28ca7c1339eac673c533de399ed194fbd673c133de399e219cf2ccf781678c6b3d0339e719ef14cf08ca7cd339e999ef1ccf78c67c0339eba101ea9dfc5e0f94b5e372f0f78125b603b94ee5bbc4228a72bedba1aed7a999fe3d5439f9fd80f92667e045fcb5cee7c33d6ea95a0d116a15ca2ae5dde5283d851d72ed72276d4b5cbb588ad9aabe6aab96a6e1e09de53dfebf3fd167a7f43651ebdbfa1328fdedf509947ef6fa8cca3f73754e6d1fb1b2af3e8fd0d9579f4fe86ca3c7a7f43651ebdbfa1328fdedf5099c7b7fbb9f57e8bca3c7abf45651ebddfa2328fde6f519947efb7a8ccd3e4194fc6039effef7e0bbc4f82cf4d6d011f9fffaa745f4616d67325f8f8f327afc38c375bdaf666a883d76c0be1ba22241ec7d916f2da5ae88eb1fa6199e3e1fd1bdb3ce169f28ca7d5339ec99ef1ccf08c679e673ce33de359e2194f8b673c933ce399ee19cf5ccf78063ce369f48c27e7194fb3673cd33ce359ec19cf1ccf781679c6d3e0194fd6339ea99ef1ccf68ca7de339e899ef14cf18c6796673c0b3ce359e819cf38cf782678c6d3e619cf4ccf78e67bc65317c223750f45d475b4b5b87f23ea3ada5ac48eba8eb616b15573d55c353fb035df9e7cec9e6cb0e76fb69947a57373db8147e2fd4e28cfd2fd773becba12bcc7a160b4dae96835e06895833e3b40bf9d02fa65202eaf9b97399e322b7314b3897d55f2b14be30cc6667d0287871f57096b219467693cb83a08d798e3e5a00f6ef3ab05f2cc405c5e372f5f1d12bb3d48568b5d5568b12b8467578db5e078719977a490d9079d4decddc9c72e8d33189bf5091c1e7eec16d64228cfd2be351c846bccf172d007eb745820cf0cc4e575f3f2306c8738cc57a79059751e1db3897d4de2b18b85ac139bf5091c1e7e5c23ac854c9ee5f1e0da205c638e97833e58a7d70ae49981b8bc6e5ebe16b683322bb3322bb3322bb3322bb3322bb3322bb3322bb3322bb3322bb3322bb332fbcd6c625f9778ecf2fc3dc6667d0287871fd7096b21936779fefefa205c638e97833eb8cdaf17c833037179ddbc7c3d6c0765566665566665566665566665566665566665566665566665566665566665f69bd9c4be21f9d8a5fb713036eb13383cfcb841580ba13c4bf3f73706e11a73bc1cf4c16d7ea3409e1988cbebe6e51b613b28b33287319bd837251ebb7c3e0f63b33e81c3c38f9b84b590c9b33c1edc1c846bccf172d007b7f9cd027966202eaf9b976f86ed1087f9ea1432abceaa7314b3eaac3a4731abceaa7314b3eaac3a4731abceaa7314b3eaac3a4731abceaa7314b3eaac3a4731abceaa7314b3ea7ce0e86c62df9278eceed2fc3dc6667d0287871fb7086b21936779fefed6205c638e97833e58a7b70ae49981b8bc6e5ebe15b6c35867be3a85cc5a1bb561d6da50e62866ad0d658e62d6da50e62866ad0d658e62d6da50e62866ad0d658e62d6da50e62866ad0d658e62d6da50e62866ad0d658e62d6da50e62866ad0d658e62d6da50e62866ad0d658e62f6a1364cecdb928f5dba9f1d63b33e81c3c38fdb84b510cab374fdcbed41b8c61c2f077db04e6f17c833037179ddbc7c3b6c87db95599943984dec3b928f5dcc3ab1599fc0e1e1c71dc25a08e5591a0fee0cc235e67839e883dbfc4e813c331097d7cdcb77c276481b336ebf4c72b14bd76d728c3afb6c7c6fb0ed71e07ba36dd783ef4db6dd00be37db7623f8de62dbe3c17717e4c6beb7daf612f0bdcdb607c077b76d6f06dfdb6d7b3bf8eeb1ed9de07b876d5f05be77daf62ef0dd6bdbbbc1f72edb1e06dfbb6dfb1af0bdc7b6af05df7b6dfb3af0bdcfb6af07df7db67d03f8eeb7ed1bc1f77edbbe097c1fb0ed9bc1f741dbbe057c0fd8f6ade07bd0b66f03df876cfb76f03d64db3bc0f761db9e00be876d7b22f83e026d7efea86d3783ef63b69d03dfc76d7b12f83e61db2de0fba46d4f06dfa76cbb157c8fd8761bf83e6ddb53c0f719db9e0abecfdaf634f03d6adbd3c1f7986dcf00dfe76c7b26f83e6fdbb3c0f705db9e0dbe2fdaf61cf07dc9b6e782efcbb63d0f7c8fdbf67cf03d61db0bc0f715dbc6edfb55dbbe037c3c5edc093e1e2fde003e1e2fde083e1e2fde043e1e2fde0c3e1e2fde023e1e2fee021fd7dd5bc1c775f736f071dddd0d3eaebbb7838febee1ef071ddbd037c5c77ef041fd7ddbde0e3ba7b17f8b8eede0d3eaebbf7808febeebde0e3ba7b1ff8b8eeee031fd7ddfde0e3ba7b3ff8b8ee3e003eaebb0f828febee01f071dd3d083eaebb0f818febee21f071dd7d187cedb6fd30f80eb26d1c3f0eb6ed8f82ef10dbfe18f80eb5ed8f83ef30dbfe04f80eb7ed4f826fa16d7f0a7c8b6cfb11f02db6ed4f838fdfc33e03bebc6d7f167c4b6dfb51f01d61db8f81afc3b63f07be4edbfe3cf80ab6fd05f075d9f617c157b4ed2f81afdbb6bf0cbe1edb7e1c7cbdb6fd04f896d9f657c0b7dcb679fc30fba9d9df3867d6a319f23b22849b7d4dc0dd1f247b0cc6b178ddbc5c0446d6bbabf68cc56a190b0ea3e1e911d00c6b881f953ee3f4004fb7008f509ea5cf38bd4e4e4527a71cf4391cf2ec15c833037179ddbcdc0bb125b6396ad168d7bbd0d1a21efa14ec9b9c799faca423afc3d46f57482e523a161c9e4248ec15c23af2ba794c5c5183d8cb9cd89d4e6c1cf7f95169df5e06cccb0598cd7afb925f6f69df3ed2ae8beb99e374424e2b4183a472c2d8196b1c87fdf5d05edb36d297fbb11efcdec9ec663fe26d89eceeeb7a9cd7e5a0cf8a90fcfb8364f3ef7378fa1c66f3396155db0887c0fe50aa81150e072f7782767d11daad00edb84f17f8f818a7177c7cacc0ebc0632a3c8ee84a3edfd0b1a737849b7dcb8031ec58a7903c63c5639d0230b26f39f02c13d26cb9c3b3d0d107df97c73b7df8b5f5d0e722786fcc86f435b53f373392177fb67e3d48765c6d14d00b3ff707a04fe068c80f66680a46e60692e499188c7cf6df3dbc73d7c62d43670f6d1ccc005abd8389cf999034eac087ed7121be20d8738a03a750798a03a750eb1c59706a85fb9b8f52262d9e4618dabe7578dd8ea11d03bb6eb86a7868f0d49d5b90bac1a147d2a80c90147dfc680a462663fa83644f9e343ab12a154f133c8f4f9ea74b28cfd21bcf0427a74627a71cf46980ff4d10c833037179ddbc3c212476820351498b89556831318467628db5c0096df6e19ecaffc7931d754e2eb847634e6e9d279a10073c0cd69fb170e67f66676fb0c98c0f4636368f9ee6a8d26c0433136adeb5cc4ca799d934439099b93433956666d2cc449a994733d3686616cd4ca299393433856666d0cc049a99bff6a03cb36766f2ccccdda1c0f514b09a4fd4e6ddd1ccbc99993633b3668eaacc27267324628e7ecd919a3932304704e653a5996130efb4e628c6bc439b775573a4668ed0cc11b539c25c45b69aec28b2a3add66bc88e213b96ec38b2e3c94e205b4b7622d9496427939d42762ad96964a7939d417626d9596467939d43762ed93ab2f3c8ce27bb80ec42b28bc82e265b4f7609d9a56497916d20db48b629289fed1a241b0aca67b9b6905d4eb695ec0ab22bc9b605e5b35d66a6de9ce13267b4cc5536e62c96396b65ce5299b352e62c9439eb64ce3299b34ae62c92396b64ce1299b342e62c9039eb737b509ee13733fa6606dfccd89b197a33236f66e0ef0aca33ec6646fdeea03c636e66c8cd8cb899013733de6686dbcc689b196c33636d66a8cd8cb499813633ce6686d9cc289b196433636c6688cd8cb099017e3828cff09a195d33836b666ccd0cad99913533b08f04e5195633a36a6650cd8ca999213533a26606d4cc789a194e33a3696630cd8ca599a13433926606f26b645f27fb06d937c9be45f66db2ef907d97ec7b64df27fb01d90fc97e44f624d98fc97e12946bf269b29f92fd8cece764bf20fb25d9afc87e4df61bb2df92fd8eecf7647f20fb23d933647f22fb33d9b3647f21fb2bd9dfc8fe4ef60fb2e7c89e27fb27d9bfc85e207b91ec25b27f93bd4cf61fb257c85e257b2d1839538103c70b768167cd370e0f0f6dbf6ab87d7867fbf66bb60d6fbd6adb0dedd76d1dbebc7de7b543bb366fdb791dbef83e3b54f1298135bb766dbca17deb8ec1a1ebdb775e33dcbe7373fba69dd7ec18dc8d2f7adcbe68eede11370e0e4607fb51dd3e903e35caa0cfd8d7f1c996932ae7f6ec6804796e342faa1f374a15ed29ac5576f99cf2116efbee6d3b87db0bed3be8efc66df49aa1c18e76fcdf6e1279f770fbeee18dbb86db37efdab9bdbdab03d7fbe3dc2892e86c1bc58b2e6cab3ef3e0ff009826ecb5716c0300", + "packedBytecode": "0x000000028df71de50000003e021f8b08000000000000ffed9d0774154796f75b4280f0d3b3088e045b3860c004e9492449c023679325030e801019e3210c382272c618b0c946e0999d4db339cfe69c739cd9303bb333bb3b3b73ce37bb5ffecef1f9aafad51dfd55543ff4e4aec77dd2ed734aaffaaabaefaffe7dab3a55777f270882a22033f550e9e9e0ee89fe9f36bf959f6eaa8a715d953e398b0a84b3b840387b140867498170f62c10ce5e05c2d9bb40384b0b84b34f8c9c9aad38683fc5cdfb80075de3664c1498a66505a069b2c0347db000342d0f0aa38fea5b209cfd0a84b37f81700e2810ce870a84f3e102e17ca440381f2d10cec70a84f3f102e11c58209c830a84737081700e2910ce270a84f3c902e1ac2810cea105c2f95481703e5d209ccf1408e7b331728e00ce61e6f739f33bdcfc529991e6f779f33bcafc8e36752c31f363541aabd954aab2fe9752a95aa51a95c659ff1bafd2049526aa34c9fcafc2fcaf56a53a95ea559aacd21495a61a1da6a9345da5192acd5469964ab3559aa3d25c95e6a9345fa5052a2d5469914a2fa8b458a5252a2d5569994acb555aa1d24a951a546a54e9459556592cab555aa3d24b2abdacd22b2abdaad25a95d6a9b45ea5269536a8d4acd2469536a9b459a52d2a6d55699b4adb55daa1d26b2aed54e975953ea3d22e9576abb447a5bd2a7d56a57d2aed57e90d4bb337557a4ba5b7557ac7e27c57a5032ab5a87450a5432a1d56e9884a47553aa6d271954ea87452a5532a9d56e98c4a67553aa7d27b2a9d57e97d952ea87451a54b2a7da0d2872a5d56e98a4a5755baa6d275956ea874d3b05043f848a55b2ab5aa745ba53b2a7dacd2e754fabc4adfa7d21754fa7e957e40a51f54e98754fa6195bea8d28fa8f4a32afd984a3faed24fa8f4932afd944a3fadd2cfa8f4b32afd9c4a3fafd22fa8f425957e51a55f52e99755fa15957e55a55f53e9d755fa0d957e53a5df52e9b755fa1d957e57a5df53e9f755fa0395fe50a53fb234ff6395fe44a53f55e9cfccffe83ad89fabf41726ff97e6f7afccef5f9bdfbfb196f95b95feceb27d59a5af58b6bf57e91f4cfe1fcdef3f99dfaf9adf7f36bf5f33bf5f37bfff627ebf617ebf697effd5fcfe9bf9fd77f3fb2df3fb1fe6f7dbe6f73b2add1c9cc997066d533a88a94faa696ed6f75048ec6141fb496bd1c3fc8f7e2b8cbdc4ccd32f69d7d3ccf7b4ecbdcc7c2f6b3da566bed4b2f733f3fd2cfb00333fc0b23f6ce61fb6ec8f9af947c19e08e05aaab16b5b0f632a021bc56131d87a06ed35d1b65eb43ab0f50eda6ba16db41d7b81ad8fb1f506db03c6560ab684b1f521cd542a33b67410574c54aed3eb4dc6bd5e737fe9c1f8799bf47acb3df1f68d9fb759afb79f075e1d1ffdcdbafa42dc0c30b67e607bc8d8fa83ed61631b00b6478ced21b03d6a6c0f83ed31637b046c8f1bdba3601b686c8f816d90b13d0e36d3ed0503c136c4d80681ed09631b0cb6278d6d08d82a8ced09b00d35b627c1f694b155808dc6ae0c05db33c6f614d89e35b6a7c1467dea3360a363be678d4df7133d8b601963a73e2a5c86fa61b00da73e186c23a8ff05db48ea7bc1f63cf826db28e857c836dad8a88fd2ff9b68f2e920ae36910adbc4a4b8d7abd6acd75b17ff7ac3fb71f5419bae69f03309b49a6cf2318ef9a942df4526911fb297407e2e94a572a407ed67885def4f6a4d7e7296e5265acb25a14cada3fee920defad7593c7516734fc8fb89d9ea94c46c87a79c63b601cadab147c73c5d316617008787981d2f31dbe129e798dd0065edd8a3e3deae18b3ab80c343ccaef313b3a94a89d9ccf5af2070c71e9dfb74c598dd041cf1c7ec3889d98e4f39c76c0b94b5638fce7fbb62ccee058ef86376c23a3936e8f09473cc9e83b276ecd1b598ae18b38781c343cc364b3fdbe129e798bd0165edd8a3eb825d3166df078ef8637692a798ad96980d32f73283c01d7b748dba2bc6ec2de0883f669be4fa6cc7a79c63f6e7a0ac1d7b74bfa42bc6ec178123fe98dde0ebfa6c4a623633862308dcb147f7eeba62cc7ec9e4f5bdb1bf34f7c69e00db5f19db9360fb6b187b40b6bf31b6a1502f0f6d60a2b4810e4f39b781bf85b2762c3f65f25db10dfc11707888d97512b31d9e728ed96f42593bf6684c43578cd9af008787986d9298edf09473ccfe77286bc71e8dafe98a314be343f5f1c23f9ae385e160fb27631b01b6af1adb48b0fdb3b13d0fb6af19db28b07dddd84683ed5f8c6d0cd8be616c63c1f64d63ab04dbbf1a5b15d8fecdd85260fb7763ab06dbb78cad066cff616ce3c0f66d631b0fb6ef18db0463d3f7b1684cd5ef1a5b2970a583f8b66d0234a0a9c89a4f43beca2f4f651278d05775fcbeaa75dd5341c7eb5e0d3c351eea9e001f1de1a9019e71f1f384e349c7c7bfde701ba72c4d13e02b05f59ae0a15e45e08bd64df3e42f09366cd3131c8cb1ef9fd57eb4087cd1ba697e2230920dfb18ea73a9fde8be7948511baf87b614ee9fd15f1a38c85f09941937b8adec50c35606ffc7fe769c65f31497615c902f5a37cd93bf32a8cfb8fc33a63aca586331faea238ac017addbf65d06f94abffa64e519cfc477ad27df769f469ad7e6c1f744cb77b5e51bfb4e9ab2eddb2602b387f394aafb719e82c70f1cce536616b595b5cf37a81fcef53c6582b51cc7f39449b02ff4d01ec218a8b53868be1ab4ab8bd0ae16b4a332cf8176befaf149160fcd8f031eeabfb13fabcc334f2503df780c4bdb0dcfa5f038c0d7f6aab41869deb5bd2602a3eb58c5c3f94cd663951a60241b5ec74979d22c6abba698f8f6102b617f443ee8d89cda2ff92b81320b7ab4955d0b7da58f18c178a4a9a3e7bcf16fa754780e5e93030f6e3b0fe755559ee2b112afdf7c12c41b6b76bf54636915758dc7575f9eb278689efc09b3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300b337f66bc9f84e3b6a8dc38268cf6f8375fd7f9c377ec9975e13da0ef7a1d0f96aac4b130340e628455e71228535edcc6f63f603c983d96286a5bfa181b9b6d5b923f1c0f968f7b88d5168fedbbcca10fde9746cd7c8d81b2fb0c9ac7f169a45f25f0f86a8f55168fed1bfb8c1453cda2fa595f630ba2e2cc359eb02236dfa9265ff775f5fbccf43b41edfdd7384bd3f05da3964df7492ff468abb78ffbbcb9de77c6fd06e5e3bc8f9b041ef4157f3f9b6a373ea13868bfafc058f735568bda158d8da8b57c97409921c56ddba60efe9f0eeede3760195a37cd8f8065ebac7597fbab6fd67128b5c04df95e56ddc6033795790af6dd7f66f29ef681a95c9f91c07d72fcfb97cc7891540e3cb8bff371cce2693f5a89f118f778117b1ca4eb7899cae018520fe377b3ee8bc99f300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb330f367d63cf63d74bcf75bcd84314f636cc2fb19f42e36bc2ff693c56d7e7ddf03a47b4e23ad3ae333ca013ca3fcb3860dc73ee07ba55cdbd2d7bdb5a86d49feb88d7d2873e8a335ab736856ef89d1ee3368be1e1849bf3ae0f1d51ea3dedde1ea332a996a16d5cffa18bb902dce5ce3142a62f39d192fe2e3be2e8d17b1f75ff67b8d709c04d9f03e78d4fbc2aa2cdbfdee035ce3da288fef5c88bfdf4cb5bb076c8f15247f384ee22b465b1a27117f3f90aaf4b98fa0364a6342528eba5299af16b795fd9ac9e358a16a58d7771dffa729db9804ec53a7c45fe770fb4e35eba2ed3bc5e13b0dac31f9ae42df45d6bac95e02f9ff567c3703e9415a13bb6e23f81eaba8e56aace5925066b2a3fee998eb3fc5e2c16dac271d3bdf8038fb2e1cebf9ea93264768340234a2329edf03eb1ce76b8f55c67eb4b7558696c5f75bfe1fe8a3a2c6a4bbf601be8e17a2f60178bc60ef173a3276bcbb8f07ec63ce437c8c07a4759707edc7e405d6fa47c2fa89ab7710bd6ff9deb938acdfe798f57bbdf7ca75ee47bc38de90caf48773bf99269fcbb9dffd3a8f779dfbe1725175c77e21ee7d23c623b2e0fb22a9cc602b1eeb22b8273a967d326259d2ca7ef7219e97e23142fcef8dccf43753acba509b9a0c75a132cf5aed26fe63a6ccf1a7af7764d2b10ef541558eba529991d0d646997c02b613ee17ea1cffa729dbf127e9a7eb3c2dfe3a87db77ba59176ddf690edf33803526df55e89b8e3fc90fd94b205f0bfb132a477a90d6c45e069cc86e2f576b2d9784326947fdd331d77f9ac533cd62d6b13316e2ac0e9eb5f0d557a703b7462341a3eff9039bebbdc6ae7d8cafe7d1a2f63155c068f79bb89fcce7b372f6f55bd7f10995c163682a330ffad984a3ac7d5d9a968b737c3a3e0f84c785f83c90af73a464d05ecfa4c5e1d377b9e5bb3c8fbefb59befbe5d1b7682e9a73d29cd3377f70df520c8c3ece1bf1fa484718f17d04b45c0f60f4f5cc662a07c66a60c4fd1d317a78bf725567bf2984c73a3d81d1c7f3c6b95eafc6f79be33b0688d1c733dab9bea71a9fdba6e57a03a38fef1ae137943ac2e8fad65129fc7af8ae515567bf0382df3aea038c3ebe0d9208da7fcfe45e8c938091967b00187ddc474a04edafabdd8b11ef57d27209cf8cd9f6ed9ec7fea472bd06918f710551c71ae8dbc3f5ff148e4de88816f57e79b21efba06f0fd7bf422dea838e6b81f7e73cdc1b0ddbf1e41c78f01e222dd71f18a77a629c9203e35460a4e5060063da13e3d41c18d3c048cb3d048c1eae43868ce91c18f17a1dd91f06c6e99e18a7e5c0381d1869b94780d1c735c504f8ed08e30c60a4e51e05c6999e1867e4c038131869b9c780719627c6993930ce02465aee71609ced8971560e8cb38191961b088c733c31cece81710e30d272838071ae27c6393930ce05465a6e3030cef3c4383707c679c048cb0d01c6f99e18e7e5c0381f1869b92780718127c6f939302e00465aee49605ce88971410e8c0b819196ab2800c6a105c0f85401303e5d008ccf1400e3b305c0585a008ccf03e3a2f819c3f3d48539302e029e17e2e709355b9403cf0b7e79c2f7132e72f85a1cbfaf54ae755f0c3c4be2e709b7c5e21c78882109cbbde09731d55946cdb3347e9e50b32539f02c05cd963834f3c098ea2ca3e659163f4fa8d9d21c789681664b1d9a79604c759651f32c8f9f27d46c590e3ccb41b3650ecd3c30a63acba87956c4cf136ab63c079e15a0d97287661e18539d65d43c2be3e709355b9103cf4ad06c8543330f8ca9ce326a9e86f87942cd56e6c0d3009aad7468e68131d55946cdd3183f4fa859430e3c8da0598343330f8ca9ce326a9e17e3e709356bcc81e745d0acd1a1192746e489fb7de38d0e5fab18d49d1890b14f01303e50008c3806c147ff956d0c42a35f7d529dd5c7d7f6ca3606017daff6a4c5aaa0e35aacf6cb93750c02fa5ee3498bd541c7b558033c2f79d022013e3ac2430c4958ae7f01300e2800c6870a80f1e102607ca400181f2d00c6c70a80f1f102601c58008c830a80717001300e2900c6270a80f1c902607cd13363b6f39797bab8efa87395aeee3beabca4abfb96389738ef0ebe25ce25cebb836f897389f3eee05be25ce2bc3bf896389738ef0ebe25ce25cebb836f897389734ebe5ff6e03b013e68ca768d9f1892b0dc8bc2d8a51991a7223e9e4aac3bfa7a8541dd5f71f01479aa3bfa7a9541dd89a1d0185f2e00c6170b805174cc8c41ec0ca3e659eb89e7d51c78d602cf3a4f3c6b73e059073cebe3e709636a5d0e3cc49084e55e2c00c6970b805174141d39318a8edd47476114466114c6fbc158087db8ec6732e72e9d61d43c4df1f3849aadcf81a70934a3e55ef0cb98ea2ca3e6d9103f4fa859530e3c1b40b32687661e18539d65d43ccdf1f3849a6dc881a71934dbe0d0cc0363aab38c9a6763fc3ca166cd39f06c04cd9a1d9a79604c759651f36c8a9f27d46c630e3c9b40b38d0ecd3c30a63acba87936c7cf136ab629079ecda0d92687661e18539d65d43c5be2e70935db9c03cf16d06cb343330f8ca9ce326a9eadf1f3849a6dc981672b68b6c5a19907c654671935cfb6f87942cdb6e6c0b30d34dbead08c2be38b05c0f87201307ad631d55946cdb3dd13cfb61c78b603cf0e4f3cdb73e0d9013cafc5cf13c6d48e1c78882109cbbd58008c2f1700a3e8283a7262141dbb8f8ec2288cc2981be32b05c028db5a18b9327a38bfcafa7cca8e2eee3beaf994aeee3beaf994aeee5be25ce2bc3bf896389738ef0ebe25ce25cebb836f897389f3eee05be25ce2bc3bf896389738ef0ebe25ce25cebb836f897389f3eee05be25ce2bc3bf896389738ef0ebe25ce25cebb836f897389f3eee05be25ce2bc3bf896389738ef0ebe25ce25cebb836f897389f3eee05be25ce2bc3bf896389738ef0ebe25ce25ce39f9de19bfef54aecfb0ee041e1fcfd47aaa67a55eefeb665d9fc4a89fd6ea3396563b2cad9250e675d0ef331ef42b02bfb46e9a277fb9320f63c0ecc977ea41b58e3e507ff2f1b2a587f6bfcb53dda3fafa5d5ddc77545fdfd57d47f5f55dddb7c4b9c47977f02d712e71de1d7c4b9c4b9c73f18df992a0edb89ddeafa4d7b1dbe47b9a792aff0a2c4765e6f5cefc9607d2867cf8963624fb8aeee05be25ce2bc3bf896389738ef0ebe25cef9c539c6c3bc3cf004164f9085271ff70f72e119c38c6706339ec9cc782630e3a962c6339219cf66663ccdcc78d633e3e9c18c673e339e99cc785e62c6338519cf44663c29663c5b99f1ac64c6b38c19cf68663c8b99f1bcca8c6716339ea9cc78d630e399c48ca79a19cf36663c5b98f10c63c6b391194f13339e05cc78d632e399cd8c27cd8ca79619cf70663c35cc78b633e3798e194f23339e06663ccb99f12c61c653c68c27c98c6721339e39cc78a631e3a963c6338e19cf2a663c9b98f16c60c6b38e19cf08663c0f32e32967c6339619cf5c663cd399f1d433e319cf8ca79219cf6a663c2b98f12c65c6d397194f3f663c8b98f18c62c653c4802711dcfd8e9304fc7f27d88aad65f563616f0e6efbff1e632f8665f69a7c0fc7baf7808d9e35dbeb581675da0375499b7ce5a79b429dd0571ae6c95f1970ec65c2338a19cf22663cfd98f1f465c6b39419cf0a663cab99f15432e319cf8ca79e19cf74663c7399f18c65c653ce8ce741663c2398f1ac63c6b38119cf26663cab98f18c63c653c78c671a339e39cc781632e34932e32963c6b38419cf72663c0dcc781a99f13cc78c673b339e1a663cc399f1d432e34933e399cd8c672d339e05cc789a98f16c64c6338c19cf16663cdb98f15433e399c48c670d339ea9cc786631e3799519cf62663ca399f12c63c6b39219cf56663c29663c1399f14c61c6f312339e99cc78e633e3e9c18c673d339e66663c9b99f18c64c653c58c6702339ec9cc786630e319c38c6727339e790e1e0fdfcf0b7968bc2aad9be67732f1ed613b84df0dfcaca73aed33ebea65d64bfce4af04ca2cea93f9d5e3757059e2b2c71763acee038d767baa4bd43b99777771df51ef64eeeabea3dec9dcd57d4b9c4b9c73f2bd2f7edf297c3685a6226b3e0d79dcbff878a6c7533ddbeddbe3fe26f07e4babdd96564928f359d06fbf07fd5cc70b344ffe72651ec68019e3a22288372ede88bf4edffbd630e9fa86a52fd6eb4d4f9a46ed43deece2bea3f6215ddd77d43ea4abfb96389738ef0ebe25ce25cebb836f897389734ebedf32f918cf1b2bd187bef64be7036f81df774cbe2846bf7a5d6f9b75d1b79189e31de0a1323f02d7a2a5cd4b9b8fcbb7ecdb24cebb836fce716ee7e91e22beb7dbd73ddea858ccc7fde5fbe93b2a16bbbaefa858eceabe25ce25ce39f97e377edfe13dc49d41fb29db3dc47781e76d0f5a78aa6778ee74c0aad34eab4e492883e772073cd4b308fcd2ba69fe006c874263d63c34961ddfcf48e55e62c248b6b7fdf284edeba5a0fd94ad7d1d001e0feda0ca533dc3f6d562d5e92587ee540663b5c5433d5d6d87e65b603bb41418b3e6a167e7883501e55e65c248b677fdf284edebd5a0fd94ad7db5008f8ffec7533dc3f675d0aad3ab0edda90cc6ea410ff574b51d9a277f85c8ac79d69a3cb126a0dc5a268c643be097a7260175a6295bfb3a083c2d1ef4f154cfb07d1db2eab436b85b772a83b17ac8433d5d6d87e60fc17610666176316b9e7526bfd6fc26a0dc3a268c646bf1ca535399803ad394ad1f3b043c3efa794fba87fdd861ab4eeb1cba53198cd5c31eeae96a3b347f18b6432eccfb0a905974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974ee1cb3e6596ff2c49a8072eb993092eda05f9ef0f99df541fba9c89a4f43fe30f01cf2a08fa77a86e3de8f58755aefd09dca60fb3ae2a19eaeb643f347603be4c2bcaf009945e7ce316b9e269327d604946b62c248b6437e79c27eac29683f65ebc78e008f8f7ede533dc37eeca855a72687ee5406dbd7510ff574b51d9a3f0adb419885d9c5ac7936983cb126a0dc06268c643bec9527153e87b821683f65ebc78e028f8f7ede93ee613f76ccaad30687ee540663f598877abada0ecd1f83ed900bf3be0264169d45e72866d159748e62169d45e72866d159748e62169d45e72866d159748e62169d45e72866d159748e62169d45e72866d1b9fbe8ac799a4d9e581350ae990923d98e78e5a90eef3b3407eda76cf71d8e018f8ffb329e740fef3b1cb7ead4ecd09dca60fb3aeea19eaeb643f3c7613b7475e67d05c82cb1911f66890d618e6296d810e62866890d618e6296d810e62866890d618e6296d810e62866890d618e6296d810e62866890d618e6296d810e62866890d618e6296d810e62866890d618e6296d810e628660eb1a179369a3cb126a0dc46268c643bea97277cefc1c6a0fd946ddcce71e039e6411f4ff50cc7ed9cb0eab4d1a13b95c1f675c2433d5d6d87e64fc07610666176316b9e4d264fac0928b7890923d98ef9e509fbb14d41fb295b3f7602787cf4f39eea19f66327ad3a6d72e84e6530564f7aa8a7abedd0fc49d80ec22ccc2e66cdb3d9e4893501e536336124db71bf3c613fb639683f65ebc74e028f8f7ede533dc37eec9455a7cd0edda90cc6ea290ff574b51d9a3f05db419885d9c5ac79b6983cb126a0dc16268c643be1972795803ad394ad1f3b053c3efa794ff50cfbb1d3569db63874a73218aba73dd4d3d57668fe346c874263d63c5b4d9e5813506e2b1346b29df4cb13b6afad41fb295bfb3a0d3c3efa1f4ff50cdbd719ab4e5b1dba53198cd5331eeae96a3b347f06b643a1316b9e6d264fac0928b78d0923d94ef9e509dbd7b6a0fd94ad7d9d011e1ffd8fa77a86edebac55a76d0edda90cc6ea590ff574b51d9a3f0bdba1d09835cf769327d60494dbce84916ca73df324a0ce34656b5f6781c747ffe3a99e61fb3a67d569bb43772af326d4f39c877abada0ecd9f031e9ae6018fafb80c2c9ec0a10f4d6398f1cc60c6339919cf04663c55cc784632e3e9c18c673e339e99cc78a630e399c88c27c58c6725339e65cc784633e3799319cf62663cb398f14c65c6b38619cf24663cd5cc788631e359c08c6736339e34339e5a663cc399f1d430e36964c6d3c08c6739339e25cc78ca98f12499f12c64c6338719cf34663c75cc78c631e359c58c6704339e0799f19433e319cb8c673f339eb9cc78a633e3a967c6339e194f25339ed5cc785630e359ca8ca72f339e7ecc781631e319c58ca788014f22b87b2c4d02febf1f6c34e6633bd8de33f933602b76f8a07bc5e7c05662f2b48ede2a1d1d7cf7ba51275fe35cd0571ae6c95f1970bcc7846714339e45cc78fa31e3e9cb8c6729339e15cc785633e3a964c6339e194f3d339ee9cc78e632e3d9cf8c672c339e72663c0f32e319c18c6715339e71cc78ea98f14c63c6338719cf42663c49663c65cc789630e359ce8ca781194f23339e1a663cc399f1d432e34933e399cd8c6701339e61cc78aa99f14c62c6b38619cf54663cb398f12c66c6f326339ed1cc789631e359c98c27c58c6722339e29cc786632e399cf8ca707339e91cc78aa98f14c60c6339919cf0c663c6398f1cc73f0ecf7c4633fe745f3fb19f8d6f3b5a08b9e12f07f7c0eec4d4f8cfb2d469a7f131891d7b766e5164fb9a5d9fdf4adeb4ff72a1e34bfb8bdf0b9070edbab3c0f9af5b378fa599add4fdf5a0bbaf74f636c707be138680edb0bc7697ae89f6b12168f9e8aacf934e4cf79d6c7533d2b71dce42731ae576b75ded26abfa55512ca9c05fdce7bd0af08fcd2ba699efc09b33047316b1eba97eb1acfbb900923d9f03d2aefc7cf5393b078f494ad7f7cdfb33e9eea19f6631702b7eeef83ee540663f582877a16815f5a37cd5f70f8ae08e2d5e26207b4b8e8e0b998672dc85faecc670b909983ce9a87c6ae136b02ca2d62c248b6f3c073297e9e9a84c5a3a76cfde325cffa78aa67d8277c10b875bf04ba53196c5f1f78a86711f8a575d3fc07b01d7261be5080cca273e79835cf629327d604945bcc84916c1781e7c3d8795295098b474fd9fab10f3debe3a79e997eec72e0d6fd43d09dca60fbbaeca19e45e097d64df397613b08b3300bb3300bb3300bb3300bb3300bb3300bb330eb32c22cccc22cccc22cccc2cc9759f3d0b3e7c49a80724b983092ed03e0b9123b4fe6be03f2e829db7d872b9ef5f153cfcc7d87ab815bf72ba03b95c158bdeaa19e45e097d64df357613b08b3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300b336f66cd43dfb020d604945bca84916c9781e75afc3c35098b474fd9ee3b5cf3ac8fa77a86f71dae076eddaf81ee540663f5ba877a16815f5a37cd5f87ed20ccc2ec62d63cf42e44624d40b9654c18c97615786ec4ce93b97f8a3c7acad68fddf0ac8f9f7a66fab19b815bf71ba03b95c158bde9a19e45e097d64df337613be4c27ca100994567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974169da3984567d1398a5974ee3e3a6b1efa4627b126a0dc72268c64bb0e3c1fc5ce535d99b078f494edbec3479ef5f153cfcc7d875b815bf78f40772a83edeb96877a16815f5a37cddf82edd0d5992f1420b3c4467e98253684398a59624398a398253684398a59624398a398253684398a59624398a398253684398a59624398a398253684398a59624398a398253684398a59624398a398253684398a59624398a39839c486e65961f2c49a80722b983092ed26f0b4c6cf5393b078f4946ddc4eab677d3cd5331cb7733b70ebde0aba53196c5fb73dd4b308fcd2ba699efc09b33047316b9e95264fac0928b7920923d96e01cf9df87952098b474fd9fab13b9ef5f154cfb01ffb3870eb7e0774a73218ab1f7ba86711f8a575d3fcc7b01d0a8d59f334987cabf94d40b906268c64bb0d3c1ee22ee4495a3c347f87816f3ddf68f265e617b757233072d85ec93c68566ef1945b9add4fdfbafeab4cfe41f38bdb6b153072d85ee579d0ac9fc5d3cfd2ec7efad65aac36f9bee617b7d76a60e4b0bdfaf9e549252c1e3d653bdef818783e1f3f4f781ef7710e3c9f079ecfc5cf53e5a99e957abddf07ec71ad576bf5054bab8f2dad92500619bee041bf22f04beba679f227ccc21cc58c7d21b126a0dc1d268c64fb1cf0f8e83774dd479975d1fa7baaf450ff36bfadf1fbadc16b0bbdcc7a8983fc9540999707b5b13d66d8cae0ffb4dd747d6e59364fcfbc55b9aef3d23cf92b0bdce7fabeaea1b65a3cb6ef32873e5ab39b0ecd6e7862b49f69a5f91bc0e8baceebeb79d1a8ebcef8bce81d4b476e9ae173c01f018fafe3e2568ba7d5a1858f3697ebf1e5470e9e4fe2e3a9c4d8405f3e6215fbb68ed4ddd57662ac7b15dec3425f1eda40b89f1a6dd645ebd7fb82dafe5e35afc1fe81f653a3ad3a97409949b09f9a92653f551cdc7d5db8c2d8a90cfdff1363b7d75111dcdf6b4b6590af35bf18a36493fd6ffb7b98b5968edc34c376dd0a3cad9e78a2ae89913fdc86750ecdea1868866d211f7176c7e2b17d27419756a69a619ce17183affeec5ed7f2701bd63b34ab67a019c7feacded2919b66aefe0c755ce8e05ec8809b639fb2d0d2919b66ae3e05755ce4e05ec4809b63bb5e64e9c84db37bb5ebc50eeec50cb839b6ebc5968edc34bb57bb5ee2e05ec2809b63bb5e62e9c84db37bb5eba50eeea50cb839b6eba5968edc34bb57bb5ee6e05ec6809b63bb5e66e9c84db37bb5ebe50eeee50cb839b6ebe5968edc34bb57bb5ee1e05ec1809b63bb5e61e9c84db37bb5eb950eee950cb839b6eb95968edc34bb57bb6e70703730e0e6d8ae1b2c1db96996effb0051f79bc81f6ec34687668d0c34e3d8a7345a3a72d32cdff701ee35061bb7e12a8766ab1868c6b13f5b65e9c84db37cf76751f79bc81f6ec3d50ecd5633d08c637fb6dad2919b6651fd596bfc3c398fb76ff5aa4fe63bcbad39f0e098291f31e5290e2a3d8da90ac7dbdbdfaf68b5b44a06777fd3c2e7d8c3a8f191e44f98855998855998855998855998855998855998855998855998855998855998f933e3f3ccade617df857a870923d9f09e948febfcbaee63ccba68fdfad9de5b03dafcc67fdf225589f75ce9b9e331569d4ba0ccff7dbc8ded63c386f71769bb456dcbfbf56e057c1f05de0bba9ff73b3f726876c3a1d9754f8c769f41f3d781d17effc3fd7ef7c41d4b476e9a45f5b3773cf144c5d91d87ef8ad87ca79a7cddd7d5ef22ec13dcbdffbae3d0d4471ce6faee0b6c17ad1e787cbde742d7e9ba55a75b569d92506618d4f37eb62d9ae6018faffe28b07802873e341533e399c18c670c339ec9cc784a99f14c60c653c58c6724339e6798f13cc18ce731663cfd99f1f461c6d38319cf7c663c3399f14c61c63391194f8a19cfb3cc785632e3799219cf32663c8f33e359cc8c6700339e0798f18c66c653c28ce779663cb398f14c65c6b38619cf24663cd5cc78f2710f34179e61cc782a98f10c64c6f310339e05cc7812cc787a32e399cd8c27cd8ca79619cf70663c35cc781a99f13cc78ca78119cf50663ccb99f10c62c6b38419cfc3cc781632e32963c69364c6d38b19cf1c663cd398f1d431e319c78c6715339ea798f10c66c6f308339e11cc781e64c653ce8c672c339edecc78e632e399ce8ca79e19cf78663c95cc785633e3799a19cf0a663c4398f1dc66c6b39419cf22663c8f32e3e9cb8ca71f339e51cc788a18f02482bb9f5dc2e7e56e818d9eb169055bb1637d342e97caebe3ceb383ef5e77b163dd371c0ca8d335a84bdae42b3fddd4eeb9a222b35e9a277f65c0718309cf28663cfd98f1f465c6f328339e45cc789632e3b9cd8c6708339e15cc789e66c6b39a194f25339ef1cc78ea99f14c67c63397194f6f663c6399f19433e3799019cf08663c8f30e319cc8ce729663cab98f18c63c653c78c671a339e39cc787a31e34932e32963c6b39019cfc3cc789630e319c48c6739339ea1cc781a98f13cc78ca791194f0d339ee1cc786a99f1a499f1cc66c6d393194f8219cf02663c0f31e319c88ca78219cf30663c3799f15433e399c48c670d339ea9cc786631e3799e194f09339ed1cc781e60c6338019cf62663c8f33e359c68ce749663c2b99f13ccb8c27c58c6722339e29cc786632e399cf8ca707339e3ecc78fa33e3798c19cf13cc789e61c63392194f15339e09cc784a99f14c66c6338619cf0c663cc5cc78e6593cf87f7dad81ae2f5e071bfdff3fcdcdfb72538feb96bf18ea5119f56d1e5f9ae194766812f56d1e0e3c3398f18c61c63399194f29339e09cc78aa98f18c64c6f30c339e2798f13cc68ca73f339e3ecc787a30e399cf8c6726339e29cc782632e34931e3799619cf4a663c4f32e359c68ce771663c8b99f10c60c6f300339ed1cc784a98f13ccf8c6716339ea9cc78d630e399c48ca79a19cf4d663c15cc780632e3798819cf02663c09663c3d99f1cc66c69366c653cb8c6738339e1a663c8dcc789e63c6d3c08c6728339ee5cc780631e359c28ce761663c0b99f19431e34932e3e9c58c670e339e69cc78ea98f18c63c6b38a19cf53cc780633e3798419cf08663c0f32e32967c63396194f6f663c7399f14c67c653cf8c673c339e4a663cab99f13ccd8c6705339e21cc786e33e359ca8c6711339e4799f1f465c6d38f19cf28663c450c78a2be8543ffef01b6ab267f1b6c574cfe26d82e9bfc75b07de8b0153b58c8df55b0d138972b60a37b7597c146d78bc8973edebd38f86ed662479d7a3858af38ea74d5b12c6e475a261dc4bb1dd1571ae6c91f7eabe72a139e51cc78fa31e3e9cb8ce751663c8b98f12c65c6739b19cf10663c2b98f13ccd8c6735339e4a663ce399f1d433e399ce8c672e339edecc78c632e32967c6f320339e11cc781e61c6339819cf53cc785631e319c78ca78e19cf34663c7398f1f462c69364c653c68c6721339e8799f12c61c6338819cf72663c4399f13430e3798e194f23339e1a663cc399f1d432e34933e399cd8ca727339e04339e05cc781e62c63390194f05339e9bcc78aa99f14c62c6b38619cf54663cb398f13ccf8ca78419cf68663c0f30e319c08c6731339ec799f12c63c6f324339e95cc789e65c69362c6339119cf14663c3399f1cc67c6d383194f1f663cfd99f13cc68ce709663ccf30e319c98ca78a19cf04663ca5cc782633e319c38c6706339e62663cf32c1ebca6580936ca57818df229b051be1a6c94af011be5c7818df2e3c146f90960a3fc44b0517e12d8284ff78cf0f99e7cbc178e7cd1ba69fe1a30de3679dc2694af03ee0f2c9be6bee489fb038b9be62f0123d5e103b051be1eb82f5a36cd7dc113f7458b9be62f0023d5e122d8283f196c949f0236ca4f05db54f04736ca4f031be5a7838df233c046f99960a3fc2cb0517e36d8283f076c949f0b36cacf031be5e7838df20bc046f985e6576fe3f72d9bdec6e74d3e1dc4bb8dc917ad9be6cf03236deff7c146f945c0fd9e65d3dce73c71bf6771d3fc3960a43abc0736ca2f06eeb3964d739ff1c47dd6e2a6f933c04875380b36ca2f01eed3964d739ff2c47ddae2a6f953c04875380d36ca2f05ee93964d739ff0c47dd2e2a6f913c04875380936ca2f03eee3964d731ff3c47ddce2a6f963c04875380e36ca2f07eea3964d731ff1c47dd4e2a6f923c04875380a36caaf00eec3964d731ff2c47dd8e2a6f943c04875380c36caaf04ee83964d73b778e23e6871d37c0b30521d0e828df2f83efa359e186f5b8cb72ddf781f178f2d0f5836cdf8ae27c6031623cdbf0b8c2d267f00780e78e269b1786cdf49d0650d53cd92606b019e5a4f3cd72c9e6b961638de0dcf05d658369fdb758dc548f30780b1c5e4f3d1365b2c1edb771274a965aa59126c2dc053e789e792c573c9d2029f73c173b75acbe673bbd65a8c765f8171867d85afb6d962f1d8be93a04b1d53cdb0cf6d019e7a4f3c172c9e0b96166590c7f3c73acbe673bbd6598c765f8171867d85afb6d962f1d8be93a04b3d53cdb0cf6d019e164f3ce72d9ef3966fdc8678bebfd0b2f9dcae0b2d469ac73ed76e0ba5908f9ba7dee2b17d27419716a69ab9da82cffeec9cc573cef28ddb10afcf2cb26c3eb7eb228b91e61702638bc9e3365ce489a7c5e2b17d2741977aa69ab9da4229b0c5cd73c6e239636981e3f6f07a5abd65f3b95da3fa8f45c0d862f2f9689b2d168fed3b09ba2c66aa191e43b6004f8b279e5316cf29cb376e43bcfeb9c4b2f9dcae4b2c469ac73ed76e0ba5908f9b67b1c563fb4e822e2d4c3573b5059ffdd9098be784e51bb7215eaf5e6ad97c6ed7a51623cd2f01c61693c76db8d4134f8bc563fb4e822e8b996ae66a0b3efbb36316cf31cb376e43bcbfb0ccb2f9dcaecb2c469a5f0a8c765b28857cdc3c51fd19f94b822e2d4c3573b58552608b9be788c573c4d2a20cf2783fa8c5b2f9dcae2d1623cd2f0346d2aa05785a3cf144c519f94b822ecb996a96045b3ef69b872c9e43966fdc8678ff6e8565f3b95d57588c34df028c765b28857cdc3ccb2d1edb77127459cc5433575b401d1b807ba565f3a9ed4a8b9be65700e362878e2b3df144f5292b41c7064b476e9ab9e211756c04ee06cbe653db068bbbc1d2d6158fa5908f9b27aa5d37808e8d968edc3473c56319b0ad02eec596cda7b651eda80118975bdafadcef456debc5a023e9d2c85433bcae89db9ad8560377a365f3a96da3c56db719dcd6d8661a3df1446deb46d0917459c55433ec7bf07cc8d7f947d4fdae7cf88eba07920fdf51d7c5f3e13bea5a693e7c47dd47cf87efa86b2af9f07daff36c9fbea3ae59e6c377d4795f3e7cdfb67cdfcea3efa8f16ff9f01d3526aaabb76fd99774af7dc9fdecd7baebbe44fa739efdf9eaf87da71241fb731a3d1559f369c8e3f9cb2a0f5a78aa67259e137e12e37a5de7d6cb2dadf0dc1acf517d9dffadb678689efc152233c645517cbe2bf13a0c7edf91ae8b54828dae8b55818dae8ba6c0d662f2d560a37b323560a3fb81e3c046f7a2e7838dc6412c001b8dc1b900361afff53ed868ece179b0d1b8d7f7c04663aecf818dc6fb9f051b3d6b72066cef98fc69b0bd6df2a7c0f696c99f04db9b267f026c6f98fc71b0ed37f96360db67f247c1f659933f02b6bd267f186c7b4cfe10d8769b3c5e7bdf65f2782de733268fd7f25e37f9f160db69f213c0f69ac94f04db0e939f04b6ed267f1b6cdb4cfe0ad8b69a3c7e5f748bc97f00b6cd267f096c9b4cfe22d8369afc64b0359bfc14b06d30f9a9606b32f934d8d69bfc34b0ad33f9e9605b6bf233c0f6aac9cf04db2b263f0b6c2f9bfc6cb0bd64f273c0f6a2c9cf05db0b263f0f6c1f9bfc41b07dcee4f13a68b1c9e3f57b7adf14def3a2775ee23d4f7aaf34de6fa76f7fb4808dbeaf85e38c4a4d1ec7b8d17ba5707c25bd4b12c7a9264c1ec79597993c3ed340dffdc06743e8db51f85c52b9c9e33371f4cdcf0360a3ef92be0b367af7d43b601b60f26f838ddee9fc16d8e83b176f828dbeddf406d8e87b9ffbc146ef98da07b6c74dfeb3601b68f27bc136c8e4f7808dbed1b41b6cf49dc85d60a377497d066cf47ec4d7c15661f23bc136d4e45f03db5326bf036cf4fdc5ed60a377466d031bbd77702bd88699fc16b0d1f70e36836db8c96f021b7dc76b23d8e8dd50cd607bdee437806d94c937816db4c9af071bbd9b671dd8c69afc5ab0d13efb55b0d13efb15b0d13efb65b0d13efb25b0d13efb45b0d13efb05b051dfff31d8a8efa7fe43b753dd7e6f99f97410df7194f6d71ab49fb21dcb1303f2c4796c9c041ef47533f6baa7c2e3f08fccba8acd7a295e6e82efebb1fbce9c03dc30ebea69d67bddf25d02654a07b66d9b6bf0ff34d48196c332b46e9a1f03cb5eb3d65d6eea7bc3537daf5b4cc47d0398a84cd9c0b6b25f32f952582646b6f07c96622d000d714a439e18fc68950acf2f3eca81e706f0c4df4e32e7d73e6202db56dce7d7f675193bd69250e63ae8e7ebbd58372c1e9a277fc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc22cccc2cc9f59f3d0fd04624d40b95b4c18c986f7ba7c5ce7c77bae78cfebe6c036bfbeefeff532eb1d6bd5b904ca7c6b601bdb6d932f83ffd3768bda961eee1366dd96dfbb5706f5c17b411eb665c873d3e2b17d9739f4d19a5d736876d513a3dd67d03c7ef385f4bb063cbedae3758bc7f68d7dc60da69a45f5b33ec625648b33d718848ad87ca79a7cddd7d563a1f4580e7bff75cbd214c740e03df32f419f44cbdc31bf09d0e70ee8733ffb007b5c02f653adc0187fbf996a770f98fafe3196a63806e2b78cb6340622fe7e2055e9731f416dd41e5b8175a532bf0ffbb93f34791c07740bd6f515c7ff69ca362601fbd4cbf1d739dcbe1f9a75d1f6bdecf0fd01b0c6e4bb0a7d1799447ec85e02f92f0f6c2b6b7f678ab42676fc1616b2dbcbb55acb25a1cc1547fdd341bcf5bf6cf15cb69875ecfc09c4d957e058cf579f742542a331a01195c1635e5ffbaf8f2c1ee2207fd88ff6b6cad0b22550e6ebd047e9ba503fdf6a7ea3f601be8e17a2f60178bc60ef17128e3aeaf8b835a08db7bb8ff5fb2fe82faec1ffd3c1a71febf75f1043aee3525aff58583f71f50ea2f72d54e67f59fb511fe793b82d6d3d712c2195f97fd00fa50665f2b99cd7ddaf73f4a8f33a1fdfcec4730d9ab2eddf711fe3a37ff154cf4ad7beeb9a55a724941906f5f4701ce3dc6fd1fc65f0edeb7ba9e4838ea1ae5b5a944099a4693bd47744e988d7256ee4a52e29e7f1e058475da8cc00a84b29d8e364f2b9ddf0384baff7a6a3ae54e6b1416d65079a7c02b613f6a5231cffa7295b7f40fae93a5f8cbfcee1f6a5e71669fb5e74f87e1f5863f2ddeefd1574bc4f7ec85e02f9e183dacadadfee24adf15bacf47c1db2dbcb5db7964b42994b8efaa78378eb1ff59d59f2a7636708c419c591cf7ef35284466341232a83f70aeceb2d51fb7d1f63e9b3edf76f02a3dd6fe2b18b4f36fb9cc5be5eee3a1ea43278ce426526403f9b7094f57f1f20736c83f5a27a04565d03abae9e8e5f6b8a2c3dd3e06734d8293e4967fa1f1ee3529969d6feccf7756ce2a67ae0fdbaab16f7354b57bc16351bb875dcdbe716789ceef99cb6068fc5ece3a1abc04e65165ac743f671dc6d475decfd747170f7b9e02756597c3629db7276fe236b19bc66e0ba268b7ddf1560499b7ce5a799aa2a2b91a9d8a185ebbea9ab4fa2768031675f47196dad07afa3acb1fa24bbacee936afbb7e943db11afb5dbd7df3d3d9b16b6b95b56fd6d8d3463abc9e336f4710fa33b3e9b561adb7a27ad2fc4f10ca5563e1edfa90db8afc8a6c555078faf6b9a515a5c75f88e4f8bf14daefd874b8b2b0e1e5fe798515a5c71f88e518b8dae6b0b2e2d2e3b787c9d6b446971d9e13b3e2d26b4bbae914d8b0f1d3cf15fd3c8ae05de13cb85f90a03e6522b1f8fef9af5ae7b772e2d3e70f0f8ba7717a5c5070edff1695135de75ceeed2e29283e7529eb5b8e4f01d9f161327b9aea9b8b4b8e8e0f1707d2dab16171dbe638c8b66bcbe964d8b0b0e9e0b79d6e282c3778cc787e3b35d33442dde77f0f8baf617a5c5fb0edf316ab14efb3edf012dce3b78cee7598bf30edff169b17e9cf6fd5e07b478cfc1f35e9eb578cfe13b3e2dd64dd4becf75408b730e9e7379d6e29cc3778ce750615c9ced8016671d3c67f3acc55987eff8b4d8101e6b9de98016671c3c67f2acc51987eff8b4a80cf7a9a73ba0c56907cfe93c6b71dae13bc6b808cf274f75408b530e9e5379d6e294c3778cfb91302e4e76408b930e9e9379d6e2a4c3777c5a6c0caf3f9de88016271c3c27f2acc50987ef18afb9847171bc035a1c77f01ccfb316c71dbee3d3a23adca71eeb8016c71c3cc7f2acc53187eff8b4680eef891ded8016471d3c47f3acc55187ef188f3bc3fee24807b438e2e03992672d8e387cc778dc195ebf38dc012d0e3b780ee7598bc30edf31f69de171e7a10e6871c8c17328cf5a1c72f88ef1b833d4e26007b438e8e03998672d0e3a7cc778dc19ee475a3aa0458b83a725cf5ab4387cc7181761df79a0035a1c70f01cc8b316071cbe63bcae15f69def76408b771d3cefe6598b771dbe633c1f09aff1bdd3012dde71f0bc93672dde71f88ef15e51780cfe7607b478dbc1f3769eb5781b7cfb1867825ad058ac5196162550e681c1995f1a8b15a523ad039fa1c5babc157b5d32e3cade8ca8cb5b50172ad317ea520af638993cd5358c19fa96028d4d6f75d495ca3c3cb8adeca3269f806d721bd635ccf17f9ab28d4122fd749df7c55fe73056e91b10b47df7397cef05d6987c57a16f1a9b4e7ec85e02f96707b795a572a407694decba8dd0373090dd5eee6d6bb92494d9efa87f3a88b7fefb2c9e7d1673f8dc03c419c5919fbe2bc3b43f42a351a01195c1317bad9e78ec3184c441fe7419dafebdad32b46c099419037d148e2ba57a2682bbc74deafabde1a97ee48bd64df3e42f09b61bc068d751c7c74330f693be0142df07d136fade077ebf6bbc65d3759de0a9aee48bd64df3138091be3f323eff8ca98e328eb31835cf240f9ae1375568cab6bf98043c133df078aa67b81faab5ea34c1aa5312cae0b38db51eea59047e69dd345f0bbe7d6c73d482f6c9c32d2d4aa0cc42ebf8314a475a878edff18ebaf8d2719cc533cee17bb2671d69ddd4274ece83ef3acb778de55bb76d8c313d656bdb75c05cef8159af774afceb0ddbf654b32e8a67f25303754a830671d5097d1759eb267b09e49b06dfcd407ad0be93d8753bc2d8895a6e92b55c12ca4c76d43f1d73fda7583cb88df5a48f1b5e84e34a0fed218c81c91607cdd780765322b49b0cda5119dcf75679d2aedee2a1f92ae0a1e3ab5ab0d1710a7ee392fe9fca03b7ddefd53ab8c986df3cac72308e8f9f313cceaab218697e3c3092ad1e78ea3c69666febe1963e784cd0db2a43cb964099fdb05f4e38ca86cf1d17b5d58bbea5f9498cf5d2ebede5412ffcce6700fa04968634114369d0f62dd038791e08dabef5b97bcfce5deb36352f6bcedcf624b4120b137f8b1cd528061be67b386c41d0fe93a62560a34f9af6045bb1250b7e4a95cad3a7137dc8857ad0ba4b2cce526089d3377e0e96a66ca1d31b787c84b20e1dfa24ac099dc65d5bf634637cf4b4383b133bfa7f3db2948b5a17c5418987ba2313ad9be6c99fd6873e8ffbfabaa66dd3766ddabba3f9b53dbb11d66e5c982fb244b07f5dcb60906063a2f5f4b4c4e913bf3835d8786dbe00fc05c012189ed2f879c240a56f0837addbbe7dc9def5dbb734cddefb5ad39e2d3b5f43457b5bca45a96d37793db9ba3a2c6b97efe5b0d9137eb1b937d8e88bcda56023ff7dc0461c0fc0ffec2de1a54d0c83f55318ebff95980af73215a210a4dd90ee4f749bd1af4dd5bb7ffd8968fd4968bdf9f4dbe2f4279ef5279df5279cf5279bf5279af52799f5db24f413defac8614890f984f29341e615b14383cc2790f5278f9f09da3e69aca7df055efd09637da8a13f51ac3f49fc7c90b954383ac8bc564dbfc6421fb2ea432b7d98a74f6bf421b83e2dd7875efa7281be74a40f63f421a23efcd1872cfa105c1f7a4f355a4f0b329f34d79f309f19643e51ae3f49ae3f413e37c87c627cbe4a0b82cca7b6170599cf07ebcf87ebcf76ebcf79ebcf7cebcfcfebcf82ebcf85ebcf88ebcfcceb4f0feb4fd0af0e329fda7e29c87cb6f89520f399e3b541e6b3c8eb83cc6794370499cf2eebcf31ebcf346f0e329f75d69f7bde16643e0fbd23c87c4e5a7f665a7f7e5a7f965a7fae5a7fc65a7fde5a5f72d7b71af425787d795b5f7ed5b740f4ad1f7d6958dfb2d4b770f52ded962033e4e150901912a38708e921537a08991e527722c80cb9d44350f5905c3d44590fd9d643d8f5907efd88837ee4433f02a31f09d28f48e947c6f42374fa3148fd58a17e4c563f36ac1fa3d6977df523e8fa56a0bedcdb1a642e09df09329f5ffe9c4a9f57e9fb54fa824adfafd20fa8f4832afd904a3facd21755fa11957e54a51f53e9c755fa09957e52a59f52e9a755fa19957e56a59f53e9e755fa0595bea4d22faaf44b2afdb24abfa2d2afaaf46b2afdba4abfa1d26faaf45b2afdb64abf1364e2f1f754fa7d95fe40a53f54e98f54fa6395fe44a53f55e9cf54fa7395fe42a5bf54e9af54fa6b95fe46a5bf55e9ef54fab24a5f51e9ef55fa0795fe51a57f52e9ab2afdb34a5f53e9eb2afd8b4adf50e99b2afdab4affa6d2bfabf42d95fe43a56fabf49da0ed33e5d8790c363dce5033bf6ecf9ee61dafefa9d8b3b362c7deed7bb6bcbefd8d8a7d5bf66caed8f9d9e65d1bb7efdc870b7fd92cfcb8999fb66bd7ba372ab6bcb6a1797fc5cebd7b2a766eac58bf73ef6b1bdaed2cffb75968f0dd1ed76dd810edacb4c7a7202debd139a783cc72f4a5fa79d9ebf6448f4e08f24c67169adbc90acd357b203a0d5b9e39e6abd8bd7de79e8aca8ad7d45fb573ddb9af79c3980afcdf6e25f2ee3d15bbf7acdbb5a762e3ae9d3b2aaac6e07a17f6e94425bed8c70f4c6ff35ea24e85ca6f0eec444dbe36b0739be33f3f0de9ffeca4d3b2419da861ffce2c347e50e708d3832265d9bd77fd9e5deb9af6442f3cebd32cbca033d55cddc96af619dc0967e59d5968f4e0ce112ee88cb37d39380bfe3f4095c818d45505009b2d6c6f00000027451f8b08000000000000ffed9d69741cc5b5c77b24595e46832d5bde37b1056fb246a3dd968d8cf70dcc8e018317c960b02d638b7d271b092121fb4202bcac2421fbbeef09d9f7852424908484247c7839efbdf3ce791f38afaa5537fa4f51dd6886be72b5e6f639d7537d55d3f7776fdfaaeea9aa6e3f1304412618daaa959c143c77a3bff79acffc0bdb5a123c569e93339312ceaa947056a784b326259ce352c2599b12cef129e19c9012ce8909726ab6aaa0784b9a7712435c9366cca62ca6752988692e65313d2105319d1ca4a38f9a9212cefa94704e4d09e7b4947036a484737a4a3867a48473664a3867a58473764a38e7a484736e4a38e7a584737e4a3817a48473614a381b53c279624a384f4a09e7c929e13c2541cec5c079aaf97c91f93ccd7c2e329f547789f95c6a3e97191f6bcc7e9392e54a9a359ff5373dd15050d2aaa4cdfa5bbb920e259d4abaccdf1acddfba95ac50b252498f92554a562b39ddc4628d923394ac55b24ec97a251b946c54b249c966255b946c55b24dc97625672a394bc90e25672b3947c9b94ace5372be920b945ca8e4228b65a7928b955ca2e45225bb945ca6e47225bb95ec51b257c93e257d4afa95ec577285922b951c50729592ab951c547248c96125034a8e28b946c95125c7940c2ab956c9754aae57728315b31b95dca4e46625b7589cb72ab94dc9ed4aee5072a792bb94bc58c94b94bc54c9cb94bc5cc9dd4a5ea1e4954aee51f22a25f72a79b592d728b94fc96b95bc4ec9eb95bc41c91b95bc49c99b95bc45c95b95bc4dc9fd4ade6e58a821bc43c9034a1e54f29092ff50f24e25ef52f26e25ef51f25e25ef53f2b092f72bf980920f2a7944c987947c58c947947c54c9c7947c5cc927947c52c9a7947c5ac967947c56c9e7947c5ec917947c51c997947c59c957947c55c9d7947c5dc937947c53c9b7947c5bc977943caae4bb4abea7e4fb4a7e60c5fc874a7ea4e4c74a7e62fe46e34b3f55f23353feb9f9fc85f9fca5f9fc95f59d5f2bf98da57b4cc96f2dddef94fcde941f379f7f309f7f349f4f98cf27cde79fcce79fcde75fcce753e6f3afe6f36fe6f369f3f977f3f90ff3f94ff3f98c92fe86a1f2846078eb0d12ea93dafafbf4dc0405fbd4a078d3b1a8367fa3cf46a3af31fbf449b11b67f6c759fa5ab35f6b1d6782d99f60e9ebcd7ebda59f66f6a759fae9667fbaa59f69f667823e1bc018a5d16b5db551654047795805ba7141714cb4ae960e07baf141712cb48ece632de8261add78d04d32ba09a0cb1add448a99923aa3eb0d92ca89fc1e7ddc5cd2c735f3362724cfbb4f1f773213ef94e479fbf571eb1978757e4c35c79a027933cde8ea4167ba95602ae8a61bdd34d0cd30ba06d0cd34bae9a09b6574334037dbe866826e8ed1cd02dd5ca39b0dba7946370774f38d6e2ee81618dd3cd02d34baf9a06b34ba05a03bd1e81682ee24a36b04ddc9467722e84e31ba934047fde7c9a0a3fbbb538c4ef7093519f88ed1537f147e87fa5cd09d46fd2de816515f0bbac5d4cf826e09d826dd52e84348b7cce8a83fd27feb32e5de20a9fc2ff4e9e376277d5c75647ddc95c91f379cd3ea0986e3da0b76ba2156ab4c39c175332d683b6384ec90be06ca1ba12ed5a378d03585d8f5b5638529af8af95e97f5bd1cd459e1f0bf3748d6ff9516cf4a8b791cf8cf93b3ad2d92b323de4aced9f3a1ae9d7b747f331673760b7030e46cbbe4ec88b79273761fd4b5738fee71c762ce5e041c0c39dbcd93b385bce4ecd0585710b8738f7ee78cc59cdd0f1cc9e76cbbe4ecc8b79273f676a86be71efdd61d8b393b081cc9e76c67b7dc1b8c782b3967ef85ba76eed1b8cb58ccd9bb80832167fba49f1df15672cede0f75eddca331c0b198b3f70147f239dbcd94b3ad92b3c1d0bc6510b8738fc6a3c762ce3e001cc9e7ec3e199f1df95672ce7e06eadab94773236331671f018ee473b68f6b7cb620393bb45e2308dcb947f3746331673f6fca7a6eece7666e6c01e87e61740b41f74b586740ba5f19dd89e017431be8943630e2ade436f06ba86be7f249a63c16dbc00f80832167bb256747bc959cb34f415d3bf768fdc258ccd9df020743ceee959c1df15672cefe17d4b5738fd6d28cc59c7dda94f5fdc2e3e67e6111e8fe60748b41f747a35b02ba278c6e29e89e34ba65a0fb93d13581eecf46b71c747f31ba66d03d657479d0fdd5e85a40f737a32b80ee69a36b05dddf8dae0d74ff30ba76d0fdd3e83a40f78cd1751a9d9ec7a235558f1add04f0bd3748eedc86eba882e22d63edf74279192f4f3e17143f2740b696276fab55fbde148cdcf7e5c0d3cce07b166c8c84a71978f2c9f384bf475b923f6e788e9bac9866c15613f85560f02b03b6e8d8b44ff672a0c37ea3e0606c4d9eb190015b746cda6f0546d2613f46cfe150fbd17df3bccc302f435b0aafcf68af1738c85e0dd4c9340cd76d346c75f077ea03eaa08cfd7cded231e56a982bf870562fecb70023f9981f7dc6c248199b2d46ae7e2303b6e8d8b6ed3a477c74cc5a1d316b63626cb51869bf0d18297eada3cf581829a3dd2f30f5492d23ed93282ef9d18fd988ce6b0e7478afd7e6606c4f9e313caf6d1623edb70323e90ac0c3753d8c6aafbed8e6b80fc17ca66b165d7fc85e0dd469ad1eaebb09aea70c7d68a1d47b53ecd3933f4f853c5ecf46c2c37cee5a98f2318f7de7b341b2b966b7f9bc152b6cf3d89773f593517d39d91366611666611666611666611666611666611666611666611666611666611666ff99a3e6e55ceb198e2723e95a8087639c3f7cf7943916ce013d06f33ac9cf5b14f238574feb1817593ed7409dffcd0cb33dee58278173e7cb2d1dd33aa5f05ce23aa55ed8277bb86e03d74d31ac3d0979965a3cb6ed3a477c7c5c47e2d31a8da8755a3ec52c073a5c0fd7c4c41395674d0edb8d89d92eece3693b85bc7ecf8f7e571ef527761bc1b56f4b2c9dee933aaa87fde6c88152e79df1ba41e524e77131dfd056f2eb6d0a45eb13aa82e26b05de5330ac51299aafa6b511ed96ed1aac5315fcfbdc74c0df7b83e7ae11c23a746cda5f04dfedb08e3d99cfdfd8feb01db8a95c6bf9b60cb8a9cea4aa611f3f67ca4cf733055c3f1b006f60f9441baecf48fe7e6f68bd48a1049e36e0e158bbc6745f9bc77c4c7abd4887152bd7fd32d56987f87530c42f6ecd1ad91366611666611666611666611666611666611666611666611666611666611666ff99f1fd17c48acf48b778c2384a6b6cc2f90c7a6f11ce8bdd5f356c977b0e90e69c165b3ee333ca4f570db33d68caf88e00d7f3ee782eb9e6d6a2ce25d9ab0b9efb9c3ed3b91cf1bb1fda1c31eb70c4ac9389d1ee3368bf1318297e1dc0c3d51edb2d1edb36f6196d9ec62caa9fe55abf129567ae750a8d89d91e5a2fc231af4beb45eceb578b15535c27413a9c07c777abe07a2cdfdeff62af5dc07e0ad76825df6f168ae680edb582640fd7497cc3c496d64924df0f14f29cd7086aa3b426a4e0f095ea3c0ad7b9ef9932ae156a81633de6f83b6d716b12b04f65785766787ee9dd8d747ebb1db657026b42b65bd076c608d9217d0d947f53355cd77e1724c59ad8751bb1df57e9fa5edefa5e0eea7439fcef0d92f5bfdbe2e9b69875eefc10f2ec31b8d7e3ea93ba02778c16418ca80edef332ac2972f691f69a695d87ceff78ab0ede9f529d27a18f8a5a93ee7a0f20d7fd42d47b00f17ec1754f63fb68af1daff4f580ff82fea203fede1bbcf0f580ff821c72dd97d2f117c3f1896b7c107d6da13aff635d47b9dad6f3bdf7caf5db8f7871bd21d5f93fe8ab969975b951bf635ccf5970fd6e887aee83ece13d5529be63bf90f4b511f31159c81ee6638d8935e5634704f772c777c7477c976245ebcbf177b21d3f1d87c4df116efa9b6ecb176a535de0cbbfafdfe00bcf3dd3d0fd67f2be16df0f511fd4eaf095ea4c8577c135987216ce13f695273bfe4e5bdcfd27bed7bc27799fc3f34befefa6f3dbe3b0bd1a5813b2dd82b6e9fe93ec90be06ca27550fd7a57a140f8a35b1eb3642f770c86e7fafddfa5e0eeaac74f8df1b24eb7f8fc5d36331ebdc99097976323c6bc1d557af8c88d1628811d5c1671deddffff85b1eaf31c7ebb73cbef313fbf66510d3d17a67aa3d7eebba3f596cc518ef4f5aa09fcd3aeadae3d2740d49727d3a3e0fb414ece2f3404b99e2990b8ae399b338386d4fb66c4f1e45dbf596edfa51b42d319798fb14739ffe2f0cfc3f2baa52c0589d02c69a14308e4b01636d0a18c7a78071420a1827a68071520a18b3c0783cafed0cf12978f6ff3dc5de6ba06d86f73984b158168c3c164dbc3cb1f73e689be11d2a25ff7f03ccff17564bb9ff17560ebe3735058cd352c0d89002c6e929609c9102c69929609c9502c6d929609c9302c6b929609c9702c6f929605c9002c68529606c4c01e38929603c29058c27a780f19414309e9a02c60929605cc2cb58289751f370bc47331b14afe37a3e1ee6f77a86ef2774bd4394e3ff9d2dd577e677fab694fb0e3c5cbfc0fbff28beb0f7f471ac4f28f53d7d71fff7341363a15c46aef526b8b665243cae3528795ec642b98c5ccf77e0f38623e171fd3fb8bccfdb0cc5ac1c46aef558a5ae17c4e7f0da1d3163602c94cbc8b5a61f9f371c098febb9c03c2f63a15c46aeb5af59b031129e2e8859a723660c8c857219999edd0a63d655020f3ee3d4e588190363a15c46cdb3822966dd25f0ac8098753b62e61323f224fdbef16e872d8e67e24af59d189071620a1827a58011d72070f45f716b10ba79e35328373e5ce72b6e0d02da667806238c05aeb97fbe58f4f0f2c4ae4140dbab986281cf443c5f2c56010fc7331a59b031121e62c8c1f7a6a680715a0a181b52c0383d058c3352c03833058cb352c0383b058c7352c03837058cf352c0383f058c0b52c0b830058cf85b95e15e31f6f7cbaa316e3beab7ca58b71df5bb64acdb963c973caf04db92e792e795605bf25cf2bc126c4b9e4b9e57826dc973c9f34ab02d792e795e09b625cf25cf7db29d86317e611c7b8cc8d3981c4f1e7d475ba77be0fbe90e9e0c93ef68abd703dfa99c36c6d529605c91024689e3d01ac4721835cf1a269ede1278d600cf194c3c6b4ae0390378d626cf13e6d41925f010430ebeb722058cab53c028719438fac42871ac9c380aa3300aa3301e0fc634f4e1729d19faed520ea3e659973c4f18b3b525f0ac8398d1f7f2bc8c85721935cffae479c298ad2b81673dc46c9d23660c8c85721935cf86e479c298ad2f816703c46cbd23660c8c85721935cfc6e479c2986d28816723c46c8323660c8c85721935cfa6e479c2986d2c816713c46ca323660c8c85721935cfe6e479c2986d2a816733c46c9323660c8c85721935cf96e479c2986d2e81670bc46cb323660c8c85721935cfd6e479c2986d2981672bc46c8b23660c8c85721935cfb6e479c2986d2d81671bc46cab2366be32ae4801e3ea143032c7b1502ea3e6d9cec4b3ad049eedc0732613cff61278ce049eb392e70973eacc1278882107df5b9102c6d5296094384a1c7d629438564e1c85511885b134c6d353c028e75a187d6564f87d15fb7cca9963dc76d4f32963dd76d4f32963ddb6e4b9e47925d8963c973caf04db92e792e795605bf25cf2bc126c4b9e4b9e57826dc973c9f34ab02d792e795e09b625cf25cf2bc1b6e4b9e47925d8963c973caf04db92e792e795605bf25cf2bc126c4b9e4b9e57826dc973c9f34ab02d792e795e09b625cf25cf2bc1b6e4b9e47925d8963c973caf04db92e792e73ed9de91bced42a9cfb0ee009eb31862c1e4675e1ff76c73ac67138c9f8ed53956acceb46295833a6743fcce61885f06ecd2b1699fec95cafc220f98996c174e50c79808fe938dd5563cb4fd73997c8feaebcf1de3b6a3fafab16e3baaaf1febb625cf25cf2bc1b6e4b9e47925d8963c973cf7c536966b82e1fb767abf923ec679a63cceec53fdd3e17b54a765fcd0e7e440da10876d694372ada804db92e792e795605bf25cf2bc126c4b9efb99e7e7276f3b9c1bc3df177a8b9b1b3b1f78ce638805939f79edd305964fe75a3ee5a00ebeb3f602063f3360978e4dfb17c079481bb3e65965cac49a857aab3c6124dd79bc3c61fb5a15146f71edeb02e06168072d4c7e86edeb42cba7558eb8531dccd50b19fc74b51ddabf10ce43da9873608f58b341f139f5819174e7f3f284edab3728dee2dad785c0c3d1ff30f919b6af8b2c9f7a1d71a73a98ab1731f8e96a3bb47f119c87b4316b9e35f077bd65a1de1a4f184977012f4f5b167ca62dae7d5d043c1cfd0f939f61fbda69f9b4c61177aa83b9ba93c14f57dba1fd9d701e8459985dcc9ae70c5326d62cd43bc31346d25dc8cad396cf82cfb4c5f5633b8187a39f678a7bd88f5d6cf9748623ee540773f562063f5d6d87f62f86f3500af3ea14324b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9ccb63d63c6b4d9958b3506fad278ca4bb8897277c7e676d50bc65acfd5e285f0c3c3b19e2c3e467b8eefd12cba7b58eb8531d6c5f9730f8e96a3bb47f099c87529857a79059e25c1eb3e65967cac49a857aeb3c6124dd4e5e9eb01f5b17146f71fdd825c0c3d1cf33f919f663975a3ead73c49dea60fbba94c14f57dba1fd4be13c08b330bb9835cf7a5326d62cd45bef0923e92e66e52984cf21ae0f8ab7b87eec52e0e1e8e799e21ef663bb2c9fd63be24e7530577731f8e96a3bb4bf0bce4329ccab53c82c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c2b27ce9a678329136b16ea6df084917497b0f2b486f30e1b82e22d6ede6117f070cccb30c53d9c77b8ccf2698323ee5407dbd7650c7ebada0eed5f06e761ac33af4e21b3e4c6e8304b6e087314b3e4863047314b6e087314b3e4863047314b6e087314b3e4863047314b6e087314b3e4863047314b6e087314b3e4863047314b6e087314b3e4863047314b6e087314b3e486304731fb901b9a67a329136b16ea6df484917497f2f284ef3dd818146f71eb762e039e5d0cf161f2335cb773b9e5d34647dca90eb6afcb19fc74b51ddabf1cce83300bb38b59f36c326562cd42bd4d9e30926e172f4fd88f6d0a8ab7b87eec72e0e1e8e799fc0cfbb1dd964f9b1c71a73a98abbb19fc74b51ddadf0de761b7300bb38359f36c366562cd42bdcd9e3092ee325e9eb01fdb1c146f71fdd86ee0e1e8e799fc0cfbb13d964f9b1d71a73a98ab7b18fc74b51dda277bc22ccc51cc9a678b29136b16ea6df184917497f3f214b2e0336d71fdd81ee0d9cd101f263fc37e6cafe5d31647dca90ee6ea5e063f5d6d87f6f7c279481bb3e6d96acac49a857a5b3d6124dd6e5e9eb07d6d0d8ab7b8f6b5177838fa1f263fc3f6b5cff269ab23ee540773751f839faeb643fbfbe03ca48d59f36c336562cd42bd6d9e30926e0f2f4fd8beb605c55b5cfbda073c1cfd0f939f61fbeab37cdae6883bd5c15ced63f0d3d57668bf0fce43da9835cf765326d62cd4dbee0923e9b09fa2ad0a18b7333106166360c507791678c633cb339ea99ef14cf48ca7da339ea59ef1747bc6d3e519cf42cf78167bc633db339e82673cd33ce359ee19cf24cf78da3de3a9f18c6799673ca779c6b3d2339e399ef13478c6b3c4339eac673ce33ce369f28ca7c7339e0ecf78e67ac6d3ea19cf74cf789a3de3a9f38c27e7194fad673c3b3ce399e719cf0ccf784ef08c67b2673ce33de3e9f48c67be673c6d9ef1ccf48ca7c5339e299ef1d47bc633c1339e459ef1643ce0c906cf5d379085bfef005d95f55d7d7dd9d030fc779aa7ad82eff49b72b5e3d87da0a379dd7ec777314e5c73cf68ab17f6c95e1d70f47bc2b3c8339e099ef1d47bc633c5339e16cf78667ac6d3e619cf7ccf783a3de319ef19cf64cf784ef08c6786673cf33ce3d9e1194fad673c39cf78ea3ce369f68c67ba673cad9ef1ccf58ca7c3339e1ecf789a3ce319e7194fd6339e259ef13478c633c7339e959ef19ce619cf32cf786a3ce369f78c6792673ccb3de399e6194fc1339ed99ef12cf68c67a1673c5d9ef1747bc6b3d4339e6acf78267ac633d5339e599ef12cf08ca7cac1b3838927ead9dd1d9ed866380f797ddcfd4c3e5d618e556b8e4bfc64af06ead49b81473ddf80df252e7bbe1dc796af801871bd372167f1d0febe316e7bb2657b7285d8aeb76cd757886dc973c9f34ab02d792e795e09b625cf25cf7db4fd6c72b6db31cfaac0960feba3e5fd49f13cf2fea4789e6acf78e4fd49f13cf2fea4781e797f523c8fbc3f299e47de9f14cf23ef4f8ae7f1edf978799f533c8fbccf299e47dee714cf23ef738ae769f28c47dee714cf23ef738ae791f739c5f3d479c693f38cc7b7f739c9fb93e279e4fd49f13cf2fea4781e797f523c8fbc3f299e47de9f14cf33c1339e459ef1643ce079bef727e17b8f68ade53ed0d17aceb8f72c65e13857808ec607e918fa7a7576c37319aae03b573ab8f63bec919d2b1ddf1d8db8a3ad5ed8277bf83ea62b3de159e419cf04cf78ea3de399e2194f8b673c333de369f38c67be673c9d9ef18cf78c67b2673c2778c633c3339e799ef1d47ac693f38ca7ce339e66cf78a67bc6d3ea19cf5ccf783a3ce3e9f18ca7c9339e719ef1643de359e2194f83673c733ce359e919cf699ef12cf38c6787673c359ef1b47bc633c9339ee59ef14cf38ca7e019cf6ccf78167bc6b3d0339e2ecf78ba3de359ea194fb5673c133de399ea19cf2ccf781678c653e5e0e17a27522e18de7a617f34dec7f47cb6f5fe52888bdeb2f0f7d1784e7287c548fbb8ce0079896729134fd473ef4b3db0adfda7df5a34679185bfe373385c39b5d462a47d574ee13ac2654c3c51cfeb2ff3c0b68e459329d31c7716fede048c5c39b5cc62a47d574ed5f3f2b465c167dae2d6f6609be338874c7ee6b1fd25f88e88bc8ed5762b564d56ac725067349e138cea0fc89e300b7314b3e6a1b11662c5ebd9683c273d1246d7f5958127ec1f9707c55b5cffb81d7838ae1f4c7e86fdd801cba7e58eb8531dccd5030c7ebada0eed1f70d86e0c928dc5552388c5550e9eab46391664af54e61d2964f621ce9a87d64e102bae276ef68491744b7979c2feb13928dee2fac7ab8087e3fac1e467d8275c6df9d4ec883bd5c1f67535839faeb643fb57c3792885f9400a9925cee5316b1e5a534dac59a8d7e20923e9b6b3f214f259f099b6b87eec6ae0e1e8e799e21ef663072d9f5a1c71a73ad8be0e32f8e96a3bb47f10ce83300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb330fbcdac79e8591562cd42bd82278ca4bb8a956768dea110146f71f30e078187635e8629eee1bcc321cba78223ee540773f510839faeb643fb87e03c08b3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3300bb3dfcc9a87dee94aac59a8d7ea0923e9aee6e5099fdb6a0d8ab7b8798743c0c3312fc3e46738ef70d8f2a9d51177aa83b97a98c14f57dba1fdc3701e8459985dcc9a87feaf0762cd42bd364f18497790956768feb42d28dee2fab1c3c0c3d1cf33c53decc7062c9fda1c71a73a98ab030c7ebada0eed0fc0792885f9400a9925ce12e7286689b3c4398a59e22c718e6296384b9ca39825ce12e7286689b3c4398a59e22c718e6296384b9ca39825ce12e728668973e5c459f3d0ff5145ac59a8d7ee0923e90eb1f2b486f30eed41f11637ef30003c1cf3324c710fe71d8e583eb53be24e75b07d1d61f0d3d57668ff089c87b1ce7c2085cc921ba3c32cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc5ec436e689e0e5326d62cd4ebf0849174877979c2f71e7404c55bdcba9d23c033c0101f263fc3753bd7583e7538e24e75b07d5dc3e0a7abedd0fe35701e8459985dcc9aa7d39489350bf53a3d6124dd002f4f210b3ed316d78f5d033c1cfd3c939f613f76d4f2a9d31177aa83b97a94c14f57dba1fda3701ed2c6ac79ba4c9958b350afcb1346d2e175b98b892767f1e41cb1385eb6f57eb729d799cf2cfcbd1b18b9fac32e8b91f631c7919778ba9978265b3c931db1385eb6b5ff2b4df904f39985bfaf0446ae9ceab61869df955393816725134fbdc553ef88c5f1b2ad63d163ca53cc6716fede038c5c39b5d262a47d574ed5034f0f134f549fd4330ab6a3dad768d88eca95d1b02d318f8e3943bb0bc7077a82e22deebe1aaf2d1c7d15939f79d7f5bbc7f209afdf788f7abcae4fc22ccc51cc4cf7b96d59cb36c527b07868bb863916a3f93bbbdbf2290dbfb3e3980fa49059e25c1eb3b67d2c79db6d59cb36c527b078683bc61c0b263fc3fe603070c798ece5a00ee6e920839f19b04bc7a6fd41380fa5301f4821b3c4b93c666dfbdac46d0fbd7f186d537c028b87b66b9963c1e3e7507f705de08e31d9cb411dccd3eb18fccc805d3a36ed5f07e74198855998855998855998855998855998855998855998855998855998855998fd66d6b6af4fdcf6d0f83ddaa6f804160f6dd733c782c7cfa1f1fb1b02778cc95e0eeae039bf81c1cf0cd8a563d3fe0d701e84599885599885599885599885599885599885599885599885599885599885d96f666dfbc6e46d87cfe3a06d8a4f60f1d07623732c98fc0cc7ef6f0adc31267b39a883e7fc26063f3360978e4dfb37c17910666176316bdb37276e7b683e0f6d537c028b87b69b9963c1e3e7507f704be08e31d9cb411d3ce7b730f89901bb746cdabf05ce4329cc0752c82c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c25ce51cc1267897314b3c459e21cc52c71963847314b9c2b27cedaf6ad89db6e0dc7efd136c527b07868bb9539163c7e0e8ddfdf16b8634cf6725007f3f436063f3360978e4dfbb7c17918ebcc0752c82cb9313acc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc921bc21cc52cb921cc51cc3ee486b67d7bf2b6c3e7d9d136c527b07868bb9d39164c7e86eb5fee08dc31267b39a883797a07839f19b04bc7a6fd3be03cdc21ccc2ec60d6b6ef4cde76216bd9a6f804160f6d7732c782c9cfb03fb82b70c798ece5a00e9ef3bb18fccc805d3a36eddf05e7216dcc78fe32c9d90ed76d928d2af3a9752f36e56ad0bdc4946b40f752531e07ba9799722de85e6ecae3417737f846ba5798f212d0bdd2947b40778f29af04ddab4cb91b74f79a7217e85e6dcad780ee35a67c1474f799f231d0bdd6940741f73a53be1674af37e5eb40f70653be1e746f34e51b40f72653be11746f36e59b40f71653be19746f35e55b40f73653be1574f79bf26da07bbb29df0eba7798f21da07bc0947780ee41539e08ba874c7912e8fe03caf4f94e53ae03ddbb4c3907ba779bf209a07b8f294f06dd7b4d790ae8de67caf5a07bd894a782eefda63c0d741f30e506d07dd094a783ee11539e01ba0f99f24cd07dd8946781ee23a63c1b741f35e539a0fb9829cf05ddc74d791ee83e61caf341f749535e00ba4f99f242d07dda94f1fc7ec694ef041df51777818efa8b17838efa8b97808efa8b97828efa8b97818efa8b97838efa8bbb414779f70ad051debd12749477f7808ef2ee55a0a3bcbb17749477af061de5dd6b404779771fe828ef5e0b3acabbd7818ef2eef5a0a3bc7b03e828efde083acabb37818ef2eecda0a3bc7b0be828efde0a3acabbb7818ef2ee7ed051debd1d749477ef001de5dd03a0a3bc7b10748da6fc10e84e3465ec3f4e32e57782ee64537e17e84e31e57783ee54537e0fe85e64caef05dd69a6fc3ed02d32e58741b7d894df0f3aba867d00744b4df983a05b66ca8f80aec9943f04bae5a6fc61d0359bf247409737e58f82aec5943f06ba82297f1c74ada6fc09d0b599f22741d76eca9f025d87297f1a749da64cfd876ea7babd91cf148f3af0afc9c14dba09c0dd1b247b0f46b6e8d8b45f00468a77cbe8331646ca98b718354f1b43cc3087688bfb8dd3063cad0c3c4c7e86bf71da2d9f0a964f39a8f322f0b39dc1cf0cd8a563d37e3bd8e638e7188b5a73dcd3ac58d4409d59e6e2a5af937171a463e8fc6d71f8c215c7bcc59377d8ee628e231d9bfac4ae51b0dd61d96eb66c63bf4f5b5cdbee00e64e06667ddceee48f1bb6ed15e65894cf64a7197c5a093148ca27b49d314276485f03e5e686e1ba548fe241d74e62d7ed88ce25b2dbdf6bb3be97833a5d0eff7b8364fdefb678ba2d66fd3be19486610e86f610e64097c541fbcd10bbee88d87541eca80e5e7bf34cb1ebb478683f0f3c747fd50e3aba4f217ebc9f6b1a056ebbdf6b777093ae0318f30ec6e6e4190b71d7856660245d27f07430c5cc3ed7a759f1c17b82f1561dfa6e0dd45907d7e5aca3ae6e77f332c37ed1effa678364fbf45a8678e1984300f109ac18d2460c1382e1718924792605c3e30ec706078eeeb9a2ff9cfe3d7d1940abb130f133e370a30a7458ae76e882a0787805876f697805876fabacb0e0b00ed5d73fe3b45b3484d17fe8c0e0f987fb0fef3b7ae391c1febe6d035720f5388b1e49a33c4052d4d13621181e08ea0d929db8a9b56cc525cf04f81c9f3c4f0b939fe1456fa2e553ade5530eea8c83bf4d64f0330376e9d8b43fd1613bc18e288cc5a411c462928367d228c70207d349872d95fe8e132d55962fd8a2d1273bcf1375880c9e0ac7cf1838fd37ddd8c71967c607c3279b7a4f7d47ab4f821e85d5572d3dcaaa47557517a4474df5054d8f8aea51503deaa94739f5a8a61ec5d4a3967a94528f4aea51483dead8180c8d2aea51443d6a780a703d0aacfad7bcbe3aea513f3dcaa747f5f45d95feb5a6ef44f49db7be2bd07703faae4fffa2d5a31bfa4aabef62f4155a5f55f55da2be3bd477f3faee56cf66ad52b25ac9e926d66b949ca164ad92754ad62bd9a064a3924d4a362bd9a264ab926d4ab62b3953c959c1d068fdd94ace5172ae92f3949cafe40225172ab948c94e25172bb944c9a54a7629b94cc9e54a762bd9a364af927d4afa94f42bd9afe40a255706432b78ae5272b592834a0e2939ac6440c9916068464dcfa0e919333d43a667c4f40c989ef1d2335c7a464bcf60e9192b3d43a567a4f40c949e71ba23189a5dd0b3097af640cf16e8d9013d1ba047ffef0e8646f7f568fe3dc1d068bd1e9dd7a3f17af45d8fb6ebd1753d9aae47cff568b91e1dd7a3e17af45b8f76ebd16d3d9aad47aff568b51e9dd6a3d17af4f9a1606874598f26ebd1633d5aac4787f568b01efd7d38181addd5a3b97af4568fd6ead1593d1aab475ff568ab1e5dd5a3a97af4548f96ead1513d1aaa473f3fabe4734a3eafe40b4abea8e44b4abeace42b4abeaae46b4abeaee41b4abea9e45b4abeade43bc1504e7e57c9f7947c5fc90f94fc50c98f94fc58c94f94fc54c9cf94fc5cc92f94fc52c9af94fc5ac96f943ca6e4b74a7ea7e4f74a1e57f207257f54f284922795fc49c99f95fc45c9534afeaae46f4a9e56f27725ff50f24f25cf04c3b324d871d498de8646ecf70c0ef61f3a32d83838d078e8da8383078e1cbcb1f1fa038357360e5cd77f74ffc181ebf1cb5f375fa6e98835478feeb9b1f1c0e1befe1b1a07ae1d6c1cd8dfb877e0dac37dc7f04b4f982fcd7baec53d7d7dd1c6fef38590fe779946ab4d3f48133d9be37dabad2e232075e57c295f5d9e437973a5a1d9f97387ee701b8f1d1c186ccc371e56ffee39a8bed3dfb7bc11ff764c05f9d860e3b1c13d47071bf71f1d38d4d8b21c8f3ba5ae0c27663694f1a5b50d23f73cf87f8198955c01d50300", "privateFunctions": [ { "selector": { @@ -44,8 +44,8 @@ exports[`ContractClass creates a contract class from a contract compilation arti "isInternal": false } ], - "id": "0x055aa066c8ac7456e491c363b2817c2e06d092d4c08d1f4d3c55f252980d0720", + "id": "0x193b0f08a5af3b2286bff06aaddcf074dd2e467e6fb1e412d747d2b64648866f", "privateFunctionsRoot": "0x05fa82a96814b6294d557d507151f7ccc12f70522ec4d9d0395a90e87e8087c6", - "publicBytecodeCommitment": "0x1ad0c37ac70788b5d3cdad82d06469037ee016b5fe662ce3d39bdca4e4ff9cbc" + "publicBytecodeCommitment": "0x0de7228dd1c2821b5dcb66dc4e0de48e1f6a88e2830be489ad6c7006fcd868b8" }" `; diff --git a/yarn-project/protocol-contracts/src/gas-token/__snapshots__/index.test.ts.snap b/yarn-project/protocol-contracts/src/gas-token/__snapshots__/index.test.ts.snap index b0ec87cd621..41071066dc1 100644 --- a/yarn-project/protocol-contracts/src/gas-token/__snapshots__/index.test.ts.snap +++ b/yarn-project/protocol-contracts/src/gas-token/__snapshots__/index.test.ts.snap @@ -2,10 +2,10 @@ exports[`GasToken returns canonical protocol contract 1`] = ` { - "address": AztecAddress<0x2a0fcbc7f1495cb6ee78f159486bcff67a4ea9dfb70cdb1c5813c0310b8adb43>, + "address": AztecAddress<0x2b3035985f1a4ed792a70cde88b7fee0f90f361b9e7f5842343fe67530906597>, "instance": { - "address": AztecAddress<0x2a0fcbc7f1495cb6ee78f159486bcff67a4ea9dfb70cdb1c5813c0310b8adb43>, - "contractClassId": Fr<0x2ef742aed183f098e02f70f8fc0238512237443d3601ce5ff50d267f74240bb4>, + "address": AztecAddress<0x2b3035985f1a4ed792a70cde88b7fee0f90f361b9e7f5842343fe67530906597>, + "contractClassId": Fr<0x065cf6dd52fb349293d583cfc8ac8f4553770e7aa48ed37a5adf679fdbee7be4>, "initializationHash": Fr<0x0bf6e812f14bb029f7cb9c8da8367dd97c068e788d4f21007fd97014eba8cf9f>, "portalContractAddress": EthAddress<0x0000000000000000000000000000000000000000>, "publicKeysHash": Fr<0x27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed>, @@ -18,7 +18,7 @@ exports[`GasToken returns canonical protocol contract 1`] = ` exports[`GasToken returns canonical protocol contract 2`] = ` { "artifactHash": Fr<0x076fb6d7493b075a880eeed90fec7c4c01e0a24d442522449e4d56c26357205f>, - "id": Fr<0x2ef742aed183f098e02f70f8fc0238512237443d3601ce5ff50d267f74240bb4>, + "id": Fr<0x065cf6dd52fb349293d583cfc8ac8f4553770e7aa48ed37a5adf679fdbee7be4>, "privateFunctions": [ { "isInternal": false, @@ -27,7 +27,7 @@ exports[`GasToken returns canonical protocol contract 2`] = ` }, ], "privateFunctionsRoot": Fr<0x13b29c3f4a96eb14d5d3539a6308ff9736ad5d67e3f61ffbb7da908e14980828>, - "publicBytecodeCommitment": Fr<0x229382af84da08ac5ee5067af6eebdfd943656484f0d7eeca40bb92fb9ac8000>, + "publicBytecodeCommitment": Fr<0x18485f6c7fc11c817ccb544ba30e0c4f9c83742b3d6318d68037290e4e8c1c51>, "version": 1, } `; diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 543a2887af7..ae278e45d44 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -2787,7 +2787,7 @@ __metadata: version: 0.0.0-use.local resolution: "@noir-lang/noirc_abi@portal:../noir/packages/noirc_abi::locator=%40aztec%2Faztec3-packages%40workspace%3A." dependencies: - "@noir-lang/types": 0.24.0 + "@noir-lang/types": 0.25.0 languageName: node linkType: soft