diff --git a/src/getting_started/nargo.md b/src/getting_started/nargo.md index 3e1ba7d..f8429b2 100644 --- a/src/getting_started/nargo.md +++ b/src/getting_started/nargo.md @@ -1,5 +1,5 @@ # Nargo -`nargo` is a command line tool for interacting with Noir programs (e.g. compiling, proving, verifying and more). +Nargo is a command line tool for interacting with Noir programs (e.g. compiling, proving, verifying and more). Alternatively, the interactions can also be performed in [TypeScript](typescript.md). diff --git a/src/getting_started/nargo/installation.md b/src/getting_started/nargo/installation.md index 2fe31eb..dd3c71b 100644 --- a/src/getting_started/nargo/installation.md +++ b/src/getting_started/nargo/installation.md @@ -1,44 +1,139 @@ # Installation -## Setup +There are two approaches to install Nargo: -1. Install [Git] and [Rust]. +- [Option 1: Binaries](#option-1-binaries) +- [Option 2: Compile from Source](#option-2-compile-from-source) - Optionally you can install [Noir VS Code extension] for syntax highlighting as well. +## Option 1: Binaries + +> **Platforms Supported:** macOS, Windows + +1. Create a directory to host the binary. For example, run: + + _macOS_ + + ```bash + mkdir -p ~/.nargo/bin + ``` + + _Windows_ + + ```sh + mkdir C:\.nargo\bin + ``` + +2. Download the binary package from [GitHub Releases](https://github.com/noir-lang/noir/releases/tag/nightly) according to your OS, and move it into the directory created in Step 1: + + - macOS (Apple Silicon): `nargo-aarch64-apple-darwin.tar.gz` + - macOS (Intel): `nargo-x86_64-apple-darwin.tar.gz` + - Windows: `nargo-x86_64-pc-windows-msvc.zip` + + > **macOS:** If you cannot find the _.nargo_ directory created, press _Command+Shift+._ in Finder to view hidden files. + +3. Paste and run the following in the terminal to extract and install the binary: + + _macOS (Apple Silicon)_ + + ```bash + cd ~/.nargo/bin && \ + gunzip -c nargo-aarch64-apple-darwin.tar.gz | tar xopf - && \ + chmod +x nargo && \ + echo '\nexport PATH=$PATH:~/.nargo/bin' >> ~/.zshrc && \ + source ~/.zshrc + ``` + + _macOS (Intel)_ + + ```bash + cd ~/.nargo/bin && \ + gunzip -c nargo-x86_64-apple-darwin.tar.gz | tar xopf - && \ + chmod +x nargo && \ + echo '\nexport PATH=$PATH:~/.nargo/bin' >> ~/.zshrc && \ + source ~/.zshrc + ``` + + _Windows (PowerShell)_ + + ```sh + cd C:\.nargo\bin;` + Expand-Archive nargo-x86_64-pc-windows-msvc.zip; ` + $Env:PATH += ";C:\.nargo\bin\nargo-x86_64-pc-windows-msvc" + ``` + +4. Check if the installation was successful by running `nargo --help`. + + > **macOS:** If you are prompted with an OS alert, right-click and open the _nargo_ executable from Finder. + > + > You can close the new terminal that popped up and `nargo` should now be accessible. + + For a successful installation, you should see something similar to the following after running the command: + + ``` + $ nargo --help + nargo 0.1 + Kevaundray Wedderburn + Noir's package manager + + USAGE: + nargo [SUBCOMMAND] + + FLAGS: + -h, --help Prints help information + -V, --version Prints version information + + SUBCOMMANDS: + build Builds the constraint system + compile Compile the program and its secret execution trace into ACIR format + contract Creates the smart contract code for circuit + gates Counts the occurences of different gates in circuit + help Prints this message or the help of the given subcommand(s) + new Create a new binary project + prove Create proof for this program + verify Given a proof and a program, verify whether the proof is valid + ``` + +Optionally you can also install [Noir VS Code extension] for syntax highlighting. + +## Option 2: Compile from Source + +> **Platforms Supported:** Linux, macOS, Windows + +### Setup + +1. Install [Git] and [Rust]. Optionally you can also install [Noir VS Code extension] for syntax highlighting. 2. Download Noir's source code from Github by running: ```bash - $ git clone git@github.com:noir-lang/noir.git + git clone git@github.com:noir-lang/noir.git ``` -3. Change directory into the nargo crate by running: +3. Change directory into the Nargo crate by running: ```bash - $ cd noir/crates/nargo + cd noir/crates/nargo ``` -[Git]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git -[Rust]: https://www.rust-lang.org/tools/install -[Noir VS Code extension]: https://marketplace.visualstudio.com/items?itemName=noir-lang.noir-programming-language-syntax-highlighter +[git]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git +[rust]: https://www.rust-lang.org/tools/install +[noir vs code extension]: https://marketplace.visualstudio.com/items?itemName=noir-lang.noir-programming-language-syntax-highlighter There are then two approaches to proceed, differing in how the proving backend is installed: -## Option 1: WASM Executable Backend +### Option 2.1: WASM Executable Backend -**Platforms Supported:** Linux, macOS, Windows +> **Platforms Supported:** Linux, macOS, Windows 4. Go into `nargo/Cargo.toml` and replace `aztec_backend = ...` with the following: ``` - aztec_backend = { optional = true, git = "https://github.com/noir-lang/aztec_backend", features = ["wasm-base"] , default-features = false } + aztec_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "fb42a54a04f3952f422e8fa4eff4f8eb2ca4e51b" } ``` -> **Note:** `nargo contract` has not been implemented yet for _wasm-base_ `nargo` installations. - -## Option 2: Compile Backend from Source +### Option 2.2: Compile Backend from Source -**Platforms Supported:** Linux, macOS +> **Platforms Supported:** Linux, macOS The [barretenberg] proving backend is written in C++, hence compiling it from source would first require certain dependencies to be installed. @@ -46,9 +141,19 @@ For macOS users, installing through [Homebrew] is highly recommended. 4. Install [CMake], [LLVM] and [OpenMP] by running: - - _macOS_ - - ```bash - $ brew install cmake llvm libomp - ``` - [barretenberg]: https://github.com/AztecProtocol/aztec-connect/tree/master/barretenberg [homebrew]: https://brew.sh/ [cmake]: https://cmake.org/install/ [llvm]: https://llvm.org/docs/GettingStarted.html [openmp]: https://openmp.llvm.org/ -## Continue with Installation +### Continue with Installation -5. Install nargo by running: +5. Install Nargo by running: ```bash - $ cargo install --locked --path=. + cargo install --locked --path=. ``` -6. Check if the installation was successful by running: +6. Check if the installation was successful by running `nargo --help`: ``` - $ nargo help + $ nargo --help nargo 0.1 Kevaundray Wedderburn Noir's package manager @@ -100,6 +199,7 @@ For macOS users, installing through [Homebrew] is highly recommended. build Builds the constraint system compile Compile the program and its secret execution trace into ACIR format contract Creates the smart contract code for circuit + gates Counts the occurences of different gates in circuit help Prints this message or the help of the given subcommand(s) new Create a new binary project prove Create proof for this program