This directory contains all precompiled contracts (precompiles) for the Lux blockchain ecosystem. Precompiles are special smart contracts implemented natively in the node software for performance-critical operations that would be too expensive or slow to implement in Solidity.
Precompiles are located at deterministic addresses starting from 0x0200000000000000000000000000000000000000. They provide optimized implementations for cryptographic operations, cross-chain messaging, and chain configuration.
| Address | Name | Description | LP |
|---|---|---|---|
0x0200000000000000000000000000000000000001 |
DeployerAllowList | Access control for contract deployment | LP-315 |
0x0200000000000000000000000000000000000002 |
TxAllowList | Access control for transaction execution | LP-316 |
0x0200000000000000000000000000000000000003 |
FeeManager | Dynamic fee configuration and management | LP-314 |
0x0200000000000000000000000000000000000004 |
NativeMinter | Mint and burn native LUX tokens | LP-317 |
0x0200000000000000000000000000000000000005 |
RewardManager | Validator reward distribution | LP-318 |
0x0200000000000000000000000000000000000006 |
ML-DSA | Post-quantum signature verification (FIPS 204) | LP-311 |
0x0200000000000000000000000000000000000007 |
SLH-DSA | Hash-based signature verification (FIPS 205) | LP-312 |
0x0200000000000000000000000000000000000008 |
Warp | Cross-chain messaging and attestation | LP-313 |
0x0200000000000000000000000000000000000009 |
PQCrypto | General post-quantum cryptography operations | LP-310 |
0x020000000000000000000000000000000000000A |
Quasar | Advanced consensus operations | LP-99 |
0x020000000000000000000000000000000000000B |
Ringtail | Lattice-based threshold signatures (LWE) | LP-320 |
0x020000000000000000000000000000000000000C |
FROST | Schnorr/EdDSA threshold signatures | LP-321 |
0x020000000000000000000000000000000000000D |
CGGMP21 | ECDSA threshold signatures with aborts | LP-322 |
0x020000000000000000000000000000000000000E |
Bridge | Cross-chain bridge verification | LP-323 (Reserved) |
These precompiles manage permissions for critical blockchain operations:
- Purpose: Control which addresses can deploy smart contracts
- Use Case: Enterprise/private chains with deployment restrictions
- Gas Cost: Minimal (configuration reads)
- Documentation: deployerallowlist/
- Purpose: Control which addresses can submit transactions
- Use Case: Permissioned blockchains, compliance requirements
- Gas Cost: Minimal (configuration reads)
- Documentation: txallowlist/
These precompiles manage blockchain economics and tokenomics:
- Purpose: Configure gas fees, base fees, and EIP-1559 parameters
- Use Case: Dynamic fee adjustment, custom fee models
- Gas Cost: Varies by operation
- Documentation: feemanager/
- LP: LP-314
- Purpose: Mint and burn native LUX tokens
- Use Case: Bridging, wrapping/unwrapping, supply management
- Gas Cost: Proportional to amount
- Documentation: nativeminter/
- Purpose: Distribute staking and validation rewards
- Use Case: Validator compensation, staking yields
- Gas Cost: Proportional to recipient count
- Documentation: rewardmanager/
These precompiles provide quantum-resistant cryptographic operations per NIST FIPS standards:
- Purpose: Verify ML-DSA-65 signatures (FIPS 204 - Dilithium)
- Security Level: NIST Level 3 (192-bit equivalent)
- Key Sizes:
- Public Key: 1,952 bytes
- Signature: 3,309 bytes
- Performance: ~108μs verification on Apple M1
- Gas Cost: 100,000 base + 10 gas/byte of message
- Use Cases:
- Quantum-safe transaction authorization
- Cross-chain message authentication
- Post-quantum multisig wallets
- Documentation: mldsa/
- LP: LP-311
- Solidity Interface: mldsa/IMLDSA.sol
- Purpose: Verify SLH-DSA signatures (FIPS 205 - SPHINCS+)
- Security Level: NIST Level 1-5 (128-256 bit)
- Key Sizes (SLH-DSA-128s):
- Public Key: 32 bytes
- Signature: 7,856 bytes
- Performance: ~286μs verification on Apple M1
- Gas Cost: 15,000 base + 10 gas/byte of message
- Use Cases:
- Hash-based quantum-safe signatures
- Long-term signature validity (archival)
- Conservative post-quantum security
- Firmware update verification
- Documentation: slhdsa/
- LP: LP-312
- Solidity Interface: slhdsa/ISLHDSA.sol
- Purpose: General post-quantum cryptography operations
- Operations:
- ML-KEM-768 key encapsulation (FIPS 203)
- Hybrid classical+PQ operations
- Quantum-safe key exchange
- Documentation: pqcrypto/
- LP: LP-310 (to be created)
These precompiles enable cross-chain communication and messaging:
- Purpose: Cross-chain message signing and verification
- Features:
- BLS signature aggregation
- Validator attestations
- Cross-chain asset transfers
- Performance: ~1.5ms per BLS verification
- Gas Cost: Variable based on validator set size
- Use Cases:
- Cross-chain token transfers
- Multi-chain contract calls
- Subnet synchronization
- Documentation: warp/
- LP: LP-313 (to be created)
Multi-party computation and threshold signatures for custody and consensus:
- Purpose: Lattice-based threshold signature verification
- Algorithm: LWE-based two-round threshold scheme
- Security: Post-quantum (Ring Learning With Errors)
- Gas Cost: 150,000 base + 10,000 per party
- Use Cases:
- Quantum-safe threshold wallets
- Distributed validator signing
- Post-quantum consensus
- Multi-party custody
- Documentation: ringtail/
- LP: LP-320
- Purpose: Schnorr/EdDSA threshold signature verification
- Algorithm: FROST (Flexible Round-Optimized Schnorr Threshold)
- Standards: IETF FROST, BIP-340/341 (Taproot)
- Gas Cost: 50,000 base + 5,000 per signer
- Signature Size: 64 bytes (compact Schnorr)
- Use Cases:
- Bitcoin Taproot multisig
- Ed25519 threshold (Solana, Cardano, TON)
- Schnorr aggregate signatures
- Lightweight threshold custody
- Documentation: frost/
- LP: LP-321
- Purpose: Modern ECDSA threshold signature verification
- Algorithm: CGGMP21 with identifiable aborts
- Security: Detects malicious parties
- Gas Cost: 75,000 base + 10,000 per signer
- Signature Size: 65 bytes (standard ECDSA)
- Use Cases:
- Ethereum threshold wallets
- Bitcoin threshold multisig
- MPC custody solutions
- Enterprise key management
- Documentation: cggmp21/
- LP: LP-322
Advanced consensus and validation operations:
- Purpose: Advanced consensus operations for Quasar hybrid consensus
- Features:
- Dual certificate verification (classical + PQ)
- BLS signature aggregation
- Hybrid BLS+ML-DSA verification
- Verkle witness verification
- Documentation: quasar/
- LP: LP-99
Each precompile directory contains:
<precompile-name>/
├── module.go # Precompile module registration
├── contract.go # Core precompile implementation
├── contract_test.go # Go test suite
├── config.go # Configuration structures (if applicable)
├── config_test.go # Configuration tests
├── I<Name>.sol # Solidity interface
├── contract.abi # ABI definition (if applicable)
└── README.md # Detailed documentation
- Choose an Address: Select next available address in sequence
- Create Directory:
mkdir -p src/precompiles/<name> - Implement Interface: Must implement
StatefulPrecompiledContract - Write Tests: Minimum 80% code coverage
- Create Solidity Interface: Include full documentation
- Write LP: Document specification in lps/LPs/
- Update This README: Add to address table and category
All precompiles must implement:
type StatefulPrecompiledContract interface {
// Address returns the precompile address
Address() common.Address
// RequiredGas calculates gas cost for input
RequiredGas(input []byte) uint64
// Run executes the precompile logic
Run(
accessibleState AccessibleState,
caller common.Address,
addr common.Address,
input []byte,
suppliedGas uint64,
readOnly bool,
) ([]byte, uint64, error)
}Each precompile must provide a module for registration:
type module struct {
address common.Address
contract StatefulPrecompiledContract
}
func (m *module) Address() common.Address {
return m.address
}
func (m *module) Contract() StatefulPrecompiledContract {
return m.contract
}Gas costs should reflect:
- Computational complexity: Higher for crypto operations
- Memory usage: Larger for big inputs/outputs
- State access: More for state reads/writes
- Benchmarks: Based on real performance measurements
Example gas formulas:
- Simple state read: ~2,000 gas
- Cryptographic verification: 50,000 - 500,000 gas
- Per-byte processing: 10 - 50 gas/byte
- State writes: ~20,000 gas per slot
All precompiles must have:
-
Unit Tests (
contract_test.go):- Valid input cases
- Invalid input cases
- Edge cases
- Gas calculation verification
-
Solidity Tests:
- Interface usage examples
- Integration with other contracts
- Gas benchmarks
-
Benchmarks:
- Performance measurements
- Gas cost validation
- Comparison with pure Solidity implementation
- Always validate input length before parsing
- Check for buffer overflows
- Validate all parameters against constraints
- Ensure gas costs prevent DoS attacks
- Test with maximum-size inputs
- Verify gas calculations don't overflow
- Only modify state in non-read-only calls
- Validate caller permissions for privileged operations
- Ensure atomic state updates
- Use constant-time implementations when possible
- Validate all cryptographic inputs
- Check signature/key sizes match expected values
- Test against known attack vectors
Performance targets on Apple M1 (reference hardware):
| Operation | Target | Current |
|---|---|---|
| ML-DSA-65 Verify | < 150μs | ~108μs ✓ |
| SLH-DSA-192s Verify | < 20ms | ~15ms ✓ |
| BLS Signature Verify | < 2ms | ~1.5ms ✓ |
| State Read | < 5μs | ~2μs ✓ |
| State Write | < 10μs | ~5μs ✓ |
Each precompile must document:
- Purpose and Use Cases: Why it exists, when to use it
- Input/Output Format: Exact byte layouts with examples
- Gas Costs: Formula and examples
- Error Conditions: All possible failure modes
- Security Considerations: Potential vulnerabilities
- Examples: Both Go and Solidity usage
- Lux Precompile Standards (LPS): ../lps/
- EVM Precompiles: ../evm/
- Solidity Interfaces: .//I.sol
- NIST PQC Standards: https://csrc.nist.gov/projects/post-quantum-cryptography
Copyright (C) 2025, Lux Industries, Inc. All rights reserved. See the file LICENSE for licensing terms.