> ## Documentation Index
> Fetch the complete documentation index at: https://docs.0x0.exchange/llms.txt
> Use this file to discover all available pages before exploring further.

# Privacy & Security

Spectre allows you to trade with **Stealth Orders**. Unlike typical exchanges where your static wallet address is visible, Stealth Orders use a unique, ephemeral address for every transaction. This breaks the linkability between your trades and your master identity.

This is achieved using the **Arcane** protocol.

## How it Works

1. **Stealth Keys**: You have a "Scanning Key" (to find your trades) and a "Spending Key" (to sign trades).
2. **Ephemeral Address**: When placing an order, you generate a random "Stealth Address" that only you can control.
3. **Metadata**: You attach `stealthData` (ephemeral public key, view tag) to the order so you can recover it later.

## Generating Stealth Data

You must include the `stealthData` parameter in `spectre_placeOrder` to enable privacy.

### Usage

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    from arcane.wallet import ArcaneWallet
    from arcane.core import get_stealth_data

    # 1. Initialize your wallet
    # In reality, load this securely!
    my_priv_key = "0x..." 
    wallet = ArcaneWallet(my_priv_key)

    # 2. Get your master Stealth Address (starts with 0X0)
    my_address = wallet.get_address()
    # e.g., "0X0..."

    # 3. Generate Stealth Data for a SELF-transfer (trading with yourself essentially)
    # For an exchange, you are designating yourself as the owner of the order.
    # The `get_stealth_data` function generates the ephemeral keys.
    stealth_tx = wallet.get_stealth_data(my_address)

    # This dictionary matches the API requirement
    stealth_data_param = {
        "ephemeralPublicKey": stealth_tx["ephemeral_public_key"],
        "viewTag": stealth_tx["view_tag"],
        "stealthPublicKey": stealth_tx["stealth_public_key"],
        # Client ID is optional, but helps you filter your own orders quickly
        # "clientId": "my-client-id" 
    }

    print("Stealth Param for API:", stealth_data_param)

    # 4. Use in API
    # rpc.call("spectre_placeOrder", { ..., "stealthData": stealth_data_param })
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    import { ArcaneWallet } from '@0x0exchange/arcane-sdk';

    // 1. Initialize
    const privateKey = "0x...";
    const wallet = new ArcaneWallet(privateKey);

    // 2. Get Address
    const myAddress = wallet.getAddress();

    // 3. Generate Stealth Data
    const stealthTx = wallet.getStealthData(myAddress);

    const stealthDataParam = {
        ephemeralPublicKey: stealthTx.ephemeralPublicKey,
        viewTag: stealthTx.viewTag,
        stealthPublicKey: stealthTx.stealthPublicKey
    };

    console.log("Stealth Param:", stealthDataParam);
    ```
  </Tab>
</Tabs>

## Client Viewing Keys

To view your trade history or decrypt your order details on a new device, you need your **Viewing Key**.

* This key allows **Read-Only** access.
* It cannot sign transactions or move funds.
* The exchange uses this to serve you your encrypted data.

## Encryption (ECIES)

Sensitive fields in `OrderMeta` are encrypted using ECIES (Elliptic Curve Integrated Encryption Scheme).

* **Encryption**: Done with the *Viewing Public Key*.
* **Decryption**: Done with the *Viewing Private Key*.

This ensures that even if the exchange database is leaked, your private order details (like exact leverage, margin, or identity) remain cryptographically secure.
