Merkle Sum Tree Proof of Reserves for Client Balances

Last updated: November 29, 2026

Quick Overview

Implement a Merkle sum tree over client balances so a custodian can publish one root committing to total liabilities, give each client an inclusion proof, and let clients verify their balance is included without learning anyone else's.

BitGo
Coding & Algorithms
Software Engineer
BitGo
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Implement a Merkle sum tree over client balances so a custodian can publish one root committing to total liabilities, give each client an inclusion proof, and let clients verify their balance is included without learning anyone else's.

Proof of reserves became a standard expectation for crypto custodians, and BitGo works with exchanges that publish liability attestations. The question tests hashing discipline, tree construction and the specific attacks a naive Merkle tree allows, such as hidden negative balances.

What the Interviewer Expects
  • Stores both a hash and a sum at each node and hashes the sums in
  • Rejects negative balances at leaves and in proof siblings
  • Salts leaves so balances cannot be brute-forced from hashes
  • Pads odd levels with a zero-sum node and domain-separates leaf and node hashes
  • Builds O(log n) proofs and verifies them correctly
  • Explains what the scheme does and does not prove
Key Topics to Cover
Merkle trees
hashing
cryptographic commitments
proof of reserves
tree algorithms
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How do you prove reserves (assets) to compare against the liability root?
  • How could the custodian still cheat with this design, and how do zk proofs help?
  • How would you hide the exact total or tree size?
  • How would you handle a client with balances in many coins?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Leaves: (user_id, balance, salt) with integer base units. Root reveals (hash, total). proof(i) returns the sibling path; verify recomputes the root from the client's own data and the path. A d...

High-Level Design

Each node is (hash, sum). Parent hash is H("node", l.hash, l.sum, r.hash, r.sum) and parent sum is l.sum + r.sum. Hashing the sums binds them, so a parent cannot claim a different total than its...


Submit Your Answer
Markdown supported

Related Questions