Silhouette Webapp
The Silhouette webapp is the frontend for interacting with the other Silhouette system components. It plays a key role in ensuring that individual order flows and balances are only visible to the trader.
Core Capabilities
- Authenticate Securely: Connect a preferred wallet.
- Manage UI Encryption Keys: The webapp handles the generation and secure local storage of a dedicated X25519 key pair used for encrypting communications with the secure enclave.
- Deposit: Initiate a direct transfer on HyperCore from the trader's wallet to the Silhouette smart contract's HyperCore wallet.
- Submit Encrypted Communications: Construct and transmit orders, cancellations, and withdrawal requests, encrypted end-to-end between the browser and the secure enclave.
- Monitor Trading Activity: View order history, balances, and status updates.
Enabling Private Trades
Silhouette achieves order flow privacy through a cryptographic protocol orchestrated by the webapp:
-
Authentication: A session is initiated by authenticating with a preferred wallet. The primary wallet's private keys remain under the exclusive control of the trader's wallet.
-
UI Encryption Key Establishment:
- The webapp generates a unique X25519 key pair (
ui_keypair
). This key pair is distinct from any authentication-related session keys. - The private component (
ui_private_key
) is stored securely within the browser's IndexedDB, namespaced by the connected account address and network ID. This key never leaves the browser. - The public component (
ui_public_key
) is registered with the Silhouette smart contract, associating it with the authenticated wallet address. - This X25519 key pair is persistent, allowing the user to decrypt their historical data. Future enhancements may include optional encryption of this key at rest in IndexedDB.
- The webapp generates a unique X25519 key pair (
-
Secure Channel with Enclave:
- The webapp retrieves the enclave's pre-published X25519 public key (
enclave_public_key
) from the Silhouette smart contract. - Using the
ui_private_key
andenclave_public_key
, the webapp computes a shared secret via the X25519 Diffie-Hellman (ECDH) algorithm (e.g., usingtweetnacl
). - This shared secret is then typically used with a Key Derivation Function (KDF), like HKDF, to derive a symmetric key suitable for AES-GCM encryption.
- The webapp retrieves the enclave's pre-published X25519 public key (
-
Encrypted Order Submission:
- When an order is submitted, the webapp encrypts order details using the derived symmetric key (AES-GCM) and a unique nonce.
- The resulting
cipher-text
andnonce
are transmitted to the Silhouette smart contract. Order details remain opaque to the blockchain.
-
Enclave Processing:
- The secure enclave monitors the Silhouette smart contract for new encrypted orders.
- For a specific order, the enclave retrieves the corresponding
ui_public_key
from the Silhouette smart contract. - Using its own private key and the
ui_public_key
, the enclave independently computes the identical shared secret. - The enclave uses this shared secret and the received
nonce
to decrypt the order. - Decrypted orders are processed within the enclave's confidential matching engine.
Webapp Security Model
The webapp focuses on protecting trading intentions and ensuring user control over primary assets:
-
Wallet Key Isolation:
- Primary wallet private keys are never exposed to the webapp. All operations requiring the primary wallet's signature are delegated to the user's connected wallet software.
- Direct access to on-chain assets (e.g., withdrawals to arbitrary addresses) is controlled by the primary wallet, not the UI's encryption keys.
-
UI Encryption Key Security:
- The X25519 private key (
ui_private_key
) used for encrypting communications is generated and stored exclusively within the browser's IndexedDB, protected by the browser's same-origin policy. - This key is persistent to allow users to access their historical encrypted data. Users should ensure their browser environment and device are secure.
- Compromise of the
ui_private_key
would allow an attacker to:- Decrypt any past and future messages exchanged between the user's browser and the enclave that were encrypted with this key.
- Potentially submit new encrypted messages (e.g., trades) to the enclave as if they were the user, depending on the enclave's authorization model beyond just decryption.
- However, such a compromise does not directly expose the user's primary wallet private keys or allow unauthorized movement of on-chain assets from the primary wallet.
- The X25519 private key (
-
End-to-End Encryption:
- Sensitive trading data (order type, size, and price) is encrypted using AES-GCM (derived from the X25519 shared secret) before leaving the browser.
- Only the secure enclave, capable of independently deriving the same shared secret and symmetric key, can decrypt this information.
- Neither Hyperliquid blockchain validators nor any other intermediaries can view raw order details, including Silhouette.