Why Privacy Matters in Trading
Traditional orderbooks expose sensitive information:| Exposed Data | Privacy Risk |
|---|---|
| Order prices | Front-running attacks |
| Order quantities | Position size exposure |
| Trade history | Trading strategy leakage |
Architecture Overview
Key Features
Encrypted Orders
Prices and quantities are encrypted client-side before submission
Private Matching
Orders matched using FHE comparisons - no plaintext exposure
Minimal Storage
Only 32-byte hash references stored on-chain
Authorization Control
PDAs control who can decrypt match results
Data Flow
1
Encrypt Order
Client encrypts price and quantity using FHE public key
2
Submit to Store
Encrypted data submitted to content-addressable store, receives hash
3
Create Order
Order account created with
EncryptedRef hashes (32 bytes each)4
Match Orders
Program loads encrypted data, performs FHE comparison and min
5
Store Result
Fill price and quantity stored, authorization PDAs created
6
Decrypt
Authorized users can request decryption of their fill details
Program Structure
Account Sizes
The orderbook uses minimal account space by storing only hash references:| Account | Size | Contents |
|---|---|---|
Order | 106 bytes | owner, price_ref, qty_ref, side, status, order_id |
Orderbook | 56 bytes | authority, next_order_id, counters |
MatchResult | 88 bytes | order IDs, fill_price_ref, fill_qty_ref, match_id |
Instructions
| Instruction | Description |
|---|---|
Initialize | Create orderbook with authority |
SubmitOrder | Submit buy/sell order with encrypted price and quantity |
MatchOrders | Match a buy and sell order using FHE |
CancelOrder | Cancel an open order (owner only) |