How zkTrue-up Guarantees Privacy, Security, and Scalability for the Term Structure Protocol

How zkTrue-up Guarantees Privacy, Security, and Scalability for the Term Structure Protocol

To efficiently manage the order book and auction processes on the Term Structure protocol on Ethereum at a minimal cost, a robust and reliable scaling solution is necessary. zkTrue-up, a tailored ZK-rollup solution, is designed specifically to operate the protocol and enhance user experience. It allows users to place orders on Layer 2 without incurring any gas fees and simultaneously enjoy the security benefits of Layer 1.

This article explores the importance of privacy, security, and scalability in the Term Structure markets and explains how zkTrue-up addresses these critical needs.

Why Privacy, Security, and Scalability are Crucial in Primary Markets and Secondary Markets

Privacy: Safeguarding Auction Fairness

Maintaining fairness in both Primary and Secondary Markets is crucial because this helps increase the credibility and reliability of the protocol. Since users trust the Term Structure protocol, they will be more willing to make transactions. Ultimately, this user confidence will contribute to long-term growth in transaction volumes and create a healthy and robust trading environment.

The fairness of the auction, conducted on an hourly basis, in the Primary Markets hinges on the confidentiality of interest rate information. Prior to order matching in each round of the auction, the interest rates must remain undisclosed to all parties. If this information were revealed, it would allow informed users to place orders with better interest rates. As a result, orders placed by uninformed users would be excluded.

Scalability: Facilitating Massive Order Volumes at Low Cost

To encourage user engagement, we have designed our system in a way that eliminates gas fees when placing orders. Transaction costs only apply to users when their orders are successfully matched.

How does Term Structure achieve this? In fact, Term Structure absorbs all the fees associated with rolling up transaction data to layer 1. As the volume of orders placed increases, so do the gas fees that Term Structure needs to cover. Therefore, there is a need for a scalable solution to minimize these gas fees to as much as possible.

Security: Ensuring Unforgeable and Traceable Orders

Security is guaranteed on Ethereum Layer 1. Due to the verification by network members and the traceability provided by Etherscan, forging transactions becomes extremely difficult. While placing orders on Layer 2 can reduce gas fees, it is still important to ensure the security and integrity of users' orders. In other words, it is important for matched orders to be traceable so users will be confident in their authenticity and fairness.

How zkTrue-up guarantees privacy, security, and scalability

Privacy: Hide Sensitive Information in Rolled-Up Data

General, publicly-available ZK-rollups typically compress and roll up primary transaction data to Layer 1 to ensure data integrity and availability. However, a significant challenge arises when certain sensitive or private data needs to remain concealed. Achieving this level of selectivity—hiding specific data while rolling up the rest to Layer 1—proves tricky on these platforms.

The sequencer within zkTrue-up offers a solution to this issue. It conceals specific information, such as user-placed interest rates, during the organization and sequencing of batched transaction data. At the same time, it reveals and rolls up the data, such as collateral details and the amount of locked assets,  required for users to safely withdraw their assets from Layer 1. This ensures the confidentiality of sensitive information while safeguarding users' assets.

This specific functionality is made possible by zkTrue-up, a custom-built ZK engine that exclusively operates on Term Structure.

Scalability: Compress transaction data

​​State Tree as Compressed Data

Maintaining data integrity while compressing data to ensure on-chain availability presents a significant challenge. Nevertheless, this is precisely where the power of ZK Rollups shines. They authenticate data integrity while effectively reducing the data size.

In the Term Structure ecosystem, the sequencer in zkTrue-up handles the sorting and structuring of matched orders in the markets. The sequencer then hashes this data, which includes changes in account balances, matched orders, minted bond tokens with specific maturity dates, and more. Then, the sequencer updates the State Tree by using a data format called Merkle Tree.

State Root

All the hash values in the State Tree are further hashed to a single value to form the State Root. The State Root is a hash value or digest created from the collection of hashes generated from structured transaction data. As is the nature of hash functions, identical data will consistently produce the same hash value, while even the smallest change in the original data will result in a drastically different digest. Given that the hash value cannot be converted back into the original data, the State Root assures both data integrity and privacy.

Changes in the State Root reflect new transactions and updates in balance over a specific period, while a sequence of State Roots represents a series of transactions. Through the rollup of this compact data to Layer 1, Term Structure can minimize gas fee consumption, ensuring data availability and safeguarding users' asset security.

                             The important role of State Tree and State Root

Security:  Proof and Verification for Order Book Data

Scalability is made possible through the compact size of the State Root data. However, the State Root alone is not sufficient to ensure security because the State Root could be manipulated during its generation and rollup. This would result in inconsistencies between Layer 1 and Layer 2 State Roots.

Ensuring Transaction Legitimacy and Correct Logic of Order Placement Through Proof Generation

A key strength of ZK Rollups is its ability to verify condensed data derived from a larger dataset without the need to inspect the original data. After updating the State Root, the prover in zkTrue-up generates proof by using the State Root and other necessary information such as signatures, account addresses, and timestamps.

The prover's function is to affirm the following elements as true. After the verification, the proof will become immutable on-chain.

  1. Signature Verification
    The prover verifies that orders are authorized by users using EdDSA signatures, which stem from the users' ECDSA signatures on Layer 1. As a ZK-friendly cryptographic algorithm, EdDSA both accommodates the zkTrue-up system and assures security inherited from Layer 1.
  2. Order Uniqueness
    The prover scrutinizes order information stored within the State Tree. It verifies the uniqueness of each borrow order, lend order, buy order, and sell order transaction. If any duplication is detected, the entire updated State Tree is considered compromised and is subsequently rejected. This verification mechanism safeguards Term Structure against replay attacks.
  3. Order Processing Logic
    The prover receives all matched orders in a given period. Each order is either fully or partially fulfilled. The prover ensures that transaction logic is sound, verifying sufficient balance for transaction execution and the correct remaining order amount after performing a series of deduction calculations for completed orders.

The prover generates a proof and sends it to the operator. Then, the operator rolls up the proof, the State Root, and other relevant data to the zkTrue-up contract on Layer 1.

Verification of the Proof

The zkTrue-up smart contract on Layer 1 executes the verification process. Upon receiving the State Root, proof, and related data, the contract hashes the compressed transaction data and cross-verifies it against the hash data generated on Layer 2 to ensure no data manipulation occurred.

Afterward, the zkTrue-up contract authenticates the truthfulness of the proof. If the verification process yields a false result, the batched transaction records will be rejected outright.

Upon successful verification of data and proof, the transaction data is stored immutably on the blockchain. On-chain data availability is accomplished through this proof and verification process. Armed with on-chain data availability, users can independently rebuild the necessary part of the State Tree on-chain. This allows them to restore transaction data and withdraw their assets on Layer 2 to assuage concerns of censorship, off-chain server downtime, or any other unforeseen circumstances."

Order Processing and Matching Mechanism in zkTrue-up

The following illustrates the order processing workflow and mechanism of zkTrue-up:

  1. Frontend Server: Users initiate orders on the Term Structure Protocol. Details such as the user's wallet address, the underlying tokens, the amount to borrow, lend, buy or sell, and desired interest rates are dispatched to the Order Manager.
  2. Order Manager: The Order Manager matches orders according to the established auction policy. Orders from the Primary Markets enter an hourly auction process, while orders from the Secondary Markets are matched instantly. Matched orders are then relayed to the Sequencer.
  3. Sequencer: The Sequencer updates the State Root based on the information from the matched orders and then sends the updated State Root and transaction data to the Prover.
  4. Prover: Upon receiving the updated State Root and transaction data, the Prover conducts a series of checks to validate the authenticity of the orders and the correctness of order logic. It then forwards the proof and pertinent data to the Operator.
  5. Operator: The Operator oversees the rollup of the proof, State Root, and relevant data to the zkTrue-up contract on Layer 1.
  6. zkTrue-up Contract: The contract validates the consistency of the received transaction data and the truthfulness of the proof. Once the proof is verified, the compressed, hashed transaction data and proof are stored in the contract.

                                             The workflow of zkTrue-up

Conclusion

With the zkTrue-up system, Term Structure effectively caters to users' needs for privacy, security, and scalability. It offers several notable benefits:

  1. Asset Security: With transaction data that is traceable on-chain, users can directly withdraw their assets on Layer 1. This on-chain data availability ensures the utmost security of users' assets.
  2. Transaction Validation: The prover ensures the transaction logic is correctly executed by the sequencer, enhancing the trustworthiness of Term Structure’s matching system. This rigorous validation process makes it extremely challenging for any manipulation of users' orders to occur.
  3. Transaction Legitimacy: The prover affirms the genuineness of transactions initiated by users by validating the signature. On Term Structure, users' transactions are legitimate, eliminating any concerns about transaction authenticity.
  4. Frictionless Trading: Thanks to the zkTrue-up off-chain system, users can place orders without incurring any gas fees. This streamlines the order placement process, eliminating cost concerns for users.
  5. Seamless Interaction: The zkTrue-up system enhances the trading experience to a level akin to centralized exchanges. Users can place orders seamlessly in the markets without waiting for on-chain signature confirmation.