Docs/Reference
Program instructions
Every instruction of the Liora program, with its accounts, its arguments, what it checks, what it emits and what makes it fail.
The program is at 8i6Rs6mak6AoQH1Cd6asXpJoGMVqWP81iEux5kdnHbA4, version 0.2.1. It is an Anchor program: each instruction's data starts with an 8-byte discriminator, followed by its arguments in Borsh. The SDK builds all of these. This page is for reading a transaction, or for building one without the SDK.
| Instruction | Who signs | What it does |
|---|---|---|
deposit | The depositing wallet | Moves public SOL into a private balance |
pay | The relayer | Pays a whitelisted recipient at a stealth address |
withdraw | The relayer | Pays a private balance out to a public wallet |
admit | The issuer | Adds a recipient to the whitelist |
remove | The issuer | Removes a recipient from the whitelist |
initialize | The admin | Creates the configuration |
configure | The admin | Replaces the roles and fees |
hash_vector | Nobody | Returns a Poseidon hash, for checking a client against the program |
Every instruction that emits an event takes two more accounts at the end, event_authority and program. Anchor uses them to record the event as an inner instruction. See Events.
#deposit
Discriminator f223c68952e1f2b6.
Forwards a public SOL deposit to the Solana Privacy Program (SPP) and records it. The note that results belongs to the owner address of owner_point.
| # | Account | Signer | Writable | What it is |
|---|---|---|---|---|
| 0 | wallet | Yes | Yes | The depositing wallet. Signs the deposit and pays its network fee. |
| 1 | config | The configuration account, read only. | ||
| 2 | event_authority | The program's event authority. | ||
| 3 | program | The Liora program. |
owner_point[u8; 32]required- The packed balance key
Bthat will own the note. nullifier_pk[u8; 32]requiredPoseidon(nullifier secret)for that balance key.sppbytesrequired- The SPP deposit instruction, byte for byte as it is forwarded.
Five more accounts follow, the ones the SPP deposit takes, in this order:
| # | Account |
|---|---|
| 0 | The Ring's output tree, writable |
| 1 | The depositing wallet, the same as wallet |
| 2 | The SPP program |
| 3 | The System Program |
| 4 | The Ring's SOL vault |
The program checks that spp is one SOL deposit of more than zero lamports, that its view tag is the owner address of owner_point, and that its owner commitment is Poseidon(identity(owner address), nullifier_pk). Then it calls SPP.
Emits DepositRecorded. Fails with InvalidSpp, InvalidOwner or InvalidField.
#pay
Discriminator 7712d841c0757adc.
Verifies the payment's proof, signs for the owners of the notes being spent, forwards the transfer to SPP, settles the two fees and emits the announcement.
| # | Account | Signer | Writable | What it is |
|---|---|---|---|---|
| 0 | relayer | Yes | Yes | The relayer in the configuration. Pays the network fee. |
| 1 | config | The configuration account, read only. | ||
| 2 | settlement | Yes | The program's settlement address, which the Ring pays the fees into. Seeds: settlement. | |
| 3 | fee_recipient | Yes | The fee recipient in the configuration. | |
| 4 | destination | Yes | For a payment, the relayer again. | |
| 5 | system_program | The System Program. | ||
| 6 | event_authority | The program's event authority. | ||
| 7 | program | The Liora program. |
ownersVec<[u8; 32]>required- 1 to 3 distinct packed public keys that own the notes being spent. Change returns to the first.
announcementPaymentAnnouncementrequired- The payment's announcement. Emitted as given once the proof verifies.
proof[u8; 128]required- The Liora proof: compressed
-A(32 bytes),B(64),C(32). sppbytesrequired- The SPP
transactinstruction with its own proof, byte for byte as it is forwarded.
The accounts of the SPP transact call follow, in the order that call takes them. With n notes spent and m owners:
| # | Account |
|---|---|
| 0 | The relayer, as fee payer of the SPP call |
| 1 | The Ring's output tree, writable |
| 2 | The SPP program |
| 3 | The System Program |
| 4 | The Ring's input tree, writable |
5 to 4 + n | The nullifier account of each note spent, writable |
5 + n to 4 + n + m | The owner address of each key in owners, in the same order |
5 + n + m | The Ring's SOL vault |
6 + n + m | The settlement address |
What the program checks, in order:
The destination and the root
destinationis the relayer, andannouncement.whitelist_rootis one of the accepted roots.The shape of the transfer
sppis atransactinstruction on the Default Ring with one input tree, 1 to 3 input slots and 2 output slots, and the only public movement in it is one SOL withdrawal of exactly the protocol fee plus the relayer fee.The owners
Each key in
ownersis listed once and its owner address is the account passed for it. The owner address of the stealth address is neither the relayer nor one of the input owners.The outputs
Exactly one output belongs to the owner address of the stealth address. Every other output belongs to the first owner.
The proof
The program computes the statement from the instruction, the accounts and the configuration, and verifies
proofagainst it. The proof says what the statement covers.The transfer and the fees
The program calls SPP with a signature for each owner address. The settlement address must receive exactly the two fees, and pays them on to the fee recipient and the relayer. The relayer must end the instruction at least 5,000 lamports above where it entered, which is the signature fee it had already paid.
Emits PaymentAnnouncement. Fails with RootExpired, InvalidSpp, InvalidOwner, InvalidSettlement, InvalidProof, InvalidField or Arithmetic.
#withdraw
Discriminator b712469c946da122.
Verifies the withdrawal's proof, signs for the owners, forwards the transfer to SPP and pays amount to destination beside the two fees.
| # | Account | Signer | Writable | What it is |
|---|---|---|---|---|
| 0 | relayer | Yes | Yes | The relayer in the configuration. Pays the network fee. |
| 1 | config | The configuration account, read only. | ||
| 2 | settlement | Yes | The program's settlement address, which the Ring pays the withdrawal and the fees into. | |
| 3 | fee_recipient | Yes | The fee recipient in the configuration. | |
| 4 | destination | Yes | The public wallet that receives the withdrawal. Bound into the proof. | |
| 5 | system_program | The System Program. | ||
| 6 | event_authority | The program's event authority. | ||
| 7 | program | The Liora program. |
ownersVec<[u8; 32]>required- 1 to 3 distinct packed public keys that own the notes being spent. Change returns to the first.
amountu64required- The lamports paid to
destination. Greater than zero. proof[u8; 128]required- The Liora proof: compressed
-A(32 bytes),B(64),C(32). sppbytesrequired- The SPP
transactinstruction with its own proof, byte for byte as it is forwarded.
The remaining accounts are laid out as for pay.
The checks are those of pay with three differences. amount is greater than zero. The one public movement is a SOL withdrawal of amount plus both fees. No output may go to a new owner: every output belongs to the first owner, so a withdrawal moves value out of the Ring or back to the holder.
The proof binds destination and amount. A relayer that changed either would submit a transaction the program rejects.
Emits WithdrawalRecorded. Fails with InvalidSettlement, InvalidSpp, InvalidOwner, InvalidProof, InvalidField or Arithmetic.
#admit
Discriminator c0a9048af85ab82f.
Writes a recipient's leaf at the next free index and creates their entry account.
| # | Account | Signer | Writable | What it is |
|---|---|---|---|---|
| 0 | issuer | Yes | Yes | The issuer in the configuration. Pays for the entry account. |
| 1 | config | Yes | The configuration account. Receives the new root and revision. | |
| 2 | entry | Yes | The recipient's entry, created here. Seeds: entry, then the packed spend key. | |
| 3 | system_program | The System Program. | ||
| 4 | event_authority | The program's event authority. Seeds: __event_authority. | ||
| 5 | program | The Liora program. |
revisionu64required- The whitelist revision the issuer decided on. Must be the current one.
spend_point[u8; 32]required- The recipient's packed public spend key
S. affine[[u8; 32]; 4]requiredS.x,S.y,V.x,V.y, each 32 big-endian bytes.siblings[[u8; 32]; 24]required- The path of the empty leaf at the next free index, against the current root.
The program checks that revision is current, that spend_point packs the coordinates given, and that siblings open an empty leaf at the next free index under the current root. It then computes the leaf, puts the new root first in the accepted roots, keeps at most 32 of them, and raises the size, the next index and the revision by one.
The entry account's address is derived from the spend key, so a spend key can be admitted once. Admitting it a second time fails because the account exists.
Emits WhitelistChanged with admitted true. Fails with RevisionChanged, InvalidPoint, InvalidTreePath or InvalidField.
#remove
Discriminator c7ba094f6081186a.
Clears a recipient's leaf and drops every earlier root.
| # | Account | Signer | Writable | What it is |
|---|---|---|---|---|
| 0 | issuer | Yes | The issuer in the configuration. | |
| 1 | config | Yes | The configuration account. Receives the new root and revision. | |
| 2 | entry | Yes | The entry being removed. | |
| 3 | event_authority | The program's event authority. | ||
| 4 | program | The Liora program. |
revisionu64required- The whitelist revision the issuer decided on. Must be the current one.
siblings[[u8; 32]; 24]required- The path of the entry's leaf against the current root.
The program checks that revision is current, that the entry is active, and that siblings open the entry's leaf under the current root. It then sets the leaf to zero, replaces the accepted roots with the new root alone, lowers the size by one, raises the revision by one and marks the entry inactive. The entry account stays, with its spend key, view key, index and leaf.
Emits WhitelistChanged with admitted false. Fails with RevisionChanged, InactiveEntry or InvalidTreePath.
#initialize
Discriminator afaf6d1f0d989bed.
Creates the configuration account with the roles, the fees and the root of an empty whitelist. It runs once: the account exists afterwards.
| # | Account | Signer | Writable | What it is |
|---|---|---|---|---|
| 0 | admin | Yes | Yes | Pays for the configuration account. Must be the program's upgrade authority. |
| 1 | config | Yes | The configuration account, created here. Seeds: config. | |
| 2 | program_data | The program's data account under the upgradeable loader, read for its upgrade authority. | ||
| 3 | system_program | The System Program. |
issuerpubkeyrequired- The wallet that may admit and remove recipients.
auditor[u8; 32]required- The auditor's public key
A, a packed Baby Jubjub point. fee_recipientpubkeyrequired- The wallet that receives the protocol fee.
relayerpubkeyrequired- The wallet that submits payments and withdrawals.
protocol_feeu64required- The flat protocol fee per payment or withdrawal, in lamports.
relayer_feeu64required- The flat amount the relayer is paid back per payment or withdrawal, in lamports.
The two fees may not both be zero, and the fee recipient may not be the settlement address. Fails with WrongAuthority, InvalidField, InvalidSettlement or Arithmetic.
#configure
Discriminator f5076c755fc436d9.
Replaces every role and both fees in one call. Pass the current value for anything that stays. The whitelist is untouched.
| # | Account | Signer | Writable | What it is |
|---|---|---|---|---|
| 0 | admin | Yes | The admin in the configuration. | |
| 1 | config | Yes | The configuration account. |
next_adminpubkeyrequired- The admin from now on. Pass the current admin to keep it.
issuerpubkeyrequired- The issuer from now on.
auditor[u8; 32]required- The auditor's public key from now on.
fee_recipientpubkeyrequired- The fee recipient from now on.
relayerpubkeyrequired- The relayer from now on.
protocol_feeu64required- The protocol fee from now on, in lamports.
relayer_feeu64required- The relayer fee from now on, in lamports.
A payment or withdrawal uses the configuration in force when it executes. Its proof binds the auditor key, the fee recipient, the relayer and both fees, so a transfer proved before a change to any of them fails with InvalidProof after it and is made again.
Fails with WrongAuthority, InvalidField, InvalidSettlement or Arithmetic, or with Anchor's ConstraintHasOne when the signer is not the admin.
#hash_vector
Discriminator a0f28d4674d81c53.
Returns, as the transaction's return data, the Poseidon hash of the values given. A client simulates it to confirm that its own Poseidon agrees with the program's. It changes nothing.
| # | Account | Signer | Writable | What it is |
|---|---|---|---|---|
| 0 | config | The configuration account, read only. |
valuesVec<[u8; 32]>required- 1 to 12 field elements, each 32 big-endian bytes.
Fails with InvalidField.
#Errors
The names above are the program's own errors, listed with their codes on Errors.