DocsThe whitelist

DocsConcepts8 of 33 · 3 min read

The whitelist

The tree of admitted recipients, its root on chain, and what admitting, refusing and removing do to it.

The whitelist is the set of meta-addresses that can be paid. The issuer decides who is on it. The chain holds one number that stands for the whole set, the root, and every payment proves that its hidden recipient is under a root the program accepts.

#Leaves

Each admitted recipient gets one leaf at an index the issuer assigns:

leaf = Poseidon(S.x, S.y, V.x, V.y)

S and V are the two public keys of the recipient's meta-address. The handle, the requesting wallet and the status live in the directory beside the tree. A spend key S belongs to one identity for good: it is what the auditor's decryption returns, so the directory never lets a second entry reuse it.

#The tree

The tree is a sparse Merkle tree of depth 24, with room for 16,777,216 recipients. An index nobody holds has the leaf 0. Each parent is Poseidon(left, right), and an empty subtree hashes the same way from empty leaves.

A recipient's path is the 24 sibling hashes from their leaf up to the root. Bit j of the leaf index, counted from the least significant, says whether the node at height j is the left or the right child.

ts
import { whitelistLeaf, whitelistPath } from "@liora/contract";

const leaf = whitelistLeaf(metaAddress);
const { root, siblings } = whitelistPath(entries, leafIndex);

With the fixture recipient as the only entry, at index 0:

json
{
  "leaf": "153de00bba7508c36273bbfc5a88538e4b4542af8afa8f8a7cdd5170dc1a3bae",
  "root": "073b116d9ea244810fb4b574cf9bac61c35d7d8b2a56b60facf9fcd4ae6608a8"
}

The sender builds the path on their own device from one snapshot of the directory, and checks that the computed root equals the snapshot's. Which leaf they picked never leaves the device, and the proof made from the path names no leaf.

#The root on chain

Every change to the tree gives a new root and a higher revision. The program keeps 32 roots, the current one and the ones before it, so a payment proved a moment before someone else was admitted still goes through. acceptedRoots in the whitelist state lists the roots a proof may use.

Indexes are handed out in order and never reused. Each admitted recipient also has an entry account on chain, addressed by their spend key.

#Admit, refuse, remove

The issuerTreeRootsDirectory status
Admits a requestThe leaf is written at a free indexNew root; earlier roots stay acceptedwhitelisted
Refuses a requestUnchangedUnchangedrefused
Removes an entryThe leaf is clearedNew root; every earlier root stops being acceptedremoved

Removal clears the leaf and drops the older roots in one step. From that revision on, a payment to the removed recipient cannot be proved against any accepted root, including one prepared before the removal.

A removed entry keeps its identity and its former index in the directory. Payments it received before the removal stay readable by the auditor.

#Who does what

Reads the directoryRequests a placeChanges the tree
AnyoneYes
A recipientYesYes, signed by their wallet
The issuerYesYes, signed by the issuer key