Page cover image

Zero-Knowledge (ZK)

Befi's integration of Zero-Knowledge (ZK) proofs is a pivotal element in its blockchain architecture, serving as a critical mechanism for ensuring the integrity and trustworthiness of the platform.

Purpose of ZK Proofs in Befi

The primary role of ZK proofs within Befi is to authenticate the continuity and unaltered state of its private blockchain to the public. Essentially, ZK proofs are deployed to verify that the blockchain remains uncompromised—neither by external malicious entities nor internal tampering. This verification process is crucial for maintaining user trust, as it transparently demonstrates that the blockchain data, particularly financial transactions, has not been manipulated for fraudulent purposes.

Operational Mechanics

Befi employs a systematic and automated process for generating and recording ZK proofs. Every 8 hours, off-chain servers perform the following steps:

  1. Extract the latest hashes from three critical datasets: spot orders, deposits, and withdrawals.

  2. Combine these hashes using a transparent and secure hashing algorithm (Keccak256).

  3. Record the resultant hash onto the Ethereum network, recognized for its high security and reliability.

This process is encapsulated in the following TypeScript code snippet


// Retrieve the latest hashes from various transaction records
latest_spot_order_hash = keccak256(latest_order);
latest_withdrawal_record_hash = keccak256(latest_withdrawal_record);
latest_deposit_record_hash = keccak256(latest_deposit_record);

// Generate the final hash to be recorded on the Ethereum network
final_hash = keccak256(latest_spot_order_hash + latest_withdrawal_record_hash + latest_deposit_record_hash);

// Store the ZK proof on the Ethereum network
saveZkProof(final_hash);

The efficacy of this method lies in its transparency and verifiability. By publicly storing the final hash on the Ethereum network, Befi enables anyone to independently verify the consistency of the trading, depositing, and withdrawing history against the recorded hash. This level of openness allows for the immediate detection of any discrepancies or anomalies, thereby ensuring the integrity of the blockchain and fostering trust among its users.

Last updated