Skip to main content

Installing Shared Libraries

Cardano Node requires the following shared libraries:

  • Sodium is a cryptographic library for which IOHK maintains a release.
  • libsecp256k1 is a library for digital signatures and other cryptographic primitives on the secp256k1 elliptic curve.
  • blst is a BLS12-381 signature library.

To install the libsodium release that IOHK maintains:

  1. To create a working directory to store source code and builds related to Cardano Node, type the following commands using a terminal window:
    mkdir $HOME/git
    cd $HOME/git
  2. To download, compile and install Sodium, type:
    git clone https://github.com/IntersectMBO/libsodium
    cd libsodium
    git checkout dbb48cc
    ./autogen.sh
    ./configure --build=x86_64-linux-gnu
    make
    sudo make install

    Note
    Note

    To resolve a cannot find -lnuma error message when compiling Sodium, type:

    sudo apt-get install libnuma-dev

  3. On each computer hosting a relay or block-producing node in your stake pool configuration, repeat steps 1 to 2

To download, compile and install the libsecp256k1 library:

  1. Using a terminal window, type:
    cd $HOME/git
    git clone --depth 1 --branch v0.3.2 https://github.com/bitcoin-core/secp256k1
    cd secp256k1
    ./autogen.sh
    ./configure --enable-module-schnorrsig --enable-experimental
    make
    make check
    sudo make install
    sudo ldconfig
  2. On each computer hosting a relay or block-producing node in your stake pool configuration, repeat step 1

To download, compile and install the blst library:

  1. Using a terminal window, type:
    cd $HOME/git
    git clone https://github.com/supranational/blst
    cd blst
    git checkout v0.3.14
    ./build.sh
    cat > libblst.pc << EOF
    prefix=/usr/local
    exec_prefix=\${prefix}
    libdir=\${exec_prefix}/lib
    includedir=\${prefix}/include

    Name: libblst
    Description: Multilingual BLS12-381 signature library
    URL: https://github.com/supranational/blst
    Version: 0.3.14
    Cflags: -I\${includedir}
    Libs: -L\${libdir} -lblst
    EOF
    sudo cp libblst.pc /usr/local/lib/pkgconfig/
    sudo cp bindings/blst_aux.h bindings/blst.h bindings/blst.hpp /usr/local/include/
    sudo cp libblst.a /usr/local/lib/
    sudo chmod u=rw,go=r /usr/local/{lib/{libblst.a,pkgconfig/libblst.pc},include/{blst.{h,hpp},blst_aux.h}}
  2. On each computer hosting a relay or block-producing node in your stake pool configuration, repeat step 1

Installing shared libraries involves editing the $HOME/.bashrc file. The $HOME environment variable or ~ tilde prefix refers to the home directory associated with your user name. The .bashrc file is a Bash script that runs each time you open a new terminal window. In the .bashrc file, you can add any command that you may type at the command prompt. Use .bashrc to set up the shell as needed for your environment.

Note
Note

Prefixing a file or folder name using a period (.) character creates a hidden file or folder. Hidden files and folders do not display by default using the file manager or typical command-line listings. To list contents of the current directory including hidden files and folders, using a terminal window type:

ls -a
For more details, refer to the man page for the ls command.

To edit the $HOME/.bashrc file:

  1. Using a text editor, open the $HOME/.bashrc file, and then add the following lines at the end of the file:
    # Set environment variables so that the compiler finds libsodium, libsecp256k1 and blst libraries on your computer
    export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
    export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
    # Set an environment variable indicating the file path to configuration files and scripts
    # related to operating Cardano Node
    export NODE_HOME="$HOME/cardano-node"
    # Set an environment variable indicating the Cardano network environment where the node runs
    export NODE_CONFIG="mainnet"
    # Set an environment variable indicating where the Cardano node socket file is located
    export CARDANO_NODE_SOCKET_PATH="$NODE_HOME/db/socket"

    Note
    Note

    If you plan to use Cardano Node in a Testnet environment instead of Mainnet, then replace the line export NODE_CONFIG="mainnet" in your $HOME/.bashrc file with export NODE_CONFIG="testnet" Also, when working through the How to Set Up a Cardano Stake Pool guide, replace every instance of the command option ‑‑mainnet with ‑‑testnet‑magic <MagicNumber> where <MagicNumber> is the network magic number for the Testnet that you use. For details on available Testnets, see Environments.

  2. Save and close the $HOME/.bashrc file.
  3. To create the folder set for the NODE_HOME environment variable in your $HOME/.bashrc file, type:
    mkdir $HOME/cardano-node
  4. To reload your shell profile, type:
    source $HOME/.bashrc
  5. On each computer hosting a relay or block-producing node in your stake pool configuration, repeat steps 1 to 4