Sub topic 12
Exchange Reserves and Proof of Reserves
This chapter assumes you have read the earlier chapters on labeling entities and on exchange wallet structure. You should know that an exchange controls many addresses (hot, warm, cold, deposit), and that a label is a claim about who controls an address, not a fact. You should also be able to read short Python functions.
What "exchange reserves" means
Exchange reserves are the total balance of one asset across all addresses attributed to one exchange. The figure is a sum over a label set:
reserves(exchange, asset) = sum of balance(address) for every address labeled as that exchangeThe result depends on the label set and nothing else. Adding or removing a cold wallet from the label set changes the reserve figure even if no coins moved. Reserves are also a stock (a balance at one moment), while netflow is a flow (a change over a period). The two are linked: if the label set stays fixed, the change in reserves over a day equals that day's netflow, plus or minus mining rewards, fees, and labeling gaps. A large gap between the two is a sign that your labels changed or are incomplete.
Here is a minimal reserve calculation. It compares on-chain reserves with a liability figure the exchange claims.
def reserves_report(balances, labels, exchange, claimed_liabilities):
"""balances: address -> amount. labels: address -> exchange name."""
reserves = sum(
amount for addr, amount in balances.items()
if labels.get(addr) == exchange
)
if claimed_liabilities > 0:
ratio = reserves / claimed_liabilities
else:
ratio = float("inf")
return {"reserves": reserves, "liabilities": claimed_liabilities,
"ratio": round(ratio, 4)}
balances = {"addr_hot": 1200.0, "addr_cold": 8800.0, "addr_user": 50.0}
labels = {"addr_hot": "ExchangeA", "addr_cold": "ExchangeA"}
print(reserves_report(balances, labels, "ExchangeA", 9500.0))The output is {'reserves': 10000.0, 'liabilities': 9500.0, 'ratio': 1.0526}. The address addr_user is not labeled, so it is excluded. If it actually belonged to the exchange, the true ratio would be higher. If one of the labeled addresses did not belong to it, the ratio would be lower. The ratio is therefore only as good as the labels behind it.
Why proof of reserves exists
A custodial exchange holds customer coins and owes customers a balance in its own database. Customers cannot see that database. If the exchange lends out customer coins or loses them, the shortfall stays hidden until withdrawals fail. Proof of reserves (PoR) is a set of methods an exchange can use to show, in a checkable way, that it holds at least as much as it owes.
A real PoR has two halves, and each answers a different question:
- Proof of assets: does the exchange control the addresses it says it holds, and how much do they hold?
- Proof of liabilities: how much does the exchange owe its customers, and is each customer's balance included?
Showing only the first half proves very little. Large balances say nothing about the size of the debt against them.
Proof of assets
On-chain balances are public, so the only thing to establish is control. The standard method is a signed message: the exchange signs a challenge string, such as a date and a verifier-chosen nonce, with the private key behind each listed address. Anyone can verify the signature against the public address. This shows that whoever produced the proof holds the keys at that moment.
Control is the weak point. Three problems come up in practice:
- Borrowed coins. An exchange could temporarily borrow coins, sign, and return them. The snapshot looks solvent even though the exchange is not.
- Omitted addresses. Listing only some addresses is harmless for assets, but it can hide the fact that other addresses are encumbered or pledged as collateral.
- Unspendable or pledged coins. A balance can be locked, wrapped, or pledged as collateral. It is visible on-chain but not freely available to repay customers.
Some exchanges instead move a small amount between addresses at a time the verifier chooses. This is stronger against pre-arranged proofs, but it still does not detect borrowing.
Proof of liabilities with a Merkle sum tree
The exchange's debt lives in a private database, so the proof must be built from that data without publishing every customer's balance. A Merkle sum tree does this. Each leaf holds a hash of a customer's identifier, a secret salt, and their balance, together with the balance itself. Each parent node holds a hash of its two children and the sum of their balances. The root contains the total liabilities.
A customer receives a path from their leaf to the root: the sibling node at each level. They recompute the hashes and sums upward and check that the result matches the published root. If the exchange left out a customer or lowered a balance, that customer's check fails. A customer who never checks provides no protection, so the proof is only as strong as the number of customers who verify.
import hashlib
PAD = ("0" * 64, 0) # empty node used when a level has an odd count
def combine(left, right):
data = f"{left[0]}|{left[1]}|{right[0]}|{right[1]}".encode()
return (hashlib.sha256(data).hexdigest(), left[1] + right[1])
def make_leaf(user_id, salt, balance):
digest = hashlib.sha256(f"{user_id}|{salt}|{balance}".encode()).hexdigest()
return (digest, balance)
def build_tree(leaves):
level = list(leaves)
levels = []
while True:
if len(level) > 1 and len(level) % 2 == 1:
level.append(PAD)
levels.append(level)
if len(level) == 1:
return levels
level = [combine(level[i], level[i + 1])
for i in range(0, len(level), 2)]
def make_proof(levels, index):
proof = []
for level in levels[:-1]:
sibling = level[index ^ 1]
proof.append((sibling, index % 2)) # 1 means our node is the right child
index //= 2
return proof
def verify(leaf, proof, root):
node = leaf
for sibling, is_right in proof:
if sibling[1] < 0:
return False # negative balances could hide a deficit
node = combine(sibling, node) if is_right else combine(node, sibling)
return node == root
customers = [("u1", "s1", 100), ("u2", "s2", 250), ("u3", "s3", 75),
("u4", "s4", 40), ("u5", "s5", 5)]
leaves = [make_leaf(*c) for c in customers]
levels = build_tree(leaves)
root = levels[-1][0]
print("total liabilities:", root[1])
proof = make_proof(levels, 1)
print("u2 included:", verify(leaves[1], proof, root))
tampered = make_leaf("u2", "s2", 200) # a lowered balance
print("tampered balance accepted:", verify(tampered, proof, root))The output reports total liabilities of 470, True for the honest leaf, and False for the tampered one. Two details matter. The salt stops an observer from guessing a leaf by hashing known user IDs and balances. The negative-balance check matters because a malicious builder could insert a negative leaf to shrink the root sum while every other customer's path still verifies.
What a PoR does not prove
Even a well-built PoR has limits that you need to keep in mind when you read an announcement.
| Gap | Why it matters |
|---|---|
| Point in time | The proof covers one snapshot. Assets can be borrowed for that day and removed after it. |
| Other liabilities | Loans, derivatives obligations, and debts to other firms are not in the customer tree. |
| Completeness | Nothing in the tree proves that every customer is in it. Only customers who check their own path catch an omission. |
| Asset quality | Coins issued by the exchange itself, or illiquid tokens, count at face value in the sum but may be worth little in a run. |
| Label dependence | If you build your own reserve estimate from clusters and labels, errors in those labels flow straight into the result. |
| Off-chain assets | Cash and bank holdings cannot be seen on a public ledger, so a purely on-chain view undercounts them. |
For these reasons PoR is best read as one input. A related approach adds a third-party audit of the exchange's books, which covers the gaps in the first four rows but is also a snapshot.
Using reserves as a signal
You can track reserves over time without any exchange cooperation, using the label set from earlier chapters. The following checks are common:
- Trend. A steady fall in reserves across many days means net outflows from the labeled set. Compare against price and against total market movement before reading it as exchange-specific.
- Label stability. Record the label set version used for every reserve figure. If a jump appears in a day when new addresses were added to the label set, the jump is likely a labeling change.
- Consistency with netflow. Over a period, the change in reserves should match the sum of daily netflows. A persistent mismatch points to missing wallets or mislabeled counterparties.
- Composition. Look at the split between hot and cold wallets. A growing share in the hot wallet can mean preparation for withdrawals. It can also be routine rebalancing.
- Comparison with published figures. If an exchange publishes a PoR address list, compare it with your own labels. Addresses on their list that you have not labeled are gaps in your data. Addresses you have labeled that they omit are worth investigating, though a labeling error is the more likely explanation.
Common errors
- Counting the same coins twice. If two exchanges both list one wallet, or a custodian wallet is shared, the sum across exchanges overstates the total.
- Mixing assets. Reserves are per asset. Adding Bitcoin and a stablecoin into one number is meaningless unless you convert to a common unit at a stated price.
- Ignoring wrapped and bridged tokens. A wrapped token on one chain is backed by coins on another. Counting both counts the same value twice.
- Treating a stale proof as current. A proof from months ago says nothing about today's reserves.
Exercise
An exchange publishes a proof of reserves showing 12,000 BTC in signed addresses, and a Merkle sum tree whose root sum is 11,400 BTC. Name two reasons you still cannot conclude the exchange is solvent, and one check an individual customer can perform.
Show answer
Possible reasons: the assets may have been borrowed just for the snapshot, and the tree covers only customer balances, so other liabilities such as loans are not counted. Also, the tree may omit some customers, which only customers checking their own paths can detect. A customer can request their inclusion proof (their leaf plus the sibling path), recompute the hashes and sums up to the root, and confirm the result equals the published root and that their own balance appears in the leaf.