Legal Verification Method, Device, Computer Equipment and Medium for Cross-Chain Transactions

Through cross-chain gateway monitoring relay chain block transactions and verifying the source, determining the application chain, simplifying the cross-chain transaction legality verification process, solving the problem of excessive resource consumption in the existing technology and improving efficiency.

CN114463002BActive Publication Date: 2025-06-20HANGZHOU QULIAN TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111682741.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-31
Publication Date
2025-06-20
Estimated Expiration
2041-12-31

AI Technical Summary

Technical Problem

In the process of cross-chain transaction legality verification, the existing technology needs to traverse a large number of transaction paths, resulting in excessive resource consumption and inefficiency.

Method used

The cross-chain transactions in the new block of the relay chain are monitored through the cross-chain gateway. If the preset structure is matched, the source of the block transaction is verified, the current application chain is determined, and the cross-chain transaction collection is traversed, and the transaction legitimacy is verified using the relay chain rule engine.

Benefits of technology

Reduces resource consumption for cross-chain transaction legality verification, simplifies the calculation content, and improves the efficiency of legality proof.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114463002B_ABST
    Figure CN114463002B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device, computer device and medium for verifying the legality of cross-chain transactions. The method includes: using a cross-chain gateway to monitor cross-chain transactions in newly generated blocks of a relay chain. When a block transaction with the same preset structure is monitored, verify the source of the block transaction to obtain a verification result. If, in the verification result, the block transaction is a cross-chain transaction between the destination chain in the newly generated block of the relay chain and the application chain connected to the cross-chain gateway, then use the application chain connected to the cross-chain gateway as the current application chain, and use the cross-chain gateway to traverse the cross-chain transaction set to check whether each transaction between the destination chain and the current application chain has passed the verification of the relay chain rule engine. If all pass, confirm that the cross-chain transaction is legal; if at least one does not pass, confirm that the cross-chain transaction is illegal. Using the present invention improves the efficiency of proving the legality of cross-chain transactions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain technology, and in particular, to a method, apparatus, computer device, and medium for verifying the legality of cross-chain transactions. Background Art

[0002] Currently, there are more and more blockchains in the production environment, and the data volume is also increasing. Each blockchain node needs to store all the chain data that needs to be maintained to work, otherwise only partial functions can be achieved, or even it cannot run safely. Especially for cross-chain transactions, the traditional solution is to store the data of the target chain locally in real time to verify the legality of the original transaction of the cross-chain transaction. In this processing mode, at each blockchain node, both the original chain and the target chain are run, so a large amount of resources such as CPU, memory, disk, and bandwidth are required, which affects the running speed. Generally, a relay chain is used to provide a proof of the legality of cross-chain transactions. In this way, when the cross-chain gateway obtains the cross-chain transactions and related information of its corresponding application chain, it can prove that the obtained cross-chain transactions actually come from the relay chain.

[0003] In the current cross-chain system adopting the relay mode, most directly construct all transactions into a transaction tree, and very few also construct transaction trees according to the destination chain address of the cross-chain transaction. For cross-chain transactions between relay chains, transaction trees are constructed separately according to the destination chain, which will lead to a situation of excessive proof information. When the cross-chain gateway proves the legality of cross-chain transactions, it often needs to calculate many additional transaction paths, increasing unnecessary calculations.

[0004] Therefore, reducing the resource consumption for verifying the legality of cross-chain transactions is an urgent problem to be solved currently. Summary of the Invention

[0005] Embodiments of the present invention provide a method, apparatus, computer device, and storage medium for verifying the legality of cross-chain transactions to improve the efficiency of verifying the legality of cross-chain transactions.

[0006] To solve the above technical problems, an embodiment of the present application provides a method for verifying the legality of cross-chain transactions, including:

[0007] Using a cross-chain gateway to monitor cross-chain transactions in newly generated blocks of a relay chain;

[0008] When a block transaction with the same preset structure is monitored, verifying the source of the block transaction to obtain a verification result;

[0009] If, in the verification result, the block transaction is a cross-chain transaction between the destination chain in the newly generated block of the relay chain and the application chain connected to the cross-chain gateway, then taking the application chain connected to the cross-chain gateway as the current application chain;

[0010] Use the cross-chain gateway to traverse the cross-chain transaction collection, and check whether each transaction on the destination chain and the current application chain has passed the verification of the relay chain rule engine. If all pass, confirm that the cross-chain transaction is legal; if at least one does not pass, confirm that the cross-chain transaction is illegal.

[0011] Optionally, the preset structure includes a block header, a block height, a cross-chain transaction collection, and a transaction tree of the relay chain.

[0012] Optionally, before verifying the source of the block transaction when a block transaction identical to the preset structure is monitored and obtaining a verification result, the cross-chain transaction legality verification method further includes:

[0013] Classify the transactions to obtain the transaction category of each transaction;

[0014] For each of the transactions, construct a corresponding Merkle transaction tree based on the transaction category, and record the root of each obtained Merkle transaction tree as L2 Root;

[0015] Construct a new Merkle transaction tree based on the roots of all the Merkle transaction trees as the transaction tree of the relay chain, and record the root node of the transaction tree of the relay chain as L1 Root;

[0016] Include the root node L1 Root of the transaction tree of the relay chain in the block header of the newly generated block of the relay chain.

[0017] Optionally, when a block transaction identical to the preset structure is monitored and the source of the block transaction is verified to obtain a verification result, it includes:

[0018] Use the cross-chain gateway to construct a Merkle transaction tree from all the L2 Root sets in the transaction tree of the relay chain, and calculate the L1 Root of the Merkle transaction tree as the data to be verified;

[0019] Read the block header hash from the newly generated block of the relay chain, and compare the block header hash with the data to be verified to obtain a comparison result;

[0020] If the comparison result is that the block header hash is consistent with the data to be verified, determine that the block transaction is a cross-chain transaction between the destination chain in the newly generated block of the relay chain and the application chain connected by the cross-chain gateway;

[0021] If the comparison result is that the block header hash is inconsistent with the data to be verified, the verification fails and the proof process ends.

[0022] Optionally, at least one of the cross-chain transactions of the application chains registered on the present relay chain, the cross-chain transactions whose destination chains are not the application chains registered on the present relay chain, and the non-cross-chain transactions are included. The transaction tree of the relay chain includes leaf nodes corresponding to transaction categories, which are at least one of the cross-chain transaction tree whose destination chain is the application chain registered on the present relay chain, the cross-chain transaction whose destination chain is not the application chain registered on the present relay chain, and the non-cross-chain transaction tree.

[0023] To solve the above technical problems, an embodiment of the present application further provides a legality verification device for cross-chain transactions, including:

[0024] A transaction monitoring module, configured to monitor cross-chain transactions in newly generated blocks of the relay chain by using a cross-chain gateway;

[0025] A source verification module, configured to verify the source of the block transaction when a block transaction with the same preset structure is monitored, to obtain a verification result;

[0026] An application chain determination module, configured to use the application chain connected to the cross-chain gateway as the current application chain if, in the verification result, the block transaction is a cross-chain transaction between the destination chain in the newly generated block of the relay chain and the application chain connected to the cross-chain gateway;

[0027] A rule verification module, configured to use the cross-chain gateway to traverse the cross-chain transaction collection, and check whether each transaction between the destination chain and the current application chain passes the verification of the relay chain rule engine. If all pass, it is confirmed that the cross-chain transaction is legal. If at least one does not pass, it is confirmed that the cross-chain transaction is illegal.

[0028] Optionally, the legality verification device for cross-chain transactions further includes:

[0029] A transaction classification module, configured to classify transactions to obtain the transaction category of each transaction;

[0030] A first transaction tree construction module, configured to construct a corresponding Merkle transaction tree for each transaction based on the transaction category, and record the root of each obtained Merkle transaction tree as L2 Root;

[0031] A second transaction tree construction module, configured to construct a new Merkle transaction tree based on the roots of all the Merkle transaction trees as the transaction tree of the relay chain, and record the root node of the transaction tree of the relay chain as L1 Root;

[0032] A data writing module, configured to record the root node L1 Root of the transaction tree of the relay chain into the block header of the newly generated block of the relay chain.

[0033] Optionally, the source verification module includes:

[0034] A unit for obtaining data to be verified, configured to use the cross-chain gateway to construct all L2Root sets in the transaction tree of the relay chain into a Merkle transaction tree, and calculate the L1 Root of the Merkle transaction tree as the data to be verified;

[0035] A data comparison unit, configured to read the block header hash from the newly generated block of the relay chain, and compare the block header hash with the data to be verified to obtain a comparison result;

[0036] A first result determination unit, configured to determine that the block transaction is a cross-chain transaction between the destination chain in the newly generated block of the relay chain and the application chain connected to the cross-chain gateway if the comparison result shows that the block header hash is consistent with the data to be verified;

[0037] A second result determination unit, configured to end the proof process with verification failure if the comparison result shows that the block header hash is inconsistent with the data to be verified.

[0038] To solve the above technical problems, an embodiment of the present application further provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above cross-chain transaction legality verification method are implemented.

[0039] To solve the above technical problems, an embodiment of the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above cross-chain transaction legality verification method are implemented.

[0040] The cross-chain transaction legality verification method, device, computer device, and storage medium provided by the embodiments of the present invention use a cross-chain gateway to monitor cross-chain transactions in newly generated blocks of the relay chain. When a block transaction with the same preset structure is monitored, the source of the block transaction is verified to obtain a verification result. If, in the verification result, the block transaction is a cross-chain transaction between the destination chain in the newly generated block of the relay chain and the application chain connected to the cross-chain gateway, the application chain connected to the cross-chain gateway is used as the current application chain, and the cross-chain gateway is used to traverse the cross-chain transaction collection to check whether each transaction between the destination chain and the current application chain has passed the verification of the relay chain rule engine. If all pass, the cross-chain transaction is confirmed to be legal; if at least one fails, the cross-chain transaction is confirmed to be illegal. When verifying the legality of relay chain cross-chain transactions using a cross-chain gateway, it is no longer necessary to traverse all transactions in the block, greatly simplifying the calculation content and improving the legality proof efficiency. Description of the Drawings

[0041] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the accompanying drawings required for the description of the embodiments of the present invention. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.

[0042] Figure 1 is a schematic diagram of the scenario of the cross-chain transaction legality verification method provided by this application;

[0043] Figure 2 is a flowchart of an embodiment of the cross-chain transaction legality verification method of this application;

[0044] Figure 3 is a schematic structural diagram of an embodiment of the cross-chain transaction legality verification device according to this application;

[0045] Figure 4 is a schematic structural diagram of an embodiment of the computer device according to this application. Detailed implementation manners

[0046] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which this application belongs; the terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above accompanying drawing descriptions are intended to cover non-exclusive inclusion. The terms "first", "second", etc. in the specification and claims of this application or the above accompanying drawings are used to distinguish different objects and are not used to describe a specific order.

[0047] Referring to "embodiment" herein means that the specific features, structures, or characteristics described in connection with the embodiment can be included in at least one embodiment of this application. The phrase appears in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.

[0048] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts belong to the scope of protection of the present invention.

[0049] Please refer to Figure 1, such as Figure 1 shown, Figure 1 is a schematic diagram of the scenario of the cross-chain transaction legality verification method in an embodiment of the present invention. The cross-chain transaction legality verification method provided by this application can be applied in an application environment such as Figure 1 . Referring to Figure 1 , blockchain organization A includes cross-chain gateway A1, relay chain A2, application chain A3, and application chain A4. Among them, application chain A3 communicates with relay chain A2 through cross-chain gateway A5, and application chain A4 communicates with relay chain A2 through cross-chain gateway A6; blockchain organization B includes cross-chain gateway B1, relay chain B2, application chain B3, and application chain B4. Among them, application chain B3 communicates with relay chain B2 through cross-chain gateway B5, and application chain B4 communicates with relay chain B2 through cross-chain gateway B6; blockchain organization C includes cross-chain gateway C1, relay chain C2, application chain C3, and application chain C4. Among them, application chain C3 communicates with relay chain C2 through cross-chain gateway C5, and application chain C4 communicates with relay chain C2 through cross-chain gateway C6; blockchain organization D includes cross-chain gateway D1, relay chain D2, application chain D3, and application chain D4. Among them, application chain D3 communicates with relay chain D2 through cross-chain gateway D5, and application chain D4 communicates with relay chain D2 through cross-chain gateway D6. Among them, the relay chain provides cross-chain services for each application chain in its blockchain organization. The communication connection structure between cross-chain gateways that achieve cross-organization communication and interaction in each blockchain organization is a ring structure. Here is only an example, and other communication connection structures (such as star structure) that can achieve communication between cross-chain gateways are also acceptable.

[0050] Please refer to Figure 2 , Figure 2 shows a cross-chain transaction legality verification method provided by an embodiment of the present invention, which is described in detail as follows:

[0051] S201: Use a cross-chain gateway to monitor cross-chain transactions in newly generated blocks of the relay chain.

[0052] Specifically, there are various types of transactions in the relay chain, and new blocks will be generated. In this embodiment, a cross-chain gateway is used to monitor cross-chain transactions in newly generated blocks of the relay chain.

[0053] S202: If a block transaction with the same preset structure is monitored, verify the source of the block transaction to obtain a verification result.

[0054] Specifically, a preset structure is pre-stored in this embodiment. When a transaction is generated in a block with the same structure as the preset structure is monitored, the source of the transaction is verified to obtain a verification result.

[0055] It should be noted that in the newly generated blocks of the relay chain, the sources of its transactions include, but are not limited to: application chains whose destination chains are cross-chain gateways, non-cross-chain (transactions between internal chains of the relay chain), and other relay chains as the destination chains.

[0056] Optionally, the preset structure includes a block header, a block height, a cross-chain transaction collection, and a transaction tree of the relay chain. For example, in a preferred manner, the preset structure and description are shown in Table 1.

[0057]

[0058] Table 1

[0059] Furthermore, before verifying the source of the block transaction and obtaining the verification result when a block transaction identical to the preset structure is monitored, the cross-chain transaction legitimacy verification method further includes:

[0060] Classify the transactions to obtain the transaction category of each transaction;

[0061] For each transaction, construct a corresponding Merkle transaction tree based on the transaction category, and record the root of each obtained Merkle transaction tree as L2 Root;

[0062] Construct a new Merkle transaction tree based on the roots of all Merkle transaction trees as the transaction tree of the relay chain, and record the root node of the transaction tree of the relay chain as L1 Root;

[0063] Record the root node L1 Root of the transaction tree of the relay chain into the block header of the newly generated block of the relay chain.

[0064] Specifically, the relay chain itself needs to provide a proof of the legitimacy of cross-chain transactions, so that the cross-chain gateway can obtain the cross-chain transactions and related information of its corresponding application chain, and can prove that the obtained cross-chain transactions actually come from the relay chain. In this embodiment, the transactions are classified according to the source (or destination address) of the transactions, and then different Merkle transaction trees are constructed, and finally the total Merkle transaction tree root is generated. This makes it unnecessary to traverse all transactions in the block during the subsequent verification of the legitimacy of cross-chain transactions, greatly simplifies the calculation content, and improves the efficiency of legitimacy verification.

[0065] Optionally, when a block transaction identical to the preset structure is monitored and the source of the block transaction is verified to obtain the verification result, it includes:

[0066] Use the cross-chain gateway to construct a Merkle transaction tree from all the L2 Root sets in the transaction tree of the relay chain, and calculate the L1 Root of the Merkle transaction tree as the data to be verified;

[0067] Read the block header hash from the newly generated block in the relay chain, and compare the block header hash with the data to be verified to obtain a comparison result;

[0068] If the comparison result shows that the block header hash is consistent with the data to be verified, determine that the block transaction is a cross-chain transaction between the target chain in the newly generated block of the relay chain and the application chain connected by the cross-chain gateway;

[0069] If the comparison result shows that the block header hash is inconsistent with the data to be verified, the verification fails and the proof process ends.

[0070] Optionally, the transaction category includes cross-chain transactions where the target chain is an application chain registered on this relay chain, such as Figure 1 the cross-chain transaction sent from application chain A3 to application chain A4 in Figure 1 cross-chain transactions where the target chain is an application chain not registered on this relay chain, such as Figure 1 the cross-chain transaction sent from application chain A to application chain B in

[0071] The transaction tree of the relay chain includes leaf nodes corresponding to transaction categories, which are at least one of the cross-chain transaction tree where the target chain is an application chain registered on this relay chain, the cross-chain transaction where the target chain is an application chain not registered on this relay chain, and the non-cross-chain transaction tree

[0072] S203: If, in the verification result, the block transaction is a cross-chain transaction between the target chain in the newly generated block of the relay chain and the application chain connected by the cross-chain gateway, then use the application chain connected by the cross-chain gateway as the current application chain.

[0073] S204: Use the cross-chain gateway to traverse the cross-chain transaction set, and check whether each transaction with the target chain and the current application chain has passed the verification of the relay chain rule engine. If all pass, confirm that the cross-chain transaction is legal; if there is at least one that does not pass, confirm that the cross-chain transaction is illegal.

[0074] In this embodiment, a cross-chain gateway is used to monitor cross-chain transactions in newly generated blocks of the relay chain. When a block transaction with the same preset structure is monitored, the source of the block transaction is verified to obtain a verification result. If, in the verification result, the block transaction is a cross-chain transaction between the destination chain in the newly generated block of the relay chain and the application chain connected to the cross-chain gateway, the application chain connected to the cross-chain gateway is used as the current application chain. The cross-chain gateway is used to traverse the cross-chain transaction set and check whether each transaction between the destination chain and the current application chain has passed the verification of the relay chain rule engine. If all pass, it is confirmed that the cross-chain transaction is legal; if at least one fails, it is confirmed that the cross-chain transaction is illegal. When verifying the legality of relay chain cross-chain transactions using a cross-chain gateway, it is no longer necessary to traverse all transactions in the block, greatly simplifying the calculation content and improving the efficiency of legality proof.

[0075] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The order of execution of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.

[0076] Figure 3 The principle block diagram of a cross-chain transaction legality verification device corresponding one-to-one to the above-mentioned cross-chain transaction legality verification method is shown. As Figure 3 shown, the cross-chain transaction legality verification device includes a transaction monitoring module 31, a source verification module 32, an application chain determination module 33, and a rule verification module 34. The detailed description of each functional module is as follows:

[0077] The transaction monitoring module 31 is used to monitor cross-chain transactions in newly generated blocks of the relay chain using a cross-chain gateway;

[0078] The source verification module 32 is used to verify the source of the block transaction when a block transaction with the same preset structure is monitored to obtain a verification result;

[0079] The application chain determination module 33 is used to use the application chain connected to the cross-chain gateway as the current application chain if, in the verification result, the block transaction is a cross-chain transaction between the destination chain in the newly generated block of the relay chain and the application chain connected to the cross-chain gateway;

[0080] The rule verification module 34 is used to traverse the cross-chain transaction set using a cross-chain gateway and check whether each transaction between the destination chain and the current application chain has passed the verification of the relay chain rule engine. If all pass, it is confirmed that the cross-chain transaction is legal; if at least one fails, it is confirmed that the cross-chain transaction is illegal.

[0081] Optionally, the cross-chain transaction legality verification device further includes:

[0082] A transaction classification module, used to classify transactions to obtain the transaction category of each transaction;

[0083] The first transaction tree construction module is used to construct a corresponding Merkle transaction tree for each transaction based on the transaction category, and record the root of each obtained Merkle transaction tree as L2 Root;

[0084] The second transaction tree construction module is used to construct a new Merkle transaction tree based on the roots of all Merkle transaction trees as the transaction tree of the relay chain, and record the root node of the transaction tree of the relay chain as L1 Root;

[0085] The data writing module is used to record the root node L1 Root of the transaction tree of the relay chain into the block header of the newly generated block of the relay chain.

[0086] Optionally, the source verification module 32 includes:

[0087] The data to be verified acquisition unit is used to use the cross-chain gateway to construct all L2Root sets in the transaction tree of the relay chain into a Merkle transaction tree, calculate the L1 Root of the Merkle transaction tree as the data to be verified;

[0088] The data comparison unit is used to read the block header hash from the newly generated block of the relay chain, and compare the block header hash with the data to be verified to obtain a comparison result;

[0089] The first result determination unit is used to determine that the block transaction is a cross-chain transaction between the destination chain in the newly generated block of the relay chain and the application chain connected by the cross-chain gateway if the comparison result is that the block header hash is consistent with the data to be verified;

[0090] The second result determination unit is used to end the proof process if the verification fails when the comparison result is that the block header hash is inconsistent with the data to be verified.

[0091] For the specific limitations of the cross-chain transaction legality verification device, reference can be made to the limitations of the cross-chain transaction legality verification method in the above text, which will not be elaborated here. Each module in the above cross-chain transaction legality verification device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above-mentioned modules.

[0092] To solve the above technical problems, an embodiment of the present application also provides a computer device. For details, please refer to Figure 4 , Figure 4 This is the basic structure block diagram of the computer device in this embodiment.

[0093] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are communicatively connected to each other via a system bus. It should be noted that only the computer device 4 with components connected to the memory 41, the processor 42, and the network interface 43 is shown in the figure. However, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Among them, those skilled in the art of the present technology can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0094] The computer device can be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server. The computer device can perform human-computer interaction with the user through means such as a keyboard, a mouse, a remote control, a touchpad, or a voice control device.

[0095] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, a hard disk, a multimedia card, a card-type memory (such as an SD or D interface display memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as the hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk equipped on the computer device 4, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as the program code for verifying the legality of cross-chain transactions. In addition, the memory 41 can also be used to temporarily store various data that have been output or will be output.

[0096] In some embodiments, the processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run the program code stored in the memory 41 or process data, such as running the program code for verifying the legality of cross-chain transactions.

[0097] The network interface 43 may include a wireless network interface or a wired network interface, which is generally used to establish a communication connection between the computer device 4 and other electronic devices.

[0098] The present application also provides another implementation manner, that is, to provide a computer-readable storage medium storing an interface display program, and the interface display program can be executed by at least one processor to enable the at least one processor to execute the steps of the method for verifying the legality of cross-chain transactions as described above.

[0099] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-described embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc) and includes several instructions for enabling a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in the various embodiments of the present application.

[0100] Obviously, the above-described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The accompanying drawings show the preferred embodiments of the present application, but do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure content of the present application more thorough and comprehensive. Although the present application has been described in detail with reference to the foregoing embodiments, for those skilled in the art, they can still modify the technical solutions described in the foregoing specific embodiments, or perform equivalent replacements for some of the technical features. Any equivalent structure made by using the specification and drawings of the present application, directly or indirectly applied in other related technical fields, is equally within the scope of the patent protection of the present application.

Claims

1. A method for verifying the legality of cross-chain transactions, characterized in that, The method for verifying the legality of cross-chain transactions includes: Using a cross-chain gateway to monitor cross-chain transactions in newly generated blocks of the relay chain. Among them, there are various types of transactions in the relay chain, and new blocks are generated when transactions occur. The transaction sources include application chains managed by the cross-chain gateway as the destination chain, non-cross-chain transactions, and other relay chains as the destination chain. Non-cross-chain transactions are transactions between internal chains of the relay chain. When a block transaction with the same preset structure is monitored, verify the source of the block transaction to obtain a verification result. If, in the verification result, the block transaction is a cross-chain transaction between the destination chain in the newly generated block of the relay chain and the application chain connected to the cross-chain gateway, then use the application chain connected to the cross-chain gateway as the current application chain. Use the cross-chain gateway to traverse the cross-chain transaction set, and check whether each transaction with the current application chain as the destination chain has passed the verification of the relay chain rule engine. If all pass, confirm that the cross-chain transaction is legal; if at least one does not pass, confirm that the cross-chain transaction is illegal. The preset structure includes a block header, a block height, a cross-chain transaction set, and a transaction tree of the relay chain. Before the step of when a block transaction with the same preset structure is monitored and the source of the block transaction is verified to obtain a verification result, the method for verifying the legality of cross-chain transactions further includes: Classify the transactions to obtain the transaction category of each transaction. For each of the transactions, construct a corresponding Merkle transaction tree based on the transaction category, and record the root of each obtained Merkle transaction tree as L2 Root. Construct a new Merkle transaction tree based on the roots of all the Merkle transaction trees as the transaction tree of the relay chain, and record the root node of the transaction tree of the relay chain as L1 Root. Include the root node L1 Root of the transaction tree of the relay chain in the block header of the newly generated block of the relay chain. The step of when a block transaction with the same preset structure is monitored and the source of the block transaction is verified to obtain a verification result includes: Use the cross-chain gateway to construct a Merkle transaction tree from all the L2 Root sets in the transaction tree of the relay chain, and calculate the L1 Root of the Merkle transaction tree as the data to be verified. Read the block header hash from the newly generated block of the relay chain, and compare the block header hash with the data to be verified to obtain a comparison result. If the comparison result shows that the block header hash is consistent with the data to be verified, determine that the block transaction is a cross-chain transaction between the destination chain in the newly generated block of the relay chain and the application chain connected to the cross-chain gateway. If the comparison result shows that the block header hash is inconsistent with the data to be verified, the verification fails and the proof process ends.

2. The method for verifying the legality of cross-chain transactions according to claim 1, characterized in that, The transaction categories include at least one of cross-chain transactions whose destination chain is an application chain registered on this relay chain, cross-chain transactions whose destination chain is not an application chain registered on this relay chain, and non-cross-chain transactions. The transaction tree of the relay chain includes leaf nodes corresponding to the transaction categories, which are at least one of a cross-chain transaction tree whose destination chain is an application chain registered on this relay chain, a cross-chain transaction whose destination chain is not an application chain registered on this relay chain, and a non-cross-chain transaction tree.

3. A device for verifying the legality of cross-chain transactions, characterized in that, Using the cross-chain transaction legality verification method according to claim 1 or 2, the cross-chain transaction legality verification device includes: A transaction monitoring module, which is used to monitor cross-chain transactions in the newly generated block of the relay chain by using a cross-chain gateway. Among them, there are various types of transactions in the relay chain, and a newly generated block will be generated when a transaction occurs. The transaction sources include an application chain managed by the cross-chain gateway as the destination chain, non-cross-chain transactions, and other relay chains as the destination chain. Non-cross-chain transactions are transactions between internal chains of the relay chain; A source verification module, which is used to verify the source of the block transaction when a block transaction with the same preset structure is monitored, and obtain a verification result; An application chain determination module, which is used to, if in the verification result, the block transaction is a cross-chain transaction between the destination chain in the newly generated block of the relay chain and the application chain connected to the cross-chain gateway, then use the application chain connected to the cross-chain gateway as the current application chain; A rule verification module, which is used to traverse the cross-chain transaction collection by using the cross-chain gateway, and check whether each transaction between the destination chain and the current application chain passes the verification of the relay chain rule engine. If all pass, it is confirmed that the cross-chain transaction is legal. If at least one does not pass, it is confirmed that the cross-chain transaction is illegal.

4. The device for verifying the legality of cross-chain transactions according to claim 3, characterized in that, The cross-chain transaction legality verification device further includes: A transaction classification module, which is used to classify transactions to obtain the transaction category of each transaction; A first transaction tree construction module, which is used to construct a corresponding Merkle transaction tree for each transaction based on the transaction category, and record the root of each obtained Merkle transaction tree as L2 Root; A second transaction tree construction module, which is used to construct a new Merkle transaction tree based on the roots of all the Merkle transaction trees as the transaction tree of the relay chain, and record the root node of the transaction tree of the relay chain as L1 Root; A data writing module, which is used to record the root node L1 Root of the transaction tree of the relay chain into the block header of the newly generated block of the relay chain.

5. The device for verifying the legality of cross-chain transactions according to claim 3, characterized in that, The source verification module includes: A data to be verified acquisition unit, which is used to use the cross-chain gateway to construct all the L2Root sets in the transaction tree of the relay chain into a Merkle transaction tree, calculate the L1 Root of the Merkle transaction tree as the data to be verified; A data comparison unit, which is used to read the block header hash from the newly generated block of the relay chain, and compare the block header hash with the data to be verified to obtain a comparison result; A first result determination unit, which is used to, if the comparison result shows that the block header hash is consistent with the data to be verified, determine that the block transaction is a cross-chain transaction between the destination chain in the newly generated block of the relay chain and the application chain connected to the cross-chain gateway; The second result determination unit is configured to end the proof process with a verification failure if the comparison result shows that the block header hash is inconsistent with the data to be verified.

6. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method for verifying the legality of cross-chain transactions as described in claim 1 or 2.

7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the method for verifying the legality of cross-chain transactions as described in claim 1 or 2.

Citation Information

Patent Citations

  • Cross-chain transaction data synchronization method, device and system and terminal equipment

    CN112651046A

  • Blockchain cross-chain transaction verification method based on multistage Merkel tree

    CN112702400A