Development Guide#

This guide is for developers who want to contribute to the NVIDIA Attestation SDK Rust bindings or build applications using the SDK from source.

Prerequisites#

System Requirements#

  • Operating System: - Supported operating systems: Ubuntu 22.04, Ubuntu 24.04, and others (see downloads for full list)

  • Architecture: x86-64 or aarch64

  • Rust: Version 1.80 or later (install from rustup.rs)

Build Dependencies#

# Update package list
sudo apt-get update

# Install build tools and dependencies
sudo apt-get install -y \
    cmake \
    git \
    pkg-config \
    clang \
    libclang-dev \
    libcurl4-openssl-dev \
    libssl-dev \
    libxml2-dev \
    libxmlsec1-dev \
    libxmlsec1-openssl

NVIDIA Dependencies#

For GPU attestation in Confidential Computing mode:

For NVSwitch attestation:

Building from Source#

Step 1: Build the C++ SDK#

The Rust bindings depend on the C++ SDK library:

# Clone the repository
git clone https://github.com/NVIDIA/attestation-sdk.git
cd attestation-sdk

# Build the C++ SDK
cd nv-attestation-sdk-cpp
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --install build
sudo ldconfig

This will:

  • Compile the C++ library (libnvat.so)

  • Generate C header files

  • Install the library system-wide

Step 2: Build the Rust Workspace#

# Navigate to Rust workspace
cd ../nv-attestation-sdk-rust

# Build all crates in the workspace
cargo build --workspace

# Build in release mode
cargo build --workspace --release

Step 3: Run Examples#

Set the library path for runtime:

export LD_LIBRARY_PATH=$(pwd)/../nv-attestation-sdk-cpp/build:$LD_LIBRARY_PATH

Run examples:

# Remote attestation example
cargo run -p nv-attestation-sdk --example basic_remote_attestation

# Local attestation example
cargo run -p nv-attestation-sdk --example basic_local_attestation

Development Workflow#

Using System-Installed Library#

For development with a system-installed SDK:

export NVAT_USE_SYSTEM_LIB=1
cargo build
cargo test

Using Local Build#

For development with a local C++ build:

# Rebuild C++ SDK
cd ../nv-attestation-sdk-cpp
cmake --build build

# Update library path
cd ../nv-attestation-sdk-rust
export LD_LIBRARY_PATH=$(pwd)/../nv-attestation-sdk-cpp/build:$LD_LIBRARY_PATH

# Build and test Rust bindings
cargo build --workspace
cargo test --workspace

Testing#

Running Tests#

# Run all tests
cargo test --workspace

# Run tests for specific crate
cargo test -p nv-attestation-sdk
cargo test -p nv-attestation-sdk-sys

# Run tests with output
cargo test --workspace -- --nocapture

# Run specific test
cargo test test_name

Code Quality#

Formatting#

Use rustfmt to format code:

# Check formatting
cargo fmt --all -- --check

# Apply formatting
cargo fmt --all

Linting#

Use clippy for linting:

# Run clippy
cargo clippy --workspace -- -D warnings

# Run clippy with all features
cargo clippy --workspace --all-features -- -D warnings

Documentation#

Generate and view documentation:

# Generate docs for all crates
cargo doc --workspace --no-deps

# Generate and open docs in browser
cargo doc --workspace --no-deps --open

FFI Bindings Generation#

The nv-attestation-sdk-sys crate automatically generates bindings at build time using bindgen.

Build Script (build.rs)#

The build script:

  1. Locates the C SDK headers

  2. Configures bindgen

  3. Generates Rust FFI bindings

  4. Writes bindings to OUT_DIR

Customizing Bindings#

To customize binding generation, modify nv-attestation-sdk-sys/build.rs:

bindgen::Builder::default()
    .header("wrapper.h")
    .allowlist_function("nvat_.*")      // Include NVAT functions
    .allowlist_type("nvat_.*")          // Include NVAT types
    .allowlist_var("NVAT_.*")           // Include NVAT constants
    .derive_debug(true)                 // Add Debug trait
    .derive_default(true)               // Add Default trait
    .generate()
    .expect("Unable to generate bindings")

Regenerating Bindings#

Bindings are regenerated automatically when:

  • Header files change

  • Build script changes

  • Running cargo clean followed by cargo build

Force regeneration:

cargo clean -p nv-attestation-sdk-sys
cargo build -p nv-attestation-sdk-sys

Troubleshooting#

Bindgen Errors#

If bindgen fails to find headers:

# Set C++ SDK build directory
export NVAT_BUILD_DIR=/path/to/nv-attestation-sdk-cpp/build

# Or install SDK system-wide
cd nv-attestation-sdk-cpp
sudo cmake --install build

Linker Errors#

If the linker can’t find libnvat.so:

# Check library installation
ldconfig -p | grep nvat

# Set LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

# Or update cache
sudo ldconfig

Runtime Errors#

For runtime issues:

# Check library loading
ldd target/debug/examples/basic_remote_attestation

Additional Resources#

Support#

For development questions: