A verification method, device and storage medium for parallel chain synchronous transactions

By using a zero-knowledge proof circuit based on transaction hash in the blockchain system, the transaction root hash is generated and verified, and the problems of long transaction verification time and large data volume are solved, and efficient transaction verification and data transmission are achieved. .

CN113793146BActive Publication Date: 2025-01-07YANGZHOU ZHIZHI INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110883010.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-02
Publication Date
2025-01-07
Estimated Expiration
2041-08-02

AI Technical Summary

Technical Problem

In the prior art, parachains need to be verified for each transaction, resulting in problems such as large amount of data transmitted on the network and long verification time.

Method used

Using a zero-knowledge proof circuit based on transaction hash, the transaction root hash is generated through the main chain node and sent to the parachain node. The parachain node verifies the transaction matching based on the block header information, reducing the amount of data transmitted and verification. time.

Benefits of technology

It achieves the effect of reducing the amount of network transmission data and shortening the transaction verification time on the parachain side, improving verification efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113793146B_ABST
    Figure CN113793146B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of computer technology, and in particular, relates to a verification method, device and storage medium for parallel chain synchronous transactions. The verification method for parallel chain synchronous transactions provided by the present invention uses the transaction hash as the input information of the zero-knowledge proof, the zero-knowledge proof circuit calculates the transaction root hash, and other non-parallel chain transactions are compressed into a very small proof as private input, so that the parallel chain only gets the parachain transaction of interest and a proof, and can verify all transactions in the block at once.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer technology, and in particular, relates to a verification method, device and storage medium for parallel chain synchronous transactions. Background Art

[0002] Parallel chains synchronize parallel chain transactions from the main chain. Considering the insecurity of network transmission, it is necessary to verify the received transactions to verify whether the transactions are on the corresponding main chain blocks. The existing solution is to obtain the main chain block header information on the main chain side, including block hash and transaction root hash, and generate a merkle tree for each parallel chain transaction to prove that the transaction is on the block. The above solution needs to generate a merkle tree for each parallel chain transaction. The entire block capacity has thousands of transactions. If there are many parallel chain transactions, it will take a lot of time to generate a merkle tree for each transaction, and the transmitted data will also become much larger. The parallel chain needs to verify each parallel chain transaction once, which takes a long time overall. Summary of the invention

[0003] In order to solve the problem that the above-mentioned prior art parallel chain needs to verify once for each parallel chain transaction, which takes a long time overall and transmits a large amount of data, the present invention provides a verification method, device and storage medium for parallel chain synchronous transactions.

[0004] The objects of the present invention are:

[0005] It reduces the amount of data transmitted on the network and shortens the time it takes to verify transactions on the parachain side.

[0006] To achieve the above objectives, the present invention adopts the following technical solutions.

[0007] In a first aspect, a method for verifying a parallel chain synchronous transaction is provided, wherein a blockchain system is configured with a zero-knowledge proof circuit based on a transaction hash, wherein the zero-knowledge proof circuit is configured with a first public input including a plurality of transaction variables, a private input including an equal number of transaction variables as the first public input, and a second public input, wherein the method is as follows:

[0008] The main chain node obtains all transactions in the block, sorts all transactions in the order of submission, and fills the transactions into the first public input and private input of the zero-knowledge proof circuit in sequence. If the transaction is a parallel chain transaction, the transaction hash of the transaction is filled into the transaction variable of the corresponding sequence number of the first public input, and the transaction variable of the corresponding sequence number of the private input is zero. If the transaction is other transactions, the transaction hash of the transaction is filled into the transaction variable of the corresponding sequence number of the private input, and the transaction variable of the corresponding sequence number of the first public input is zero. If there is no transaction with the sequence number corresponding to the first public input and the private input, the transaction variables of the first public input and the private input of the sequence number are both zero. The zero-knowledge proof circuit calculates the transaction root hash of all transactions based on the first public input and the private input to generate a first root hash, and fills the first transaction root into the second public input of the zero-knowledge proof circuit. The zero-knowledge proof circuit generates proof information based on the first public input, the second public input and the private input. The generated proof information is that the zero-knowledge proof circuit determines that if the transaction variable of the private input is 0, the public input with the same sequence number is taken for calculation;

[0009] The blockchain server sends the proof information, the parachain transaction and the serial number of the parachain transaction, the first transaction root hash and the block header information to the parachain;

[0010] The parachain node fills the transaction hash for the transaction into the first public input of the zero-knowledge proof circuit based on the parachain transaction and the serial number of the parachain transaction, sets the transaction variables other than the transaction variables corresponding to the serial number of the parachain transaction to zero, and performs verification based on the proof information;

[0011] The parachain node verifies the block match based on the block header information and the transaction root hash of the second public input.

[0012] In a second aspect, a computer device is provided, comprising one or more processors;

[0013] a memory for storing one or more programs,

[0014] When the one or more programs are executed by the one or more processors, the one or more processors execute the method as described in any one of the first aspects above.

[0015] According to a third aspect, a storage medium storing a computer program is provided, and when the program is executed by a processor, the method described in any one of the first aspects is implemented.

[0016] The beneficial effect of the present invention is that the transaction hash is used as the input information of the zero-knowledge proof, the zero-knowledge proof circuit calculates the transaction root hash, and other non-parallel chain transactions are compressed into a very small proof as private inputs, so that the parachain only gets the parachain transaction of interest and a proof, and can verify all transactions in the block at once. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 This is a schematic diagram of the structure of a computer device according to Embodiment 2 of the present invention. DETAILED DESCRIPTION

[0018] The present invention is further described in detail below in conjunction with specific embodiments and the accompanying drawings. A person of ordinary skill in the art will be able to implement the present invention based on these descriptions. In addition, the embodiments of the present invention involved in the following description are generally only embodiments of a part of the present invention, rather than all embodiments. Therefore, based on the embodiments of the present invention, all other embodiments obtained by a person of ordinary skill in the art without making creative work should fall within the scope of protection of the present invention.

[0019] Example 1

[0020] This embodiment provides a method for verifying parallel chain synchronous transactions. The blockchain system is configured with a zero-knowledge proof circuit based on transaction hash. The zero-knowledge proof circuit is configured with a first public input including multiple transaction variables, a private input including the same number of transaction variables as the first public input, and a second public input. The method is as follows:

[0021] The main chain node obtains all transactions in the block, sorts all transactions in the order of submission, and fills the transactions into the first public input and private input of the zero-knowledge proof circuit in sequence. If the transaction is a parallel chain transaction, the transaction hash of the transaction is filled into the transaction variable of the corresponding sequence number of the first public input, and the transaction variable of the corresponding sequence number of the private input is zero. If the transaction is other transactions, the transaction hash of the transaction is filled into the transaction variable of the corresponding sequence number of the private input, and the transaction variable of the corresponding sequence number of the first public input is zero. If there is no transaction with the sequence number corresponding to the first public input and the private input, the transaction variables of the first public input and the private input of the sequence number are both zero. The zero-knowledge proof circuit calculates the transaction root hash of all transactions based on the first public input and the private input to generate a first root hash, and fills the first transaction root into the second public input of the zero-knowledge proof circuit. The zero-knowledge proof circuit generates proof information based on the first public input, the second public input and the private input. The generated proof information is that the zero-knowledge proof circuit determines that if the transaction variable of the private input is 0, the public input with the same sequence number is taken for calculation;

[0022] The blockchain server sends the proof information, the parachain transaction and the serial number of the parachain transaction, the first transaction root hash and the block header information to the parachain;

[0023] The parachain node fills the transaction hash for the transaction into the first public input of the zero-knowledge proof circuit based on the parachain transaction and the serial number of the parachain transaction, sets the transaction variables other than the transaction variables corresponding to the serial number of the parachain transaction to zero, and performs verification based on the proof information;

[0024] The parachain node verifies the block match based on the block header information and the transaction root hash of the second public input.

[0025] The principle of this embodiment is to verify the parallel chain transaction information sent by the main chain based on zero-knowledge proof, and use the transaction hash as the input of the zero-knowledge proof, specifically the transaction hash of the parallel chain transaction as the public input, and other transactions as the private input. The root hash of the transaction is calculated through the zero-knowledge proof circuit and the proof information is generated. After the transaction is synchronized, the public input is generated again on the parallel chain side based on the parallel chain transaction and serial number sent by the main chain, and the transaction root hash is recalculated in the zero-knowledge proof circuit to generate the proof information. If the transaction root hash and proof information generated twice are compared and consistent, it means that all the parallel chain transactions of the transaction have not been tampered with. In this way, the parallel chain side only receives the parallel chain transactions that need to be synchronized, the corresponding serial numbers and proof information of the parallel chain transactions, the data volume of the message is greatly reduced, and all the parallel chain transactions can be verified at one time, which greatly improves the efficiency of verification. Finally, the calculated transaction root hash is verified to be consistent with the transaction root hash in the block header information to determine whether the transaction submitted by the block matches the verified transaction, so as to ensure the accuracy of the verification.

[0026] The following is an actual example. The blockchain system first presets a zero-knowledge proof circuit based on transaction hashes. All transaction hashes are input in order, and the root hash of all transaction hashes is calculated in the zero-knowledge proof circuit. Assuming that the capacity of a block is 3,000 transactions, the input of the zero-knowledge proof includes: (1) public input: 3,000 transaction variables, which are filled with 0 if there is no transaction; (2) public input: transaction root hash; (3) private input: 3,000 transaction variables, which are filled with 0 if there is no transaction. Among them, the transaction hash of the corresponding parallel chain transaction will be filled into the corresponding variable of the public input, and other transactions will be filled into the private input. At the same time, after the transaction hash of the parallel chain transaction is filled into the corresponding variable of the public input, the variable corresponding to the private transaction will be filled with zero, and vice versa. Therefore, the 3,000 transaction variables of the public input and private input are the 3,000 transactions in the corresponding block. When there are insufficient transactions, the public input and private input of the corresponding sequence number are both zero. The zero-knowledge proof circuit will calculate the transaction root hash of all transactions. The algorithm of this transaction root hash is consistent with the algorithm of calculating the transaction root hash of the block. The calculation of the root hash only requires the transaction hash value of all transactions. The public input and private input of the zero-knowledge proof circuit contain the transaction hash value of all transactions, so it can be calculated. The calculation method is the existing technology and will not be repeated. For example, a block has 5 transactions, of which 1, 2, and 3 are parallel chain A transactions, and 4 and 5 are other transactions.

[0027] Common input section

[0028] 1:paraTx1

[0029] 2:paraTx2

[0030] 3:paraTx3 4:0 5:0 6:0

[0034] …

[0035] Private input part: 1:0 2:0 3:0

[0039] 4:tx4

[0040] 5:tx5 6:0

[0042] …

[0043] When the zero-knowledge proof circuit calculates the root hash, if the private input is 0, the public input is used for calculation. This will generate a zero-knowledge proof. The proof is very small, only a few hundred bytes, and especially will not increase with the number of transactions. Then the blockchain server sends the proof information and the parallel chain transaction as well as the serial number of the parallel chain transaction, the transaction root hash and the block header information to the parallel chain. The parallel chain side uses the parallel chain transaction as the public input, and the other transaction inputs are 0, which are verified together with the proof information. If the verification passes, it means that there is no problem with the transaction hash. Then the parallel chain verifies whether the transaction root hash of the public input is consistent with the root hash of the transaction in the block contained in the block header information. If they are consistent, it means that the transaction and block match and the transaction can be trusted.

[0044] Example 2

[0045] A computer device, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the method described in Example 2.

[0046] A storage medium storing a computer program, which, when executed by a processor, implements the method described in the above embodiment 2.

[0047] Figure 1 A schematic diagram of the structure of a device provided in this embodiment.

[0048] like Figure 1 As shown, as another aspect, the present application also provides a computer device 500, including one or more central processing units (CPU) 501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 502 or the program loaded from the storage part 508 to the random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the device 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0049] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A driver 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the driver 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.

[0050] In particular, according to the embodiments disclosed in the present application, the method described in the above embodiment 1 can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program tangibly contained on a machine-readable medium, and the computer program includes a program code for executing the method described in any of the above embodiments. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 509, and / or installed from the removable medium 511.

[0051] As another aspect, the present application further provides a computer-readable storage medium, which may be a computer-readable storage medium included in the apparatus of the above embodiment; or a computer-readable storage medium that exists independently and is not assembled into the device. The computer-readable storage medium stores one or more programs, which are used by one or more processors to execute the method described in the present application.

[0052] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be realized by a dedicated hardware-based system that performs a specified function or operation, or can be realized by a combination of dedicated hardware and computer instructions.

[0053] The units or modules involved in the embodiments described in the present application may be implemented by software or by hardware. The units or modules described may also be arranged in a processor. For example, each of the units may be a software program arranged in a computer or a mobile smart device, or may be a separately configured hardware device. The names of these units or modules do not, in some cases, constitute limitations on the units or modules themselves.

[0054] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the concept of the present application. For example, the above features are replaced with the technical features with similar functions disclosed in the present application (but not limited to) to form a technical solution.

Claims

1. A method for verifying parallel chain synchronous transactions, characterized in that: The blockchain system is configured with a zero-knowledge proof circuit based on transaction hash, wherein the zero-knowledge proof circuit is configured with a first public input including multiple transaction variables, a private input including the same number of transaction variables as the first public input, and a second public input, wherein the method is as follows: the main chain node obtains all transactions in the block, sorts all transactions in the order of submission, and sequentially fills the transactions into the first public input and the private input of the zero-knowledge proof circuit, wherein if the transaction is a parallel chain transaction, the transaction hash of the transaction is filled into the transaction variable of the corresponding sequence number of the first public input, and the transaction variable of the corresponding sequence number of the private input is zero, and if the transaction is other transactions, the transaction hash of the transaction is filled into Among the transaction variables of the corresponding sequence number of the private input, the transaction variable of the corresponding sequence number of the first public input is zero. If there is no transaction with the sequence number corresponding to the first public input and the private input, the transaction variables of the first public input and the private input of the sequence number are both zero. The zero-knowledge proof circuit calculates the transaction root hash of all transactions based on the first public input and the private input to generate a first root hash, and fills the first root hash into the second public input of the zero-knowledge proof circuit. The zero-knowledge proof circuit generates proof information based on the first public input, the second public input and the private input. The generated proof information is that the zero-knowledge proof circuit determines that if the transaction variable of the private input is 0, the public input with the same sequence number is taken for calculation; The blockchain server sends the proof information, the parachain transaction, the serial number of the parachain transaction, the first root hash and the block header information to the parachain; The parachain node fills the transaction hash of the corresponding transaction into the first public input of the zero-knowledge proof circuit based on the parachain transaction and the serial number of the parachain transaction, sets the transaction variables other than the transaction variable corresponding to the serial number of the parachain transaction to zero, and performs verification based on the proof information; The parachain node verifies the block match based on the block header information and the transaction root hash of the second public input.

2. A computer device, characterized in that: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors are caused to perform the method as claimed in claim 1 .

3. A storage medium storing a computer program, characterized in that: When the program is executed by a processor, the method according to claim 1 is implemented.

Citation Information

Patent Citations

  • Privacy protection method and device used for anonymous cross-blockchain transaction, and storage medium

    CN107862216A

  • Parallel chain main chain transaction state synchronization method and device, and storage medium

    CN110084601A