A Method for Generating, Querying, and Verifying Index Information of Cross-Chain Transactions in Blockchain
By generating and storing index information of cross-chain transactions, the problem of incomplete transaction query in the cross-chain system is solved, complete transaction query and verification are realized, and query efficiency and reliability of results are improved.
Patent Information
- Application Number
- CN202310120348.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-15
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2043-02-15
AI Technical Summary
In a cross-chain system, users cannot obtain a complete cross-chain transaction circulation chain and cannot verify the authenticity of the transaction, resulting in incomplete query results.
It provides a method for generating index information for cross-chain transactions in blockchain. By obtaining historical index information and adjacent link lists, it generates the current index structure, and uses vector commitments and proofs for storage, supporting transaction query and verification.
It realizes complete query and result verification of cross-chain transactions, improves query efficiency and completeness of results, and ensures that users can obtain all relevant transactions and verify their authenticity.
Smart Images

Figure CN116804986B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of blockchain, and particularly relates to a method for generating, querying, and verifying index information of cross-chain transactions in a blockchain. Background Art
[0002] A blockchain is a decentralized ledger formed by linking several data blocks through hash pointers. Due to the hash algorithm and consensus protocol used in the blockchain, it has characteristics such as security, trustworthiness, and anti-tampering. Therefore, more people have started to pay attention to the capabilities of the blockchain in general applications. As a result, more blockchain platforms that support general applications (such as Ethereum) have emerged one after another. Nowadays, the blockchain has been more widely used as a distributed database in fields such as supply chain, finance, and healthcare.
[0003] However, the decentralized nature of the blockchain and the consensus algorithm it uses result in limited scalability of a single blockchain. Usually, multiple blockchains need to cooperate with each other to jointly support large-scale applications. Thus, cross-chain technologies that enable interconnection between blockchains have emerged to improve the interoperability and scalability between blockchains. The founder of Ethereum classified existing cross-chain technologies into three categories: notary mechanism, hash locking, and side chain / relay chain. No matter which solution is adopted, it focuses on the implementation of cross-chain logic, such as how to break the data silos between different chains and how to ensure the atomicity of cross-chain transactions. There is little work discussing the problems existing in cross-chain systems during retrieval. Specifically, when a user wants to query the complete transaction circulation chain in a cross-chain system, since the chain where the user is located may intentionally or unintentionally ignore the information that some transactions on this chain and transactions on other chains are a pair of cross-chain transactions, it is very likely that only all relevant transactions queried on this chain are returned to the user. After receiving these transactions, the user cannot know whether the obtained transaction circulation chain is complete. Moreover, since these transactions are obtained from the chain, there will be no abnormality when the user verifies their authenticity. This leads to the situation that when a user requests the complete circulation chain of a certain transaction in the entire cross-chain system, it is very likely that an incomplete result will be obtained and the user cannot know it. Summary of the Invention
[0004] In order to solve the above problems existing in the related technologies, the present invention provides a method for generating, querying, and verifying index information of cross-chain transactions in a blockchain. The technical problems to be solved by the present invention are realized through the following technical solutions:
[0005] The present invention provides a method for generating index information of cross-chain transactions in a blockchain, including:
[0006] When a pair of cross-chain transaction information between two ordinary chains is currently monitored, obtain historical index information, and obtain the acquisition result of the first historical entry of the linear list, the acquisition result of the proof of the first historical entry, and the acquisition result of the adjacency linked list; the pair of cross-chain transaction information includes: the first cross-chain transaction information and the second cross-chain transaction information with an associated relationship;
[0007] According to the first cross-chain transaction information, the second cross-chain transaction information, and the acquisition result of the first historical entry, determine the new first entry of the linear list, and obtain the current linear list including multiple first entries;
[0008] According to the current linear list and the acquisition result of the adjacency linked list, determine the new adjacency linked list of each first entry, and obtain the current adjacency linked list of each first entry including at least one second entry;
[0009] Store the current index structure composed of the current linear list and the current adjacency linked list;
[0010] Generate public parameters according to the number of the multiple first entries and preset parameters;
[0011] Generate a vector commitment of the current linear list according to the first public sub-parameter in the public parameters and the multiple first entries;
[0012] Generate a proof for each new first entry according to the multiple first entries, and the second public sub-parameter and the third public sub-parameter in the public parameters;
[0013] Store the vector commitment and the proof;
[0014] Obtain the current index information according to the acquisition result of the proof of the first historical entry, the current index structure, the vector commitment, and the proof; the current index information is used for querying transactions and verifying the obtained query results.
[0015] The present invention also provides a blockchain cross-chain transaction query method, including:
[0016] Receive a query request sent by the user terminal and including a hash value to be queried;
[0017] According to the hash value to be queried, determine the transaction to be queried and determine the first ordinary chain corresponding to the transaction to be queried; each transaction corresponds to a unique hash value;
[0018] Determine the first initial transaction in the transaction circulation chain of the first ordinary chain including the transaction to be queried; the transaction circulation chain is composed of one or at least two transactions with a sequential order, and each transaction is a cross-chain transaction or a non-cross-chain transaction;
[0019] When the first initial transaction belongs to a first entry in the current linear list generated according to the above claims 1-6, all second entries in the current adjacency list of this first entry are used as first entries to be queried;
[0020] For each first entry to be queried, a first cross-chain transaction to be queried and a first ordinary chain to be queried are obtained, and a second initial transaction in the transaction circulation chain of the first ordinary chain that includes the first cross-chain transaction to be queried is determined;
[0021] When the second initial transaction belongs to a first entry in the current linear list, all second entries in the current adjacency list of this first entry are used as second entries to be queried. After that, for each second entry to be queried, a second cross-chain transaction to be queried and a second ordinary chain to be queried are obtained, and a third initial transaction in the transaction circulation chain of the second ordinary chain that includes the second cross-chain transaction to be queried is determined. This cycle continues until the determined initial transaction does not belong to any first entry in the current linear list. Then, all the transaction circulation chains, the vector commitment in the current index information, and the proofs of each cross-chain transaction in the transaction circulation chain are used as query results and sent to the user terminal.
[0022] The present invention also provides a method for verifying cross-chain transactions in a blockchain, including:
[0023] Receiving a query result sent by a relay chain; the query result includes: a transaction circulation chain, a vector commitment, and proofs of each cross-chain transaction in the transaction circulation chain;
[0024] According to the number of cross-chain transactions in the transaction circulation chain and preset parameters, a fourth common sub-parameter is generated, as well as a fifth common sub-parameter and a sixth common sub-parameter for each cross-chain transaction;
[0025] For any cross-chain transaction in the transaction circulation chain, according to the fourth common sub-parameter, as well as the fifth common sub-parameter, the sixth common sub-parameter, and the proof of the any cross-chain transaction, a value to be verified for the any cross-chain transaction is determined;
[0026] When the vector commitment is equal to the value to be verified, an associated query request including the hash value of the any cross-chain transaction is sent to the relay chain;
[0027] Receiving a cross-chain transaction associated with the any cross-chain transaction returned by the relay chain in response to the associated query request;
[0028] When all cross-chain transactions associated with any one of the received cross-chain transactions exist in the transaction circulation chain, it is determined that the associated transactions of any one of the cross-chain transactions are complete; otherwise, the associated transactions of any one of the cross-chain transactions are incomplete.
[0029] When the associated transactions of all cross-chain transactions in the transaction circulation chain are complete, it is determined that the query result is complete.
[0030] When the associated transactions of one cross-chain transaction in the transaction circulation chain are incomplete, it is determined that the query result is incomplete.
[0031] The present invention has the following beneficial technical effects:
[0032] Through the provided method for generating index information of blockchain cross-chain transactions, on the one hand, all cross-chain transactions can be recorded, so that when querying transactions, all relevant transactions of a certain transaction on other chains can be quickly obtained, and thus searches can be conducted on all relevant chains, without missing a chain with relevant transactions, and complete query of transactions can be supported; on the other hand, by setting vector commitments and proofs for each cross-chain transaction, when the user obtains the query result, the integrity of the query result can be verified based on the vector commitments and each cross-chain transaction.
[0033] Through the provided method for querying blockchain cross-chain transactions, not only parallel retrieval of multiple ordinary chains can be supported, but also the complete circulation chain of a certain transaction can be queried, thereby improving the query efficiency and the integrity of the query result.
[0034] Through the provided method for verifying blockchain cross-chain transactions, when the user obtains the query result, the integrity of the query result can be verified.
[0035] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 FIG. is a flowchart of a method for generating index information of blockchain cross-chain transactions provided by an embodiment of the present invention;
[0037] Figure 2 FIG. is a schematic diagram of an exemplary index structure provided by an embodiment of the present invention;
[0038] Figure 3 FIG. is another schematic diagram of an exemplary index structure provided by an embodiment of the present invention;
[0039] Figure 4 FIG. is a flowchart of a method for querying blockchain cross-chain transactions provided by an embodiment of the present invention;
[0040] Figure 5Another schematic diagram of the index structure provided by the embodiments of the present invention;
[0041] Figure 6 A flowchart of a blockchain cross-chain transaction verification method provided by the embodiments of the present invention. Detailed implementation manners
[0042] The present invention will be further described in detail below with reference to specific embodiments, but the implementation manners of the present invention are not limited thereto.
[0043] In the description of the present invention, the terms "first" and "second" are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the present invention, "a plurality of" means two or more, unless otherwise specifically defined.
[0044] In the description of this specification, the descriptions with reference to the terms "an embodiment", "some embodiments", "example", "specific example", or "some examples", etc. mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine the different embodiments or examples described in this specification.
[0045] Although the present invention has been described herein in connection with various embodiments, however, in the process of implementing the claimed invention, those skilled in the art can understand and realize other variations of the disclosed embodiments by viewing the accompanying drawings, the disclosure content, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "one" does not exclude a plurality of situations. A single processor or other unit can implement several functions recited in the claims. Certain measures are recited in mutually different dependent claims, but this does not mean that these measures cannot be combined to produce good results.
[0046] Figure 1 is a flowchart of a method for generating index information of a blockchain cross-chain transaction provided by the embodiments of the present invention. As Figure 1 shown, the method includes the following steps:
[0047] S101. When a pair of cross-chain transaction information between two ordinary chains is currently monitored, obtain historical index information to obtain the acquisition result of the first historical entry of the linear list, the acquisition result of the proof of the first historical entry, and the acquisition result of the adjacency list; a pair of cross-chain transaction information includes: the first cross-chain transaction information and the second cross-chain transaction information with an associated relationship.
[0048] In the embodiments of the present invention, two blockchains can correspond to one relay chain, and the two blockchains corresponding to the relay chain can be called two ordinary chains.
[0049] Here, the first cross-chain transaction information may include the identifier of the first cross-chain transaction and the IP address of the ordinary chain corresponding to the first cross-chain transaction; the second cross-chain transaction information may include the identifier of the second cross-chain transaction and the IP address of the ordinary chain corresponding to the second cross-chain transaction. For example, the first cross-chain transaction information may be "Tx1: IP" chain1 ", and the second cross-chain transaction information may be "Tx2: IP" chain2 ".
[0050] Here, when the relay chain stores data, it stores each piece of data by creating a block. Thus, when the relay chain currently monitors a pair of cross-chain transaction information between two ordinary chains, it can obtain the stored historical index information from the previously created block, so as to obtain the acquisition result of the first historical entry of the linear list, the acquisition result of the proof of the first historical entry, and the acquisition result of the adjacency list of the first historical entry.
[0051] In some embodiments, when the relay chain monitors a pair of cross-chain transactions between two ordinary chains for the first time, it indicates that there is no historical index information currently. Therefore, there is no historical linear list containing the first historical entry, nor is there a historical adjacency list containing at least one second historical entry. Thus, the acquisition result of the first historical entry of the linear list is: the first historical entry is not obtained, the acquisition result of the proof of the first historical entry is: the proof of the first historical entry is not obtained, and the acquisition result of the adjacency list is: the adjacency list is not obtained.
[0052] In some embodiments, when the relay chain is not monitoring a pair of cross-chain transactions between two ordinary chains for the first time, it indicates that there is historical index information currently. Therefore, there is a historical linear list containing the first historical entry, and there is a historical adjacency list containing the second historical entry. Thus, the acquisition result of the first historical entry of the linear list is: the historical linear list containing the first historical entry is obtained, the acquisition result of the proof of the first historical entry is: the proof of each first historical entry is obtained, and the acquisition result of the adjacency list is: the historical adjacency list of each first historical entry is obtained.
[0053] S102. Determine the new first entry of the linear list based on the first cross-chain transaction information, the second cross-chain transaction information, and the acquisition result of the first historical entry, and obtain the current linear list containing multiple first entries.
[0054] In some embodiments, when the acquisition result of the first historical entry is: the historical linear list containing the first historical entry is not obtained, use the first cross-chain transaction information and the second cross-chain transaction information as two new first entries to obtain the current linear list.
[0055] For example, when the first cross-chain transaction information is "Tx1: IP chain1 ", the second cross-chain transaction information is "Tx2: IP chain2 ", and the historical linear list containing the first historical entry is not obtained, the generated current linear list is shown in Table 1:
[0056]
[0057]
[0058] Table 1
[0059] In some embodiments, when the acquisition result of the first historical entry is: the historical linear list containing the first historical entry is obtained, and when at least one of the first cross-chain transaction information and the second cross-chain transaction information is the first historical entry, use the information in the first cross-chain transaction information and the second cross-chain transaction information that is not the first historical entry as the new first entry of the historical linear list to obtain the current linear list.
[0060] For example, when the first cross-chain transaction information is "Tx2: IP chain2 ", the second cross-chain transaction information is "Tx3: IP chain3 ", and the obtained historical linear list containing the first historical entry is as shown in Table 1 above, the generated current linear list is shown in Table 2, where "Tx1: IP chain1 " and "Tx2: IP chain2 " are two first historical entries, and "Tx3: IP chain3 " is a new first entry.
[0061] <![CDATA[Tx1: IP chain1 > <![CDATA[Tx2: IP chain2 > <![CDATA[Tx3: IP chain3 >
[0062] Table 2
[0063] S103. Determine the new adjacency list for each first entry based on the current linear list and the acquisition result of the adjacency list, and obtain the current adjacency list for each first entry containing at least one second entry.
[0064] In some embodiments, when the obtained result of the adjacency list is: the historical adjacency list is not obtained, a new first entry in the current linear list is used as the new adjacency list of another new first entry, and the current adjacency list containing at least one second entry for each first entry is obtained.
[0065] For example, continuing with the above example, when the current linear list is Table 1 above, the generated current adjacency list is Figure 2 the linked list on the right in, where "Tx2: IP chain2 " is the current adjacency list of "Tx1: IP chain1 ", and "Tx1: IP chain1 " is the current adjacency list of "Tx2: IP chain2 ".
[0066] In some embodiments, when the obtained result of the adjacency list is: the historical adjacency lists of each historical first entry are obtained, for each new first entry, the first entries associated with the new first entry are screened from all the first entries included in the current linear list to obtain the first associated entries; the new first entry is used as the new adjacency list of each first associated entry, and each first associated entry is used as the new adjacency list of the new first entry; the historical second entries associated with the new first entry are screened from the historical adjacency lists of each first entry to obtain the second associated entries; the new first entry is used as the new adjacency list of the first entry of each second associated entry, and the current adjacency list containing at least one second entry for each first entry is obtained.
[0067] For example, continuing with the above example, when the current linear list is Table 2 above, the generated current adjacency list is Figure 3 the linked list on the right in, where, for the first entry "Tx1: IP chain1 " in the first row of the current linear list, "Tx2: IP chain2 " and "Tx3: IP chain3 " are the current adjacency lists of "Tx1: IP chain1 ", and, "Tx2: IP chain2 " and "Tx3: IP chain3 " are the two second entries.
[0068] S104. Store the current index structure composed of the current linear list and the current adjacency list.
[0069] Here, after each generation of the linear list and the adjacency list, the relay chain can recreate a block and store the generated linear list and adjacency list in the block body of the newly created block, so that when a pair of cross-chain transactions is monitored next time, the linear list and the adjacency list can be obtained from the block body of the block created this time.
[0070] S105. Generate common parameters according to the quantities of multiple first items and preset parameters.
[0071] In some embodiments, the preset parameters may include a first parameter k, a second parameter l, and a third parameter a. Based on this, the above S105 can be implemented through S1051 to S1055:
[0072] S1051. Determine a first intermediate parameter and a second intermediate parameter according to the first parameter.
[0073] Exemplarily, two bit random prime numbers p1 and p2 can be selected to obtain a first intermediate parameter p1 and a second intermediate parameter p2.
[0074] S1052. Determine a third common sub-parameter according to the first intermediate parameter and the second intermediate parameter.
[0075] Exemplarily, the product of p1 and p2 can be used as the third common sub-parameter to obtain a third common sub-parameter N = p1 × p2.
[0076] S1053. Determine a second common sub-parameter according to the first intermediate parameter, the second intermediate parameter, the quantities of multiple first items, and the second parameter.
[0077] Exemplarily, first, according to p1 and p2, v = (p1 - 1)(p2 - 1) can be obtained. When multiple first items are m1,..., m q and the quantity of multiple first items is q, then q(l + 1)-bit prime numbers e1, e2,... e q that are relatively prime to v can be selected, where e i is the second common sub-parameter of the i-th first item m i , and i is 1,..., q, indicating the row number of the first item m in the current linear list.
[0078] S1054. Determine a first common sub-parameter according to the second common sub-parameter and the third parameter.
[0079] Exemplarily, the first common sub-parameter of the i-th first item m i is S i , where
[0080] S1055. Take the third common sub-parameter, the third parameter, the first common sub-parameter, and the second common sub-parameter as the common parameters.
[0081] Exemplarily, the common parameters are (N, a, S1,..., S q , e1,..., e q ).
[0082] S106. Generate a vector commitment of the current linear list according to the first common sub-parameter in the common parameters and multiple first entries.
[0083] Here, according to each first entry and the first common sub-parameter of this first entry, the sub-vector commitment of this first entry can be obtained, and the product of the sub-vector commitments of all first entries in the current linear list is used as the vector commitment of the current linear list.
[0084] Exemplarily, the vector commitment where is the sub-vector commitment of the first entry m i .
[0085] In some embodiments, when a certain first entry m i in the current linear list is changed to m' i , the new vector commitment of this current linear list is The proof of the first entry m' is
[0086]
[0087] S107. Generate a proof for each newly added first entry according to multiple first entries, and the second common sub-parameter and the third common sub-parameter in the common parameters.
[0088] Here, for each newly added first entry, the root value can be determined according to the second common sub-parameter of this newly added first entry, multiple first entries, and the first common sub-parameter; perform a modulo operation on the third common sub-parameter according to the root value to obtain the proof of this first entry.
[0089] Exemplarily, the proof of the newly added first entry m z is where e z is the second common sub-parameter of m z , m j is the j-th first entry among q first entries, S j is the first common sub-parameter of m j , j is 1,..., q, and j ≠ z, z represents the row number of the newly added first entry m z in the current linear list, N is the third common sub-parameter, and mod represents the modulo operation.
[0090] S108. Store the vector commitment and the proof.
[0091] Here, after the relay chain generates the vector commitment C of each linear list and the proof θ of each newly added first entry, the vector commitment C and the proof θ of each newly added first entry can be stored in the block header of the block where the linear list generated this time is located. That is, after the relay chain generates a linear list and an adjacency list each time, it can recreate a block, store the linear list and the adjacency list generated this time in the block body of the newly created block, and store the vector commitment of the linear list generated this time and the proof of the newly added first entry in the block header of the newly created block.
[0092] S109. Obtain the current index information based on the acquisition result of the proof of the historical first entry, the current index structure, the vector commitment, and the proof; the current index information is used for querying transactions and verifying the obtained query results.
[0093] In the embodiments of the present invention, through the provided method for generating index information for cross-chain transactions of a blockchain, on the one hand, all cross-chain transactions can be recorded, so that when querying transactions, all relevant transactions of a certain transaction on other chains can be quickly obtained, and thus searches can be made on all relevant chains, without missing a chain with relevant transactions, and complete query of transactions can be supported; on the other hand, by setting the vector commitment and the proof of each cross-chain transaction, the integrity of the query result can be verified according to the vector commitment and each cross-chain transaction when the user obtains the query result.
[0094] As Figure 4 shown, the embodiments of the present invention also provide a method for querying cross-chain transactions of a blockchain, and the method includes:
[0095] S201. Receive a query request sent by the user terminal and containing the hash value to be queried.
[0096] Here, when a user on a certain ordinary chain needs to initiate a query for the traceability information of a certain transaction to the ordinary chain or the relay chain, the user terminal carries the hash value of the transaction in the query request and sends it to the ordinary chain or the relay chain.
[0097] Here, the transaction corresponding to the hash value to be queried can be a cross-chain transaction or a non-cross-chain transaction.
[0098] S202. Determine the transaction to be queried according to the hash value to be queried, and determine the first ordinary chain corresponding to the transaction to be queried; each transaction corresponds to a unique hash value.
[0099] Here, the transaction uniquely corresponding to the hash value to be queried can be used as the transaction to be queried, and then the ordinary chain (the first ordinary chain) corresponding to the transaction to be queried is determined.
[0100] S203. Determine the first initial transaction in the transaction circulation chain of the first ordinary chain that contains the transaction to be queried; the transaction circulation chain consists of one or at least two transactions in sequence, and each transaction is a cross-chain transaction or a non-cross-chain transaction.
[0101] Here, the first ordinary chain includes at least one transaction circulation chain, and each transaction circulation chain consists of one or at least two transactions in sequence.
[0102] For example, "Tx1→Tx2→Tx3" is a transaction circulation chain that contains 3 transactions in sequence, and Tx1 is the initial transaction of this transaction circulation chain.
[0103] S204. When the first initial transaction belongs to one of the first entries in the current linear list generated according to the above method, all the second entries in the current adjacent linked list of this first entry are used as the first entries to be queried.
[0104] Here, when the first initial transaction is obtained, the first initial transaction can be searched for in the current linear list. When the first initial transaction belongs to a certain first entry in the current linear list, for example, the first entry A, all the second entries in the current adjacent linked list corresponding to the first entry A are used as the first entries to be queried.
[0105] For example, when the current linear list is Figure 5 in the linear list, and the first initial transaction is "Tx1", since "Tx1" belongs to Figure 5 the first entry "Tx1: IP chain1 " in the first row of the linear list, and all the second entries in the current adjacent linked list of "Tx1: IP chain1 " are "Tx2: IP chain2 " and "Tx3: IP chain3 ", so "Tx2: IP chain2 " and "Tx3: IP chain3 " are two first entries to be queried.
[0106] S205. Obtain a first cross-chain transaction to be queried and a first ordinary chain to be queried according to each first entry to be queried, and determine the second initial transaction in the transaction circulation chain of the first ordinary chain to be queried that contains the first cross-chain transaction to be queried.
[0107] For example, continuing with the above example, when "Tx2: IP chain2 " and "Tx3: IP chain3 " are two first entries to be queried, for "Tx2: IP chain2”, it can be determined that “Tx2” is the first cross-chain transaction to be queried, and “IP chain2 ” is the first ordinary chain to be queried. Therefore, from the transaction circulation chain of the first ordinary chain “IP chain2 ”, the transaction circulation chain containing “Tx2” can be determined. Then, the initial transaction in the transaction circulation chain containing “Tx2” is used as the second initial transaction. For “Tx3: IP chain3 ”, a second initial transaction can also be determined in the same way.
[0108] Here, according to the two first items to be queried, “Tx2: IP chain2 ” and “Tx3: IP chain3 ”, when searching for the second initial transaction, parallel search can be performed, which can improve the search efficiency.
[0109] S206. When the second initial transaction belongs to a first item in the current linear list, all the second items in the current adjacency linked list of this first item are used as the second items to be queried. Then, continue to obtain a second cross-chain transaction to be queried and a second ordinary chain to be queried according to each second item to be queried, and determine the third initial transaction in the transaction circulation chain of the second ordinary chain that contains the second cross-chain transaction to be queried. Repeat this process until the determined initial transaction does not belong to any first item in the current linear list. At this time, all the transaction circulation chains, the vector commitment in the current index information, and the proofs of each cross-chain transaction in the transaction circulation chain are used as the query results and sent to the client.
[0110] For example, continuing with the above example, when the determined second initial transaction is “Tx4” and the current linear list is Figure 5 the linear list in, it can be continued to determine whether “Tx4” belongs to a first item in the current linear list. As Figure 5 shown, obviously “Tx4” belongs to the first item “Tx4: IP chain4 ”. At this time, all the second items in the current adjacency linked list of “Tx4: IP chain4 ” can be used as the second items to be queried. According to Figure 5 it is known that “Tx5: IP chain5 ” is the second item to be queried. The second cross-chain transaction to be queried obtained according to the second item to be queried “Tx5: IP chain5 ” is “Tx5”, and the second ordinary chain to be queried is “IP chain5 ”. Therefore, from the transaction circulation chain of the second ordinary chain “IP chain5 ”, the transaction circulation chain containing “Tx5” can be determined. Then, the initial transaction in the transaction circulation chain containing “Tx5” is used as the third initial transaction.
[0111] For example, continuing with the above example, when the third initial transaction is "Tx7" and the current linear list is Figure 5 the linear list shown, since "Tx7" does not belong to Figure 5 any of the first entries in the shown linear list, the query ends. At this time, all the transaction circulation chains queried above, that is, the transaction circulation chain including the first initial transaction "Tx1", the transaction circulation chain including "Tx2", the transaction circulation chain including "Tx3", and the transaction circulation chain including "Tx5", can be used as the transaction circulation chains to be sent to the client.
[0112] Here, after obtaining the transaction circulation chains to be sent to the client, the relay chain can find the vector commitment of the current linear list from the currently newly created block, and find the proofs of each cross-chain transaction in the transaction circulation chains to be sent to the client, and send the transaction circulation chains, vector commitment, and proofs to the client together as the query result.
[0113] Here, the relay chain will also include the row number (which row) of each cross-chain transaction in the current linear list in the query result, so as to facilitate the client to verify the query result later.
[0114] In some embodiments, after S206, it further includes:
[0115] S207. Receive an associated query request including a hash value sent by the client.
[0116] S208. Determine the cross-chain transaction to be queried according to the hash value.
[0117] S209. When the cross-chain transaction to be queried belongs to a first entry in the current linear list, use all the cross-chain transactions corresponding to the second entries in the current adjacency list of this first entry as the cross-chain transactions having an associated relationship with the cross-chain transaction to be queried, and return them to the client.
[0118] In the embodiments of the present invention, through the provided blockchain cross-chain transaction query method, it can not only support parallel retrieval of multiple ordinary chains, but also query the complete circulation chain of a certain transaction, thereby improving the query efficiency and the integrity of the query result.
[0119] As Figure 6 shown, the embodiments of the present invention also provide a blockchain cross-chain transaction verification method, and the method includes:
[0120] S301. Receive the query result sent by the relay chain; the query result includes: transaction circulation chains, vector commitment, and proofs of each cross-chain transaction in the transaction circulation chains.
[0121] Here, the query result also includes the row number (which row) of each cross-chain transaction in the transaction circulation chain in the current linear list.
[0122] S302. Generate a fourth common sub-parameter, as well as a fifth common sub-parameter and a sixth common sub-parameter for each cross-chain transaction, according to the number of cross-chain transactions in the transaction circulation chain and preset parameters.
[0123] Here, the preset parameters can also include a first parameter k, a second parameter l, and a third parameter a. The user side can select two bit random prime numbers p1 and p2 according to the first parameter k, so as to obtain a third intermediate parameter p1 and a fourth intermediate parameter p2. According to N = p1×p2, obtain the fourth common sub-parameter N, and according to v = (p1 - 1)(p2 - 1), obtain v. From the row numbers of the cross-chain transactions included in the query result in the current linear list, determine the maximum row number q'. Then, according to q' and l, select q'(l + 1) bit prime numbers e1, e2,..., e q' , according to the row number x of each cross-chain transaction in the current linear list, select the corresponding e q' from e1, e2,..., e x as the fifth common sub-parameter of the cross-chain transaction, where x is an integer from 1 to q'. For example, when the row number of a certain cross-chain proof in the current linear list is 2, e2 is the fifth common sub-parameter of the cross-chain transaction. According to the third parameter a and e1, e2,..., e q' , calculate the sixth common sub-parameter of each cross-chain transaction
[0124] S303. For any cross-chain transaction in the transaction circulation chain, determine the value to be verified for any cross-chain transaction according to the fourth common sub-parameter, as well as the fifth common sub-parameter, the sixth common sub-parameter and the proof of any cross-chain transaction.
[0125] Here, for any cross-chain transaction in the transaction circulation chain, the product value can be determined according to the fifth common sub-parameter, the sixth common sub-parameter and the proof of the cross-chain transaction; perform a modulo operation on the fourth common sub-parameter according to the product value to obtain the value to be verified for any cross-chain transaction.
[0126] Exemplarily, for any cross-chain transaction m x , the value to be verified is where, S x is the sixth common sub-parameter of cross-chain transaction m x , e x is the fifth common sub-parameter of cross-chain transaction m x , θ x is the sixth common sub-parameter of cross-chain transaction m xProof, is the product value, and N is the fourth common subparameter.
[0127] S304. When the vector commitment is equal to the value to be verified, send an associated query request containing the hash value of any cross-chain transaction to the relay chain.
[0128] For example, when it can output 1, indicating that the cross-chain transaction m is included in the index structure x , that is, the cross-chain transaction m x has an associated transaction on other chains. At this time, the client can generate an associated query request containing the hash value according to the uniquely corresponding hash value of the cross-chain transaction m x and send it to the relay chain. The relay chain can query the cross-chain transactions associated with the cross-chain transaction m x by executing the above steps S207 - S209, and send the cross-chain transactions associated with the cross-chain transaction m x to the client. When it outputs 0, indicating that the cross-chain transaction m x has no associated transaction on other chains. At this time, the client does not need to send an associated query request to the relay chain.
[0129] Here, when the value to be verified corresponding to each cross-chain transaction in the transaction circulation chain is not equal to the vector commitment, it indicates that the query result is complete and the following S305 - S308 do not need to be executed; otherwise, the following S305 - S308 need to be executed.
[0130] S305. Receive the cross-chain transactions associated with any cross-chain transaction returned by the relay chain for the associated query request.
[0131] S306. When all the cross-chain transactions associated with any cross-chain transaction received exist in the transaction circulation chain, determine that the associated transactions of any cross-chain transaction are complete; otherwise, the associated transactions of any cross-chain transaction are incomplete.
[0132] Here, after the client receives the cross-chain transactions associated with the cross-chain transaction m x , it can search for the cross-chain transactions associated with the cross-chain transaction m x from all the received transaction circulation chains. If all the cross-chain transactions associated with the cross-chain transaction m x exist in all the received transaction circulation chains, it indicates that the associated transactions of the cross-chain transaction m x are complete; otherwise, it indicates that the associated transactions of the cross-chain transaction m x are incomplete.
[0133] S307. When all the associated transactions of all cross-chain transactions in the transaction circulation chain are complete, it is determined that the query result is complete.
[0134] S308. When the associated transaction of one cross-chain transaction in the transaction circulation chain is incomplete, it is determined that the query result is incomplete.
[0135] In the embodiment of the present invention, through the provided blockchain cross-chain transaction verification method, the integrity of the query result can be verified when the user obtains the query result.
[0136] Through the above method, the present invention provides an index structure to store the associated cross-chain transactions, which is maintained on the relay chain. In this way, users can quickly obtain all the relevant transactions of a certain transaction on other chains, so as to search on all relevant chains and will not miss a chain with relevant transactions to achieve a complete query. The present invention generates a proof for the entries in the index through a type of accumulator - vector commitment and stores it in the relay chain block header. Users can verify whether the query result is complete through this proof. The index structure designed by the present invention supports parallel retrieval of multiple chains, which greatly improves the retrieval efficiency.
[0137] The above content is a further detailed description of the present invention in combination with specific preferred embodiments. It cannot be determined that the specific implementation of the present invention is only limited to these descriptions. For those of ordinary skill in the technical field to which the present invention belongs, without departing from the concept of the present invention, several simple deductions or substitutions can still be made, which should all be regarded as belonging to the protection scope of the present invention.
Claims
1. A method for generating index information of cross-chain transactions in a blockchain, characterized in that, Including: When a pair of cross-chain transaction information between two ordinary chains is currently monitored, obtain historical index information, and obtain the acquisition result of the first historical entry of the linear list, the acquisition result of the proof of the first historical entry, and the acquisition result of the adjacency list; The pair of cross-chain transaction information includes: the first cross-chain transaction information and the second cross-chain transaction information with an associated relationship; According to the first cross-chain transaction information, the second cross-chain transaction information, and the acquisition result of the first historical entry, determine the new first entry of the linear list, and obtain the current linear list including multiple first entries; According to the current linear list and the acquisition result of the adjacency list, determine the new adjacency list of each first entry, and obtain the current adjacency list of each first entry including at least one second entry; Store the current index structure composed of the current linear list and the current adjacency list; Generate common parameters according to the number of the multiple first entries and preset parameters; Generate a vector commitment of the current linear list according to the first common sub-parameter in the common parameters and the multiple first entries; Generate a proof for each new first entry according to the multiple first entries, and the second common sub-parameter and the third common sub-parameter in the common parameters; Store the vector commitment and the proof; Obtain the current index information according to the acquisition result of the proof of the first historical entry, the current index structure, the vector commitment, and the proof; the current index information is used for querying transactions and verifying the obtained query results.
2. The method for generating index information of cross-chain transactions in a blockchain according to claim 1, wherein The acquisition result of the first historical entry includes: not obtaining the historical linear list including the first historical entry; the acquisition result of the adjacency list includes: not obtaining the historical adjacency list; the determining the new first entry of the linear list according to the first cross-chain transaction information, the second cross-chain transaction information, and the acquisition result of the first historical entry, and obtaining the current linear list including multiple first entries includes: Use the first cross-chain transaction information and the second cross-chain transaction information as two new first entries to obtain the current linear list; The determining the new adjacency list of each first entry according to the current linear list and the acquisition result of the adjacency list, and obtaining the current adjacency list of each first entry including at least one second entry includes: Use one new first entry in the current linear list as the new adjacency list of another new first entry to obtain the current adjacency list of each first entry including at least one second entry.
3. The method for generating index information of blockchain cross-chain transactions according to claim 1, wherein The acquisition result of the first historical entry includes: obtaining the historical linear list including the first historical entry; the acquisition result of the adjacency list includes: obtaining the historical adjacency list of each first historical entry, and the historical adjacency list includes at least one historical second entry; the determining the new first entry of the linear list according to the first cross-chain transaction information, the second cross-chain transaction information, and the acquisition result of the first historical entry, and obtaining the current linear list including multiple first entries includes: When at least one of the first cross-chain transaction information and the second cross-chain transaction information is the first entry in the history, use the information in the first cross-chain transaction information and the second cross-chain transaction information that is not the first entry in the history as the new first entry in the historical linear list to obtain the current linear list; The obtaining the current adjacency list including at least one second entry for each first entry according to the obtained results of the current linear list and the adjacency list includes: For each newly added first entry, screen the first entries associated with the newly added first entry from the multiple first entries to obtain the first associated entries; Use the newly added first entry as the newly added adjacency list of each first associated entry, and use each first associated entry as the newly added adjacency list of the newly added first entry; Screen the historical second entries associated with the newly added first entry from the historical adjacency list of each first entry to obtain the second associated entries; Use the newly added first entry as the newly added adjacency list of the first entry of each second associated entry to obtain the current adjacency list including at least one second entry for each first entry.
4. The method for generating index information of blockchain cross-chain transactions according to claim 1, wherein The preset parameters include: a first parameter, a second parameter, and a third parameter; the generating the common parameters according to the number of the multiple first entries and the preset parameters includes: Determine a first intermediate parameter and a second intermediate parameter according to the first parameter; Determine the third common sub-parameter according to the first intermediate parameter and the second intermediate parameter; Determine the second common sub-parameter according to the first intermediate parameter, the second intermediate parameter, the number of the multiple first entries, and the second parameter; Determine the first common sub-parameter according to the second common sub-parameter and the third parameter; Use the third common sub-parameter, the third parameter, the first common sub-parameter, and the second common sub-parameter as the common parameters.
5. The method for generating index information of blockchain cross-chain transactions according to claim 1 or 4, characterized in that, The generating the vector commitment of the current linear list according to the first common sub-parameter in the common parameters and the multiple first entries includes: Obtain the sub-vector commitment of each first entry according to each first entry and the first common sub-parameter of the first entry; Use the product of the sub-vector commitments of all the first entries in the current linear list as the vector commitment of the current linear list.
6. The method for generating index information of blockchain cross-chain transactions according to claim 1 or 4, characterized in that, Generate the proof for each newly added first entry according to the multiple first entries and the second common sub-parameter and the third common sub-parameter in the common parameters, including: For each newly added first entry, determine the root value according to the second common sub-parameter of the newly added first entry, the multiple first entries, and the first common sub-parameter; Perform a modulo operation on the third common sub-parameter according to the root value to obtain the proof of the first entry.
7. A method for querying cross-chain transactions in a blockchain, characterized in that, including: Receive a query request sent by the client including the hash value to be queried; Determine the transaction to be queried according to the hash value to be queried, and determine the first ordinary chain corresponding to the transaction to be queried; each transaction corresponds to a unique hash value; Determine the first initial transaction in the transaction circulation chain of the first ordinary chain that contains the transaction to be queried; the transaction circulation chain is composed of one or at least two transactions with a sequential order, and each transaction is a cross-chain transaction or a non-cross-chain transaction; When the first initial transaction belongs to one of the first entries in the current linear list generated according to the above claims 1 to 6, all the second entries in the current adjacent linked list of this first entry are used as the first entries to be queried; According to each first entry to be queried, obtain a first cross-chain transaction to be queried and a first ordinary chain to be queried, and determine the second initial transaction in the transaction circulation chain of the first ordinary chain to be queried that contains the first cross-chain transaction to be queried; When the second initial transaction belongs to one of the first entries in the current linear list, all the second entries in the current adjacent linked list of this first entry are used as the second entries to be queried. After that, continue to obtain a second cross-chain transaction to be queried and a second ordinary chain to be queried according to each second entry to be queried, and determine the third initial transaction in the transaction circulation chain of the second ordinary chain to be queried that contains the second cross-chain transaction to be queried. Loop like this until the determined initial transaction does not belong to any of the first entries in the current linear list. Then, all the transaction circulation chains queried, the vector commitment in the current index information, and the proofs of each cross-chain transaction in the transaction circulation chain are used as the query results and sent to the client.
8. The blockchain cross-chain transaction query method according to claim 7, wherein The method further includes: Receive an associated query request containing a hash value sent by the client; According to the hash value, determine the cross-chain transaction to be queried; When the cross-chain transaction to be queried belongs to one of the first entries in the current linear list, the cross-chain transactions corresponding to all the second entries in the current adjacent linked list of this first entry are used as the cross-chain transactions having an associated relationship with the cross-chain transaction to be queried and returned to the client.
9. A blockchain cross-chain transaction verification method, characterized in that, It includes: Receive the query result sent by the relay chain; The query result includes: a transaction circulation chain, a vector commitment, and the proof of each cross-chain transaction in the transaction circulation chain; According to the number of cross-chain transactions in the transaction circulation chain and preset parameters, generate a fourth common sub-parameter, as well as a fifth common sub-parameter and a sixth common sub-parameter for each cross-chain transaction; For any cross-chain transaction in the transaction circulation chain, according to the fourth common sub-parameter, as well as the fifth common sub-parameter, the sixth common sub-parameter and the proof of the any cross-chain transaction, determine the value to be verified of the any cross-chain transaction; When the vector commitment is equal to the value to be verified, send an associated query request containing the hash value of the any cross-chain transaction to the relay chain; Receive the cross-chain transaction having an associated relationship with the any cross-chain transaction returned by the relay chain in response to the associated query request; When all the cross-chain transactions having an associated relationship with the any cross-chain transaction received exist in the transaction circulation chain, determine that the associated transaction of the any cross-chain transaction is complete; otherwise, the associated transaction of the any cross-chain transaction is incomplete; When all the associated transactions of the cross-chain transactions in the transaction circulation chain are complete, it is determined that the query result is complete; When there is an incomplete associated transaction of a cross-chain transaction in the transaction circulation chain, it is determined that the query result is incomplete.
10. The blockchain cross-chain transaction verification method according to claim 9, wherein The determining of the value to be verified of any one cross-chain transaction according to the fourth common sub-parameter, the fifth common sub-parameter, the sixth common sub-parameter, and the proof of any one cross-chain transaction includes: For any one cross-chain transaction in the transaction circulation chain, a product value is determined according to the fifth common sub-parameter, the sixth common sub-parameter, and the proof of any one cross-chain transaction; A modulo operation is performed on the fourth common sub-parameter according to the product value to obtain the value to be verified of any one cross-chain transaction.