Cointime

Download App
iOS & Android

How zk-SNARKs Improve Binance’s Proof of Reserves System

Validated Venture

Main Takeaways

  • In November 2022, Binance released its Proof of Reserves system utilizing Merkle tree cryptography to allow users to verify their holdings.
  • Binance has now improved its solution by implementing zk-SNARKs, a form of zero-knowledge proof.
  • Users can now check that each account’s total net balance is non-negative and that all user assets are part of Binance’s claimed total net balance of user assets – in a private and secure manner.

Take a look under the hood of Binance’s new proof-of-reserves solution. Combining zk-SNARKs and Merkle tree information, it gives users a new and improved way of verifying the state of Binance’s reserves.

Over the last few months, Binance’s dev team has been hard at work building advanced proof-of-solvency solutions. Such tools have become critical for centralized crypto exchanges amid the crisis of trust that engulfed the industry in the wake of the FTX collapse. User funds stored on Binance are backed at a 1:1 ratio, plus reserves, and finding a way to prove this to the public seamlessly has become a major part of Binance’s plan to restore industry trust. 

In November 2022, we released our proof-of-reserves system utilizing a Merkle tree cryptographic technique to allow users to verify their holdings on Binance. Although an advancement in Binance’s user fund transparency push, the initial design of this solution had two shortcomings:

  • To protect user privacy, leaf nodes in Merkle proof represented the hash of users’ holdings – thus, the Merkle root couldn’t reflect the sum of its leaf nodes’ balance information.
  • The entity whose reserves were being verified could potentially add a negative balance under a fake account somewhere in the tree to make the total required reserves appear smaller. The following diagram from Vitalik Buterin’s blog shows an example of such a malicious Merkle tree (although, in this case, the root reflects the sum of all leaf nodes’ balances, which can introduce privacy issues).

We now have a solution that can remedy these shortcomings and thus strengthen Binance’s proof-of-reserves system. Relying on zero-knowledge proof protocols, zk-SNARKs, we can prove that:

  1. All leaf nodes of the Merkle tree have contributed to Binance’s claimed total user balance of each asset.
  2. There is no user with a negative total net balance (an overall USD value of all assets the user holds) included in the Merkle tree.

A Word on Negative Balances and Performance

Since Binance offers margin, crypto loans, and futures trading products, each user’s balance of each crypto asset may be comprised of assets and liabilities. A user’s balance of a particular crypto asset can be negative, but their total net balance across all crypto assets should not be negative (as all loans are fully collateralized).

In this hypothetical scenario, let’s say that Alice had deposited 10,000 BUSD to Binance, then used 4,000 BUSD as collateral to borrow 2 BNB (at a rate of 1 BNB = 1,000 BUSD, assuming that Binance is always over-collateralizing). The following table shows Alice’s balance sheet.

If Alice then trades 1 BNB for 1,000 BUSD with Bob (who had also deposited 10,000 BUSD), their balance sheet would look like this after the trade is matched:

In this case, Alice’s BNB balance will amount to -1, which is not a valid node in a Merkle tree and that only covers one asset: BNB. However, if we are looking at total net balances, Alice is still at 10,000.

Another challenge comes from the sheer scale of Binance’s user base. A viable solution has to generate user proof and zk-SNARK proof for tens of millions of users, some of whom may hold more than 300 crypto assets on our platform. 

All in all, we want to provide proof of the following facts within a reasonable time window:

  1. Each Binance user’s assets are part of our claimed total user balance shown in the snapshot. Users can verify our claimed total user balance against the assets held at Binance-controlled addresses using a blockchain explorer (like Etherscan for Ethereum wallets or BscScan for BNB Chain wallets).
  2. Each user’s total net balance is non-negative, which means Binance didn’t create dummy accounts with a negative balance to reduce the size of our verified reserves artificially.

What Are zk-SNARKs?

Before we dive into the details of our solution, a brief overview of the zero-knowledge proof mechanism is in order. Zero-knowledge protocols like zk-SNARK allow one party, the prover, to demonstrate to another party, the verifier, that the prover had executed certain computations accurately with certain inputs under certain constraints, all without disclosing the inputs. The computation might be time-consuming, but the underlying mathematical mechanism can help the verifier assess the proof quickly and securely.

The prover (Binance) starts with defining a set of constraints of the computation it wants to prove. The constraints are defined in circuits that can be expressed in a higher-level programming language (in our case, a forked version of gnark.)

The prover then executes the heavy computation, hashing all users’ ids and balance sheets, and generates proof of the computation meeting the constraints set out previously. To do so, it uses the computation trace (witness) and public or private inputs. 

The verifier (user) gets the proof and verifies it with the public input of the circuit to satisfy itself that the computation has been executed accurately with all constraints met. The verification computation takes an extremely short time compared to the proving time. If the prover does not generate the proof on the pre-defined circuits, it cannot produce valid proof to pass the verification.

Our Solution

The fundamental building block of the upgraded proof-of-reserves solution is still a Merkle tree. For the example above, it would look like this:

In addition to the Merkle tree, we also maintain a global state that represents a list of the total net balances of each asset that each Binance customer holds.

To prove our reserves, we will generate zk-SNARK proof for the construction of the Merkle tree. For each user’s balance set – a leaf node of the Merkle tree – our circuit would make sure that:

  1. Every asset’s balance of this user is included in the global state list mentioned above.
  2. The user’s total net balance is not negative. 
  3. The change of the Merkle tree root is valid after updating this user’s information to the leaf node hash.

Please refer to this technical specification and our source code for the circuit (constraints) for implementation detail.

In each instance of proving our reserves, we will publish:

1. The Merkle proof: the hashes for each user (for Alice, represented by blue nodes in the above picture).

2. zk-SNARK proofs and public input (a hash of the list of total net balances of each asset and the Merkle root) of the circuit for all users.

By verifying the Merkle proof, users can make sure their balance sheet is included in the Merkle tree root. By verifying the zk-SNARK proof, users can make sure the construction of the Merkle tree meets the constraints defined in the circuit.

The security of this solution relies heavily on the setup of the proving key and verification key. We are working on a decentralized setup of the keys. When it comes to existing decentralized trusted setup ceremonies, the Ethereum ceremony offers a good example. We are very close to having an MPC solution to make the setup trustless.

Performance

Given the number of Binance users whose balances should be included, there’s no way to get a single proof of the Merkle tree construction that would cover all users at once. A solution to this is splitting users into batches of 864 each so as to have a smaller-scale circuit and parallel proving procedures.

For a batch that contains 864 users where each user owns 350 different assets, suppose each asset balance is in the range [0, 2^64-1]. With a 32-core 128GB server, zk proof generation time is about 110 seconds, and proof verification time is less than 1 millisecond.

Binance will start 1000 provers at the same time so as to generate proof for all accounts in 2 hours. The cost of this prover server for one hour is about 0.56 USD, so the total cost of generating all zk proofs covering all users would be about 1000 USD.

Conclusion

We will provide the first iteration of proof for users generated by this new solution in a subsequent proof-of-reserves announcement. Also, we have open-sourced our user data processor, prover, circuit, and verifier, so that every centralized exchange relying on the same model as we do can generate proof for their users and assets easily.

We hope this will be instrumental in pushing the transparency of the digital asset industry to a new level. We are also working on implementing the solution mentioned in Vitalik’s blog to achieve better performance, which will allow us to provide the proof more frequently at a lower cost.

As this is the first version of our zk-SNARK, we are looking forward to receiving community feedback so we can continue to improve the system.

Read more: https://www.binance.com/en/blog/ecosystem/how-zksnarks-improve-binances-proof-of-reserves-system-6654580406550811626

Comments

All Comments

Recommended for you

  • BTC Falls Below $65,000

    Market data shows BTC has fallen below $65,000, currently reported at $64,999.23, with a 24-hour increase of 1.01%. Market volatility is high, please exercise risk control.

  • Hedge Fund AISituational Awareness's Mysterious $400 Million Investment Targets Chip Startup Source Foundry

    On August 8, sources revealed that the hedge fund Situational Awareness, managed by former OpenAI researcher Leopold Aschenbrenner, made a mysterious $400 million investment in the chip manufacturing startup Source Foundry just days after facing imminent collapse. Previously, Bloomberg reported that the hedge fund invested in a private company backed by Sequoia Capital, but did not disclose the name of the specific company. The Wall Street Journal had earlier reported that the recipient of the investment was Source Foundry, unveiling the target of this mysterious funding deployment by Situational Awareness.

  • US Spot Bitcoin ETF Sees $101.79M Net Inflow Yesterday

    On August 8, according to Trader T's monitoring, US spot bitcoin ETFs saw a net inflow of $101.79 million yesterday.

  • US Official: Ukraine Agrees to Avoid Strikes on Non-Russian Tankers and Black Sea Oil Facilities

    On August 8, according to a US official, Ukraine has agreed not to target certain non-Russian tankers and Black Sea infrastructure vital to Kazakhstan's crude oil exports. This follows ship attacks last month that caused loading disruptions. The US official said Ukraine has set up contact points so commercial shipping companies can communicate information and ensure safe passage. The commitment was reached after meetings between senior US government leaders and Ukrainian leadership, marking a potentially significant step toward increasing regional oil shipments. Previously, activity in the region had cooled significantly due to several recent attacks near the Caspian Pipeline Consortium terminal in Russia's Novorossiysk. (Jin Shi)

  • U.S. July Nonfarm Payrolls Fall by 23,000, Missing Market Expectations

    On August 7, U.S. nonfarm payrolls decreased by 23,000 in July, compared with market expectations of an increase of 80,000, and the previous value was an increase of 57,000.

  • US May and June Nonfarm Payroll Additions Revised Down by 103,000 Combined

    On August 7, the US Bureau of Labor Statistics: May nonfarm payroll additions were revised down from 129,000 to 63,000; June nonfarm payroll additions were revised down from 57,000 to 20,000. After the revisions, the combined additions for May and June were 103,000 lower than previously reported.

  • U.S. Rate Futures Market Sees Lower Odds of Fed September Hike

    On August 7, the probability of a Fed rate hike in September as priced by U.S. interest rate futures declined.

  • New York Gold Futures Top $4,400 per Ounce

    New York gold futures topped $4,400 per ounce, up 2.36% on the day.

  • Japan Finance Minister: FX Market Affected by Moves Not Driven by Actual Demand

    Japanese Finance Minister Satsuki Katayama said she and U.S. Treasury Secretary Bessent agreed that the foreign exchange market has been affected by moves not driven by actual demand.

  • BTC Breaks Through $65,000

    Market data shows BTC has broken through $65,000, currently reported at $65,007.44, with a 24-hour increase of 0.6%. The market is highly volatile, please exercise risk control.