Original Title: "Zero-Knowledge Proof Technology: Igniting the New Star of DeFi"
Original Author: LZ
Decentralized Finance (DeFi) is an important development direction in the current financial innovation field. In DeFi, hiding transaction information and maintaining user privacy is crucial. With the continuous expansion and deepening of DeFi, various projects are emerging and full of vitality. The application of Zero-knowledge proof (ZK) technology opens up new possibilities for privacy protection in DeFi. ZK technology allows one party to prove to another that they know certain information without revealing any specific details about that information. The application of this technology in DeFi projects such as ZigZag, unyfy, and OKX's ZK DEX greatly enhances the privacy protection ability of DeFi, especially for transaction information. It can be foreseen that the widespread application of ZK technology will bring innovation to the way DeFi and the entire cryptocurrency field handle things, promote the future development of the entire industry, and achieve significant breakthroughs.
There are no secrets on the blockchain, and the transparency of DeFi data is indisputable. For example, we can easily view the details of a transaction on Uniswap V3 through the Etherescan website (as shown in Figure 1). For instance, the address 0x3A4D...a6f2 exchanged 2 WETH for 17,654,123,249,375 Bonk on Uniswap V3, with a transaction fee of 0.0046 Ether. Key information such as the sender (From), receiver (To), transaction amount (Value), and transaction fee (Transaction Fee) in these transactions are all publicly available.

Figure 1: Transaction details publicly available on etherscan
We can also view all transaction records under the address 0x3A4D...a6f2 (as shown in Figure 2), and if conditions permit, we can speculate on the real-world identity of this address.

Figure 2: The list of all transactions for a specific address is publicly available on Etherescan
However, the transparency of DeFi data may have some adverse effects. If you are a DeFi whale, every transaction you make may attract market attention. For example, when a whale withdraws 11.24 million WOO (approximately 4.2 million USD) from Binance, this transaction will attract widespread attention. Similarly, any large payments or institutional-level transaction behavior may also attract public attention.
Other market participants may make buying and selling decisions based on these trading behaviors, which may have a negative impact on your investment strategy. For example, if you invest a large amount of money in a certain project, once your trades are noticed by the market, other investors may follow suit, causing asset prices to rise and increasing your investment costs. In addition, your selling actions may also trigger market panic, causing prices to fall and affecting your investment returns.
This situation highlights the urgent need for privacy protection in DeFi projects and for users. If we do not want our transaction details to be made public, we can choose to keep certain information about DeFi transactions private.
ZK technology can ensure the legitimacy of transactions while hiding transaction details. Users need to submit two types of information: one is a transaction with partially hidden details (such as the recipient or amount) (i.e. a privacy transaction), and the other is a ZK proof about these hidden details. Validating the legitimacy of a privacy transaction is actually validating the corresponding ZK proof.
Assuming you are fortunate enough to learn that a large company is about to purchase a large amount of a certain asset, you may choose to purchase this asset before the company does. Then, when the company's large purchase behavior drives up the asset price, you can sell it to make a profit. In this case, the transaction you made before the large company is called a front-running transaction.
Front-running is an investment strategy in financial trading that typically occurs on exchanges such as Uniswap. This is because transactions on the blockchain are public and transaction confirmations require some time. Therefore, some malicious traders may prioritize their transactions over others by increasing the transaction gas fee, in order to achieve the goal of front-running.
Front-running trades can cause harm to other traders because it alters the original trading environment, making it difficult for other traders to execute their trades as planned. On the other hand, attackers initiate front-running trades for their own profit, as they can profit from price changes before they occur. Therefore, many DeFi projects are attempting to prevent front-running trades from occurring through various means.
ZK technology can play a key role in resisting front-running transactions. Below, we take the sandwich attack in decentralized exchanges (DEX) as an example, which is a common type of front-running transaction, for case analysis.
What is a sandwich attack?
Assuming there is a liquidity pool on a DEX with a reserve of 100 ETH / 300,000 USDT. Alice initiates a transaction to buy USDT, exchanging 20 ETH. When she submits the transaction, the DEX returns a result based on the current reserve of the liquidity pool, telling Alice that she can buy approximately 50,000 USDT. However, in reality, Alice only received 45,714 USDT.
Here, let's first briefly understand why Alice can buy 50,000 USDT with 20 ETH. The DEX adopts the Automated Market Maker (AMM) model and automatically calculates the buying and selling prices through the Constant Product Market Maker (CPMM) algorithm. CPMM is currently a widely used automatic market maker algorithm, which maintains the constant product of two assets in the trading pool to provide liquidity and automatically adjust asset prices. In this example, the formula 50,000=300,000-(100*300,000)/(100+20) (assuming no transaction fees) is used to calculate the amount of USDT that Alice can buy.
Alice did not buy the expected amount of USDT because she was subjected to a sandwich attack.
The sandwich attack mainly occurs in AMM-based DEXs. In the sandwich attack, the attacker places two transactions around the victim's regular transaction to manipulate asset prices and profit from the victim's loss. These two transactions are called front-running and back-running transactions, with the transaction before the regular transaction being the front-running transaction and the transaction after the regular transaction being the back-running transaction.
So, how did the sandwich attack on Alice happen? As shown in Figure 3.

Figure 3 Sandwich Attack Process
1. Attacker's front-running: Before Alice's purchase of USDT is executed, the attacker also initiated a purchase of USDT (front-running), exchanging 5 ETH for USDT. Moreover, the attacker paid a higher gas fee to the miner for this transaction than Alice did, so the attacker's transaction will be executed before Alice's.
2. After the attacker executed the transaction to purchase USDT, he obtained approximately 14,286 USDT from the liquidity pool, where 14,286 ≈ 300,000 - (100*300,000)/(100+5). The reserve of the liquidity pool changed from the initial state of 100 ETH / 300,000 USDT to 105 ETH / 285,714 USDT. However, Alice was unaware of the change in the reserve status of the liquidity pool during the time between submitting her transaction and its execution.
However, when you turn to DeFi lending platforms such as Aave or Compound, the situation is different. Due to their decentralized nature, most DeFi lending platforms do not have traditional bank KYC (Know Your Customer) procedures and risk assessment processes, nor can they investigate borrowers' credit status through credit bureaus. In this case, you may wonder how your credit will be evaluated?
On DeFi lending platforms, you can prove your creditworthiness through reputation tokens. Reputation tokens are a credit system based on blockchain technology that uses digital tokens to represent and quantify a user's reputation. The number of reputation tokens is an important indicator for evaluating a user's creditworthiness. The more tokens a user has, the better their reputation and credit rating, which may lead to a higher loan limit on DeFi lending platforms.
However, the generation of reputation tokens relies on users' transaction history and financial information, which may infringe on users' privacy rights.
ZK technology can protect user privacy. The combination of ZK technology and reputation tokens can maintain and track users' reputation on the network while protecting their privacy.
Users can use ZK technology to generate reputation tokens without disclosing their transaction history. On the one hand, users can generate proofs of historical transactions based on ZK technology; on the other hand, the proof is verified by a smart contract (usually referred to as a reputation token generation contract), and if the verification is successful, reputation tokens can be generated.
In addition, on some DeFi lending platforms that require over-collateralization, reputation tokens can lower collateral requirements, thereby solving the problem of over-guarantee and increasing market liquidity. The application of reputation tokens based on ZK technology is not limited to DeFi lending platforms, but can also be widely used in fields such as insurance and medical subsidies.
This article explores various use cases of ZK technology in achieving privacy protection in DeFi, especially in resisting front-running transactions, liquidity manipulation, and lending. In the process of exploring DeFi, we face multiple challenges, especially those related to privacy and security. Privacy challenges in the DeFi ecosystem are a key issue, and ZK technology provides a unique solution that not only enhances privacy protection but also improves transaction efficiency and security. If you want to introduce ZK technology to your DApp, please contact Salus.
In the future, ZK technology may be applied in deeper DeFi fields, such as liquidity staking, derivative protocols, real-world assets, insurance, etc. Salus focuses on researching and exploring the application of ZK technology in DeFi and other Ethereum-based projects. We sincerely invite blockchain researchers, technical developers, and all professionals in the web3 field to work with us to promote the deep development and wide application of ZK technology, driving the development of DeFi and even the entire industry.
This article is from a submission and does not represent the views of BlockBeats.
Welcome to join the official BlockBeats community:
Telegram Subscription Group: https://t.me/theblockbeats
Telegram Discussion Group: https://t.me/BlockBeats_App
Official Twitter Account: https://twitter.com/BlockBeatsAsia
