A bilateral clearing storage optimization method for blockchain transactions based on prime number mapping

Through the bilateral clearing method of blockchain transactions based on prime mapping, the problems of insufficient scalability of blockchain storage and limited liquidity are solved, efficient transaction data management and security improvement are achieved, and continuous optimization of blockchain is supported. Storage efficiency.

CN118552313BActive Publication Date: 2024-12-17HEFEI INSTITUTE OF PHYSICAL SCIENCE CHINESE ACADEMY OF SCIENCES +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411018612.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-29
Publication Date
2024-12-17
Estimated Expiration
2044-07-29

AI Technical Summary

Technical Problem

Inadequate scalability of blockchain storage leads to reduced transaction processing speed and limited liquidity of funds. Current technologies such as asset lock-in periods limit the instant clearing of transactions, affecting the efficiency and security of blockchain systems.

Method used

Using a bilateral blockchain transaction clearing method based on prime mapping, backward liquidation is carried out after the transaction falls, and transactions are grouped and net results are calculated through prime mapping, replacing the original transaction records, avoiding asset lock-up period, and improving storage efficiency and security. sex.

Benefits of technology

It significantly improves blockchain storage efficiency, supports continuous optimization, ensures asset liquidity and transaction experience, improves the security and stability of the clearing process, and reduces the risks of errors and fraud.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118552313B_ABST
    Figure CN118552313B_ABST
Patent Text Reader

Abstract

The present invention discloses a blockchain transaction bilateral clearing storage optimization method based on prime number mapping, which is used for bilateral clearing of historical transfer transactions that have been placed in the blockchain, including: demarcating the historical area that needs to be cleared; converting the blockchain addresses of all transactions involved in the demarcated historical area into prime numbers, and then grouping the transactions according to the accumulator value obtained by multiplying the prime numbers corresponding to the addresses of the transaction sender and the receiver as a unique identifier; for each group of transactions, counting and calculating the total sending amount and the total receiving amount of all transactions in the group, and determining the final transaction result; generating a new transaction record according to the determined final transaction result; writing the cleared transaction record into the blockchain to replace the original transaction before clearing. The present invention uses mathematical principles to realize rapid grouping and clearing of both parties to the transaction, and uses the cleared transaction to replace the original transaction, so as to release the blockchain storage space.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of financial technology (Fintech), and in particular to a method and device for optimizing bilateral clearing storage of blockchain transactions and a computer program product thereof. Background Art

[0002] Blockchain technology is a distributed database technology that records and manages data in a decentralized manner. The core features of blockchain technology include immutability, traceability, and transparency, and it is widely used in cross-border payments, smart contracts, supply chain management, identity verification, and other fields.

[0003] Based on the characteristics of blockchain, the academic community has summarized three important characteristics that are difficult to achieve at the same time, which are also known as the "impossible triangle" of blockchain. That is, it is difficult for any blockchain system to have high scalability, high security and strong decentralization at the same time.

[0004] As for the "impossible triangle" summarized by the industry, the lack of some factors will lead to imbalances in other dimensions, which will in turn lead to a significant reduction in the availability of the entire blockchain system. For example, the size of the ledger stored in the full node of the current mainstream public blockchain has expanded to a level that is difficult for home computers to bear. For example, the disk space required to run a full node is at least 1.5TB, and high-performance storage devices such as solid-state drives are required. Therefore, it faces very severe challenges in scalability. The backwardness of blockchain storage scalability will aggravate the degree of network centralization. Therefore, fewer and fewer users can run a complete full node, the participation threshold of the blockchain network is gradually increasing, the number of participants is gradually decreasing, and the monopoly of block generation and accounting rights is intensified. When the degree of decentralization is lower than a certain threshold, the security of the network will also be threatened. It is meaningless to simply consider the security of the network, and it turns to trust a small number of monopolists. Therefore, the scalability research of blockchain storage is crucial and will affect many aspects of the "impossible triangle".

[0005] Specifically, data accumulation on the blockchain is initially executed in the form of transactions in the consensus engine of the node, and the state changes caused by the transactions, the blocks formed by the transactions, and the transactions are written to the database after execution to form persistent storage. In order to realize the legitimacy verification of transactions and states, the mainstream blockchain system often adopts a multi-level KV database at the underlying database level, such as levelDB. When the number of transactions continues to increase, the number of database read and write calls required for state construction and maintenance will further increase, and the disk access performance will be degraded, which will eventually slow down the speed of blockchain transaction processing and cause transaction congestion.

[0006] When the number of transactions in the blockchain reaches a certain level, the storage burden will cause the degradation of the read and write performance of the blockchain nodes, affecting the execution and verification of subsequent transactions. How to effectively manage and optimize the storage in the blockchain system has become an important research direction. Storage optimization aims to reduce system operating costs and improve data processing efficiency, including but not limited to technical strategies such as off-chain channel expansion and clearing optimization.

[0007] Off-chain expansion technologies, such as Lightning Network, Raiden Network, and Optimistic Rollup, are a solution to the scalability problem of blockchain. By placing a large amount of transaction processing off-chain and only changing the state on-chain at the beginning and end of the transaction, this type of technology significantly reduces the requirements for on-chain storage and processing, and improves the transaction processing speed and the overall efficiency of the system. However, there are still limitations. The main limitation is that an asset lock-up period needs to be set, that is, all transactions initiated off-chain must go through a certain period of time, during which the device assets are frozen. Although this mechanism is intended to ensure the security and eventual consistency of transactions, in practice, the asset lock-up period limits the liquidity of funds and constitutes an obstacle for application scenarios that require instant settlement.

[0008] Ultra-light node technology based on zero-knowledge proof uses non-interactive concise zero-knowledge proof (zk-SNARKs, etc.) to implement transaction verification, and the legitimacy of transactions can be verified without the participation of all nodes. By putting transaction proofs instead of all transaction data on the chain, the demand for on-chain storage space is greatly reduced while maintaining the privacy and security of transactions, but it faces some challenges in practical applications. The main problem is that the generation speed of zero-knowledge proofs is relatively slow, which affects the consensus time of transactions and slows down the transaction processing speed of the entire system. In addition, the process of generating zero-knowledge proofs is computationally expensive, which may limit its application on resource-constrained devices.

[0009] In financial and trading systems, clearing is an accounting process used to determine the payable and receivable relationships between the two parties to a transaction. In the blockchain field, clearing technology focuses on how to effectively process and simplify on-chain transactions to reduce redundant data and optimize the data storage and processing capabilities of the blockchain. Clearing technology in existing blockchain application scenarios is mainly used in the field of off-chain payment channels. For example, in off-chain expansion scenarios such as the Lightning Network, transaction clearing technology aggregates the amounts of multiple small transfers that occur off-chain and settles the aggregated amounts on the chain when the channel is closed.

[0010] In order to solve the problems of capital liquidity limitation and transaction processing delay in existing blockchain storage optimization technology, and effectively improve the storage and processing efficiency of blockchain system, the present invention provides a different clearing technology solution. By performing backward clearing after the transaction is placed, the problem of asset lock-up period and impact on consensus is avoided. Summary of the invention

[0011] The purpose of the present invention is to provide a bilateral clearing and storage optimization method for blockchain transactions based on prime number mapping, which avoids the problem of asset lock-up period and consensus impact by performing backward clearing after the transaction is placed.

[0012] To this end, the present invention provides a blockchain transaction bilateral clearing storage optimization method based on prime number mapping, which is used for bilateral clearing of historical transfer transactions that have been placed in the blockchain, including: S1, delineating a historical area that needs to be cleared, wherein the basis for selecting this historical area is that all transactions in this historical area have been confirmed and solidified by the blockchain network; S2, converting the blockchain addresses of all transactions involved in the delineated historical area into prime numbers, and then grouping the transactions according to the accumulator value ACC obtained by multiplying the prime numbers corresponding to the addresses of the transaction sender and the receiver as a unique identifier; S3, for each group of transactions, counting and calculating the total sending amount and the total receiving amount of all transactions in the group, after obtaining the total sending amount and the total receiving amount of each group of transactions, comparing the two values ​​to determine the final transaction result; S4, generating a new transaction record according to the determined final transaction result, which will reflect the net result of all transactions in the transaction group, wherein the new transaction record will contain the information of the sender and the receiver, the net amount of the transfer, and a new unique identifier generated based on the accumulator value ACC of the original transaction group; S5, writing the cleared transaction record into the blockchain to replace the original transaction before clearing.

[0013] The present invention also provides a blockchain transaction bilateral clearing storage optimization device, including a computer program, which, when executed by a processor, implements the steps of the blockchain transaction bilateral clearing storage optimization method based on prime number mapping.

[0014] The present invention also provides a computer program product, including a computer program, characterized in that when the computer program is executed by a processor, it implements the steps of the blockchain transaction bilateral clearing storage optimization method based on prime number mapping.

[0015] The present invention uses mathematical principles to quickly group and clear both parties of a transaction, and uses cleared transactions to replace original transactions, thereby releasing blockchain storage space.

[0016] Compared with the prior art, the present invention has the following technical advantages / effects:

[0017] 1. Significant improvement in storage efficiency: By performing efficient bilateral settlement of transaction data that has been stored on disk, the present invention significantly reduces the need to store redundant historical transaction data, thereby reducing storage overhead and improving the storage efficiency of the entire blockchain system.

[0018] 2. No need for asset lock-up period: Unlike some off-chain expansion technologies that require asset lock-up period, the liquidation process of the present invention will not freeze or lock user assets, ensuring asset liquidity and user trading experience.

[0019] 3. Support continuous optimization: The present invention supports multiple rounds of iterative liquidation over time, so that the optimization of blockchain storage space is not a one-time thing, but can be carried out continuously, further improving storage efficiency as the system develops.

[0020] 4. Improve the security and stability of the clearing process: The bilateral clearing mechanism based on prime number mapping enhances the security and stability of the clearing process. The mathematical principles are used to ensure the accurate identification and grouping of transaction pairs, reducing the risk of errors and fraud.

[0021] In addition to the above-described purposes, features and advantages, the present invention has other purposes, features and advantages. The present invention will be further described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The drawings constituting a part of the present application are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0023] Figure 1 It is a flow chart of the blockchain transaction bilateral clearing storage optimization method based on prime number mapping of the present invention;

[0024] Figure 2 is a flowchart of the blockchain address mapping method of the present invention;

[0025] Figure 3 It is a flow chart of finding prime numbers in the blockchain address mapping method of the present invention;

[0026] Figure 4 It is an overall schematic diagram of the bilateral settlement of the present invention;

[0027] Figure 5 It is an overall schematic diagram of the iterative clearing of the present invention. DETAILED DESCRIPTION

[0028] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.

[0029] This method is to perform bilateral settlement of historical transfer transactions that have been placed in the blockchain. Without changing the final execution result of the transaction, the transaction process is cleaned up and optimized, blockchain storage space is vacated, and performance expansion of blockchain storage and transaction execution is achieved.

[0030] This method mainly includes the following steps when executing:

[0031] The purpose of blockchain address mapping is to enable the subsequent bilateral settlement process to quickly locate the transaction group consisting of the sender and the receiver, and to perform settlement according to the transaction group.

[0032] Bilateral transaction settlement is the settlement of all transfer transaction amounts within the same group, involving the merging of amounts and the determination of transfer directions, and ultimately obtaining a cleared transaction to replace multiple transactions before settlement.

[0033] Blockchain address mapping

[0034] Among them, the method of blockchain address mapping is as follows:

[0035] S11. Define the hash function address_to_prime from blockchain address to prime number, which accepts three parameters: blockchain address, security parameter k, and truncated number of bits short_bits.

[0036] S12. In the address_to_prime function, a loop is used to find a prime number w that satisfies the conditions:

[0037] S121. Input the blockchain address x, security parameter k, and the number of truncated bits short_bits.

[0038] S122. Calculate w = 2^k + h(x) + Fk(r), where x is the blockchain address and r is a counter.

[0039] S123. Use the Miller-Rabin algorithm to detect whether w is a prime number.

[0040] S124. If w is a prime number, truncate it and take the highest short_bits bits to obtain truncated.

[0041] S125. If truncated is not a prime number, increment it until a prime number is found.

[0042] S126. If w is not a prime number, increase the value of the counter r and continue to search for the next candidate number.

[0043] Here, function h takes one parameter x, converts it to a string and calculates the SHA-256 hash value, then converts the hash value to a large integer and returns it. Fk takes one parameter r, converts it to a string and calculates the SHA-256 hash value, then converts the hash value to a large integer and returns it.

[0044] Through the above algorithm, a blockchain address (160 bits) can be deterministically mapped to a prime number with a shorter length (64 bits). Traditional prime number mapping may need to be implemented by recording a prime number table, but this method can establish a deterministic mapping relationship through this algorithm, without the need to save the prime number table, reducing storage space, and the algorithm will not change the result of running multiple times for the same input under the same configuration, so it is a deterministic algorithm.

[0045] Through the above algorithm, the blockchain address is converted into a collision-resistant prime number, and a unique identifier will be constructed for the transaction group consisting of the specified sender and receiver based on the prime number.

[0046] The method for constructing a unique identifier for a transaction group is to convert the addresses of the transaction sender and receiver into prime numbers using the above method, and multiply the two prime numbers to obtain an accumulator value ACC, which is used as the unique identifier of the transaction group.

[0047] The reason why the accumulator value can be used as the unique identifier of the transaction group is that the accumulator value is bound to the prime numbers corresponding to the sender and receiver, that is, when it is prime factorized, only the prime numbers corresponding to the sender and receiver of the transaction will be obtained. The result corresponds to the identity of the transaction participants one by one, is completely bound, and has nothing to do with the order. For example, if there are two blockchain addresses A and B, the accumulator value obtained by multiplying the two prime numbers converted from A and B can identify the transaction from A to B, or the transaction from B to A. Therefore, it can be used as the unique identifier of the transaction group to facilitate the settlement of all transactions in the group.

[0048] Bilateral clearing of transactions

[0049] Determine the liquidation scope: Before starting liquidation, you first need to define the historical area that needs to be liquidated based on the height of the latest block. The basis for selecting this historical area is that all transactions in the area have been confirmed and solidified by the blockchain network and will not be rolled back. This step ensures the stability and reliability of the liquidation process.

[0050] Transaction grouping: First, the system converts all blockchain addresses participating in transactions within the defined interval into prime numbers through the above-mentioned prime number mapping algorithm. Then, the transactions are grouped according to the prime number product (accumulator value ACC) corresponding to the addresses of the sender and receiver of the transaction, ensuring that the participants (sender and receiver) in each group of transactions are the same, and the transactions are accurately classified using the uniqueness and binding of the accumulator value.

[0051] Calculate transaction amount: For each group of transactions, the system will count and calculate the total amount sent and received for all transactions in the group. Since the accumulator value ACC can uniquely identify a pair of transaction parties, the system can ensure the accuracy and consistency of the calculation process.

[0052] Determine the final transaction result: After obtaining the total amount sent and the total amount received for each group of transactions, the system will compare these two values ​​to determine the final transaction result. If the total amount sent is greater than the total amount received, the final transaction will be reflected in the form of the difference between the sender and the receiver; otherwise, it will be reflected in the form of the difference between the receiver and the sender.

[0053] Generate final transaction record: Based on the final transaction result, the system will generate a new transaction record, which will reflect the net result of all transactions in the transaction group. The new transaction record will contain the information of the sender and receiver, the net amount of the transfer, and a new unique identifier generated based on the accumulator value ACC of the original transaction group to ensure the traceability and verifiability of the final transaction record.

[0054] Update blockchain storage: Finally, the system writes the transaction record after clearing to the blockchain, replacing the original transaction before clearing. This step completes the bilateral clearing process, optimizes the storage space of the blockchain, and ensures the integrity and consistency of the blockchain ledger.

[0055] Through the above bilateral clearing process, the present invention can effectively simplify a group of multiple transactions that offset each other into one final transaction, greatly reducing the data storage requirements on the blockchain while maintaining the transparency and verifiability of the transaction. This process not only optimizes storage efficiency, but also improves the overall processing performance of the blockchain system, providing important support for the application and development of blockchain technology.

[0056] In addition, the clearing process can be repeated and iterated. As the blockchain itself grows, the historical clearable area will be extended, always maintaining a certain distance from the latest block height. Transactions in this extended area may create space for further clearing with cleared transactions, thereby ensuring that within the clearing interval, there will be only one transaction between the sender and receiver of all transfer transactions.

[0057] Example 1

[0058] exist Figure 4 In the figure, it is assumed that there are a total of 4 transaction participants in the settlement cycle, where A, B, C and D represent these 4 transaction participants, and the numbers 10, 11, 21, 59, etc. represent the net amount of transaction transfers between the transaction participants. The role of bilateral settlement is to simplify the multiple transactions between these participants into one transaction, so that the simplified single transaction produces the same balance change effect as multiple transactions, thereby saving on-chain storage space.

[0059] Example 2

[0060] exist Figure 5In the example, assuming that the transaction settlement cycle is once every 1000 block heights, and that bilateral settlement has been carried out for block heights 0-1000, and that blocks with heights 1001-2000 have not been settled, an iterative settlement strategy can be used to settle all transactions occurring within a height of 0-2000. As the block height increases, participants in previous bilateral settlements may generate new transactions, so iterative settlement is required to prevent the blockchain storage space from growing too fast.

[0061] Compared with the prior art, this method has the following characteristics:

[0062] 1. Prime number mapping and clearing method specifically for transfer type transactions: The present invention innovatively proposes a clearing method specifically for transfer type transactions in the blockchain. By mapping the account addresses of both parties to the transaction into large prime numbers, efficient identification and grouping of transactions are achieved, providing a new idea for storage optimization of transfer transactions.

[0063] 2. Backward liquidation mechanism without asset lock-up period: Unlike some existing off-chain expansion technologies, the liquidation process of the present invention is aimed at the arrangement of historical solidified transactions, and will not introduce asset lock-up period, ensuring the liquidity and accessibility of assets, while also optimizing the storage efficiency of transaction data.

[0064] 3. Iterative clearing process: The present invention supports clearing through multiple rounds of iterations, allowing the system to regularly adjust the clearing strategy based on actual storage and processing needs, thus realizing a method for dynamically and continuously optimizing blockchain storage.

[0065] Introduction to the application areas of this method:

[0066] 1. Cross-border payments and remittances: Blockchain-based cross-border payments and remittances are an important part of the cross-border financial services sector, especially for scenarios that are extremely sensitive to transaction costs. The present invention can improve the efficiency and user satisfaction of cross-border payment systems by optimizing transaction record storage, reducing processing delays and costs.

[0067] 2. Micropayment system: Blockchain-based micropayment systems, especially those applications that need to process a large number of small transactions (such as digital content payment, etc.), will generate a large amount of transaction data. The clearing method of the present invention can effectively reduce storage requirements, making the micropayment system more efficient and economical.

[0068] The present invention also provides a blockchain transaction bilateral clearing storage optimization device, including a computer program, which, when executed by a processor, implements the steps of the above-mentioned blockchain transaction bilateral clearing storage optimization method based on prime number mapping.

[0069] In an optional example, a clearing node is separately set up in the blockchain network, and the clearing node can perform transaction clearing on the target blockchain node according to the clearing request. In another optional example, the above clearing method can be used as an extended function (optional function) of the blockchain node that needs to be optimized for storage, and can be turned on when needed to save the node's storage space. In addition, the clearing request can be initiated by the customer, and the node can also select the clearing interval according to its own storage situation.

[0070] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of a blockchain transaction bilateral clearing storage optimization method based on prime number mapping.

[0071] The above description is only an embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for optimizing bilateral clearing storage of blockchain transactions based on prime number mapping, characterized in that: Used for bilateral settlement of historical transfer transactions that have been placed in the blockchain, including: S1. Define the historical area that needs to be cleared. The basis for selecting this historical area is that all transactions in this historical area have been confirmed and solidified by the blockchain network; S2. Convert all blockchain addresses participating in transactions within the designated historical area into prime numbers, and then group transactions according to the accumulator value ACC obtained by multiplying the prime numbers corresponding to the addresses of the sender and receiver of the transaction as a unique identifier; S3. For each group of transactions, the total sending amount and total receiving amount of all transactions in the group are counted and calculated. After obtaining the total sending amount and total receiving amount of each group of transactions, the two values ​​are compared to determine the final transaction result; S4. Generate a new transaction record based on the final transaction result. The new transaction record will reflect the net result of all transactions in the transaction group. The new transaction record will contain the information of the sender and the receiver, the net amount of the transfer, and a new unique identifier generated based on the accumulator value ACC of the original transaction group. S5. Write the transaction record after liquidation into the blockchain to replace the original transaction before liquidation. Methods for converting blockchain addresses into prime numbers include: S11. Define the hash function address_to_prime from blockchain address to prime number, which accepts three parameters: blockchain address, security parameter k, and truncated number of bits short_bits; S12. In the address_to_prime function, a loop is used to find prime numbers that meet the conditions. Step S12 includes: S121, input blockchain address x, security parameter k and truncated number of bits short_bits; S122. Calculate w = 2^k + h(x) + Fk(r), where x is the blockchain address and r is a counter; S123, using the Miller-Rabin algorithm to detect whether w is a prime number; S124, if w is a prime number, truncate it, take the highest short_bits bit, and get truncated; S125. If truncated is not a prime number, increment it until a prime number is found; S126. If w is not a prime number, increase the value of the counter r and continue to look for the next candidate number. Among them, function h takes a parameter x, converts it to a string and calculates the SHA-256 hash value, then converts the hash value to a large integer and returns it; Fk takes a parameter r, converts it to a string and calculates the SHA-256 hash value, then converts the hash value to a large integer and returns it.

2. The method for optimizing bilateral clearing storage of blockchain transactions based on prime number mapping according to claim 1 is characterized in that: The historical area that needs to be liquidated is delineated based on the height of the latest block.

3. The method for optimizing bilateral clearing storage of blockchain transactions based on prime number mapping according to claim 1 is characterized in that: During the growth of the blockchain itself, the regional chain is liquidated iteratively with a liquidation cycle of once every m blocks.

4. The method for optimizing bilateral clearing storage of blockchain transactions based on prime number mapping according to claim 1 is characterized in that: If the total amount sent is greater than the total amount received, the final transaction result is reflected in the form of the transfer difference between the sender and the receiver, or in the form of the transfer difference between the receiver and the sender.

5. The method for optimizing bilateral clearing storage of blockchain transactions based on prime number mapping according to claim 1 is characterized in that: For cross-border payments and remittances based on blockchain.

6. The method for optimizing bilateral clearing storage of blockchain transactions based on prime number mapping according to claim 1 is characterized in that: For blockchain-based micropayment systems.

7. A blockchain transaction bilateral clearing storage optimization device, comprising a computer program, characterized in that: When executed by a processor, the program implements the steps of the blockchain transaction bilateral settlement storage optimization method based on prime number mapping according to any one of claims 1 to 6.

8. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the steps of the blockchain transaction bilateral settlement storage optimization method based on prime number mapping according to any one of claims 1 to 6.