A Transaction Reconciliation Method and System Based on Merkle Tree

Through the Merkel tree-based transaction reconciliation method, the hash value determinism and irreversibility can be used to quickly determine the information consistency between the two parties of the transaction, solving the problem of inefficiency in the existing technology, and achieving efficient and secure transaction reconciliation.

CN114266578BActive Publication Date: 2025-07-25AISINO CORPORATION
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111402571.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-23
Publication Date
2025-07-25
Estimated Expiration
2041-11-23

AI Technical Summary

Technical Problem

The existing manual reconciliation methods cannot quickly determine whether the information between the two parties to the transaction is consistent, resulting in inefficient reconciliation.

Method used

The Merkel tree-based transaction reconciliation method is used to generate the hash value of transaction data, and use the determinism and irreversibility of the Merkel tree to compare the hash values of both parties to determine the reconciliation results, and obtain specific transaction data for reconciliation when inconsistent.

Benefits of technology

It improves the efficiency and accuracy of transaction reconciliation, reduces the consumption of computing resources, and enhances the security of data transmission and parsing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114266578B_ABST
    Figure CN114266578B_ABST
Patent Text Reader

Abstract

The present invention discloses a transaction reconciliation method and system based on a Merkle tree, including: both parties to the reconciliation generate a hash value corresponding to each transaction according to a preset hash algorithm, transaction data, and reconciliation initiation time; the hash value is a leaf node of the Merkle tree corresponding to the transaction time period; perform a hash operation on the hash values of two leaf nodes to generate a hash value corresponding to an intermediate node of the Merkle tree, and perform a hash operation on the hash values of two intermediate nodes to generate a hash value corresponding to the root node of the Merkle tree; compare the hash values corresponding to the nodes of the Merkle trees of both parties to the reconciliation. If the comparison result is consistent, the reconciliation result is a balanced account; if the comparison result is inconsistent, obtain the hash values of the leaf nodes with inconsistent comparison results; obtain the corresponding transaction data according to the hash values of the leaf nodes; both parties to the reconciliation perform transaction reconciliation according to the transaction data. This solves the problem that the existing manual reconciliation method cannot quickly determine whether the transaction information of both parties is consistent, resulting in low reconciliation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data processing, and particularly to a transaction reconciliation method and system based on a Merkle tree. Background Art

[0002] Transaction reconciliation refers to the process of mutual confirmation of transaction information or bill data between two parties in a transaction or between upstream and downstream of a transaction. The two parties in the transaction include, but are not limited to, individuals or institutions such as consumers, sellers, third-party payment institutions, banks, and UnionPay.

[0003] The current mainstream transaction reconciliation methods and steps are: obtaining a reconciliation file, parsing the reconciliation file, reconciliation processing, and error account processing. Among them, the general method for obtaining a reconciliation file is to upload or download the upstream reconciliation data file through a scheduled task in a dedicated network environment. The obtained file is decoded and read into the computer memory through a file parsing program, and then transferred to a database or data cache. The reconciliation process needs to formulate reconciliation rules based on dimensions such as payment status, transaction amount, transaction time, and transaction data benchmark, and then perform line-by-line data comparison on the transaction information in the database or data cache through the reconciliation rules. When errors such as multiple accounts or short accounts occur in the data comparison, automatic or manual account balancing is performed to resolve the transaction error accounts. The existing manual reconciliation method cannot quickly determine whether the transaction information of both parties is consistent, resulting in low reconciliation efficiency. Summary of the Invention

[0004] To solve the above problems, this application provides a transaction reconciliation method based on a Merkle tree, including:

[0005] The two parties in the reconciliation generate a hash value corresponding to each transaction according to a preset hash algorithm, transaction data, and reconciliation initiation time; the hash value is the leaf node of the Merkle tree corresponding to the transaction time period;

[0006] Perform a hash operation on the hash values of the two leaf nodes to generate a hash value corresponding to the intermediate node of the Merkle tree, and perform a hash operation on the hash values of the two intermediate nodes to generate a hash value corresponding to the root node of the Merkle tree;

[0007] Compare the hash values corresponding to the nodes of the Merkle trees generated by the two parties in the reconciliation. If the comparison result is consistent, the reconciliation result is a balanced account; if the comparison result is inconsistent, compare the hash values of the leaf nodes corresponding to the Merkle trees of the two parties in the reconciliation to obtain the hash values of the leaf nodes with inconsistent comparison results; according to the hash values of the leaf nodes, obtain the corresponding transaction data; the two parties in the reconciliation perform transaction reconciliation according to the transaction data.

[0008] Preferably, the two parties performing the reconciliation generate a hash value corresponding to each transaction based on a preset hash algorithm, transaction data, and the reconciliation initiation time, including:

[0009] Select any one of the hash algorithms including MD5, sha1, sha256, crc32, and haval as the preset hash algorithm for the two parties performing the reconciliation;

[0010] Run the transaction data and the reconciliation initiation time through the hash algorithm to generate a hash value corresponding to each transaction.

[0011] Preferably, the transaction data includes: the payee, the payer, the transaction amount, the transaction status, the transaction type, the transaction time, and the transaction voucher number.

[0012] Preferably, perform a hash operation on the hash values of two leaf nodes to generate a hash value corresponding to an intermediate node of the Merkle tree, and perform a hash operation on the hash values of two intermediate nodes to generate a hash value corresponding to the root node of the Merkle tree, including:

[0013] Pair two adjacent leaf nodes, and perform a hash operation on the hash values of the two adjacent leaf nodes to generate a hash value corresponding to an intermediate node of the Merkle tree;

[0014] If there are more than two intermediate nodes, pair two adjacent intermediate nodes, and perform a hash operation on the hash values of the two adjacent intermediate nodes to generate a hash value corresponding to a new intermediate node of the Merkle tree until the generated hash value of the intermediate node is unique; the node corresponding to the unique hash value is the root node of the Merkle tree.

[0015] Preferably, it further includes:

[0016] If the leaf node or the intermediate node cannot be paired, perform a hash operation on the leaf node or the intermediate node with a preset default hash value.

[0017] Preferably, the two parties performing the reconciliation perform transaction reconciliation based on the transaction data, including:

[0018] The two parties performing the reconciliation confirm and reconcile the inconsistent parts of the transaction data.

[0019] This application also provides a transaction reconciliation system based on a Merkle tree, including:

[0020] A leaf node generation module for the two parties performing the reconciliation to generate a hash value corresponding to each transaction based on a preset hash algorithm, transaction data, and the reconciliation initiation time; the hash value is the leaf node of the Merkle tree corresponding to the transaction time period;

[0021] The Merkle tree generation module is used to perform a hashing operation on the hash values of two leaf nodes to generate the hash value corresponding to the intermediate node of the Merkle tree, and perform a hashing operation on the hash values of two intermediate nodes to generate the hash value corresponding to the root node of the Merkle tree;

[0022] The reconciliation module is used to compare the hash values corresponding to the nodes of the Merkle trees generated by both parties in the reconciliation. If the comparison result is consistent, the reconciliation result is a balanced account; if the comparison result is inconsistent, the hash values of the leaf nodes corresponding to the Merkle trees of both parties in the reconciliation are compared to obtain the hash values of the leaf nodes with inconsistent comparison results; according to the hash values of the leaf nodes, the corresponding transaction data is obtained; both parties in the reconciliation perform transaction reconciliation based on the transaction data.

[0023] Preferably, the Merkle tree generation module includes:

[0024] The leaf node pairing sub-module is used to pair two adjacent leaf nodes, and perform a hashing operation on the hash values of the two adjacent leaf nodes to generate the hash value corresponding to the intermediate node of the Merkle tree;

[0025] The intermediate node pairing sub-module is used to, if there are more than two intermediate nodes, pair two adjacent intermediate nodes, and perform a hashing operation on the hash values of the two adjacent intermediate nodes to generate the hash value corresponding to the new intermediate node of the Merkle tree until the generated hash value of the intermediate node is unique; the node corresponding to the unique hash value is the root node of the Merkle tree.

[0026] Preferably, it further includes:

[0027] The default pairing sub-module is used to, if the leaf node or the intermediate node fails to be paired, perform a hashing operation on the leaf node or the intermediate node with a preset default hash value.

[0028] Preferably, the reconciliation module includes:

[0029] The processing sub-module is used to confirm and balance the places where the transaction data of both parties in the reconciliation is inconsistent. Description of the Drawings

[0030] Figure 1 is a schematic flowchart of a transaction reconciliation method based on a Merkle tree provided by the present application;

[0031] Figure 2 is a data structure block diagram and generation process diagram of a transaction reconciliation Merkle tree related to the present application;

[0032] Figure 3 is a schematic structural diagram of a transaction reconciliation system based on a Merkle tree provided by the present application. Detailed implementation mode

[0033] In the following description, many specific details are set forth in order to provide a thorough understanding of the present application. However, the present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the connotation of the present application. Therefore, the present application is not limited by the specific implementations disclosed below.

[0034] Figure 1 is a schematic flow chart of a transaction reconciliation method based on a Merkle tree provided by the present application. The following will be combined with Figure 1 to describe the method provided by the present application in detail.

[0035] Step S101, the two parties involved in the reconciliation generate a hash value corresponding to each transaction according to a preset hash algorithm, transaction data, and the reconciliation initiation time; the hash value is the leaf node of the Merkle tree corresponding to the transaction time period.

[0036] The Merkle tree is also called a hash tree. Its essence is a tree-like data structure composed of data blocks, leaf nodes, intermediate nodes, and root nodes. The data of any parent node is equal to the result of hashing the sum of the data of the left and right child nodes. The topmost node is called the Merkle root. It is a binary tree with characteristics such as determinism, irreversibility, unified length, and efficient retrieval and comparison. Hash is a function that maps data of any length into data of a fixed length, including but not limited to MD5, sha1, sha256, crc32, haval, etc. And if any change occurs to the original data, the hash value will change significantly.

[0037] The two parties involved in the reconciliation select any one of the hash algorithms including MD5, sha1, sha256, crc32, haval as the preset hash algorithm for the two parties involved in the reconciliation; the transaction data and the reconciliation initiation time are run through the hash algorithm to generate a hash value corresponding to each transaction. The hash value is the leaf node of the Merkle tree corresponding to the transaction time period. The transaction data includes: payee, payer, transaction amount, transaction status, transaction type, transaction time, transaction voucher number.

[0038] Step S102, perform a hash operation on the hash values of two leaf nodes to generate a hash value corresponding to the intermediate node of the Merkle tree, and perform a hash operation on the hash values of two intermediate nodes to generate a hash value corresponding to the root node of the Merkle tree.

[0039] Pair two adjacent leaf nodes, perform a hash operation on the hash values of the two adjacent leaf nodes to generate the hash value corresponding to the intermediate node of the Merkle tree; if there are more than two intermediate nodes, pair two adjacent intermediate nodes, perform a hash operation on the hash values of the two adjacent intermediate nodes to generate the hash value corresponding to the new intermediate node of the Merkle tree until the generated hash value of the intermediate node is unique; the node corresponding to the unique hash value is the root node of the Merkle tree.

[0040] If the leaf node or the intermediate node fails to be paired, perform a hash operation on the leaf node or the intermediate node with a preset default hash value.

[0041] Step S103, compare the hash values corresponding to the nodes of the Merkle trees generated by the two parties in the reconciliation. If the comparison result is consistent, the reconciliation result is a balanced account; if the comparison result is inconsistent, compare the hash values of the leaf nodes corresponding to the Merkle trees of the two parties in the reconciliation to obtain the hash values of the leaf nodes with inconsistent comparison results; obtain the corresponding transaction data according to the hash values of the leaf nodes; the two parties in the reconciliation perform transaction reconciliation according to the transaction data.

[0042] When the comparison result is inconsistent, according to the obtained corresponding transaction data, the two parties in the reconciliation confirm and balance the places where the transaction data is inconsistent.

[0043] The specific embodiments of the application are as follows:

[0044] The main functions of this application include reconciliation settings, hash generation, reconciliation hash tree generation, and reconciliation execution. Reconciliation settings are used to set the transaction fields for generating hash values, including settings such as reconciliation type, field name, field order, dictionary value conversion, separator, hash default value, reconciliation time, etc. It can be customized according to dimensions such as transaction type, transaction status, and reconciliation time to achieve centralized and standardized management of different business reconciliations. The hash generation module is triggered at the set reconciliation time point, and performs hash calculations on the corresponding transaction records according to the rules of the reconciliation settings to obtain the corresponding hash value for each transaction. The generated hash values are then pairwise hash calculated again. The transaction hashes that cannot be paired pairwise are paired by the hash default value set by the system, and finally a hash tree containing the entire reconciliation transaction is generated, that is, the reconciliation hash tree. The downstream institution obtains the reconciliation hash tree generated by the upstream institution. First, it obtains the root node and determines whether the root node is the same as the root node of the reconciliation hash tree generated by this institution. According to the determinacy and irreversibility of the Merkle tree, if the two are the same, it means that the transaction information of both parties is the same and the reconciliation work ends. If they are not the same, it means that there is inconsistent transaction information and the accounts need to be balanced. Then, perform a post-order traversal of the reconciliation hash trees of both parties, compare the traversal results, output the leaf nodes corresponding to the inconsistent hash values, and then match the transaction information records corresponding to the leaf node hashes to trigger the manual processing process, and the reconciliation work ends.

[0045] The specific process of the reconciliation setting function is as follows:

[0046] Click to add a reconciliation setting record on the system function page, set information such as reconciliation type, field name, field order, dictionary value conversion, separator, hash default value, hash algorithm, reconciliation time, etc., and then save. When the reconciliation record is selected and set to be effective, the system background will record this setting and generate a scheduled task according to the reconciliation time of this record. When the reconciliation record is selected and set to be invalid, the system background does not generate a scheduled task and only records this setting.

[0047] The specific process of the hash generation function is as follows:

[0048] After the scheduled task generated by the reconciliation setting module is started at a specific reconciliation time point, the transaction information is selectively and sequentially concatenated according to the field items of the reconciliation settings. After the concatenation is completed, it is batch processed through the agreed hash algorithm to generate the corresponding transaction hash value for each transaction, and stored in the computer. The storage locations include but are not limited to memory, cache, database, file, etc.

[0049] The specific process of the reconciliation hash tree generation function is as follows:

[0050] The adjacent transaction hash values are paired in pairs. If there are less than two, they are paired with the default hash value of the reconciliation setting. After pairing, hash again. The adjacent transaction hashes are used as leaf nodes, and the result of hashing again is used as its parent node to create a Merkle tree. The parent nodes are paired in pairs and connected again, and the result of hashing again is used as its new parent node. Repeat the above steps to finally get the reconciliation hash tree. See the attached file for details. Figure 2 .

[0051] The specific process of reconciliation execution function is as follows:

[0052] The downstream reconciliation agency obtains the data file or string containing the reconciliation hash tree through online or offline methods such as network request and email notification. Parse the reconciliation hash tree data file or string, convert it into a tree structured program object, read the root node, and determine whether it is consistent with the root node of the reconciliation hash tree generated by this agency. If it is consistent, the reconciliation result is output as a balance, and the reconciliation execution ends; if it is inconsistent, traverse the reconciliation hash tree in a post-order traversal manner, compare it with the reconciliation hash tree of this agency, remove the intermediate nodes, and output the inconsistent leaf node transaction hash in the reconciliation hash tree of this agency. According to the specific transaction detail records corresponding to the transaction hash query summary, the reconciliation result and the corresponding detail records are output, and the reconciliation execution ends.

[0053] It can be seen from the above embodiments that when the two parties to a transaction are conducting a transaction, the transaction systems of both parties splice the key transaction information such as the payee, payee, transaction amount, transaction status, transaction type, transaction time, transaction voucher number, etc. according to the transaction data items and data dictionary agreed in advance, and then perform hash operations in real time to obtain the unique hash value of the transaction. After that, the hash of the transaction is hashed again in pairs, and a Merkle tree of the hash of the transaction information for a certain period of time is generated according to the creation rules of the Merkle tree. If the transaction data of the two parties to the transaction are completely consistent during the transaction period, that is, the hash value of each transaction data is consistent, then the Merkle tree root of the time period finally generated must be consistent. According to the certainty and irreversibility of the Merkle tree, if the Merkle tree root finally generated is inconsistent, it can be explained that the transaction data of the two parties to the transaction must have an error account. After that, the Merkle tree of both parties is traversed, and the branches with inconsistent transaction hashes are retrieved and compared, and then the branch is traversed to determine the specific transaction data hash involved in the branch, and then a specific error transaction is locked, triggering automatic or manual settlement to solve the transaction error account.

[0054] The transaction reconciliation method provided by this application converts complex and huge transaction reconciliation files into a simple, secure binary tree data format with unified format and open standard. It has made great improvements in the processes of transmission, parsing, comparison, etc. compared with the previous methods, reducing network dependence and consuming less computing resources. The standardized parsing makes the docking between upstream and downstream more convenient and efficient. Due to the application of the certainty and irreversibility of hash values, it ensures that the data cannot be tampered with, making the data reconciliation process safer and more accurate.

[0055] Based on the same inventive concept, this application also provides a transaction reconciliation system 300 based on a Merkle tree, as Figure 3 shown, including:

[0056] A leaf node generation module 310, configured to generate a hash value corresponding to each transaction for both parties in the reconciliation according to a preset hash algorithm, transaction data, and reconciliation initiation time; the hash value is the leaf node of the Merkle tree corresponding to the transaction time period;

[0057] A Merkle tree generation module 320, configured to perform a hash operation on the hash values of two leaf nodes to generate a hash value corresponding to an intermediate node of the Merkle tree, and perform a hash operation on the hash values of two intermediate nodes to generate a hash value corresponding to the root node of the Merkle tree;

[0058] A reconciliation module 330, configured to compare the hash values corresponding to the nodes of the Merkle trees generated by both parties in the reconciliation. If the comparison result is consistent, the reconciliation result is a balanced account; if the comparison result is inconsistent, compare the hash values of the leaf nodes corresponding to the Merkle trees of both parties in the reconciliation to obtain the hash values of the leaf nodes with inconsistent comparison results; obtain the corresponding transaction data according to the hash values of the leaf nodes; both parties in the reconciliation perform transaction reconciliation according to the transaction data.

[0059] Preferably, the Merkle tree generation module includes:

[0060] A leaf node pairing sub-module, configured to pair two adjacent leaf nodes, and perform a hash operation on the hash values of the two adjacent leaf nodes to generate a hash value corresponding to an intermediate node of the Merkle tree;

[0061] An intermediate node pairing sub-module, configured to, if there are more than two intermediate nodes, pair two adjacent intermediate nodes, and perform a hash operation on the hash values of the two adjacent intermediate nodes to generate a hash value corresponding to a new intermediate node of the Merkle tree until the generated hash value of the intermediate node is unique; the node corresponding to the unique hash value is the root node of the Merkle tree.

[0062] Preferably, it further includes:

[0063] The default pairing sub-module is used to perform a hashing operation on the leaf node or the intermediate node with a preset default hash value if the leaf node or the intermediate node fails to be paired.

[0064] Preferably, the reconciliation module includes:

[0065] The processing sub-module is used for both parties in the reconciliation to confirm and reconcile the inconsistent parts of the transaction data.

[0066] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the above embodiments, those of ordinary skill in the art should understand that modifications or equivalent replacements can still be made to the specific implementation manners of the present invention. Any modification or equivalent replacement without departing from the spirit and scope of the present invention shall be covered by the scope of the claims of the present invention.

Claims

1. A transaction reconciliation method based on a Merkle tree, characterized in that, Including: The two parties for account reconciliation generate a hash value corresponding to each transaction according to a preset hash algorithm, transaction data, and the time of initiating account reconciliation; The hash value is the leaf node of the Merkle tree corresponding to the transaction time period; Perform a hash operation on the hash values of the two leaf nodes to generate a hash value corresponding to the intermediate node of the Merkle tree, and perform a hash operation on the hash values of the two intermediate nodes to generate a hash value corresponding to the root node of the Merkle tree; Compare the hash values corresponding to the root nodes of the Merkle trees generated by the two parties for account reconciliation. If the comparison result is consistent, the account reconciliation result is balanced; if the comparison result is inconsistent, compare the hash values of the leaf nodes corresponding to the Merkle trees of the two parties for account reconciliation to obtain the hash values of the leaf nodes with inconsistent comparison results; obtain the corresponding transaction data according to the hash values of the leaf nodes; the two parties for account reconciliation perform transaction reconciliation according to the transaction data; Performing a hash operation on the hash values of the two leaf nodes to generate a hash value corresponding to the intermediate node of the Merkle tree, and performing a hash operation on the hash values of the two intermediate nodes to generate a hash value corresponding to the root node of the Merkle tree, including: Pair two adjacent leaf nodes, and perform a hash operation on the hash values of the two adjacent leaf nodes to generate a hash value corresponding to the intermediate node of the Merkle tree; If there are more than two intermediate nodes, pair two adjacent intermediate nodes, and perform a hash operation on the hash values of the two adjacent intermediate nodes to generate a hash value corresponding to the new intermediate node of the Merkle tree until the generated hash value of the intermediate node is unique; the node corresponding to the unique hash value is the root node of the Merkle tree.

2. The method according to claim 1, characterized in that, The two parties for account reconciliation generate a hash value corresponding to each transaction according to a preset hash algorithm, transaction data, and the time of initiating account reconciliation, including: Select any one of the hash algorithms including MD5, sha1, sha256, crc32, and haval as the preset hash algorithm for the two parties for account reconciliation; Run the transaction data and the time of initiating account reconciliation through the hash algorithm to generate a hash value corresponding to each transaction.

3. The method according to claim 1, wherein Transaction data includes: payee, payer, transaction amount, transaction status, transaction type, transaction time, transaction voucher number.

4. The method according to claim 1, wherein It also includes: If the leaf node or the intermediate node fails to be paired, perform a hash operation on the leaf node or the intermediate node with a preset default hash value.

5. The method according to claim 1, characterized in that, The two parties for account reconciliation perform transaction reconciliation according to the transaction data, including: The two parties for account reconciliation confirm and balance the places where the transaction data is inconsistent.

6. A transaction reconciliation system based on a Merkle tree, characterized in that, Including: A leaf node generation module for the two parties for account reconciliation to generate a hash value corresponding to each transaction according to a preset hash algorithm, transaction data, and the time of initiating account reconciliation; The hash value is the leaf node of the Merkle tree corresponding to the transaction time period; The Merkle tree generation module is used to perform a hash operation on the hash values of two leaf nodes to generate the hash value corresponding to the intermediate node of the Merkle tree, and perform a hash operation on the hash values of two intermediate nodes to generate the hash value corresponding to the root node of the Merkle tree; The reconciliation module is used to compare the hash values corresponding to the root nodes of the Merkle trees generated by both parties in the reconciliation. If the comparison result is consistent, the reconciliation result is balanced; if the comparison result is inconsistent, the hash values of the leaf nodes corresponding to the Merkle trees of both parties in the reconciliation are compared to obtain the hash values of the leaf nodes with inconsistent comparison results; According to the hash value of the leaf node, obtain the corresponding transaction data; Both parties in the reconciliation perform transaction reconciliation according to the transaction data; The Merkle tree generation module includes: The leaf node pairing sub-module is used to pair two adjacent leaf nodes, and perform a hash operation on the hash values of the two adjacent leaf nodes to generate the hash value corresponding to the intermediate node of the Merkle tree; The intermediate node pairing sub-module is used to, if there are more than two intermediate nodes, pair two adjacent intermediate nodes, and perform a hash operation on the hash values of the two adjacent intermediate nodes to generate the hash value corresponding to the new intermediate node of the Merkle tree until the hash value generated by the intermediate node is unique; the node corresponding to the unique hash value is the root node of the Merkle tree.

7. The system according to claim 6, wherein It further includes: The default pairing sub-module is used to, if the leaf node or the intermediate node fails to be paired, perform a hash operation on the leaf node or the intermediate node with a preset default hash value.

8. The system according to claim 6, wherein The reconciliation module includes: The processing sub-module is used to confirm and balance the places where the transaction data of both parties in the reconciliation are inconsistent.

Citation Information

Patent Citations

  • Hash-based account checking method and device

    CN112785408A