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

# Viewing keys and selective disclosure

> Let an auditor, accountant or counterparty verify an account's history without being able to spend

Every Cloak account has a **viewing key** (`nk`, 32 bytes). It finds and decrypts the account's
transaction records and notes. It can never spend. Sharing it is how a user proves their history to
someone they choose, without making it public.

## What the viewing key reveals

| With `nk`, a holder can | A holder cannot |
| - | - |
| Run `scanTransactions` and see every transaction the account made: type, token, amount, fee, recipient, time | Spend or move anything |
| See notes sent to the account (when the sender used recipient discovery) | Derive the spending key |
| Export a report or CSV | See other accounts' activity |

Disclosure is all or nothing for that account: `nk` opens its whole history, past and future. Treat a
shared viewing key as permanent.

## Disclose to an auditor

1. Derive `nk` for the account. See [Transaction history](https://docs.cloak.ag/guides/transaction-history.md#get-the-viewing-key).
2. Choose what to hand over:
   * **A report** (`toComplianceReport` or `formatComplianceCsv`): a snapshot. The auditor sees only
     what you exported, but must trust that you exported everything.
   * **The viewing key itself**: the auditor runs the scan on their own RPC and verifies against the
     chain. Nothing to trust, but they see the full history.
3. Send it over a private channel. Anyone who obtains `nk` gains the same read access.

```ts theme={null}
import { bytesToHex } from "@cloak.dev/sdk";

declare const nk: Uint8Array;
const viewingKeyHex = bytesToHex(nk); // 64 hex characters, read-only access to this account
```

The auditor turns it back into bytes with `hexToBytes` and passes it as `viewingKeyNk` to
`scanTransactions`.

## Compliance on the protocol side

Separately from what a user discloses, the protocol screens activity:

* Deposits carry a signed risk assessment that the program checks on chain.
* Withdrawals, swaps and payouts are screened before they are authorized. A refused recipient throws
  `payout.screening_refused` and nothing moves.
* Every account registers its viewing key with Cloak before it spends. `createCloak` does this
  automatically; the low-level API does it on the first call unless you set
  `enforceViewingKeyRegistration: false`.

The model is described in [Viewing keys and compliance](https://docs.cloak.ag/concepts/viewing-keys-compliance.md), and the
user-facing view in [Compliance](https://docs.cloak.ag/guide/compliance.md).

## Receiving keys are different

To receive a private send, a user shares their `cloak_` address. It contains a public delivery
key that lets a sender seal a note to them. It does not grant read access to anything. Never confuse
it with `nk`.

## Related

* [Privacy guarantees](https://docs.cloak.ag/concepts/privacy-guarantees.md)
* [Transaction history](https://docs.cloak.ag/guides/transaction-history.md)


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