Lux Docs
Lux Skills Reference

Lux C++ - High-Performance C++ Libraries for Blockchain & AI

Documentation for Lux C++ - High-Performance C++ Libraries for Blockchain description: '### Why LuxCPP?' AI

Overview

LuxCPP is a modular C++ library suite providing GPU-accelerated cryptography, FHE, lattice operations, DEX matching, and networking for the Lux blockchain ecosystem. It consists of 8 componentized libraries with Metal, CUDA, and WebGPU GPU backends, all built via CMake + Conan.

Why LuxCPP?

  • Multi-backend GPU: Metal (Apple Silicon), CUDA (NVIDIA), WebGPU (Dawn), CPU (SIMD) — compile-time or runtime backend selection
  • Full FHE stack: TFHE/CKKS/BGV via OpenFHE integration with GPU-accelerated NTT
  • Post-quantum crypto: BLS12-381 pairings, ML-DSA (Dilithium), lattice-based NTT
  • DEX engine: C++ CLOB matching engine for sub-microsecond order processing
  • Zero-copy FFI: C API boundary (lux/gpu.h) for Go, Rust, Python, WASM bindings

Tech Stack

  • Language: C++20
  • Build: CMake 3.26+ with Conan 2.x package manager
  • GPU: Metal (MLX), CUDA (CCCL), Dawn (WebGPU/WGSL)
  • Version: 1.0.0
  • License: BSD-3-Clause
  • Repo: github.com/luxfi/luxcpp

Components

ComponentLibraryPurpose
lux-gpulibluxgpuGPU compute dispatch (Metal/CUDA/WebGPU/CPU)
lux-cryptolibluxcryptoBLS12-381, ML-DSA, secp256k1, hashing
lux-latticelibluxlatticeNTT, ring operations, RLWE
lux-fhelibluxfheTFHE/CKKS/BGV (OpenFHE-based)
lux-cudalibluxcudaCUDA kernels (proprietary)
lux-httplibluxhttpHTTP/REST framework
lux-grpclibluxgrpcgRPC services
lux-dexlibluxdexDEX matching engine

Dependency Hierarchy

lux-gpu      ← Foundation (cross-platform GPU acceleration)

lux-crypto   ← BLS pairings, post-quantum (depends on gpu)
lux-lattice  ← NTT acceleration (depends on gpu)

lux-fhe      ← TFHE/CKKS/BGV (depends on crypto + lattice)

When to use

  • Building GPU-accelerated blockchain operations (ZK proofs, FHE, NTT)
  • Integrating C++ crypto into Go/Rust services via FFI
  • Running high-performance DEX matching engines
  • Accelerating lattice-based post-quantum cryptography
  • Building cross-platform GPU compute (macOS Metal + Linux CUDA)

Hard requirements

  1. CMake 3.26+ for build
  2. Conan 2.x for dependency management
  3. C++20 compiler (Clang 15+ or GCC 13+)
  4. Metal SDK (macOS) or CUDA Toolkit (Linux/Windows) for GPU backends
  5. Dawn (optional, for WebGPU backend)

Quick reference

ItemValue
Build systemCMake + Conan
Version1.0.0
LicenseBSD-3-Clause
C++ standardC++20
GPU backendsMetal, CUDA, WebGPU (Dawn), CPU (SIMD)
Install prefixinclude/lux/<pkg>/, lib/liblux<pkg>.*
CMake targetslux::gpu, lux::crypto, lux::lattice, lux::fhe
pkg-configlux-gpu, lux-crypto, etc.
Repogithub.com/luxfi/luxcpp

One-file quickstart

Build all components

# Install dependencies
conan install . --output-folder=build --build=missing

# Configure and build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake \
  -DCMAKE_BUILD_TYPE=Release
cmake --build .

# Run tests
ctest --test-dir .

Platform-specific profiles

# macOS Apple Silicon (Metal backend)
conan install . -pr:b=default -pr:h=profiles/macos-arm64

# Linux x86_64 (CUDA backend)
conan install . -pr:b=default -pr:h=profiles/linux-x86_64

# Windows x86_64
conan install . -pr:b=default -pr:h=profiles/windows-x86_64

Use from CMake

find_package(lux-gpu REQUIRED)
target_link_libraries(myapp lux::gpu)

find_package(lux-crypto REQUIRED)
target_link_libraries(myapp lux::crypto)

Core Concepts

Directory Structure

luxcpp/
├── gpu/                    # lux-gpu: GPU compute library
│   ├── include/lux/gpu.h   # C API (stable FFI boundary)
│   ├── src/                # Core dispatch, CPU backend, ZK ops
│   ├── webgpu/             # Dawn WebGPU backend + WGSL kernels
│   ├── kernels/cpu/        # CPU kernel implementations
│   ├── benchmarks/         # Performance tests
│   └── test/               # Unit tests
├── crypto/                 # lux-crypto: Cryptographic primitives
├── lattice/                # lux-lattice: NTT, ring operations
├── fhe/                    # lux-fhe: FHE (OpenFHE-based)
├── dex/                    # lux-dex: Matching engine
├── http/                   # lux-http: HTTP/REST
├── grpc/                   # lux-grpc: gRPC services
├── session/                # Session-related C++ components
├── consensus/              # Consensus C++ components
├── cuda/                   # CUDA kernel sources
├── metal/                  # Metal shader sources
├── webgpu/                 # WebGPU/WGSL shader sources
├── lux-accel/              # Umbrella acceleration package
├── lux-cuda/               # CUDA-specific build
├── lux-gpu/                # GPU-specific build
├── lux-metal/              # Metal-specific build
├── lux-webgpu/             # WebGPU-specific build
├── mlx-c-api/              # MLX C API bindings
├── third_party/            # Vendored dependencies
├── cmake/                  # CMake modules
├── profiles/               # Conan build profiles
├── scripts/                # Build & install scripts
├── conanfile.py            # Conan package definition
└── LIBRARY_CONTRACT.md     # Standard layout specification

GPU Backend Selection

The GPU library auto-selects the best available backend at compile time, with runtime fallback:

BackendPlatformAcceleration
MetalmacOS (Apple Silicon)MLX integration
CUDALinux/Windows (NVIDIA)CCCL/cuBLAS
DawnCross-platformWebGPU via WGSL shaders
CPUAll platformsSIMD (AVX2/NEON) fallback

Install Layout Convention

All libraries follow a canonical install layout:

  • Headers: include/lux/<pkg>/*.h
  • Libraries: lib/liblux<pkg>.\{dylib,so,a\}
  • CMake config: lib/cmake/lux-<pkg>/
  • pkg-config: lib/pkgconfig/lux-<pkg>.pc

Conan Build Options

# Component toggles
with_gpu=True       # GPU compute
with_fhe=True       # FHE operations
with_crypto=True    # Cryptographic primitives
with_lattice=True   # Lattice crypto
with_dex=True       # DEX matching engine
with_http=True      # HTTP framework
with_grpc=False     # gRPC (opt-in, large dep)

# Backend toggles
with_metal=True     # Metal (macOS)
with_cuda=True      # CUDA (Linux/Windows)
with_webgpu=True    # WebGPU (Dawn)
with_openmp=True    # OpenMP parallelism

# Features
with_tests=False    # Build tests
with_benchmarks=False  # Build benchmarks
embed_kernels=True  # Embed kernel sources in binary

Troubleshooting

IssueCauseSolution
Metal not foundWrong platformMetal only on macOS with Xcode
CUDA not foundMissing toolkitInstall CUDA Toolkit 12+
Conan errorsWrong versionRequires Conan 2.x (not 1.x)
Dawn build failsMissing depsgit submodule update --init in Dawn
Link errorsMissing componentCheck find_package(lux-<pkg>) in CMakeLists
  • lux/lux-gpu.md — Go bindings for GPU acceleration (wraps this C++ code)
  • lux/lux-fhe.md — Go FHE library (uses lattice from here)
  • lux/lux-lattice.md — Go lattice crypto (EPFL, complements C++ NTT)
  • lux/lux-crypto.md — Go crypto primitives
  • lux/lux-dex.md — Go/Rust DEX engine (C++ matching core)
  • lux/lux-accel.md — Rust acceleration (complements C++)

On this page