# Cloak Shielded Payment

**Cloak Shielded Payment** is the core privacy primitive of Tirai.

It transforms a regular Solana transfer into a **structurally unlinkable** deposit-withdrawal pair, severing the on-chain edge between the project's treasury and the researcher's wallet.

<figure><img src="/files/M63dOPkIYn8e4mhhIMWt" alt="" width="563"><figcaption></figcaption></figure>

## How a Shielded Payment Works

The flow uses three primitives composed by the Cloak SDK:

* **Groth16 zero-knowledge proof** — proves a valid deposit without revealing UTXO contents
* **Poseidon Merkle tree** — accumulates UTXO commitments into a single root
* **Per-deposit viewing key** — issued at deposit time, scoped to one project

Each shielded payment generates exactly:

* One on-chain deposit transaction (visible publicly, pool destination only)
* One claim ticket (delivered off-chain to the researcher)
* One viewing key (held by the project for audit)

## Payment Generation Steps

<figure><img src="/files/4UaAViqPW3alWXgtCj3y" alt="" width="563"><figcaption></figcaption></figure>

When the project clicks **Pay bounty**:

1. **Tirai forwards the request** to `@tirai/api`
2. **SDK builds the proof** — Cloak SDK calls `transact()` with the amount and label
3. **Generate Groth16 proof** — Cloak generates the deposit proof inside the browser
4. **Sign and broadcast** — Phantom (or another adapter) signs the deposit transaction
5. **Confirmation & return** — the transaction confirms on Solana and Cloak returns `{ ticket, viewingKey, signature, feeLamports }`

<figure><img src="/files/XeVGRGeXoC8KG2qRcXpE" alt="" width="563"><figcaption></figcaption></figure>

## What the Project Receives

After a successful payment:

* **Claim ticket** — delivered to the researcher off-chain
* **Viewing key** — stored by the project, shared with their auditor later
* **Transaction signature** — for on-chain verification of the deposit

The project never sees:

* The eventual destination wallet of the researcher
* Whether the researcher chose existing or fresh wallet mode
* The withdrawal transaction signature

## Privacy Guarantees

The shielded payment model guarantees:

* A public observer sees only **Treasury → Cloak Pool**, never **Treasury → Researcher**
* The withdrawal is unlinkable to any specific deposit on chain
* The Merkle tree's anonymity set grows with every new deposit, strengthening privacy over time

This is the cryptographic foundation that makes Tirai possible.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://moai-3.gitbook.io/tirai-frontier/products/cloak-shielded-payment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
