Last Updated: 2025-12-30
Module: luxcpp/crypto
Role: GPU-accelerated cryptographic primitives
luxcpp/gpu ← Foundation (optional MLX backend)
▲
│
luxcpp/crypto ← YOU ARE HERE (BLS, ML-DSA, hashing)
│
▼
luxcpp/lattice ← NTT operations for ML-DSA
Depends on:
luxcpp/lattice(for ML-DSA NTT operations)luxcpp/gpu(optional, for MLX backend)- Metal framework (macOS, for BLS12-381 compute shaders)
C++ library providing GPU-accelerated:
- BLS12-381: Pairing-based signatures with Metal compute shaders
- ML-DSA: Post-quantum signatures (Dilithium) with NTT acceleration
- Hashing: SHA3-256, SHA3-512, BLAKE3
- Threshold: Shamir secret sharing, threshold signatures
Native Metal compute shaders for elliptic curve operations:
| Kernel | Description | Parallelism |
|---|---|---|
g1_batch_add |
Parallel point addition | Per-point |
g1_batch_double |
Parallel point doubling | Per-point |
g1_batch_scalar_mul |
Parallel scalar multiplication | Per-point |
bls_batch_verify_msm |
Multi-scalar multiplication for batch verification | Threadgroup reduction |
Performance target: 8+ signatures for GPU dispatch (below that, CPU is faster).
bls12_381.metal ← Metal compute shaders (G1 arithmetic)
↓
metal_bls.mm ← Objective-C++ Metal API wrapper
↓
crypto.cpp ← C++ API with automatic GPU dispatch
↓
crypto.h ← Public C API
cd /Users/z/work/luxcpp/crypto
mkdir -p build && cd build
# Metal BLS acceleration (recommended on macOS)
cmake -DWITH_METAL=ON ..
make -j$(sysctl -n hw.ncpu)
# With MLX GPU backend (requires luxcpp/gpu built first)
cmake -DWITH_METAL=ON -DWITH_GPU=ON -DGPU_ROOT=../gpu ..
make -j$(sysctl -n hw.ncpu)
# CPU only
cmake -DWITH_METAL=OFF ..
make -j$(sysctl -n hw.ncpu)| Dependency | Required | Purpose |
|---|---|---|
luxcpp/lattice |
Required | NTT operations for ML-DSA |
luxcpp/gpu |
Optional | MLX backend |
| Metal framework | macOS | BLS12-381 compute shaders |
| Foundation/Security | macOS | Apple frameworks |
| Package | Uses For |
|---|---|
lux/crypto |
Via CGO bridge |
lux/threshold |
BLS threshold signatures |
| File | Purpose |
|---|---|
src/metal/bls12_381.metal |
Metal compute shaders for G1 arithmetic |
src/metal_bls.mm |
Metal API wrapper (Objective-C++) |
include/metal_bls.h |
Metal BLS C interface |
src/crypto.cpp |
Main implementation with GPU dispatch |
include/crypto.h |
Public C API |
- ALWAYS use
-DWITH_METAL=ONon macOS for GPU acceleration - Build
luxcpp/latticefirst (required for ML-DSA) - Build
luxcpp/gpufirst if enabling WITH_GPU - Test BLS batch operations with >= 8 signatures to trigger GPU path
- Metal shaders compile to
.metallibat build time
This file is symlinked as AGENTS.md, CLAUDE.md