Docs · Concepts
The account and its notes
What a Mesa account is made of, the four kinds of note, who owns them on chain, and how an account finds and reads its own.
A Mesa account is a set of keys and the notes those keys open. It has no account on Solana and no address. Everything it holds sits in the Privacy Rings pool as notes, and the account is whoever can read and spend them.
Notes
A note is one unspent output (a UTXO) in the Privacy Rings pool. The pool stores it as a commitment and a ciphertext. Its asset and amount are encrypted, and a note is spent by publishing a nullifier that reveals nothing about which note it was.
Every Mesa note also carries a piece of committed data that says what it is. There are four kinds.
| Note | Holds | Its data |
|---|---|---|
| Balance | An amount of one asset, free to place | Who may spend it |
| Share | A claim on a pool or a vault | The pool or vault and the number of shares |
| Action | The funds an order, a supply or another batch action has locked | The action's terms, which open when its batch closes |
| Position | The collateral of a borrow or a perp | Debt or size, entry terms and the deadline it is renewed to |
Your balance of an asset is the sum of your balance notes of that asset. A spend consumes notes and creates new ones: placing an order of 4 SOL from a 10 SOL balance note spends that note and creates an action note of 4 SOL and a balance note of 6 SOL.
One authority owns every note
On chain, every Mesa note has the same owner: the Mesa authority, a program address derived from the seed authority. In the default Ring the owner of each output is public, so this is the address the chain shows for everything inside Mesa. Your own address appears at deposit and at withdrawal and nowhere between.
Notes owned by the Mesa address, inside Privacy Rings
Your viewing key finds your notes by their tag and reads them in your browser.
Your spending key proves a note is yours when you move it.
A read-only key opens the same view for someone you choose, and can spend nothing.
The authority signs a transaction in the pool only after the mesa program has verified a proof that fixes every Mesa-owned output of that transaction. What separates your notes from everyone else's is inside the commitment: each note is bound to keys only its holder has, and to a spend authorization only its owner can satisfy.
The keys behind an account
An account starts from one 32-byte master secret. In the app it is derived from a signature your wallet makes over a fixed message, so the same wallet always arrives at the same account. A script reads it from a key file. Two keys come from it.
- The spend secret authorizes spending. Every note commits to a value derived from it and a fresh random nonce, and a circuit that spends on your behalf takes the secret as a private input.
- The read seed derives the viewing key and nullifier key of every note you hold. With it, a note can be found, decrypted and checked for being spent.
The read seed together with the public half of the spend secret is your read-only key. It reads the whole account and spends nothing.
Holders
A note is encrypted to a holder: a pair of keys derived from the read seed. An account uses several, so that what opens in a batch cannot be linked to the account or to its other actions.
| Holder | Derived for | Owns |
|---|---|---|
| Account holder | The account, once | Balance and share notes |
| Action holder | Each action the account places | That action's note |
| Receive holder | Each action the account places | What that action settles into |
| Position holder | Each position the account opens | That position |
When an action opens, its receive holder becomes public as part of its terms. It is used for that one action and never again.
How an account reads itself
Mesa keeps no list of your notes. Your client rebuilds the account from the chain each time.
Fetch Mesa's outputs
Every Mesa transaction creates outputs tagged with the Mesa authority. The client pages through them from the API's
GET /v1/notes, or directly from a Privacy Rings indexer withgetShieldedTransactionsByTags.Try each with your keys
The client tries to decrypt each output with the account holder's viewing key, and with the action, receive and position holders' keys for every counter up to the highest it has found plus a look-ahead window. An output that decrypts is yours.
Drop what is spent
For each note found, the client computes its nullifier with the holder's nullifier key and asks the indexer whether that nullifier exists. A note whose nullifier is absent is unspent.
What is left is the account: balances per asset, open orders, shares and positions. Decryption happens in your browser or your script. The API serves ciphertexts and never holds a key that opens them, except a position's own key when you enrol that position with the watcher.
Where the master secret lives
The app stores nothing. When you connect, your wallet signs the message Mesa account v1 followed by its own address, and the master secret is derived from that signature. Ed25519 signatures are deterministic, so signing again on another device recovers the same account. A script holds the master secret in a key file or derives it from a keypair's signature.
Anyone who holds the master secret, or can make that signature, holds the account.
Amounts and prices
Amounts are integers in the asset's smallest unit. Prices are quote atoms per base atom scaled by 10^12. Indexes and share prices are scaled by 10^18. The SDK and the app convert to and from decimals. The program reference gives each field's type.