BingX-API / BingX-proof-of-reserves

62 stars 23 forks source link

Proof Of Reserves

This tutorial introduces the background of BingX Proof-of-Reserves and how to verify individual liabilities in Merkle Tree. Both Bitcoin and Ethereum use Merkle trees.

Background

BingX Proof-of-Reserves utilizes the technique of Merkle Tree, a data structure designed to encrypt blockchain data securely. This technique allows individual users to verify that their funds are included in the attestation.

Verification

Merkle root is a straightforward mathematical technique for verifying the data on a Merkle tree. Users can verify the data by calculating their Merkle leafs with Merkle path to get the Merkle root. If the result matches the expected root, you get the proof-of-inclusion.

Build the Merkle leaf

Users can get the Merkle leaf in BingX proof-of-reserves page, and skip to the Verification. Users can also calculate their Merkle leaf with the following steps below.

Hashed User ID

Hash your BingX UID with SHA256. All UID of the individuals will be hashed with SHA256 before generating the Merkle tree or handing it over to the auditor. This will ensure independent auditor only sees the users' hashed UID and never any personally identifiable information.

Combine with assets

  1. Check your balance in BingX proof-of-reserves page.
  2. Combine users' hashed User ID with their assets in the following format. Assets are in the order below.

{Hashed UID},{Asset1}:{Balance1},{Asset2}:{Balance2},{Asset3}:{Balance3},{Asset4}:{Balance4},Total:{TotalValueInUsd}

e.g.

abcdefg,BTC:1.132142,ETH:2.54469871,USDT:20384,USDC:50.3,Total:49875.12599

Use the following number formatting rules to format the balance:

  1. Hash the output of step 2 with SHA256

Verification

  1. Get your Merkle path from BingX proof-of-reserves page.
  2. Get the Merkle root from BingX proof-of-reserves page.
  3. Run the Python script with the Merkle path

Command line tool to facilitate the verification

Requirement

Python 3.4 or above

Examples

e.g.

python por.py hash abcdefg,BTC:1.132142,ETH:2.54469871,USDT:20384,USDC:50.3,Total:49875.12599