Files
crypto/ROADMAP_CIRCL.md
T
Hanzo Dev e4205c2176 feat: unified crypto package with single implementations
- Consolidated all cryptographic primitives into ONE implementation each
- SECP256K1: Decred (pure Go) + libsecp256k1 (CGO optimized)
- Verkle/IPA: Single unified implementation replacing external deps
- Added VOPRF, HPKE, and KangarooTwelve from Cloudflare CIRCL
- Performance: 2-6x improvement with CGO enabled
- All packages (geth, node, evm, coreth) now use luxfi/crypto
- Removed github.com/ethereum/go-verkle dependency
- Removed github.com/crate-crypto/go-ipa dependency
- Added comprehensive precompiles for Verkle operations
- Full test coverage for CGO=0 and CGO=1 builds
2025-08-16 02:24:36 -05:00

6.2 KiB

Lux Crypto Enhancement Roadmap - CIRCL Integration

Executive Summary

Integrate high-value cryptographic primitives from Cloudflare CIRCL to make Lux the most comprehensive blockchain for advanced cryptography.

Phase 1: Critical Privacy & Performance (Q1 2025)

1. VOPRF (Verifiable Oblivious PRF) - HIGH PRIORITY

Why: Essential for privacy-preserving DeFi, anonymous authentication

// Precompile addresses: 0x01A0-0x01A3
crypto/oprf/
├── voprf.go         // Core VOPRF implementation
├── voprf_test.go    // Tests
└── precompile.go    // Precompile interface

Use Cases:

  • Private DEX matching
  • Anonymous voting
  • Password-authenticated key exchange
  • Privacy-preserving rate limiting

2. HPKE (Hybrid Public Key Encryption) - HIGH PRIORITY

Why: Modern encryption standard (RFC 9180), essential for secure communication

// Precompile addresses: 0x01A4-0x01A7
crypto/hpke/
├── hpke.go          // HPKE implementation
├── modes.go         // Base, PSK, Auth, AuthPSK modes
└── precompile.go    // Precompile interface

Use Cases:

  • Encrypted smart contract storage
  • Secure cross-chain messaging
  • Private transaction data

3. KangarooTwelve (K12) - HIGH PRIORITY

Why: 7x faster than SHAKE for large data

// Precompile addresses: 0x01B0-0x01B2
crypto/xof/k12/
├── k12.go           // KangarooTwelve implementation
├── k12_cgo.go       // Optimized C version
└── precompile.go    // Precompile interface

Use Cases:

  • Fast Merkle tree hashing
  • High-throughput commitments
  • State tree operations

Phase 2: Zero-Knowledge & Cross-Chain (Q2 2025)

4. DLEQ Proofs - MEDIUM PRIORITY

Why: Essential for cross-chain proofs and threshold signatures

// Precompile addresses: 0x0193-0x0195
crypto/zk/dleq/
├── dleq.go          // Discrete log equality proofs
├── schnorr.go       // Schnorr knowledge proofs
└── precompile.go    // Precompile interface

Use Cases:

  • Cross-chain atomic swaps
  • Threshold signature verification
  • Mix networks

5. X-Wing Hybrid KEM - MEDIUM PRIORITY

Why: Quantum-safe transition (X25519 + ML-KEM-768)

// Precompile addresses: 0x0184
crypto/kem/xwing/
├── xwing.go         // Hybrid KEM implementation
└── precompile.go    // Precompile interface

Use Cases:

  • Transition-safe encryption
  • Hybrid security model

Phase 3: Advanced Privacy (Q3 2025)

6. Blind RSA Signatures - LOWER PRIORITY

Why: Anonymous credentials (RFC 9474)

// Precompile addresses: 0x01A8-0x01AB
crypto/blind/
├── blindrsa.go      // Blind RSA implementation
└── precompile.go    // Precompile interface

Use Cases:

  • Anonymous tokens
  • Privacy coins
  • Voting systems

7. Ristretto255 Group - LOWER PRIORITY

Why: Clean prime-order group operations

// Precompile addresses: 0x01C0-0x01C3
crypto/group/ristretto/
├── ristretto255.go  // Ristretto group operations
└── precompile.go    // Precompile interface

Implementation Guide

Step 1: Import from CIRCL

# Add CIRCL dependency
go get github.com/cloudflare/circl@latest

# Import specific packages
import (
    "github.com/cloudflare/circl/oprf"
    "github.com/cloudflare/circl/hpke"
    "github.com/cloudflare/circl/xof/k12"
)

Step 2: Create Precompile Wrappers

// Example: VOPRF Precompile
package precompile

type VOPRFEvaluate struct{}

func (v *VOPRFEvaluate) RequiredGas(input []byte) uint64 {
    return 200000 // Base cost
}

func (v *VOPRFEvaluate) Run(input []byte) ([]byte, error) {
    // Parse input: [mode][key][element]
    // Execute VOPRF evaluation
    // Return proof + output
}

Step 3: Register Precompiles

// In precompile/export.go
func init() {
    // VOPRF
    PostQuantumRegistry.contracts[Address{0x01, 0xA0}] = &VOPRFSetup{}
    PostQuantumRegistry.contracts[Address{0x01, 0xA1}] = &VOPRFEvaluate{}
    PostQuantumRegistry.contracts[Address{0x01, 0xA2}] = &VOPRFVerify{}
    
    // HPKE
    PostQuantumRegistry.contracts[Address{0x01, 0xA4}] = &HPKEEncrypt{}
    PostQuantumRegistry.contracts[Address{0x01, 0xA5}] = &HPKEDecrypt{}
}

Testing Strategy

Unit Tests

func TestVOPRF(t *testing.T) {
    // Test all VOPRF modes
    // Test edge cases
    // Benchmark performance
}

Integration Tests

// Solidity test contract
contract TestVOPRF {
    address constant VOPRF_EVALUATE = 0x00000000000000000000000000000000000001A1;
    
    function testEvaluation(bytes memory input) public returns (bytes memory) {
        (bool success, bytes memory output) = VOPRF_EVALUATE.staticcall(input);
        require(success, "VOPRF failed");
        return output;
    }
}

Gas Cost Structure

Precompile Base Gas Per-Byte Input Per-Byte Output
VOPRF Setup 150,000 200 100
VOPRF Evaluate 200,000 200 100
VOPRF Verify 250,000 200 50
HPKE Encrypt 150,000 100 150
HPKE Decrypt 180,000 150 100
K12 Hash 10,000 50 20
DLEQ Prove 150,000 200 100
DLEQ Verify 100,000 200 50

Success Metrics

  1. Performance: K12 should be 5-7x faster than SHAKE for large inputs
  2. Gas Efficiency: VOPRF operations under 300K gas
  3. Compatibility: Full RFC compliance for HPKE, Blind RSA
  4. Security: Pass all CIRCL test vectors
  5. Adoption: Enable new privacy-preserving dApps

Benefits to Lux Ecosystem

  1. Privacy DeFi: VOPRF enables private DEX, anonymous lending
  2. Performance: K12 dramatically speeds up Merkle operations
  3. Interoperability: HPKE enables secure cross-chain communication
  4. Future-Proof: X-Wing provides quantum-safe transition
  5. Innovation: First blockchain with comprehensive ZK precompiles

Next Steps

  1. Immediate: Start with VOPRF implementation (highest impact)
  2. Week 1: Complete HPKE and K12 implementations
  3. Week 2: Add comprehensive tests and benchmarks
  4. Week 3: Deploy to testnet for validation
  5. Month 2: Begin Phase 2 implementations

This roadmap positions Lux as the premier blockchain for advanced cryptography, enabling entirely new classes of privacy-preserving and high-performance applications.