DocsProgram accounts

DocsReference24 of 33 · 2 min read

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.

AddressSeedsHolds
ConfigurationconfigRoles, fees and the whitelist's roots
Entryentry, packed spend keyOne admitted recipient
Owner addressowner, packed public keyNothing. It owns notes inside the Ring
Settlement addresssettlementNothing. Fees and withdrawals pass through it
Event authority__event_authorityNothing. 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:

OffsetBytesFieldTypeWhat it holds
832adminpubkeyMay call configure.
4032issuerpubkeyMay call admit and remove.
7232auditor[u8; 32]The auditor's public key A, packed. Every payment encrypts its recipient to it.
10432fee_recipientpubkeyReceives the protocol fee.
13632relayerpubkeyMust sign pay and withdraw. Receives the relayer fee.
1688protocol_feeu64Lamports per payment or withdrawal.
1768relayer_feeu64Lamports per payment or withdrawal.
1848revisionu64Rises by one with each admission and removal.
1924next_indexu32The leaf index the next admission gets. Indexes are never reused.
1964sizeu32The number of active entries.
2004, then 32 eachrootsVec<[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:

OffsetBytesFieldTypeWhat it holds
832spend_point[u8; 32]The recipient's packed public spend key S.
4032view_point[u8; 32]The recipient's packed public view key V.
724indexu32The leaf index.
7632leaf[u8; 32]Poseidon(S.x, S.y, V.x, V.y).
1081activeboolFalse 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 isThe address owns
A balance key BDeposits and change
A stealth addressOne received payment
ts
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.