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

# Keys and view keys

> How one wallet signature becomes a spend key, what a shielded address and a view key contain, and exactly what read-only access does and does not reveal.

A shielded wallet in Fluton has one secret, the **spend key**. Everything else (the address other users pay, the key that decrypts your notes, the key that tells you which of them are spent) is derived from it, one way, so that each piece can be handed out without handing out the ability to spend.

## Spend key

Nothing stores a random spend key per browser. Instead your wallet signs one fixed, domain-bound message (EIP-191 `personal_sign`), and the signature is hashed into the key:

```text theme={null}
spendKey = keccak256("fluton-spend-key" || signature)[1..32)   (31 bytes, always below the field prime)
```

ECDSA in Ethereum wallets uses RFC 6979 deterministic nonces, so the same account always produces the same signature bytes, and therefore the same spend key on every device. There is nothing to back up beyond the wallet itself. The signature never touches the chain and the derivation is one-way, so nothing on-chain links your shielded address to the wallet that signed.

The message names the chain and the pool it is for, and spells out what signing it does:

```text theme={null}
Fluton - shielded spend key

Signing this message derives the SECRET key that controls your shielded balance and
decrypts your private payment history. Only sign it inside the Fluton app.

Chain ID: <chain id>
Pool: 0x…
```

A different chain or a different pool address yields an unrelated key. In the SDK this is one call, and one wallet prompt:

```ts theme={null}
const spendKey = await deriveSpendKey(walletClient, { chainId, pool });
```

> [!WARNING]
>
> Anyone who can obtain that signature (through phishing, or a compromised wallet) owns the
> shielded funds and can decrypt the whole note history. Only sign it in the app you mean to use.

Pasting a raw key stays available as a fallback. It behaves the same afterwards; it is simply not reproducible from a signature.

## Shielded address

To be paid privately, you hand out a shielded address. It carries two public values: your Poseidon **spend public key**, which outputs are created for, and an **x25519** public key, which note ciphertexts are encrypted to. The x25519 keypair is derived deterministically from the spend key, so the single secret recovers everything.

```text theme={null}
pp-addr:<spendPubHex>:<encPubHex>
```

That is all a payer needs. The recipient of a [private transfer](https://docs.fluton.io/concepts/private-transfers.md) never touches the chain, never needs gas, and never appears in the calldata.

## View key

The spend key is split in two, so read-only access is possible without any ability to move funds. Two derived secrets do the reading:

* `nullifierKey` is `Poseidon(spendKey, NULLIFIER_KEY_DOMAIN)`, one-way. It computes each note's nullifier, so its holder can ask the pool which notes are spent and derive the true balance.
* the x25519 encryption secret is also one-way from the spend key. It decrypts every note ever sent to the address, yielding `(amount, blinding, asset)`, which together with the spend public key reconstructs each commitment and finds its leaf.

Handing out those two plus the spend public key is a **view key**:

```text theme={null}
pp-view:<spendPubHex>:<nullifierKeyHex>:<encSecretHex>
```

```ts theme={null}
const view = await viewKeyFromSpendKey(spendKey);
```

A view key watches exactly the same shielded address as the spend key it came from, and it is enough to run a full scan. What it shows an auditor, an accountant, a server tracking incoming payments, or a **watch-only** wallet on a device you do not trust:

| A view key shows | A view key does not show |
| - | - |
| Every note ever sent to the address, of every token | The spend key, which neither derived value yields |
| Which notes are spent, so the real balance | The recipient of an outgoing payment |
| The full history: deposits, received payments, change | The amount of an outgoing payment, beyond the change that came back |

Neither derived value yields the spend key, and a transaction proof needs the spend key itself, so a view-key holder cannot move funds: the SDK refuses to build transaction inputs for a watch-only keypair rather than producing an unprovable witness. An outgoing viewing key, which would reveal where your payments went, is not implemented.

> [!NOTE]
>
> A view key is a secret, even though it cannot spend. It reveals your entire balance and payment
> history to whoever holds it, and it cannot be rotated without moving your notes to a new spend
> key.

The web wallet can reveal a view key for the current wallet and can open a pasted one in watch-only mode; see [using the wallet](https://docs.fluton.io/wallet/using-the-wallet.md). The SDK side (deriving keys, encoding addresses and scanning with either kind of key) is [keys and scanning](https://docs.fluton.io/sdk/keys-and-scanning.md), and what a scan can and cannot see from the chain alone is in [what stays public](https://docs.fluton.io/concepts/privacy-model.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.