A transaction security protection method and device based on a double-layer block chain structure
By using a two-layer blockchain structure of aggregated chain and sharded chain management, the problems of low efficiency and insufficient security in the management of terminal equipment in smart grids are solved, and efficient and secure data transactions are realized.
Patent Information
- Application Number
- CN202411456228.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2044-10-18
AI Technical Summary
In smart grids, power companies find it difficult to manage a large number of terminal devices, resulting in low management efficiency. In addition, the centralized management method of the blockchain's central nodes lacks security protection during data transactions, which hinders the stable and efficient development of smart grids.
It adopts a two-layer blockchain structure, including a central chain and multiple independently operating shard chains. The central chain centrally manages the shard chains, the shard chains enhance the scalability of the blockchain, and the integrity and security of data transactions are ensured by verifying the correctness and security of blocks.
It improves the management efficiency of smart grids, raises the configuration requirements of terminal equipment, ensures the correctness, integrity and security of data transactions between sharded chains, and prevents the behavior of malicious nodes.
Smart Images

Figure CN119603319B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of smart grid technology, and in particular to a transaction security protection method and device based on a double-layer blockchain structure. Background Art
[0002] Smart grids are the evolution of traditional power grids. This concept, which involves communications technologies, new power systems, and various advanced metering, control, and management systems, can be used to improve the utilization and efficiency of renewable energy. However, with the increasing number of terminal devices connected to the grid, power companies are struggling to manage the large number of nodes, resulting in low management efficiency. Furthermore, power companies' reliance on centralized management via blockchain-based central nodes is prone to insufficient security protection during data transactions, hindering the stable and efficient development of smart grids. Summary of the Invention
[0003] The present application provides a transaction security protection method and device based on a double-layer blockchain structure to solve one or more technical problems existing in the prior art and at least provide a beneficial option or create conditions.
[0004] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by practice of the present application.
[0005] According to one aspect of an embodiment of the present application, a transaction security protection method based on a two-layer blockchain structure is provided. The two-layer blockchain structure includes an aggregation chain and multiple independently running shard chains. The aggregation chain stores the ledger data of each shard chain. The method is executed on the aggregation chain, and the method includes:
[0006] Receiving a first consensus result sent from the first target shard chain, where the first consensus result includes a block and account transaction data bound to the block, where the block carries identification information for verification;
[0007] Performing a correctness check on the block based on the identification information to obtain a first verification result of the block;
[0008] Performing security verification on the block based on the account transaction data and the ledger data to obtain a second verification result of the block;
[0009] If both the first verification result and the second verification result are correct, generating a second consensus result corresponding to the first consensus result, the second consensus result including the verified block and the account transaction data;
[0010] Send the second consensus result to the second target shard chain so that the second target shard chain executes the target transaction operation according to the second consensus result.
[0011] In one embodiment of the present application, based on the aforementioned solution, the identification information is a transaction root for identification, and the correctness verification of the block based on the identification information to obtain a first verification result of the block includes:
[0012] Comparing the hash value of the transaction root with a preset reference hash value;
[0013] If the hash value of the transaction root is consistent with the reference hash value, determining that the first verification result is correct;
[0014] If the hash value of the transaction root is inconsistent with the reference hash value, the first verification result is determined to be incorrect.
[0015] In one embodiment of the present application, based on the aforementioned solution, the account transaction data includes the account transaction deduction amount and account balance of the target node associated with the block in the first target shard chain, and the ledger data includes the account balance data of each node in each of the shard chains; the security verification of the block based on the account transaction data and the ledger data to obtain the second verification result of the block includes:
[0016] Determine the total account balance of the target node before the transaction based on the sum of the account transaction deduction amount and the account balance;
[0017] Comparing the total account balance with the target account balance data corresponding to the target node in the ledger data, and if the comparison is consistent, determining that the second verification result is correct;
[0018] If the comparison is inconsistent, the second verification result is determined to be wrong.
[0019] In one embodiment of the present application, based on the above solution, the method further includes:
[0020] Obtaining the historical reputation value of the target node corresponding to the block;
[0021] Calculating the reputation value of the target node after the correctness check and the security verification based on a preset reputation value calculation formula, a positive evaluation index, and a negative evaluation index;
[0022] The positive evaluation indicator and the negative evaluation indicator are both related to the first verification result and the second verification result.
[0023] In one embodiment of the present application, based on the aforementioned solution, after calculating the reputation value of the target node after the correctness check and the security verification, the method further includes:
[0024] If the reputation value is lower than the preset reputation reference value, the target node is determined to be a risky node, and risk warning information corresponding to the risky node is sent to the first target shard chain, so that the master node in the first target shard chain can isolate the risky node according to the risk warning information.
[0025] According to one aspect of an embodiment of the present application, a transaction security protection device based on a two-layer blockchain structure is further provided. The two-layer blockchain structure includes a polymer chain and multiple independently running shard chains. The polymer chain stores the ledger data of each shard chain. The device is applied to the polymer chain and includes:
[0026] A receiving unit, configured to receive a first consensus result sent from a first target shard chain, wherein the first consensus result includes a block and account transaction data bound to the block, and the block carries identification information for verification;
[0027] a verification unit, configured to perform a correctness verification on the block based on the identification information to obtain a first verification result of the block;
[0028] a verification unit, configured to perform security verification on the block based on the account transaction data and the ledger data, and obtain a second verification result of the block;
[0029] a consensus unit, configured to generate a second consensus result corresponding to the first consensus result when both the first verification result and the second verification result are correct, the second consensus result including the verified block and the account transaction data;
[0030] A sending unit is configured to send the second consensus result to a second target shard chain, so that the second target shard chain executes a target transaction operation according to the second consensus result.
[0031] According to one aspect of an embodiment of the present application, a transaction security protection method based on a two-layer blockchain structure is also provided. The two-layer blockchain structure includes an aggregate chain and multiple independently running shard chains, and the aggregate chain stores the ledger data of each shard chain. The method is executed on a first target shard chain, and the method includes:
[0032] If transaction operation information is received from the target node, a corresponding block and the account transaction data of the target node bound to the block are generated based on the transaction operation information;
[0033] If a first consensus result generated by the master node in the first target shard chain is obtained, the first consensus result is sent to the aggregation chain so that the aggregation chain can perform correctness verification and security verification on the block and the account transaction data in the first consensus result based on the ledger data;
[0034] Among them, when the verification results of the correctness check and the security verification are both correct, the aggregation chain can generate a second consensus result and send the second consensus result to the second target shard chain, so that the second target shard chain executes the target transaction operation corresponding to the transaction operation information according to the second consensus result.
[0035] In one embodiment of the present application, based on the above solution, the first consensus result is generated by the following steps:
[0036] Obtaining the consensus verification results of each node in the first target shard chain. If more than two-thirds of the consensus verification results are correct, the master node generates a first consensus result containing the block and the account transaction data.
[0037] The consensus verification result is generated by the node performing legitimacy verification on the block and the account transaction data.
[0038] In one embodiment of the present application, based on the above solution, the method further includes:
[0039] Obtain node status data of each node in the first target shard chain, and determine the reputation value of each node based on each node status data, wherein the reputation value is used to indicate whether the node has a malicious behavior risk;
[0040] Determining nodes to be determined that have a risk of malicious behavior based on the reputation value;
[0041] If the risk warning information sent by the aggregation chain is received, the corresponding risk node is determined according to the risk warning information;
[0042] A target risk node belonging to the risk node is found in each of the nodes to be determined, and the target risk node is isolated.
[0043] According to one aspect of an embodiment of the present application, a transaction security protection device based on a two-layer blockchain structure is provided. The two-layer blockchain structure includes an aggregate chain and multiple independently running shard chains. The aggregate chain stores the ledger data of each shard chain. The device is applied to a first target shard chain and includes:
[0044] a generating unit configured to, upon receiving transaction operation information sent by a target node, generate a corresponding block and account transaction data of the target node bound to the block based on the transaction operation information;
[0045] a transmission unit configured to, upon obtaining a first consensus result generated by the master node in the first target shard chain, send the first consensus result to the aggregation chain, so that the aggregation chain can perform correctness and security verification on the block and the account transaction data in the first consensus result based on the ledger data;
[0046] Among them, when the verification results of the correctness check and the security verification are both correct, the aggregation chain can generate a second consensus result and send the second consensus result to the second target shard chain, so that the second target shard chain executes the target transaction operation corresponding to the transaction operation information according to the second consensus result.
[0047] The beneficial effects of the present application are as follows: the present application proposes a two-layer blockchain structure, wherein the two-layer blockchain structure includes an aggregation chain and multiple independently running shard chains. Through the overall management of the aggregation chain, the aggregation chain centrally manages each independently running shard chain, and the shard chain can be used to improve the scalability of the blockchain, reducing the configuration requirements of terminal equipment in the smart grid; the aggregation chain can also be used to manage global power data, grasp the overall operation of the smart grid, and improve management efficiency.
[0048] Furthermore, based on the two-layer blockchain structure, a transaction security protection method is proposed. First, the first consensus result sent by the first target shard chain is checked for correctness and security verification, wherein the correctness verification is used to verify the integrity and correctness of the block in the first consensus result, and the account transaction data corresponding to the block is compared with the ledger data stored in the aggregation chain, that is, security verification, to check whether there are data errors in the account transaction data. After the correctness verification and security verification are passed, the second consensus result generated by the aggregation chain can be sent to the second target shard chain, so that the second target shard chain executes the target transaction operation according to the second consensus result. In this way, the data transaction between the shard chains is completed. This transaction security protection method can ensure that the data transaction between the shard chains is correct, complete and secure. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] To more clearly illustrate the technical solutions in the embodiments of this application, the following briefly describes the drawings required for describing the embodiments. Obviously, the drawings described are only part of the embodiments of this application, not all of them. Those skilled in the art can also derive other design solutions and drawings based on these drawings without inventive effort.
[0050] Figure 1 This is a flowchart of a transaction security protection method based on a double-layer blockchain structure according to an embodiment of the present application;
[0051] Figure 2 This is an overall block diagram of a double-layer blockchain structure according to an embodiment of the present application;
[0052] Figure 3 A logical block diagram of hash value verification according to an embodiment of the present application;
[0053] Figure 4 1 is a structural block diagram of a transaction security protection device based on a double-layer blockchain structure according to an embodiment of the present application;
[0054] Figure 5 This is another flow chart of a transaction security protection method based on a double-layer blockchain structure according to an embodiment of the present application;
[0055] Figure 6 Schematic diagram of verification and information interaction between a shard chain and an aggregation chain according to an embodiment of the present application;
[0056] Figure 7 This is a logical diagram of balancing terminal loads according to an embodiment of the present application;
[0057] Figure 8 This is another structural block diagram of a transaction security protection device based on a double-layer blockchain structure according to an embodiment of the present application. DETAILED DESCRIPTION
[0058] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be thorough and complete and will fully convey the concepts of the example embodiments to those skilled in the art.
[0059] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner.In the following description, many specific details are provided so as to provide a full understanding of the embodiments of the present application. However, it will be appreciated by those skilled in the art that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps etc. can be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring the various aspects of the application.
[0060] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically separate entities. That is, these functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or micro-controller node devices.
[0061] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, while others may be combined or partially combined. Therefore, the actual execution order may vary depending on the actual situation.
[0062] It should be noted that the term "plurality" used in this document refers to two or more. "And / or" describes a relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A alone, A and B together, or B alone. The character " / " generally indicates an "or" relationship between the associated objects.
[0063] The following is a detailed description of the implementation details of the technical solution of the embodiment of the present application:
[0064] First of all, it should be noted that the purpose of this application is to propose a transaction security protection method based on a double-layer blockchain, and to propose an edge-end combined double-layer blockchain architecture. Figure 2 As shown in Figure 1, a shard chain consists of multiple terminal nodes, which are power terminal devices with limited performance, such as smart meters and power load terminals. The aggregation chain, on the other hand, consists of multiple edge nodes, which can be base stations and authorized edge computing devices. Blockchain sharding technology is used in the shard chain to divide terminal devices (terminal nodes) in different regions into different shards, solving the scalability problem of blockchain in smart grids.
[0065] Next, this application proposes another type of blockchain at the edge layer (aggregation chain), called an aggregation chain. By collecting the consensus results of blockchains in shard chains (the first consensus result in this application), the aggregation chain can achieve more reliable cross-shard power transaction data processing and detect malicious nodes in the shard chain (failure of block correctness verification and / or security verification of account transaction data). This solves the problem of low shard security and ensures data security in smart grids.
[0066] The consensus results in this application, whether the first consensus result or the second consensus result, are achieved by using the Practical Byzantine Fault Tolerance (PBFT) algorithm.
[0067] According to one aspect of an embodiment of the present application, a transaction security protection method based on a double-layer blockchain structure is provided. Figure 1 This is a flowchart of a transaction security protection method based on a double-layer blockchain structure according to an embodiment of the present application. The method is executed on the aggregation chain and includes at least steps 110 to 150, which are described in detail as follows:
[0068] In step 110, a first consensus result sent from the first target shard chain is received, where the first consensus result includes a block and account transaction data bound to the block, and the block carries identification information for verification.
[0069] Specifically, the first target shard chain is the shard chain where the transaction initiation operation is located, wherein a terminal node performs the transaction initiation operation, and then the consensus of all nodes in the first target shard chain is performed based on the transaction initiation operation, and the generated first consensus result is sent to the aggregation chain. The first consensus result includes the block and the account transaction data bound to the block. The first consensus result can also be defined as <<Type1, {B, ASlist, Sid}> , S>; Type1 specifies the message type; B is a block containing transaction content; ASlist is a list of changed account statuses (i.e., account transaction data in this application), which records the current status of an account in a certain changed node, including account balance, number of executed transactions, Nonce, and account address; Sid is the name of the first target shard chain, used to mark the shard to which the block belongs; S is the signature of the shard chain master node.
[0070] In step 120, the block is verified for correctness based on the identification information to obtain a first verification result of the block.
[0071] Specifically, the block contains transaction content and identification information for verification, that is, the transaction root. The aggregation chain can verify the correctness of the transaction root. The transaction root is in the form of a hash value string. By verifying the correctness of the hash value string, it can be determined whether the received block is complete and correct.
[0072] In one embodiment of the present application, the identification information is a transaction root for identification, and the correctness verification of the block based on the identification information to obtain the first verification result of the block includes:
[0073] Comparing the hash value of the transaction root with a preset reference hash value;
[0074] If the hash value of the transaction root is consistent with the reference hash value, determining that the first verification result is correct;
[0075] If the hash value of the transaction root is inconsistent with the reference hash value, the first verification result is determined to be incorrect.
[0076] Furthermore, Figure 3 As shown, Figure 3 This is the overall logic diagram for hash value verification. The preset reference hash value can be the correct transaction root for comparison corresponding to the block pre-stored in the aggregation chain, that is, the correct hash value. Then, by comparing the hash value corresponding to the transaction root with the reference hash value, if they are consistent, the first verification result is determined to be correct, that is, the correctness and integrity of the block have been passed. Otherwise, the first verification result is determined to be incorrect. At this time, an incorrect block and the account transaction data corresponding to the block may have been sent. The first verification result needs to be fed back to the first target shard chain so that the first target shard chain can analyze the cause of the error. If the block is generated by the first consensus result sent by a malicious node or a transaction initiated by a malicious node, the reputation value of the malicious node will be updated. If the accumulated reputation value falls below a certain threshold, the malicious node will be isolated. The isolation operation means that the malicious node in the shard chain cannot participate in or execute transaction initiation operations. Even if a transaction initiation operation is initiated, no other node will respond to the transaction initiation operation.
[0077] In step 130, security verification is performed on the block based on the account transaction data and the ledger data to obtain a second verification result of the block.
[0078] Specifically, the embodiment of the present application stores the ledger data of all terminal nodes of each shard chain in the aggregation chain, that is, the account balance of each terminal node before the transaction. If the sum of the account transaction amount and the account balance after the transaction in the first consensus result is inconsistent with the account balance before the transaction stored in the aggregation chain, then it means that there is an error in the account transaction data in the first consensus result. At this time, it is necessary to feedback to the first target shard chain, and based on this, update the reputation value of the terminal node corresponding to the account transaction data to prevent malicious behavior of malicious nodes or collusion nodes from happening again.
[0079] In one embodiment of the present application, the account transaction data includes the account transaction deduction amount and account balance of the target node associated with the block in the first target shard chain, and the ledger data includes the account balance data of each node in each of the shard chains; the security verification of the block based on the account transaction data and the ledger data to obtain the second verification result of the block includes:
[0080] Determine the total account balance of the target node before the transaction based on the sum of the account transaction deduction amount and the account balance;
[0081] Comparing the total account balance with the target account balance data corresponding to the target node in the ledger data, and if the comparison is consistent, determining that the second verification result is correct;
[0082] If the comparison is inconsistent, the second verification result is determined to be wrong.
[0083] Specifically, the account transaction data includes the account transaction deduction amount and account balance corresponding to the block, and the block is associated with the target node, which is the transaction initiating node. Then, the total account balance of the target node before the transaction can be determined based on the sum of the account transaction deduction amount and the account balance. By comparing the total account balance before the transaction with the target account balance data of the target node stored in the ledger data, if they are consistent, it means that the account transaction data this time is correct, and the second verification result can be determined to be correct.
[0084] In step 140, when both the first verification result and the second verification result are correct, a second consensus result corresponding to the first consensus result is generated, where the second consensus result includes the verified block and the account transaction data.
[0085] If both the first verification result and the second verification result are correct, then the second consensus result corresponding to the first consensus result is generated by the PBFT algorithm, where the consensus result C2 can be defined as <<Type2, {CTxList, Rid, Sid}> , S>. Type2 specifies the message type; CTxlist is the cross-shard transaction list of the first target shard chain, in which the block and account transaction data are marked as verified; Rid is the name of the second target shard chain; Sid is the name of the aggregation chain; and S is the signature of the aggregation chain master node.
[0086] In step 150, the second consensus result is sent to the second target shard chain so that the second target shard chain executes the target transaction operation according to the second consensus result.
[0087] Specifically, by sending the second consensus result to the second target shard chain, so that the second target shard chain executes the target transaction operation according to the second consensus result, the second target shard chain quickly executes the transaction operation corresponding to the consensus result according to the second consensus result, thereby completing the data transaction between cross-shard chains.
[0088] In general, the above steps 110-150 only provide for the verification and subsequent processing of a single first consensus result. In the entire two-layer blockchain structure, multiple first consensus results can be uniformly identified at the same time. That is, there can be multiple first target shard chains, and each of them sends its own first consensus result to the aggregation chain at the same time. The aggregation chain can verify the multiple first consensus results received at the same time and perform subsequent operations based on the verification results (i.e., the first verification result and the second verification result).
[0089] Therefore, the aggregation chain verifies each block in these first consensus results and the associated account transaction data one by one, and finally obtains the verification result of each block.<B1.v:false, B2.v:true, ..., Bj.v:true> Bi represents a block, where a value marked as true indicates successful verification, and a value marked as false indicates a verification failure, indicating a problem with the block or the account transaction within it. Regardless of the verification result, the master node in the aggregation chain should generate these blocks for consensus within the aggregation chain and broadcast them to other nodes for consensus.
[0090] In one embodiment of the present application, the method further includes:
[0091] Obtaining the historical reputation value of the target node corresponding to the block;
[0092] Calculating the reputation value of the target node after the correctness check and the security verification based on a preset reputation value calculation formula, a positive evaluation index, and a negative evaluation index;
[0093] The positive evaluation indicator and the negative evaluation indicator are both related to the first verification result and the second verification result.
[0094] Specifically, the target node corresponding to each block has a reputation value. This is because the target node is assigned an initial reputation value when it is included in the shard chain. Subsequently, during continuous data transactions, it is verified based on the generated blocks and corresponding account transaction data, and its reputation value is continuously updated. In other words, both the first and second verification results affect the target node's reputation update. The historical reputation value of the target node corresponding to the block is obtained, that is, the reputation value of the target node corresponding to the block before the update is obtained. The reputation value of the target node after the correctness check and security verification is calculated using a preset reputation value calculation formula, positive evaluation indicators, and negative evaluation indicators.
[0095] The preset reputation value calculation formula can be as follows:
[0096] (1)
[0097] (2)
[0098] Among them, formula (1) is the Beta probability formula, that is, the probability density function of the Beta distribution. In the formula, α is a positive evaluation indicator for evaluating the positive behavior of the node. It is determined by the behavior taken by the target node during the operation of the blockchain. When the block verification of the target node's shard is correct, the α value increases by 1, and when the account transaction data verification is passed, the α value increases by 1; while β is a negative evaluation indicator for evaluating the negative behavior of the node. When the block verification of the node's shard is incorrect, the β value increases by 1, and when the account transaction data verification fails, the β value increases by 1. In addition, the β value of the master node of that round and the node that supports the proposal increases by 1 because they are malicious nodes or collusion nodes. Note that when the target node first joins the network, since it has no historical behavior, the reputation value cannot be calculated at this time, and it should be uniformly assigned an initial value; after the target node joins the blockchain, we record its behavior in each round and can calculate its reputation value based on this behavior data.
[0099] In one embodiment of the present application, after calculating the reputation value of the target node after the correctness check and the security verification, the method further includes:
[0100] If the reputation value is lower than the preset reputation reference value, the target node is determined to be a risky node, and risk warning information corresponding to the risky node is sent to the first target shard chain, so that the master node in the first target shard chain can isolate the risky node according to the risk warning information.
[0101] Formula (2) calculates the final reputation value, and compares it with the preset reputation benchmark value. If it is lower than the preset reputation benchmark value, it means that the target node is a risky node. The preset reputation benchmark value can be set according to actual needs and is not limited or given as a specific numerical example here.
[0102] By sending risk warning information corresponding to the risky node to the first target shard chain, the master node in the first target shard chain can isolate the risky node based on the risk warning information. It should be noted that after receiving the risk warning information, the master node in the first target shard chain needs to further verify the risky node in the risk warning information. Only after verification can the malicious node be isolated.
[0103] Figure 4This is a block diagram of a transaction security protection device 400 based on a double-layer blockchain structure according to an embodiment of the present application. According to a transaction security protection device 400 based on a double-layer blockchain structure according to an embodiment of the present application, the double-layer blockchain structure includes an aggregation chain and multiple shard chains that run independently of each other, and the aggregation chain stores the ledger data of each shard chain; the device is applied to the aggregation chain, and the device 400 includes: a receiving unit 401, a verification unit 402, a verification unit 403, a consensus unit 404, and a sending unit 405.
[0104] The receiving unit 401 is used to receive a first consensus result sent from the first target shard chain, where the first consensus result includes a block and account transaction data bound to the block, and the block carries identification information for verification.
[0105] The verification unit 402 is configured to perform a correctness verification on the block based on the identification information to obtain a first verification result of the block.
[0106] The verification unit 403 is configured to perform security verification on the block based on the account transaction data and the ledger data to obtain a second verification result of the block.
[0107] The consensus unit 404 is configured to generate a second consensus result corresponding to the first consensus result when both the first verification result and the second verification result are correct, wherein the second consensus result includes the verified block and the account transaction data.
[0108] The sending unit 405 is configured to send the second consensus result to the second target shard chain so that the second target shard chain executes the target transaction operation according to the second consensus result.
[0109] According to one aspect of an embodiment of the present application, a transaction security protection method based on a double-layer blockchain structure is provided. Figure 5 This is a flowchart of a transaction security protection method based on a two-layer blockchain structure according to an embodiment of the present application. The two-layer blockchain structure includes an aggregate chain and multiple independently running shard chains. The aggregate chain stores the ledger data of each shard chain. The method is executed on the first target shard chain. The method includes at least steps 510 to 520, which are described in detail as follows:
[0110] In step 510, if the transaction operation information sent by the target node is received, a corresponding block and the account transaction data of the target node bound to the block are generated based on the transaction operation information.
[0111] Specifically, the target node is the terminal node where the transaction initiator is located. The corresponding block and the account transaction data of the target node bound to the block can be generated through the transaction operation information. The specific transaction verification and execution process can be as follows: Figure 6 As shown, the first target shard chain executes the transaction initiator's deduction operation and sends the consensus result C1 to the aggregation chain. The aggregation chain verifies the block and the account transaction data contained therein; the aggregation chain reaches a consensus on the verification result and sends the consensus result C2 to the second target shard chain. The second target shard chain receives the cross-shard transaction information (second consensus result) from the aggregation chain, thereby enabling the transaction recipient to execute the target transaction operation corresponding to the transaction operation information.
[0112] In one embodiment of the present application, the first consensus result is generated by the following steps:
[0113] Obtaining the consensus verification results of each node in the first target shard chain. If more than two-thirds of the consensus verification results are correct, the master node generates a first consensus result containing the block and the account transaction data.
[0114] The consensus verification result is generated by the node performing legitimacy verification on the block and the account transaction data.
[0115] Specifically, the first consensus result is obtained according to the Practical Byzantine Fault Tolerance (PBFT) algorithm, which is also verified by verifying the hash value corresponding to the transaction root of the block in the consensus result. If the transaction operation is initiated by a malicious node and the majority of nodes pass the proposal (block) as collusion nodes, then the aggregation chain can verify and identify the first consensus result corresponding to the proposal to prevent the malicious node from maliciously deducting funds, reporting false data, etc., and update its reputation value, so that the master node of the first target shard chain can isolate these malicious nodes and collusion nodes.
[0116] The accuracy of global ledger data is ensured by eliminating errors during transmission and verifying the correct execution of transactions within the shard chain. The second step is to verify the physical status of the relevant nodes in the shard chain. Certain indicators of a normally functioning terminal node fluctuate within a certain range. If a specific indicator value is abnormal, it may be compromised. We need to identify these potentially malicious nodes and then use the Beta formula to calculate their reputation and determine whether they are malicious.
[0117] The reputation value update process may involve two reputation value updates. The first update is based on the consensus result within the shard, that is, the reputation value is updated based on the node status data of each node in the first target shard chain. If the node status data of a node (physical status, such as whether the voltage, current, power and other values in the power grid are within the normal range) is abnormal, then the reputation value of the node will be updated at this time.
[0118] The second time is determined by the aggregation chain. When the aggregation chain verifies that the transaction data is wrong or there is a malicious node, it needs to return the verification failure result and recalculate the terminal's reputation value. The verification failure result Vf is defined as <<Tpye3,{B,AcList, Sid},V, Txlist,blackList> , S>. Type3 indicates the message type; B is the block that failed verification; ASlist is the list of related account status; Sid is the ID of the received shard; V value represents the verification failure type. If the received block is incorrect, the correct block needs to be resent; if the transaction execution error is, the account status needs to be rolled back to the correct time. If there is a malicious node, isolation measures need to be implemented; Txlist indicates the transaction list with verification errors; blackList indicates the existence of malicious nodes in this shard; S is the signature of the aggregation chain master node.
[0119] In one embodiment of the present application, the method further includes:
[0120] Obtain node status data of each node in the first target shard chain, and determine the reputation value of each node based on each node status data, wherein the reputation value is used to indicate whether the node has a malicious behavior risk;
[0121] Determining nodes to be determined that have a risk of malicious behavior based on the reputation value;
[0122] If the risk warning information sent by the aggregation chain is received, the corresponding risk node is determined according to the risk warning information;
[0123] A target risk node belonging to the risk node is found in each of the nodes to be determined, and the target risk node is isolated.
[0124] Specifically, the node status data can be the physical status of the terminal node, such as the voltage data, current data, power data, etc. of a smart meter. If these data are not within the normal threshold range, it means that the terminal node has an abnormality, and its reputation value is updated. At the same time, it is necessary to determine whether the node has a malicious behavior risk. If abnormal data appears for a long time, it can be determined that the current node is a node to be determined with a malicious behavior risk.
[0125] Furthermore, after knowing the node to be determined, it cannot be directly determined as a malicious node. It needs to be compared with the risk nodes in the risk warning information sent by the aggregation chain. If a node is identified as a node to be determined and is determined as a risk node, after double determination, it means that the node is a target risk node, that is, a malicious node. By finding all malicious nodes and isolating them, the transactions of the double-layer blockchain structure can be effectively protected.
[0126] In step 520, if the first consensus result generated by the master node in the first target shard chain is obtained, the first consensus result is sent to the aggregation chain so that the aggregation chain can perform correctness and security verification on the blocks and account transaction data in the first consensus result based on the ledger data;
[0127] Among them, when the verification results of the correctness check and the security verification are both correct, the aggregation chain can generate a second consensus result and send the second consensus result to the second target shard chain, so that the second target shard chain executes the target transaction operation corresponding to the transaction operation information according to the second consensus result.
[0128] Specifically, by sending the first consensus result to the aggregation chain, the aggregation chain can perform correctness verification and security verification on the block and the account transaction data in the first consensus result according to the ledger data, and then, when the verification results of the correctness verification and the security verification are both correct, the aggregation chain can generate a second consensus result and send the second consensus result to the second target shard chain, so that the second target shard chain executes the target transaction operation corresponding to the transaction operation information according to the second consensus result.
[0129] The embodiments of the present application undergo multiple verifications and security protections, and manage terminal nodes in a sharding manner, which can achieve fast, accurate and secure data processing.
[0130] In one embodiment of this application, the method also involves balancing the load of shard chains. When processing smart grid power transaction data on a blockchain, the load on shard chains in different shards may vary. This is generally because users in a particular shard may be more active, resulting in a higher number of transactions. This can cause that shard to be fully loaded while another shard is idle. This approach can provide a more balanced load on the terminal layer (shard chain), indirectly improving shard chain performance.
[0131] This application also proposes a CLPA (Constrained Label Propagation Algorithm) algorithm to divide smart grid users into different shards based on the operation of the blockchain system. The specific implementation is carried out on the aggregation chain of the edge layer. The process and description are as follows:
[0132] like Figure 7 As shown in the figure, when the aggregation chain begins running, it must first initialize the CLPA configuration, including defining weight penalties, the number of iterations, and the number of shards. The aggregation chain then continuously monitors newly generated blocks and calls CLPA to generate a new account graph. Specifically, when the aggregation chain receives a block from a shard chain, it uses the transaction initiator and receiver as input to update the vertices and edges of the account graph. Subsequently, the aggregation chain periodically executes CLPA to partition accounts at predefined epoch times and sends the partition results to the shard chains. When a shard chain receives partition information from the aggregation chain, it undergoes a consensus round. Before this special consensus round, each shard sends the partitioned account information and related transactions in the current transaction pool to the partitioned shard. After the master node gathers the partition information, it reaches consensus using the PBFT algorithm. If this consensus round succeeds, each node in the shard chain adds the partitioned account and transaction information, and the resulting block is stored on-chain.
[0133] According to one aspect of an embodiment of the present application, a transaction security protection device based on a two-layer blockchain structure is provided. The two-layer blockchain structure includes an aggregate chain and multiple independently running shard chains. The aggregate chain stores the ledger data of each shard chain. The device is applied to a first target shard chain. Figure 8 This is a block diagram of a transaction security protection device 800 based on a double-layer blockchain structure provided in an embodiment of the present application. The device 800 includes a generation unit 801 and a transmission unit 802.
[0134] The generating unit 801 is configured to generate, upon receiving transaction operation information sent by a target node, a corresponding block and account transaction data of the target node bound to the block based on the transaction operation information;
[0135] The transmission unit 802 is configured to send the first consensus result generated by the master node in the first target shard chain to the aggregation chain if the first consensus result is obtained, so that the aggregation chain can perform correctness verification and security verification on the block and the account transaction data in the first consensus result based on the ledger data.
[0136] Among them, when the verification results of the correctness check and the security verification are both correct, the aggregation chain can generate a second consensus result and send the second consensus result to the second target shard chain, so that the second target shard chain executes the target transaction operation corresponding to the transaction operation information according to the second consensus result.
[0137] As another aspect, the present application further provides a computer-readable storage medium having stored thereon a program product capable of implementing the methods provided above in this specification. In some possible implementations, various aspects of the present application may also be implemented in the form of a program product, which includes program code. When the program product is executed on a terminal device, the program code is used to cause the terminal device to perform the steps described in the "Example Method" section above in accordance with various exemplary embodiments of the present application.
[0138] According to an embodiment of the present application, a program product for implementing the above method can be a portable compact disc read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present application is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0139] The program product may utilize any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0140] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0141] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0142] The program code used to perform the operations of the present application can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, as a stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0143] Furthermore, the above-mentioned figures are merely illustrative of the processes included in the methods according to exemplary embodiments of the present application and are not intended to be limiting. It is readily understood that the processes illustrated in the above-mentioned figures do not indicate or limit the temporal order of these processes. Furthermore, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.
[0144] It should be understood that the present application is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be performed without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A transaction security protection method based on a double-layer blockchain structure, characterized in that: The two-layer blockchain structure includes an aggregate chain and multiple independently running shard chains, and the aggregate chain stores the ledger data of each shard chain; The method is performed on the polymer chain, and the method includes: Receiving a first consensus result sent from the first target shard chain, where the first consensus result includes a block and account transaction data bound to the block, where the block carries identification information for verification; Performing a correctness check on the block based on the identification information to obtain a first verification result of the block; Performing security verification on the block based on the account transaction data and the ledger data to obtain a second verification result of the block; If both the first verification result and the second verification result are correct, generating a second consensus result corresponding to the first consensus result, the second consensus result including the verified block and the account transaction data; Send the second consensus result to the second target shard chain so that the second target shard chain executes the target transaction operation according to the second consensus result.
2. The method according to claim 1, characterized in that The identification information is a transaction root used for identification, and the correctness verification of the block based on the identification information to obtain a first verification result of the block includes: Comparing the hash value of the transaction root with a preset reference hash value; If the hash value of the transaction root is consistent with the reference hash value, determining that the first verification result is correct; If the hash value of the transaction root is inconsistent with the reference hash value, the first verification result is determined to be incorrect.
3. The method according to claim 2, characterized in that The account transaction data includes the account transaction deduction amount and account balance of the target node associated with the block in the first target shard chain, and the ledger data includes the account balance data of each node in each of the shard chains; The performing security verification on the block based on the account transaction data and the ledger data to obtain a second verification result of the block includes: Determine the total account balance of the target node before the transaction based on the sum of the account transaction deduction amount and the account balance; Comparing the total account balance with the target account balance data corresponding to the target node in the ledger data, and if the comparison is consistent, determining that the second verification result is correct; If the comparison is inconsistent, the second verification result is determined to be wrong.
4. The method according to claim 3, characterized in that The method further comprises: Obtaining the historical reputation value of the target node corresponding to the block; Calculating the reputation value of the target node after the correctness check and the security verification based on a preset reputation value calculation formula, a positive evaluation index, and a negative evaluation index; The positive evaluation indicator and the negative evaluation indicator are both related to the first verification result and the second verification result.
5. The method according to claim 4, characterized in that After calculating the reputation value of the target node after the correctness check and the security verification, the method further includes: If the reputation value is lower than the preset reputation reference value, the target node is determined to be a risky node, and risk warning information corresponding to the risky node is sent to the first target shard chain, so that the master node in the first target shard chain can isolate the risky node according to the risk warning information.
6. A transaction security protection device based on a double-layer blockchain structure, characterized in that: The two-layer blockchain structure includes an aggregate chain and multiple independently running shard chains, and the aggregate chain stores the ledger data of each shard chain; The device is applied to the polymer chain, and the device comprises: A receiving unit, configured to receive a first consensus result sent from a first target shard chain, wherein the first consensus result includes a block and account transaction data bound to the block, and the block carries identification information for verification; a verification unit, configured to perform a correctness verification on the block based on the identification information to obtain a first verification result of the block; a verification unit, configured to perform security verification on the block based on the account transaction data and the ledger data, and obtain a second verification result of the block; a consensus unit, configured to generate a second consensus result corresponding to the first consensus result when both the first verification result and the second verification result are correct, the second consensus result including the verified block and the account transaction data; A sending unit is configured to send the second consensus result to a second target shard chain, so that the second target shard chain executes a target transaction operation according to the second consensus result.
7. A transaction security protection method based on a double-layer blockchain structure, characterized in that: The two-layer blockchain structure includes an aggregate chain and multiple independently running shard chains, and the aggregate chain stores the ledger data of each shard chain; The method is executed on a first target shard chain, and includes: If transaction operation information is received from the target node, a corresponding block and the account transaction data of the target node bound to the block are generated based on the transaction operation information; If a first consensus result generated by the master node in the first target shard chain is obtained, the first consensus result is sent to the aggregation chain so that the aggregation chain can perform correctness verification and security verification on the block and the account transaction data in the first consensus result based on the ledger data; Among them, when the verification results of the correctness check and the security verification are both correct, the aggregation chain can generate a second consensus result and send the second consensus result to the second target shard chain, so that the second target shard chain executes the target transaction operation corresponding to the transaction operation information according to the second consensus result.
8. The method according to claim 7, characterized in that The first consensus result is generated through the following steps: Obtaining the consensus verification results of each node in the first target shard chain. If more than two-thirds of the consensus verification results are correct, the master node generates a first consensus result containing the block and the account transaction data. The consensus verification result is generated by the node performing legitimacy verification on the block and the account transaction data.
9. The method according to claim 8, characterized in that The method further comprises: Obtain node status data of each node in the first target shard chain, and determine the reputation value of each node based on each node status data, wherein the reputation value is used to indicate whether the node has a malicious behavior risk; Determining nodes to be determined that have a risk of malicious behavior based on the reputation value; If the risk warning information sent by the aggregation chain is received, the corresponding risk node is determined according to the risk warning information; A target risk node belonging to the risk node is found in each of the nodes to be determined, and the target risk node is isolated.
10. A transaction security protection device based on a double-layer blockchain structure, characterized in that: The two-layer blockchain structure includes an aggregate chain and multiple independently running shard chains, and the aggregate chain stores the ledger data of each shard chain; The device is applied to a first target shard chain, and includes: a generating unit configured to, upon receiving transaction operation information sent by a target node, generate a corresponding block and account transaction data of the target node bound to the block based on the transaction operation information; a transmission unit configured to, upon obtaining a first consensus result generated by the master node in the first target shard chain, send the first consensus result to the aggregation chain, so that the aggregation chain can perform correctness and security verification on the block and the account transaction data in the first consensus result based on the ledger data; Among them, when the verification results of the correctness check and the security verification are both correct, the aggregation chain can generate a second consensus result and send the second consensus result to the second target shard chain, so that the second target shard chain executes the target transaction operation corresponding to the transaction operation information according to the second consensus result.
Citation Information
Patent Citations
Consensus verification method, check node and block chain system
CN110875893A
Double-layer multi-partition block chain system
CN117914861A