Proof of reserves
When an exchange or custodian fails, customers find out too late that the money wasn’t there. The usual remedies are weak. An auditor’s report asks you to trust the auditor. Publishing every account balance destroys customer privacy. A plain Merkle proof lets you see your neighbours’ balances. Stablecoin issuers, bridges, lending protocols and DAO treasuries face the same question: can you prove you’re solvent without opening your books?
Her balance is one of the leaves.
Her path holds a neighbour's leaf, but without the neighbour's salt she can't guess their balance from it.
- Alice████500████
- Bob████1,200████
- Charlie████300████
- Diana████2,500████
- Eve████800████
- Frank████150████
- Grace████3,000████
- Henry████50████
Every account gets a fresh 252-bit salt. + 8 padding slots, random id, balance 0.
liabilitiesRootthey add up to totalLiabilitiesisSolvent = 1: reserves cover liabilitiesNo attestation for this period yet.
ReserveAttestation · token I2OSP8(p)- period
- p
- liabilitiesRoot
- 0xcf6b…ac0f
- totalLiabilities
- 8,500
- totalReserves
- 10,000
Reserves are declared by the custodian, not checked against on-chain holdings.
1. Salted snapshot
The custodian takes every balance at one moment and gives every account a fresh 252-bit salt. Each leaf is Poseidon(Poseidon(idTag, salt), balance), and only the root is published. Without the salt, anyone holding a neighbour's leaf could hash each plausible balance until one matched.
2. Prove
The proof shows that every balance is a non-negative 64-bit number, that the leaves rebuild the published root, that they add up to exactly the total, and whether the declared reserves cover it. Drag the reserves below 8,500 ADA to see what changes.
3. Mint the attestation
The custodian mints one token for period p into an output at the attestation script's address. The minting policy reads the four values from that output's datum and verifies the proof against them with isSolvent = 1, so only a solvent statement mints. A datum without the token proves nothing.
4. Customers verify against the chain
Alice gets her salt, balance, leaf index and path, and her browser recomputes the root. It reads the period's attestation token from the chain indexer, not from the custodian's API, refuses the period if it was minted more than once, and compares the roots. She also compares the balance with her own records.
5. Next period
Each period gets fresh salts and its own token. The period isn't one of the proof's public inputs and the mint doesn't check the time, so a custodian could re-attest an old solvent tree, or mint a future period in advance; customers catch that when their balance looks stale. The reserves figure still needs its own evidence.
The zero-knowledge idea
Section titled “The zero-knowledge idea”The custodian proves “the balances committed in this published liabilities root are all non-negative, add up to exactly this total, and that total is covered by our reserves”, without revealing any balance.
Each customer account becomes a leaf in a Merkle tree, and the root is published. The circuit rebuilds the whole tree from the private balances, so the root commits to exactly the numbers being summed. The custodian can’t sum one set of balances and publish another. Every balance is a 64-bit unsigned integer, and range checks rule out a negative “balance” that would quietly shrink the total.
Customers close the loop. Each gets the Merkle path for their own leaf, recomputes the root, and compares it with the attestation on the chain. If the custodian left someone out or understated a balance, that customer can tell.
Why the leaves are salted
Section titled “Why the leaves are salted”A customer’s Merkle path contains other customers’ leaves: the sibling next to their own leaf is a
neighbour’s. If a leaf were just Poseidon(accountId, balance), a customer who can guess the
neighbour’s id could hash every plausible balance until one matched the sibling, and so learn the
neighbour’s balance. The demo’s leaves used to work that way.
Now every account gets a fresh 252-bit salt in every snapshot, and the leaf is
leaf = Poseidon(Poseidon(idTag, salt), balance)where idTag is a fixed Poseidon encoding of the account id. A neighbour who doesn’t know the
salt has nothing small left to guess. Unused slots get a random id and balance 0, so they look like any other leaf.
What stays private, what’s public
Section titled “What stays private, what’s public”| Input | Visibility | Why |
|---|---|---|
accountIds | Secret | Each is the salted id Poseidon(idTag, salt), so identities stay private and leaves can’t be guessed |
balances | Secret | Individual balances; each is range-checked to 64 bits |
totalReserves | Public | The custodian’s claimed reserves, which must be checked independently |
liabilitiesRoot | Public | Commits to every leaf; customers check their inclusion against it |
totalLiabilities | Public | The exact sum of all balances |
isSolvent | Public | Proven equal to totalReserves ≥ totalLiabilities; the minting policy fixes it to 1 |
How it works
Section titled “How it works”- Snapshot. The custodian takes the customer balances at a point in time, draws a fresh salt for every account and builds the Poseidon Merkle tree.
- Prove. It generates a Groth16 proof over the private balances with the four public inputs above.
- Attest on-chain. It mints this period’s attestation token into an output at the attestation script’s address. The minting policy verifies the proof against the values in that output’s datum, so an insolvent claim can’t mint.
- Customers verify. Each customer receives their salt, balance and Merkle path, recomputes the root in their browser, reads the attestation from the chain, and compares the two.
- Repeat. Each period gets new salts, a new proof and its own token.
custodian (private) public─────────────────── ──────16 × (salted id, balance) ─prove─▶ mint token I2OSP8(p), locked at the script address(8 accounts + 8 random padding) datum: Attestation(p, liabilitiesRoot, totalLiabilities, totalReserves) redeemer: Groth16 proof, checked against the datum with isSolvent = 1customer: salt + leaf + path ──────▶ root from the chain indexer = my root? ✓The circuit
Section titled “The circuit”This is simplified from the demo’s SolvencyProof: constructor validation is trimmed, and the demo
requires numLeaves == 1 << treeDepth. Salting didn’t change the circuit. Its accountIds witness
now holds the salted ids, so the existing keys still work.
import org.zeroj.circuit.annotation.*;import org.zeroj.circuit.lib.poseidon.PoseidonParams;import org.zeroj.circuit.lib.poseidon.PoseidonParamsBLS12_381T3;import org.zeroj.circuit.lib.zk.ZkPoseidon;
@ZKCircuit(name = "solvency-proof", nameTemplate = "solvency-proof-d{treeDepth}-n{numLeaves}-bls-poseidon", version = 1)public class SolvencyProof { private static final PoseidonParams POSEIDON = PoseidonParamsBLS12_381T3.INSTANCE; private final int treeDepth; private final int numLeaves;
public SolvencyProof(@CircuitParam("treeDepth") int treeDepth, @CircuitParam("numLeaves") int numLeaves) { this.treeDepth = treeDepth; this.numLeaves = numLeaves; }
@Prove ZkBool prove(ZkContext zk, @Public @UInt(bits = 64) ZkUInt totalReserves, @Public ZkField liabilitiesRoot, @Public @UInt(bits = 64) ZkUInt totalLiabilities, @Public ZkBool isSolvent, @Secret @FixedSize(param = "numLeaves") ZkArray<ZkField> accountIds, @Secret @UInt(bits = 64) @FixedSize(param = "numLeaves") ZkArray<ZkUInt> balances) {
// Leaves and running sum over the private balances ZkUInt sum = balances.get(0); ZkField[] level = new ZkField[numLeaves]; for (int i = 0; i < numLeaves; i++) { level[i] = ZkPoseidon.hash(zk, POSEIDON, accountIds.get(i), balances.get(i).asField()); if (i > 0) sum = sum.add(balances.get(i)); }
// Rebuild the Merkle root from the same leaves for (int d = 0; d < treeDepth; d++) { ZkField[] next = new ZkField[level.length / 2]; for (int i = 0; i < next.length; i++) { next[i] = ZkPoseidon.hash(zk, POSEIDON, level[2 * i], level[2 * i + 1]); } level = next; }
return level[0].isEqual(liabilitiesRoot) .and(sum.asField().isEqual(totalLiabilities.asField())) .and(isSolvent.isEqual(totalReserves.gte(totalLiabilities))); }}The circuit covers a fixed batch. The demo defaults to depth 4, which is 16 accounts. A real book of accounts needs a much larger circuit or a batching scheme, and proving cost grows with it. See Performance.
On Cardano
Section titled “On Cardano”An attestation is a minted, locked token. The demo’s ReserveAttestation is one JuLC
multi-validator that is both the attestation’s minting policy and its script address. Its
parameters are the custodian’s key hash, the period clock (genesisMs, periodMs) and the
verification key. Period p covers [genesisMs + p·periodMs, genesisMs + (p+1)·periodMs); the demo
uses five-minute periods.
- Mint (attest). The custodian signs. The mint is exactly one token named
I2OSP8(p)(the period as 8 bytes), sent to the single output at the script’s own enterprise address (payment credential, no stake credential). That output holds only ADA and the token, carries no reference script, and has the inline datumAttestation(period, liabilitiesRoot, totalLiabilities, totalReserves). The redeemer is the proof, which must verify against[totalReserves, liabilitiesRoot, totalLiabilities, 1]read from that datum. An honest proof of insolvency hasisSolvent = 0, so it can’t mint. - Spend (release). The only spend is a custodian-signed burn of that token, after the period has ended. The datum can’t change while the token exists.
Why a token? The demo used to lock a plain UTxO with the four public inputs in its datum and check the proof only when someone spent it. Anyone can create a UTxO with any datum, so a datum alone proved nothing. Now readers look only for the token, and the token can’t exist without a proof over its own datum.
One per period. The script doesn’t stop the custodian minting a second token for the same period, but every mint is visible. The demo’s custodian service refuses a second attestation for a period itself (HTTP 409), and the customer check reads the token’s whole mint history from the chain indexer and refuses a period unless it shows exactly one mint and no burn. Without that check, a custodian could split its liabilities across several trees against the same reserves.
The mint also doesn’t check the transaction’s validity range. Only the burn checks time. So a custodian can mint a future period’s token in advance, from today’s tree. The customer check looks only at the current period, so when that period arrives it is checked against the old tree.
Checking against the chain, not the custodian. The customer page gets its salt, balance, leaf index and path from the custodian, and recomputes the root in the browser. It then finds the current period’s token under the known policy id through the chain indexer (Yaci Store), not through the custodian’s API, and compares the attested root with its own. The customer also compares the balance with their own records.
A valid proof is still not the whole story. The proof checks the sum of the balances the custodian put in the tree. It doesn’t check that those balances are true, or that the reserves exist. See Application security.
Security considerations
Section titled “Security considerations”- Reserves are custodian-declared.
totalReservesis whatever the custodian puts in the datum; the demo doesn’t check it against on-chain holdings. Check holdings directly, or rely on an attestation you trust. Watch for reserves borrowed just for the snapshot. Proving over several periods, or at unpredictable times, makes that harder. - The proof checks the sum, not the balances. The custodian chooses the balances in the tree. Omissions and understated balances are only caught by customers who check. Make checking easy.
- The proof isn’t bound to its period. The period is in the token name and datum, not in the proof’s public inputs, and the mint doesn’t check the validity range. A custodian could re-attest an old solvent tree (the same root, liabilities and reserves) for a new period, or mint a future period’s token in advance. Customers would then see old balances, so comparing the balance with their own records is what catches it. A real design puts the period in the public inputs.
- Trust the indexer and the page. The customer trusts the indexer they point the page at. In the demo the custodian serves the customer page, and the policy id and clock it pins on first load come from the custodian. A real customer takes them from a published, independent source and runs the check from code they trust, such as a wallet or a third-party page.
- Operator view. The demo server is the custodian. It holds every balance, every salt and the
custodian key, and its
/accountsand/verify/{id}endpoints answer anyone. That’s the demo operator’s view; a real custodian gives each customer only their own inclusion data, after authenticating. Privacy in the demo holds against chain observers, not against the demo server. - Trusted setup. The demo uses a single-party development setup. Production keys come from a multi-party ceremony (Trusted setup, explained).
Try it
Section titled “Try it”The demo lives in
proof-of-reserves. With
Yaci DevKit running (see Run the demos):
./demo.sh proof-of-reserves --run--run builds the liabilities tree over the demo accounts and proves solvency against 10,000 ADA of
declared reserves, and mints the current period’s attestation token, whose minting policy verifies
the proof. In the UI you can add accounts, try a reserve figure below total liabilities to see the
attestation refused, try a second attestation in the same period (the demo server refuses it, and the customer page
would refuse the period too), and run a customer’s
inclusion check against the chain. The first start generates a development setup cache and a
random custodian key, which can take a few minutes. ./demo.sh proof-of-reserves --clean-cache
removes the key, the deployment state and the attested snapshot together.
Design notes: Proof of reserves — detailed design (Merkle sum trees, stake pool pledge, stablecoin and bridge variants).
Related
Section titled “Related”- Prove you’re over 18: the range-check pattern on a single value
- Annotations:
@UInt,@FixedSizeand@CircuitParam - Verify your proof on Cardano: lock and unlock with a proof on Yaci DevKit
- Performance: sizing larger circuits
- Proof of solvency with hidden balances: the same question with Pedersen commitments, hiding the total as well