Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/getting_started/nargo.md
Original file line number Diff line number Diff line change
@@ -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).
158 changes: 129 additions & 29 deletions src/getting_started/nargo/installation.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,159 @@
# 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 <kevtheappdev@gmail.com>
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" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kobyhallx pointed out that this commit is slightly outdated. It will work on multiple systems however there was a fix for installing the wasm backend on windows that this commit is missing. The commit should be updated to 484d1f3e780010d04892490641de6a9d92ed805b. This is the most recent commit from this PR (noir-lang/acvm-backend-barretenberg#17)

```

> **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.

For macOS users, installing through [Homebrew] is highly recommended.

4. Install [CMake], [LLVM] and [OpenMP] by running:

<!---
TODO: Supplement Linux scripts.
_macOS_

```bash
brew install cmake llvm libomp
```

_Linux_

```bash
TBC
```

<!---
Linux's command for openMP from barretenberg's GitHub README:

```bash
Expand All @@ -61,30 +166,24 @@ For macOS users, installing through [Homebrew] is highly recommended.
```
--->

_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 <kevtheappdev@gmail.com>
Noir's package manager
Expand All @@ -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
Expand Down