From 3de4cbaa336c4ff608497462468fa2a80c605b29 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Wed, 16 Aug 2023 15:24:05 -0400 Subject: [PATCH 01/23] update commands --- docs/nargo/01_commands.md | 138 +++++++++++++++++++++++++++++--------- 1 file changed, 106 insertions(+), 32 deletions(-) diff --git a/docs/nargo/01_commands.md b/docs/nargo/01_commands.md index 9e6e496..7e7aee9 100644 --- a/docs/nargo/01_commands.md +++ b/docs/nargo/01_commands.md @@ -40,56 +40,110 @@ _Arguments_ Generate the `Prover.toml` and `Verifier.toml` files for specifying prover and verifier in/output values of the Noir program respectively. +**Options** + +``` + --package The name of the package to check + --workspace Check all packages in the workspace + --print-acir Display the ACIR for compiled circuit + --deny-warnings Treat all warnings as errors +-h, --help Print help +``` + ## `nargo codegen-verifier` Generate a Solidity verifier smart contract for the program. -## `nargo compile ` +**Options** + +``` + --package The name of the package to codegen + --workspace Codegen all packages in the workspace + --print-acir Display the ACIR for compiled circuit + --deny-warnings Treat all warnings as errors +-h, --help Print help +``` + +## `nargo compile` Compile the program into a JSON build artifact file containing the ACIR representation and the ABI of the circuit. This build artifact can then be used to generate and verify proofs. -You can also use "build" as an alias for compile. +You can also use "build" as an alias for compile (e.g. `nargo build`). -For example, `nargo build `. - -_Arguments_ +**Options** -- `` - The name of the circuit file +``` + --include-keys Include Proving and Verification keys in the build artifacts + --package The name of the package to compile + --workspace Compile all packages in the workspace + --print-acir Display the ACIR for compiled circuit + --deny-warnings Treat all warnings as errors +-h, --help Print help +``` -_Options_ +## `nargo new ` -- `-c, --contracts` - Compile each contract function used within the program -- `--print-acir` - Displays the ACIR for the compiled circuit +Creates a new Noir project in a new folder. -## `nargo new [path]` +**Arguments** -Creates a new Noir project in a new folder called ` The path to save the new project +``` -_Arguments_ +**Options** -- `` - Name of the package -- `[path]` - The path to save the new project +``` + --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 +-h, --help Print help +``` ## `nargo init` Creates a new Noir project in the current directory. -## `nargo execute [witness_name]` +**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 +-h, --help Print help +``` + +## `nargo execute [WITNESS_NAME]` Runs the Noir program and prints its return value. -_Arguments_ +**Arguments** + +``` +[WITNESS_NAME] Write the execution witness to named file +``` -- `[witness_name]` - The name of the witness +**Options** + +``` +-p, --prover-name The name of the toml file which contains the inputs for the prover [default: Prover] + --package The name of the package to execute + --workspace Execute all packages in the workspace + --print-acir Display the ACIR for compiled circuit + --deny-warnings Treat all warnings as errors +-h, --help Print help +``` _Usage_ The inputs to the circuit are read from the `Prover.toml` file generated by `nargo check`, which must be filled in. -To save the witness to file, run the command with a value for the `witness-name` argument. A -`.tr` file will then be saved in the `build` folder. +To save the witness to file, run the command with a value for the `WITNESS_NAME` argument. A +`.tr` file will then be saved in the `./target` folder. > **Info:** The `.tr` file is the witness file. The witness file can be considered as program inputs > parsed for your program's ACIR. @@ -98,27 +152,39 @@ To save the witness to file, run the command with a value for the `witness-name` > verification. See the [TypeScript](../typescript#proving-and-verifying-externally-compiled-files) > section to learn more. -## `nargo prove ` +## `nargo prove` Creates a proof for the program. -_Arguments_ - -- `` - The name of the proof +**Options** -_Options_ - -- `-v, --verify` - Verify proof after proving +``` +-p, --prover-name The name of the toml file which contains the inputs for the prover [default: Prover] +-v, --verifier-name The name of the toml file which contains the inputs for the verifier [default: Verifier] + --verify Verify proof after proving + --package The name of the package to prove + --workspace Prove all packages in the workspace + --print-acir Display the ACIR for compiled circuit + --deny-warnings Treat all warnings as errors +-h, --help Print help +``` -## `nargo verify ` +## `nargo verify` Given a proof and a program, verify whether the proof is valid. -_Arguments_ +**Options** -- `` - The proof to verify +``` +-v, --verifier-name The name of the toml file which contains the inputs for the verifier [default: Verifier] + --package The name of the package verify + --workspace Verify all packages in the workspace + --print-acir Display the ACIR for compiled circuit + --deny-warnings Treat all warnings as errors +-h, --help Print help +``` -## `nargo test ` +## `nargo test [TEST_NAME]` Nargo will automatically compile and run any functions which have the decorator `#[test]` on them if you run `nargo test`. To print `println` statements in tests, use the `--show-output` flag. @@ -127,9 +193,17 @@ Takes an optional `--exact` flag which allows you to select tests based on an ex See an example on the [testing page](./testing). -_Arguments_ +**Options** -- `` - a pattern to indicate to only run tests with names containing the pattern +``` + --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 + --print-acir Display the ACIR for compiled circuit + --deny-warnings Treat all warnings as errors +-h, --help Print help +``` ## `nargo gates` From 2c483572a7bcb2f593f624ee797df9e4be8a53a5 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Wed, 16 Aug 2023 20:13:58 -0400 Subject: [PATCH 02/23] start workspaces page --- docs/modules_packages_crates/workspaces.md | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 docs/modules_packages_crates/workspaces.md diff --git a/docs/modules_packages_crates/workspaces.md b/docs/modules_packages_crates/workspaces.md new file mode 100644 index 0000000..e542a3e --- /dev/null +++ b/docs/modules_packages_crates/workspaces.md @@ -0,0 +1,35 @@ +--- +title: Workspaces +--- + +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 packages 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: + +``` +[workspace] +members = ["crates/a", "crates/b"] +default-member = "crates/a" +``` + +`members` indicates which packages should be included in the workspace, for example, when the `--workspace` flag is used with various commands. + +`default-member` indicates which packages should be included in the workspace be default. `default-members` can be particularly useful in scenarios where certain members of a workspace are auxiliary tools or infrequently-used components, and you don't want them to be built or tested every time you work with the main components. From 9f4f8d7e324134179e2ec3706c76bf46c84ccb2a Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Fri, 18 Aug 2023 15:10:47 -0400 Subject: [PATCH 03/23] add nargo.toml example --- docs/getting_started/02_breakdown.md | 37 ++++++++++++++++++---------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/docs/getting_started/02_breakdown.md b/docs/getting_started/02_breakdown.md index 9aa00c8..7c9f444 100644 --- a/docs/getting_started/02_breakdown.md +++ b/docs/getting_started/02_breakdown.md @@ -35,25 +35,36 @@ _Verifier.toml_ contains public in/output values computed when executing the Noi _Nargo.toml_ contains the environmental options of your project. It contains a "package" section and a "dependencies" section. -#### Package section - -The package section requires a number of fields including: - -- name - the name of the package -- type - can be "bin", "lib", or "contract" to specify whether its a binary, library or Aztec contract -- authors -- compiler_version - specifies the version of the compiler to use. This is not currently enforced by the compiler, but will be in future versions. - -For example: +Example Nargo.toml: -```toml +```yaml [package] name = "noirstarter" type = "bin" authors = ["Alice"] compiler_version = "0.9.0" + +[dependencies] +ecrecover = {tag = "v0.9.0", git = "https://github.com/colinnielsen/ecrecover-noir.git"} +``` + +Nargo.toml for a workspace will look a bit different. For example: + +```yaml +[workspace] +members = ["crates/a", "crates/b"] +default-member = "crates/a" ``` +#### Package section + +The package section requires a number of fields including: + +- name - the name of the package +- type - can be "bin", "lib", or "contract" to specify whether its a binary, library or Aztec contract +- authors - authors of the project +- compiler_version - specifies the version of the compiler to use. This is not currently enforced by the compiler, but will be in future versions. + #### Dependencies section This is where you will specify any dependencies for your project. See the [Dependencies page](../modules_packages_crates/dependencies) for more info. @@ -90,7 +101,7 @@ public). In our hello world program the _Prover.toml_ file looks like this: -```toml +```yaml x = "1" y = "2" ``` @@ -121,7 +132,7 @@ fn main(foos: [Foo; 3]) -> pub Field { Prover.toml: -```toml +```yaml [[foos]] # foos[0] bar = 0 baz = 0 From 4958fb56892cd9442794f2cd8bc6bc83b2f1f985 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Fri, 18 Aug 2023 15:11:13 -0400 Subject: [PATCH 04/23] toml to yaml highlighting --- docs/modules_packages_crates/dependencies.md | 4 ++-- .../getting_started/hello_world/00_hello_world.md | 4 ++-- .../getting_started/hello_world/01_breakdown.md | 2 +- .../version-0.9.0/getting_started/02_breakdown.md | 6 +++--- .../version-0.9.0/modules_packages_crates/dependencies.md | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/modules_packages_crates/dependencies.md b/docs/modules_packages_crates/dependencies.md index 2807ad5..ef6ea5d 100644 --- a/docs/modules_packages_crates/dependencies.md +++ b/docs/modules_packages_crates/dependencies.md @@ -21,7 +21,7 @@ semver 2.0 guidelines. For example, to add the [ecrecover-noir library](https://github.com/colinnielsen/ecrecover-noir) to your project, add it to `Nargo.toml`: -```toml +```yaml # Nargo.toml [dependencies] @@ -47,7 +47,7 @@ For example, this file structure has a library and binary crate Inside of the binary crate, you can specify: -```toml +```yaml # Nargo.toml [dependencies] diff --git a/versioned_docs/version-0.3.2/getting_started/hello_world/00_hello_world.md b/versioned_docs/version-0.3.2/getting_started/hello_world/00_hello_world.md index 0078005..df90919 100644 --- a/versioned_docs/version-0.3.2/getting_started/hello_world/00_hello_world.md +++ b/versioned_docs/version-0.3.2/getting_started/hello_world/00_hello_world.md @@ -107,7 +107,7 @@ Now that the project is set up, we can create a proof of correct execution on ou Fill in input values for execution in the _Prover.toml_ file. For example: -```toml +```yaml x = "1" y = "2" ``` @@ -124,7 +124,7 @@ A new folder _proofs_ would then be generated in your project directory, contain The _Verifier.toml_ file would also be updated with the public values computed from program execution (in this case the value of `y`): -```toml +```yaml y = "0x0000000000000000000000000000000000000000000000000000000000000002" ``` diff --git a/versioned_docs/version-0.3.2/getting_started/hello_world/01_breakdown.md b/versioned_docs/version-0.3.2/getting_started/hello_world/01_breakdown.md index 9df2e50..1cdd395 100644 --- a/versioned_docs/version-0.3.2/getting_started/hello_world/01_breakdown.md +++ b/versioned_docs/version-0.3.2/getting_started/hello_world/01_breakdown.md @@ -64,7 +64,7 @@ public). In our hello world program the _Prover.toml_ file looks like this: -```toml +```yaml x = "1" y = "2" ``` diff --git a/versioned_docs/version-0.9.0/getting_started/02_breakdown.md b/versioned_docs/version-0.9.0/getting_started/02_breakdown.md index c444db6..e0358ec 100644 --- a/versioned_docs/version-0.9.0/getting_started/02_breakdown.md +++ b/versioned_docs/version-0.9.0/getting_started/02_breakdown.md @@ -23,7 +23,7 @@ commands, you would get a minimal Nargo project of the following structure: 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_ 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. +_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_ contains public in/output values computed when executing the Noir program. @@ -92,7 +92,7 @@ fn main(foos: [Foo; 3]) -> pub Field { Prover.toml: -```toml +```yaml [[foos]] # foos[0] bar = 0 baz = 0 @@ -119,7 +119,7 @@ nargo prove p This command looks for proof inputs in the custom **OtherProver.toml** and generates proof `pp`: ```bash -nargo prove -p OtherProver pp +nargo prove -p OtherProver pp ``` ## Verifying a Proof diff --git a/versioned_docs/version-0.9.0/modules_packages_crates/dependencies.md b/versioned_docs/version-0.9.0/modules_packages_crates/dependencies.md index 2807ad5..ef6ea5d 100644 --- a/versioned_docs/version-0.9.0/modules_packages_crates/dependencies.md +++ b/versioned_docs/version-0.9.0/modules_packages_crates/dependencies.md @@ -21,7 +21,7 @@ semver 2.0 guidelines. For example, to add the [ecrecover-noir library](https://github.com/colinnielsen/ecrecover-noir) to your project, add it to `Nargo.toml`: -```toml +```yaml # Nargo.toml [dependencies] @@ -47,7 +47,7 @@ For example, this file structure has a library and binary crate Inside of the binary crate, you can specify: -```toml +```yaml # Nargo.toml [dependencies] From 3fe6ccca4e7f3e555a1018d2f28850d2c22117a2 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Mon, 21 Aug 2023 20:34:05 -0400 Subject: [PATCH 05/23] updates --- docs/getting_started/02_breakdown.md | 2 +- docs/modules_packages_crates/crates_and_packages.md | 9 +++++++-- docs/modules_packages_crates/dependencies.md | 2 +- docs/modules_packages_crates/workspaces.md | 10 ++++++---- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/docs/getting_started/02_breakdown.md b/docs/getting_started/02_breakdown.md index 7c9f444..979692a 100644 --- a/docs/getting_started/02_breakdown.md +++ b/docs/getting_started/02_breakdown.md @@ -48,7 +48,7 @@ compiler_version = "0.9.0" ecrecover = {tag = "v0.9.0", git = "https://github.com/colinnielsen/ecrecover-noir.git"} ``` -Nargo.toml for a workspace will look a bit different. For example: +Nargo.toml for a [workspace](../modules_packages_crates/workspaces) will look a bit different. For example: ```yaml [workspace] diff --git a/docs/modules_packages_crates/crates_and_packages.md b/docs/modules_packages_crates/crates_and_packages.md index 34f28a7..c70c869 100644 --- a/docs/modules_packages_crates/crates_and_packages.md +++ b/docs/modules_packages_crates/crates_and_packages.md @@ -1,7 +1,6 @@ --- title: Crates and Packages -description: - Learn how to use Crates and Packages in your Noir project +description: Learn how to use Crates and Packages in your Noir project keywords: [Nargo, dependencies, package management, crates, package] --- @@ -14,8 +13,12 @@ Crates can contain modules, and the modules may be defined in other files that g A Noir crate can come in one of two forms: a binary crate or a library crate. +#### 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. ### Crate Root @@ -28,6 +31,8 @@ A Nargo _package_ is a collection of one of more crates that provides a set of f A package _must_ contain either a library or a binary crate, but not both. +Binary packages (but not library packages) can be defined as a [workspace](./workspaces). + ### 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. diff --git a/docs/modules_packages_crates/dependencies.md b/docs/modules_packages_crates/dependencies.md index ef6ea5d..124512a 100644 --- a/docs/modules_packages_crates/dependencies.md +++ b/docs/modules_packages_crates/dependencies.md @@ -1,5 +1,5 @@ --- -title: Managing Dependencies +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. diff --git a/docs/modules_packages_crates/workspaces.md b/docs/modules_packages_crates/workspaces.md index e542a3e..4190da5 100644 --- a/docs/modules_packages_crates/workspaces.md +++ b/docs/modules_packages_crates/workspaces.md @@ -4,7 +4,7 @@ title: Workspaces 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 packages is expected to contain exactly one "named circuit", being the "name" defined in Nargo.toml with the program logic defined in `./src/main.nr`. +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: @@ -24,12 +24,14 @@ For a project with the following structure: You can define a workspace in Nargo.toml like so: -``` +```yaml [workspace] members = ["crates/a", "crates/b"] default-member = "crates/a" ``` -`members` indicates which packages should be included in the workspace, for example, when the `--workspace` flag is used with various commands. +`members` indicates which packages are included in the workspace. This is used when the `--workspace` flag is used with various commands. + +`default-member` indicates which packages are included in the workspace by default. `default-members` can be particularly useful in scenarios where certain members of a workspace are auxiliary tools or infrequently-used components and you don't want them to be built or tested every time you work with the main components. -`default-member` indicates which packages should be included in the workspace be default. `default-members` can be particularly useful in scenarios where certain members of a workspace are auxiliary tools or infrequently-used components, and you don't want them to be built or tested every time you work with the main components. +Note that library packages cannot be defined as workspaces. From 5bc2e0bbdadd3229023c356db6b9f382309ab299 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Mon, 21 Aug 2023 20:37:23 -0400 Subject: [PATCH 06/23] update title --- docs/modules_packages_crates/modules.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/modules_packages_crates/modules.md b/docs/modules_packages_crates/modules.md index e429b33..147c9b2 100644 --- a/docs/modules_packages_crates/modules.md +++ b/docs/modules_packages_crates/modules.md @@ -1,13 +1,11 @@ --- -title: Understanding Modules +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] --- -# Modules - Noir's module system follows the same convention as the _newer_ version of Rust's module system. ## Purpose of Modules @@ -51,7 +49,8 @@ crate ``` ### Importing a module throughout the tree -All modules are accessible from the ``crate::`` namespace. + +All modules are accessible from the `crate::` namespace. ``` crate @@ -60,7 +59,8 @@ crate └── main ``` -In the above snippet, if ``bar`` would like to use functions in ``foo``, it can do so by ``use crate::foo::function_name``. + +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 From 8c7d3df0b95fa3a60da424894c5adfd6c87dd2e4 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Mon, 21 Aug 2023 20:59:23 -0400 Subject: [PATCH 07/23] add nargo check contract note --- .../version-0.3.2/getting_started/nargo/01_commands.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/versioned_docs/version-0.3.2/getting_started/nargo/01_commands.md b/versioned_docs/version-0.3.2/getting_started/nargo/01_commands.md index 0446fe3..b4f9e9d 100644 --- a/versioned_docs/version-0.3.2/getting_started/nargo/01_commands.md +++ b/versioned_docs/version-0.3.2/getting_started/nargo/01_commands.md @@ -41,6 +41,8 @@ _Arguments_ Generate the `Prover.toml` and `Verifier.toml` files for specifying prover and verifier in/output values of the Noir program respectively. +This command will not write a Prover.toml file for contract packages. + ## `nargo codegen-verifier` Generate a Solidity verifier smart contract for the program. From 5dd093004bafa0a3691f5655a39d5b55b1b2b4ed Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 25 Aug 2023 10:32:24 -0400 Subject: [PATCH 08/23] Update docs/getting_started/02_breakdown.md Co-authored-by: Blaine Bublitz --- docs/getting_started/02_breakdown.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting_started/02_breakdown.md b/docs/getting_started/02_breakdown.md index 979692a..4c19064 100644 --- a/docs/getting_started/02_breakdown.md +++ b/docs/getting_started/02_breakdown.md @@ -37,7 +37,7 @@ _Nargo.toml_ contains the environmental options of your project. It contains a " Example Nargo.toml: -```yaml +```toml [package] name = "noirstarter" type = "bin" From f075aa320cd88455122ce5400930b435f15f43e7 Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 25 Aug 2023 10:32:37 -0400 Subject: [PATCH 09/23] Update docs/getting_started/02_breakdown.md Co-authored-by: Blaine Bublitz --- docs/getting_started/02_breakdown.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting_started/02_breakdown.md b/docs/getting_started/02_breakdown.md index 4c19064..97ac962 100644 --- a/docs/getting_started/02_breakdown.md +++ b/docs/getting_started/02_breakdown.md @@ -101,7 +101,7 @@ public). In our hello world program the _Prover.toml_ file looks like this: -```yaml +```toml x = "1" y = "2" ``` From 56b3bef27c20afd60dad62c13bc461d195f4cc00 Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 25 Aug 2023 10:32:47 -0400 Subject: [PATCH 10/23] Update docs/getting_started/02_breakdown.md Co-authored-by: Blaine Bublitz --- docs/getting_started/02_breakdown.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting_started/02_breakdown.md b/docs/getting_started/02_breakdown.md index 97ac962..950bb3c 100644 --- a/docs/getting_started/02_breakdown.md +++ b/docs/getting_started/02_breakdown.md @@ -132,7 +132,7 @@ fn main(foos: [Foo; 3]) -> pub Field { Prover.toml: -```yaml +```toml [[foos]] # foos[0] bar = 0 baz = 0 From 9b5c1414edc9b70160ef07629f2710683afc58c3 Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 25 Aug 2023 10:32:56 -0400 Subject: [PATCH 11/23] Update versioned_docs/version-0.3.2/getting_started/hello_world/01_breakdown.md Co-authored-by: Blaine Bublitz --- .../version-0.3.2/getting_started/hello_world/01_breakdown.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versioned_docs/version-0.3.2/getting_started/hello_world/01_breakdown.md b/versioned_docs/version-0.3.2/getting_started/hello_world/01_breakdown.md index 1cdd395..9df2e50 100644 --- a/versioned_docs/version-0.3.2/getting_started/hello_world/01_breakdown.md +++ b/versioned_docs/version-0.3.2/getting_started/hello_world/01_breakdown.md @@ -64,7 +64,7 @@ public). In our hello world program the _Prover.toml_ file looks like this: -```yaml +```toml x = "1" y = "2" ``` From c9dd17003cd6a6f30b9d17a78e3c6428eec5c0ea Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 25 Aug 2023 10:33:08 -0400 Subject: [PATCH 12/23] Update versioned_docs/version-0.9.0/modules_packages_crates/dependencies.md Co-authored-by: Blaine Bublitz --- .../version-0.9.0/modules_packages_crates/dependencies.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versioned_docs/version-0.9.0/modules_packages_crates/dependencies.md b/versioned_docs/version-0.9.0/modules_packages_crates/dependencies.md index ef6ea5d..0698b00 100644 --- a/versioned_docs/version-0.9.0/modules_packages_crates/dependencies.md +++ b/versioned_docs/version-0.9.0/modules_packages_crates/dependencies.md @@ -47,7 +47,7 @@ For example, this file structure has a library and binary crate Inside of the binary crate, you can specify: -```yaml +```toml # Nargo.toml [dependencies] From 95067088f5a57f9a1d830549b3ec41e103096269 Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 25 Aug 2023 10:33:17 -0400 Subject: [PATCH 13/23] Update versioned_docs/version-0.9.0/modules_packages_crates/dependencies.md Co-authored-by: Blaine Bublitz --- .../version-0.9.0/modules_packages_crates/dependencies.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versioned_docs/version-0.9.0/modules_packages_crates/dependencies.md b/versioned_docs/version-0.9.0/modules_packages_crates/dependencies.md index 0698b00..2807ad5 100644 --- a/versioned_docs/version-0.9.0/modules_packages_crates/dependencies.md +++ b/versioned_docs/version-0.9.0/modules_packages_crates/dependencies.md @@ -21,7 +21,7 @@ semver 2.0 guidelines. For example, to add the [ecrecover-noir library](https://github.com/colinnielsen/ecrecover-noir) to your project, add it to `Nargo.toml`: -```yaml +```toml # Nargo.toml [dependencies] From 2f8ff4e3a074583b63b6f8b3ae196d9a480f25a6 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Fri, 25 Aug 2023 10:33:29 -0400 Subject: [PATCH 14/23] add toml --- docusaurus.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus.config.js b/docusaurus.config.js index 321900e..1abf122 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -130,7 +130,7 @@ const config = { prism: { theme: lightCodeTheme, darkTheme: darkCodeTheme, - additionalLanguages: ['rust', 'powershell', 'solidity'], + additionalLanguages: ['rust', 'powershell', 'solidity', 'toml'], }, stylesheets: [ { From 3e449e9f1efe1a73e0db1fe7c3910b2f9c55fddc Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 25 Aug 2023 10:34:29 -0400 Subject: [PATCH 15/23] Update docs/modules_packages_crates/dependencies.md Co-authored-by: Blaine Bublitz --- docs/modules_packages_crates/dependencies.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules_packages_crates/dependencies.md b/docs/modules_packages_crates/dependencies.md index 124512a..8f33a30 100644 --- a/docs/modules_packages_crates/dependencies.md +++ b/docs/modules_packages_crates/dependencies.md @@ -21,7 +21,7 @@ semver 2.0 guidelines. For example, to add the [ecrecover-noir library](https://github.com/colinnielsen/ecrecover-noir) to your project, add it to `Nargo.toml`: -```yaml +```toml # Nargo.toml [dependencies] From 19aad58ac036c07cf98df11cfc0a0793a94121ff Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 25 Aug 2023 10:34:42 -0400 Subject: [PATCH 16/23] Update versioned_docs/version-0.9.0/getting_started/02_breakdown.md Co-authored-by: Blaine Bublitz --- versioned_docs/version-0.9.0/getting_started/02_breakdown.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versioned_docs/version-0.9.0/getting_started/02_breakdown.md b/versioned_docs/version-0.9.0/getting_started/02_breakdown.md index e0358ec..7c320ce 100644 --- a/versioned_docs/version-0.9.0/getting_started/02_breakdown.md +++ b/versioned_docs/version-0.9.0/getting_started/02_breakdown.md @@ -92,7 +92,7 @@ fn main(foos: [Foo; 3]) -> pub Field { Prover.toml: -```yaml +```toml [[foos]] # foos[0] bar = 0 baz = 0 From 9917a451c2a70249a845362c149c50d8c75363f5 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Fri, 25 Aug 2023 10:44:53 -0400 Subject: [PATCH 17/23] remove prove and verify args --- docs/getting_started/01_hello_world.md | 10 +++++----- docs/getting_started/02_breakdown.md | 17 ++++++++--------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/docs/getting_started/01_hello_world.md b/docs/getting_started/01_hello_world.md index 0f21ad4..8b4416b 100644 --- a/docs/getting_started/01_hello_world.md +++ b/docs/getting_started/01_hello_world.md @@ -110,14 +110,14 @@ x = "1" y = "2" ``` -Prove the valid execution of your Noir program with your preferred proof name, for example `p`: +Prove the valid execution of your Noir program: ```sh -nargo prove p +nargo prove ``` A new folder _proofs_ would then be generated in your project directory, containing the proof file -`p.proof`. +`.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`): @@ -133,10 +133,10 @@ y = "0x0000000000000000000000000000000000000000000000000000000000000002" Once a proof is generated, we can verify correct execution of our Noir program by verifying the proof file. -Verify your proof of name `p` by running: +Verify your proof by running: ```sh -nargo verify p +nargo verify ``` The verification will complete in silence if it is successful. If it fails, it will log the diff --git a/docs/getting_started/02_breakdown.md b/docs/getting_started/02_breakdown.md index 950bb3c..058b1aa 100644 --- a/docs/getting_started/02_breakdown.md +++ b/docs/getting_started/02_breakdown.md @@ -106,13 +106,12 @@ x = "1" y = "2" ``` -When the command `nargo prove my_proof` is executed, two processes happen: +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 not equal constraint is due to the line `assert(x != y)`. -2. Noir creates and stores the proof of this statement in the _proofs_ directory and names the proof - file _my_proof_. Opening this file will display the proof in hex format. +2. Noir creates and stores the proof of this statement in the _proofs_ directory in a file called .proof. So if your project is named "private_voting" (defined in the project Nargo.toml), the proof will be saved at `./proofs/private_voitng.proof`. Opening this file will display the proof in hex format. #### Arrays of Structs @@ -150,23 +149,23 @@ baz = 2 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 proof `p`: +This command looks for proof inputs in the default **Prover.toml** and generates the proof and saves it at `./proofs/.proof`: ```bash -nargo prove p +nargo prove ``` -This command looks for proof inputs in the custom **OtherProver.toml** and generates proof `pp`: +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 pp +nargo prove -p OtherProver ``` ## Verifying a Proof -When the command `nargo verify my_proof` is executed, two processes happen: +When the command `nargo verify` is executed, two processes happen: -1. Noir checks in the _proofs_ directory for a file called _my_proof_ +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 From 941a26d97724b20c677231b9eac2cb4e0c28b957 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Fri, 25 Aug 2023 10:47:46 -0400 Subject: [PATCH 18/23] fix formatting --- docs/getting_started/02_breakdown.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting_started/02_breakdown.md b/docs/getting_started/02_breakdown.md index 058b1aa..ef54625 100644 --- a/docs/getting_started/02_breakdown.md +++ b/docs/getting_started/02_breakdown.md @@ -111,7 +111,7 @@ 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 not equal 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 .proof. So if your project is named "private_voting" (defined in the project Nargo.toml), the proof will be saved at `./proofs/private_voitng.proof`. Opening this file will display the proof in hex format. +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 From 951425563aa928642e7776b7850cb9e037290d90 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Fri, 25 Aug 2023 10:55:28 -0400 Subject: [PATCH 19/23] note on libs in workspaces --- docs/modules_packages_crates/dependencies.md | 8 ++++++-- docs/modules_packages_crates/workspaces.md | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/modules_packages_crates/dependencies.md b/docs/modules_packages_crates/dependencies.md index 8f33a30..4cfed77 100644 --- a/docs/modules_packages_crates/dependencies.md +++ b/docs/modules_packages_crates/dependencies.md @@ -34,7 +34,7 @@ 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 @@ -47,7 +47,7 @@ For example, this file structure has a library and binary crate Inside of the binary crate, you can specify: -```yaml +```toml # Nargo.toml [dependencies] @@ -79,6 +79,10 @@ can import multiple items in the same line by enclosing them in curly braces: 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. diff --git a/docs/modules_packages_crates/workspaces.md b/docs/modules_packages_crates/workspaces.md index 4190da5..82676f3 100644 --- a/docs/modules_packages_crates/workspaces.md +++ b/docs/modules_packages_crates/workspaces.md @@ -34,4 +34,6 @@ default-member = "crates/a" `default-member` indicates which packages are included in the workspace by default. `default-members` can be particularly useful in scenarios where certain members of a workspace are auxiliary tools or infrequently-used components and you don't want them to be built or tested every time you work with the main components. -Note that library packages cannot be defined as workspaces. +Libraries can be defined in a workspace. We just don't have a way to consume libraries from inside a workspace as external dependencies right now. + +Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. From 0b8c4b2e0339b1db020e2de26f04b0676b6bcfd6 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Fri, 25 Aug 2023 11:02:36 -0400 Subject: [PATCH 20/23] add nargo.toml details --- docs/getting_started/02_breakdown.md | 19 +++++++++++++------ docs/modules_packages_crates/workspaces.md | 2 +- .../hello_world/00_hello_world.md | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/docs/getting_started/02_breakdown.md b/docs/getting_started/02_breakdown.md index ef54625..3fa3a35 100644 --- a/docs/getting_started/02_breakdown.md +++ b/docs/getting_started/02_breakdown.md @@ -43,6 +43,9 @@ name = "noirstarter" 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"} @@ -50,7 +53,7 @@ ecrecover = {tag = "v0.9.0", git = "https://github.com/colinnielsen/ecrecover-no Nargo.toml for a [workspace](../modules_packages_crates/workspaces) will look a bit different. For example: -```yaml +```toml [workspace] members = ["crates/a", "crates/b"] default-member = "crates/a" @@ -60,16 +63,20 @@ default-member = "crates/a" The package section requires a number of fields including: -- name - the name of the package -- type - can be "bin", "lib", or "contract" to specify whether its a binary, library or Aztec contract -- authors - authors of the project -- compiler_version - specifies the version of the compiler to use. This is not currently enforced by the compiler, but will be in future versions. +- `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` (optional) - specifies the version of the compiler to use. This is not currently enforced by the compiler, but will be in future versions. +- `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](../modules_packages_crates/dependencies) for more info. -_proofs_ and _contract_ directories will not be immediately visible until you create a proof or +`./proofs/` and `./contract/` directories will not be immediately visible until you create a proof or verifier contract respectively. ### main.nr diff --git a/docs/modules_packages_crates/workspaces.md b/docs/modules_packages_crates/workspaces.md index 82676f3..c7c8f78 100644 --- a/docs/modules_packages_crates/workspaces.md +++ b/docs/modules_packages_crates/workspaces.md @@ -24,7 +24,7 @@ For a project with the following structure: You can define a workspace in Nargo.toml like so: -```yaml +```toml [workspace] members = ["crates/a", "crates/b"] default-member = "crates/a" diff --git a/versioned_docs/version-0.3.2/getting_started/hello_world/00_hello_world.md b/versioned_docs/version-0.3.2/getting_started/hello_world/00_hello_world.md index df90919..0078005 100644 --- a/versioned_docs/version-0.3.2/getting_started/hello_world/00_hello_world.md +++ b/versioned_docs/version-0.3.2/getting_started/hello_world/00_hello_world.md @@ -107,7 +107,7 @@ Now that the project is set up, we can create a proof of correct execution on ou Fill in input values for execution in the _Prover.toml_ file. For example: -```yaml +```toml x = "1" y = "2" ``` @@ -124,7 +124,7 @@ A new folder _proofs_ would then be generated in your project directory, contain The _Verifier.toml_ file would also be updated with the public values computed from program execution (in this case the value of `y`): -```yaml +```toml y = "0x0000000000000000000000000000000000000000000000000000000000000002" ``` From 4279f0ec4a5f08b90aacba4a919b669bddc18f88 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Fri, 25 Aug 2023 11:11:41 -0400 Subject: [PATCH 21/23] add contract crate type --- docs/modules_packages_crates/crates_and_packages.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/modules_packages_crates/crates_and_packages.md b/docs/modules_packages_crates/crates_and_packages.md index c70c869..fb83a33 100644 --- a/docs/modules_packages_crates/crates_and_packages.md +++ b/docs/modules_packages_crates/crates_and_packages.md @@ -11,7 +11,7 @@ Crates can contain modules, and the modules may be defined in other files that g ### Crate Types -A Noir crate can come in one of two forms: a binary crate or a library crate. +A Noir crate can come in several forms: binaries, libraries or contracts. #### Binaries @@ -21,6 +21,10 @@ _Binary crates_ are programs which you can compile to an ACIR circuit which you _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/yarn-project/noir-contracts/src/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. @@ -31,8 +35,6 @@ A Nargo _package_ is a collection of one of more crates that provides a set of f A package _must_ contain either a library or a binary crate, but not both. -Binary packages (but not library packages) can be defined as a [workspace](./workspaces). - ### 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. From b4ab9ebe308af535078924dfa4de25822bbc1d96 Mon Sep 17 00:00:00 2001 From: josh crites Date: Mon, 28 Aug 2023 13:49:09 -0400 Subject: [PATCH 22/23] Update docs/modules_packages_crates/workspaces.md Co-authored-by: Blaine Bublitz --- docs/modules_packages_crates/workspaces.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules_packages_crates/workspaces.md b/docs/modules_packages_crates/workspaces.md index c7c8f78..20e0968 100644 --- a/docs/modules_packages_crates/workspaces.md +++ b/docs/modules_packages_crates/workspaces.md @@ -30,7 +30,7 @@ members = ["crates/a", "crates/b"] default-member = "crates/a" ``` -`members` indicates which packages are included in the workspace. This is used when the `--workspace` flag is used with various commands. +`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 packages are included in the workspace by default. `default-members` can be particularly useful in scenarios where certain members of a workspace are auxiliary tools or infrequently-used components and you don't want them to be built or tested every time you work with the main components. From 2643c050594e9bd10153bbdf9a41f9dfd1ed069e Mon Sep 17 00:00:00 2001 From: josh crites Date: Mon, 28 Aug 2023 13:49:33 -0400 Subject: [PATCH 23/23] Update docs/modules_packages_crates/workspaces.md Co-authored-by: Blaine Bublitz --- docs/modules_packages_crates/workspaces.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules_packages_crates/workspaces.md b/docs/modules_packages_crates/workspaces.md index 20e0968..eaa0950 100644 --- a/docs/modules_packages_crates/workspaces.md +++ b/docs/modules_packages_crates/workspaces.md @@ -32,7 +32,7 @@ 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 packages are included in the workspace by default. `default-members` can be particularly useful in scenarios where certain members of a workspace are auxiliary tools or infrequently-used components and you don't want them to be built or tested every time you work with the main components. +`default-member` indicates which package various commands process by default. Libraries can be defined in a workspace. We just don't have a way to consume libraries from inside a workspace as external dependencies right now.