Overview
Ballet implements low-level building blocks used throughout Firedancer, including signature verification, hashing, serialization, and Solana-specific data structures. All implementations are optimized for x86 architectures with AVX/AVX-512 support.Ballet components are designed to be platform-aware, automatically selecting the best implementation based on available CPU features (AVX-512, AVX, or fallback).
Core Modules
Cryptographic Primitives
Cryptographic Primitives
Signature Schemes
Ed25519 (ed25519/fd_ed25519.h)- ED25519 signature generation and verification
- Optimized signature batch verification
- Public key derivation from private keys
- Error codes:
FD_ED25519_SUCCESS,FD_ED25519_ERR_SIG,FD_ED25519_ERR_PUBKEY,FD_ED25519_ERR_MSG
secp256k1/)- ECDSA signature operations
- Used for Ethereum compatibility
secp256r1/)- NIST P-256 curve operations
- Used for secure enclave integration
bls/fd_bls12_381.h)- BLS signature aggregation
- Pairing-based cryptography
Hash Functions
SHA-256 (sha256/fd_sha256.h)- Standard SHA-256 hashing
- Block size: 64 bytes, Hash size: 32 bytes
- Constants:
FD_SHA256_HASH_SZ,FD_SHA256_BLOCK_SZ
sha512/fd_sha512.h)- SHA-512 hashing
- Used in Ed25519 operations
blake3/fd_blake3.h)- BLAKE3 cryptographic hash function
- High-performance parallel hashing
keccak256/)- Ethereum-compatible Keccak hashing
- Used for EVM integration
Encoding & Serialization
Encoding & Serialization
Text Encoding
Base58 (base58/fd_base58.h)- Solana address encoding/decoding
- Optimized with AVX instructions
- Standard for Solana public key representation
base64/fd_base64.h)- Standard Base64 encoding/decoding
- Used for RPC responses
hex/)- Hexadecimal encoding utilities
Binary Formats
Protocol Buffers (pb/, nanopb/)- Protobuf serialization
- Nanopb integration for compact encoding
toml/)- Configuration file parsing
json/)- JSON parsing and generation
Solana Data Structures
Solana Data Structures
Transaction Components
Transaction (txn/)- Transaction parsing and validation
- Signature verification
- Account metadata extraction
shred/fd_shred.h)- Shred encoding/decoding
- FEC (Forward Error Correction) operations
- Merkle tree validation
block/fd_microblock.h)- Block data structure handling
- Microblock operations for consensus
Proof of History
PoH (poh/)- Proof of History hash chain operations
- SHA-256 based sequential hashing
Advanced Cryptography
Advanced Cryptography
Zero-Knowledge Proofs
ZK-SDK (zksdk/)- Zero-knowledge proof primitives
- Used for confidential transfers
- Range proofs and sigma protocols
Elliptic Curves
BN254 (bn254/fd_bn254.h)- Barreto-Naehrig curve operations
- Scalar field arithmetic
- Poseidon hash function (
fd_poseidon.h) - GLV endomorphism optimization
fiat-crypto/)- Formally verified cryptographic primitives
- Generated from Coq proofs
Utilities & Algorithms
Utilities & Algorithms
Data Structures
Binary Merkle Tree (bmtree/fd_bmtree.h)- Efficient Merkle tree operations
- Used for shred verification
reedsol/)- Forward error correction encoding
- Used for shred redundancy
Hashing & Checksums
SipHash-1-3 (siphash13/)- Fast keyed hash function
- Used for hash tables
murmur3/)- Non-cryptographic hash function
- Fast hash table operations
lthash/)- Lattice-based homomorphic hashing
Encryption
AES (aes/fd_aes_gcm.h)- AES-GCM authenticated encryption
- Hardware-accelerated (AES-NI)
chacha/fd_chacha.h)- ChaCha20 stream cipher
- ChaCha20-RNG for random number generation
Other
Weighted Sampling (wsample/)- Weighted random sampling algorithms
- Used for leader schedule computation
utf8/)- UTF-8 validation and processing
x509/)- Certificate parsing and validation
zstd/)- Zstandard compression
bzip2/)- Bzip2 compression support
elf/)- ELF binary parsing
- Used for eBPF program loading
sbpf/)- Solana BPF program support
- VM bytecode operations
Configuration
Key Constants
| Constant | Value | Description |
|---|---|---|
FD_TPU_MTU | 1232 bytes | Maximum Solana transaction size |
FD_ALIGN | 8-64 bytes | Platform-dependent alignment |
FD_ED25519_SIG_SZ | 64 bytes | Ed25519 signature size |
FD_SHA256_HASH_SZ | 32 bytes | SHA-256 hash output size |
FD_BASE58_ENCODED_32_SZ | 44 bytes | Max base58 encoded address length |
Usage Example
Performance Characteristics
- Ed25519 Batch Verification: Up to 8x faster than individual verification
- SHA-256: Hardware-accelerated on x86 with SHA extensions
- Base58: AVX-optimized encoding/decoding
- AES-GCM: AES-NI accelerated encryption
- All algorithms: Cache-line aware, minimize false sharing