Installation

Using Sunscreen in your app no different than any other Rust crate.

Simply add

sunscreen = { version = "*", features = ["bulletproofs"] }

to your application's Cargo.toml [dependencies] section. The bulletproofs feature enables the ZKP backend that will be used in the following examples.

You also need cmake, clang, and a C++ compiler toolchain installed on your machine and visible in your $PATH. If you have ever built any other crate that wraps a C++ library, you may already be done.

Linux

Using Yum (e.g. CentOS)

In your terminal, run

sudo yum install cmake3 clang git

Use gcc10-g++ as your compiler

In some distros (e.g Amazon Linux), the default compiler (i.e. gcc7 from the gcc-c++ package), crashes when building SEAL. If g++ --version yields version 7, you need to install and use gcc10.

Run

sudo yum install gcc10 gcc10-c++

then

export CC=/usr/bin/gcc10-gcc
export CXX=/usr/bin/gcc10-g++

before building your application with Cargo. You may wish to add these exports to your shell's rc file (e.g. ~/.bash_profile).

Using Apt (e.g. Debian)

sudo apt install build-essential cmake3 clang git

On some distros (e.g. Ubuntu), the cmake package is already version 3 and you can just use it directly.

Alias cmake3 as cmake

Then, make cmake3 appear in your $PATH as cmake. A simple way to do this is run

sudo ln /usr/bin/cmake3 /usr/bin/cmake

However, this globally creates a hard link for all users and may conflict with also installing the cmake (CMake 2.x) package. As an alternative, you can simply create the hard link or symlink somewhere under your $PATH with higher search precedence than /usr/bin.

MacOS

Using Brew

brew install cmake git

When you first attempt to build your application, MacOS will prompt you to install the command-line developer tools. Do this.

Windows

Install Rust toolchain

Install the MSVC C++ toolchain

When prompted for what to install, ensure you additionally check the Windows 10 SDK. You'll need to rerun the tool and modify your installation if you forget to do this.

Install Rustup. Run the executable and hit return a bunch of times to accept the default options.

Cmake

Install cmake 3.

When prompted, add cmake to either the system or user path. You can also do this later by editing your system's environment variables.

Clang

Install llvm+clang. In the installer, select the option to add LLVM to your %PATH%. If you forget to do check this option, add C:\Program Files\LLVM\bin to your %PATH%.

git

Install git. Defaults are fine.