Docs/Reference
Program accounts
Every account the Liora program owns or derives, with its seeds and fields.
The program at 8i6Rs6mak6AoQH1Cd6asXpJoGMVqWP81iEux5kdnHbA4 keeps two kinds of account and derives three kinds of address that hold no data.
| Address | Seeds | Holds |
|---|---|---|
| Configuration | config | Roles, fees and the whitelist's roots |
| Entry | entry, packed spend key | One admitted recipient |
| Owner address | owner, packed public key | Nothing. It owns notes inside the Ring |
| Settlement address | settlement | Nothing. Fees and withdrawals pass through it |
| Event authority | __event_authority | Nothing. It signs the program's events |
Seeds written as words are their UTF-8 bytes. A packed key is the 32 bytes of a Baby Jubjub point in circomlib's packed form.
#Config
One per program. Discriminator 9b0caae01efacc82, followed by:
| Offset | Bytes | Field | Type | What it holds |
|---|---|---|---|---|
| 8 | 32 | admin | pubkey | May call configure. |
| 40 | 32 | issuer | pubkey | May call admit and remove. |
| 72 | 32 | auditor | [u8; 32] | The auditor's public key A, packed. Every payment encrypts its recipient to it. |
| 104 | 32 | fee_recipient | pubkey | Receives the protocol fee. |
| 136 | 32 | relayer | pubkey | Must sign pay and withdraw. Receives the relayer fee. |
| 168 | 8 | protocol_fee | u64 | Lamports per payment or withdrawal. |
| 176 | 8 | relayer_fee | u64 | Lamports per payment or withdrawal. |
| 184 | 8 | revision | u64 | Rises by one with each admission and removal. |
| 192 | 4 | next_index | u32 | The leaf index the next admission gets. Indexes are never reused. |
| 196 | 4 | size | u32 | The number of active entries. |
| 200 | 4, then 32 each | roots | Vec<[u8; 32]> | The accepted roots, newest first. The first is the current root. |
roots is a list: a 4-byte count, then 32 bytes for each root. It holds at most 32 roots. An admission puts the new root first and drops the oldest beyond that number. A removal leaves the new root alone in the list.
A proof may use any root in the list. revision is what the issuer signs against, so two issuer actions prepared from the same state cannot both land.
The SDK's config() and whitelist() return these values through the API.
#Entry
One per admitted recipient, created by admit and kept after remove. Discriminator 3f129871d7f6ddfa, followed by:
| Offset | Bytes | Field | Type | What it holds |
|---|---|---|---|---|
| 8 | 32 | spend_point | [u8; 32] | The recipient's packed public spend key S. |
| 40 | 32 | view_point | [u8; 32] | The recipient's packed public view key V. |
| 72 | 4 | index | u32 | The leaf index. |
| 76 | 32 | leaf | [u8; 32] | Poseidon(S.x, S.y, V.x, V.y). |
| 108 | 1 | active | bool | False once the entry is removed. |
The address comes from the spend key, so looking up the key the auditor decrypted leads straight to the entry. An inactive entry still answers that lookup.
#Owner addresses
owner(P) = PDA(["owner", packed P])Every note Liora holds in the Ring names one of these addresses as its owner. The address has no account behind it and no private key. The program signs for it, in its call into the Solana Privacy Program, after verifying a proof that the caller knows the secret key of P.
P is | The address owns |
|---|---|
A balance key B | Deposits and change |
| A stealth address | One received payment |
import { ownerAddress } from "@liora/contract";
const owner = await ownerAddress(point, programId);#Settlement address
settlement = PDA(["settlement"])A payment or withdrawal has the Ring pay SOL out to this address: the two fees, and for a withdrawal the amount as well. In the same instruction the program pays the protocol fee to the fee recipient, the relayer fee to the relayer and the amount to the destination. The program checks that the address received exactly what was due and ends with the balance it started with.