Skip to content

Latest commit

 

History

History
384 lines (348 loc) · 24.5 KB

File metadata and controls

384 lines (348 loc) · 24.5 KB

🏗️ Architecture Overview

System Architecture

High-Level Flow

┌─────────────────────────────────────────────────────────────────┐
│                         USER LAYER                               │
│  (Your Computer / Wallet)                                        │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  1. User initiates transfer                                     │
│     Input: "Send 0.03 SOL to Alice"                            │
│                                                                  │
│  2. Wallet encrypts amount                                      │
│     ┌──────────────────────────────────┐                       │
│     │ Pedersen Commitment Generator     │                       │
│     │ Input: 0.03 SOL                   │                       │
│     │ Output: Commitment (64 bytes)     │                       │
│     │ Time: <1ms                         │                       │
│     └──────────────────────────────────┘                       │
│                                                                  │
│  3. Generate Zero-Knowledge Proof                               │
│     ┌──────────────────────────────────┐                       │
│     │ Bulletproof Generator             │                       │
│     │ Proves: Amount is valid           │                       │
│     │ Hides: Actual amount              │                       │
│     │ Time: ~3 seconds                  │                       │
│     └──────────────────────────────────┘                       │
│                                                                  │
│  4. Package transaction                                         │
│     ┌──────────────────────────────────┐                       │
│     │ Transaction Builder               │                       │
│     │ • Sender address                  │                       │
│     │ • Receiver address                │                       │
│     │ • Encrypted commitment            │                       │
│     │ • ZK proof                        │                       │
│     └──────────────────────────────────┘                       │
│                                                                  │
└────────────────────────┬────────────────────────────────────────┘
                         │
                         │ Submit Transaction
                         │
                         ▼
┌─────────────────────────────────────────────────────────────────┐
│                      BLOCKCHAIN LAYER                            │
│  (Solana Network)                                                │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  5. Privacy Transfer Program receives transaction               │
│     Program ID: HHvRt9CScrgHkfhDGUiwbskYpCSA9PetdT4uVwQ5C7f5   │
│                                                                  │
│  6. Verify Zero-Knowledge Proof                                 │
│     ┌──────────────────────────────────┐                       │
│     │ Bulletproof Verifier              │                       │
│     │ ✅ Proof is valid                 │                       │
│     │ ✅ Amount in valid range          │                       │
│     │ ✅ Sender has sufficient balance  │                       │
│     │ ❌ Cannot see actual amount!      │                       │
│     │ Time: <100ms                      │                       │
│     └──────────────────────────────────┘                       │
│                                                                  │
│  7. Update encrypted balances                                   │
│     ┌──────────────────────────────────┐                       │
│     │ Balance Update (Homomorphic)      │                       │
│     │ Sender: C_old - C_amount          │                       │
│     │ Receiver: C_old + C_amount        │                       │
│     │ (All encrypted!)                  │                       │
│     └──────────────────────────────────┘                       │
│                                                                  │
│  8. Store on blockchain                                         │
│     ┌──────────────────────────────────┐                       │
│     │ On-Chain Storage                  │                       │
│     │ • Sender commitment (encrypted)   │                       │
│     │ • Receiver commitment (encrypted) │                       │
│     │ • Proof data                      │                       │
│     │ • Transaction metadata            │                       │
│     └──────────────────────────────────┘                       │
│                                                                  │
└────────────────────────┬────────────────────────────────────────┘
                         │
                         │ Transaction Confirmed
                         │
                         ▼
┌─────────────────────────────────────────────────────────────────┐
│                       PUBLIC VIEW                                │
│  (Solana Explorer / Anyone)                                      │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  What anyone can see:                                           │
│  ✅ Transaction signature                                       │
│  ✅ Sender address                                              │
│  ✅ Receiver address                                            │
│  ✅ Transaction status (confirmed)                              │
│  ✅ Timestamp                                                   │
│  🔒 Encrypted commitment (cannot decrypt)                       │
│  ❌ Transfer amount (HIDDEN)                                    │
│  ❌ Account balances (HIDDEN)                                   │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

Component Architecture

Client-Side Components

┌─────────────────────────────────────────────────────────────┐
│                    Wallet Application                        │
├─────────────────────────────────────────────────────────────┤
│                                                              │
│  ┌──────────────────────────────────────────────┐          │
│  │         User Interface Layer                  │          │
│  │  • CLI commands                               │          │
│  │  • Transaction history                        │          │
│  │  • Balance display                            │          │
│  └────────────────┬─────────────────────────────┘          │
│                   │                                          │
│  ┌────────────────▼─────────────────────────────┐          │
│  │         Wallet Management Layer               │          │
│  │  • Key storage (AES-256-GCM)                 │          │
│  │  • Account management                         │          │
│  │  • Transaction signing                        │          │
│  └────────────────┬─────────────────────────────┘          │
│                   │                                          │
│  ┌────────────────▼─────────────────────────────┐          │
│  │         Privacy Layer                         │          │
│  │  • Commitment generation                      │          │
│  │  • Proof generation (Bulletproofs)           │          │
│  │  • Proof verification                         │          │
│  │  • Balance decryption                         │          │
│  └────────────────┬─────────────────────────────┘          │
│                   │                                          │
│  ┌────────────────▼─────────────────────────────┐          │
│  │         Cryptography Layer                    │          │
│  │  • Elliptic curve operations                 │          │
│  │  • Pedersen commitments                       │          │
│  │  • Schnorr proofs                             │          │
│  │  • Hash functions                             │          │
│  └────────────────┬─────────────────────────────┘          │
│                   │                                          │
│  ┌────────────────▼─────────────────────────────┐          │
│  │         Solana Integration Layer              │          │
│  │  • RPC communication                          │          │
│  │  • Transaction building                       │          │
│  │  • Account management                         │          │
│  └──────────────────────────────────────────────┘          │
│                                                              │
└─────────────────────────────────────────────────────────────┘

On-Chain Components

┌─────────────────────────────────────────────────────────────┐
│              Privacy Transfer Program (Rust)                 │
│  Program ID: HHvRt9CScrgHkfhDGUiwbskYpCSA9PetdT4uVwQ5C7f5   │
├─────────────────────────────────────────────────────────────┤
│                                                              │
│  Instructions:                                               │
│  ┌──────────────────────────────────────────────┐          │
│  │  1. Initialize Encrypted Account              │          │
│  │     • Create PDA for encrypted storage        │          │
│  │     • Initialize commitment to zero           │          │
│  └──────────────────────────────────────────────┘          │
│                                                              │
│  ┌──────────────────────────────────────────────┐          │
│  │  2. Initialize SOL Escrow                     │          │
│  │     • Create escrow account                   │          │
│  │     • Set up ownership                        │          │
│  └──────────────────────────────────────────────┘          │
│                                                              │
│  ┌──────────────────────────────────────────────┐          │
│  │  3. Deposit SOL                               │          │
│  │     • Transfer SOL to escrow                  │          │
│  │     • Update encrypted commitment             │          │
│  └──────────────────────────────────────────────┘          │
│                                                              │
│  ┌──────────────────────────────────────────────┐          │
│  │  4. Confidential Transfer                     │          │
│  │     • Verify ZK proof                         │          │
│  │     • Update sender commitment                │          │
│  │     • Update receiver commitment              │          │
│  │     • Transfer SOL between escrows            │          │
│  └──────────────────────────────────────────────┘          │
│                                                              │
│  ┌──────────────────────────────────────────────┐          │
│  │  5. Withdraw SOL                              │          │
│  │     • Verify balance                          │          │
│  │     • Transfer from escrow to wallet          │          │
│  │     • Update commitment                       │          │
│  └──────────────────────────────────────────────┘          │
│                                                              │
└─────────────────────────────────────────────────────────────┘

Data Flow

Transaction Data Flow

User Input
    ↓
┌─────────────────────┐
│ Amount: 0.03 SOL    │
│ To: Alice           │
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│ Generate Commitment │
│ C = rG + vH         │
│ r = random blinding │
│ v = amount (0.03)   │
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│ Generate Proof      │
│ π = Bulletproof     │
│ Proves: 0 ≤ v ≤ max │
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│ Build Transaction   │
│ • Commitment C      │
│ • Proof π           │
│ • Addresses         │
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│ Submit to Solana    │
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│ Program Verifies    │
│ Verify(π, C) = ✅   │
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│ Update Balances     │
│ C_sender -= C       │
│ C_receiver += C     │
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│ Store On-Chain      │
│ (Encrypted)         │
└─────────────────────┘

Security Architecture

Key Management

┌─────────────────────────────────────────────────────────────┐
│                    Key Hierarchy                             │
├─────────────────────────────────────────────────────────────┤
│                                                              │
│  User Password                                               │
│       ↓                                                      │
│  PBKDF2 (100,000 iterations)                                │
│       ↓                                                      │
│  Encryption Key (256-bit)                                   │
│       ↓                                                      │
│  ┌──────────────────────────────────┐                      │
│  │  Encrypted Storage                │                      │
│  │  • Solana keypair (Ed25519)      │                      │
│  │  • Blinding factors              │                      │
│  │  • Transaction history           │                      │
│  └──────────────────────────────────┘                      │
│                                                              │
└─────────────────────────────────────────────────────────────┘

Privacy Guarantees

┌─────────────────────────────────────────────────────────────┐
│                  What's Protected                            │
├─────────────────────────────────────────────────────────────┤
│                                                              │
│  🔒 Computational Security:                                 │
│     • Discrete logarithm problem                            │
│     • 256-bit elliptic curve                                │
│     • Same security as Bitcoin/Ethereum                     │
│                                                              │
│  🔒 Cryptographic Commitments:                              │
│     • Pedersen commitments (hiding + binding)               │
│     • Cannot change after commitment                        │
│     • Cannot determine value without key                    │
│                                                              │
│  🔒 Zero-Knowledge Proofs:                                  │
│     • Bulletproofs (range proofs)                           │
│     • Schnorr proofs (equality)                             │
│     • Prove validity without revealing data                 │
│                                                              │
└─────────────────────────────────────────────────────────────┘

Performance Characteristics

Time Complexity

Operation Time Notes
Commitment generation O(1) ~1ms
Bulletproof generation O(log n) ~3s for n=32
Bulletproof verification O(log n) ~100ms
Transaction submission O(1) ~1s (network)
Total transfer time ~4s End-to-end

Space Complexity

Data Size Notes
Commitment 64 bytes Elliptic curve point
Bulletproof ~700 bytes For n=32 range
Schnorr proof 96 bytes Equality proof
Transaction overhead ~200 bytes Solana metadata
Total per transfer ~1 KB On-chain storage

Scalability

Throughput

Regular Solana:     ~1,000 TPS (theoretical)
Privacy Transfer:   ~250 TPS (estimated)

Bottleneck: Proof verification on-chain
Solution: Batch verification (future optimization)

Cost Scaling

Transfers per day    Cost (Regular)    Cost (Private)    Difference
─────────────────────────────────────────────────────────────────
1                    $0.000025         $0.000030         +$0.000005
10                   $0.000250         $0.000300         +$0.000050
100                  $0.002500         $0.003000         +$0.000500
1,000                $0.025000         $0.030000         +$0.005000

Conclusion: Privacy adds ~20% cost overhead

Future Optimizations

Planned Improvements

  1. Batch Verification

    • Verify multiple proofs together
    • Reduce on-chain compute
    • Increase throughput
  2. Proof Aggregation

    • Combine multiple proofs
    • Smaller on-chain footprint
    • Lower costs
  3. WASM Acceleration

    • Faster proof generation
    • Browser compatibility
    • Better UX
  4. GPU Acceleration

    • Parallel proof generation
    • Sub-second proofs
    • High-volume use cases

For more details: