Data collection method and system based on blockchain and IoT data aggregation gateway
By setting up a data aggregation gateway at the gathering place of IoT devices and using blockchain technology, the data of IoT devices is encrypted and transmitted and multi-factor verified, which solves the problem of data transmission security and efficiency of IoT devices when the base station signal is weak. problem, achieving trusted collection and non-tamperable storage of data.
Patent Information
- Application Number
- CN202210171036.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-23
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2042-02-23
AI Technical Summary
Existing IoT devices have difficulty ensuring data security and transmission efficiency when the base station signal is weak, and data transmission is unprotected and unencrypted, making data susceptible to tampering and loss during transmission.
Adopting a data collection method based on blockchain and IoT data aggregation gateway, by setting up a data aggregation gateway at the IoT device collection point, the original data is encrypted, and the encrypted data is transmitted in the full transmission link, using multiple factors Verification ensures the authentication of the data source and the consensus algorithm of the blockchain node guarantees the security and integrity of the data.
Transform the traditional unprotected IoT data transmission method into encrypted transmission to ensure the integrity and security of data during transmission, reduce the possibility of data fraud, and ensure the traceability of data through the non-tampering characteristics of the blockchain and trusted collection.
Smart Images

Figure CN115085926B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Internet of Things technology, and more specifically, to a data collection method and system based on blockchain and Internet of Things data aggregation gateway. Background Art
[0002] In the existing data collection method based on the Internet of Things, data is mainly collected by a mobile terminal, the mobile terminal monitors the system information sent by the first base station, the mobile terminal monitors the synchronization signal sent by the second base station, and the mobile terminal determines the link status of the second communication link between the mobile terminal and the second base station based on the synchronization signal sent by the second base station; in response to determining the link status of the second communication link, the mobile terminal determines whether the link status of the second communication link is greater than the first link quality threshold; if it is determined that the link status of the second communication link is greater than the first link quality threshold, the mobile terminal sends a base station addition measurement report to the first base station; in response to receiving the base station addition measurement report, the first base station determines whether the second base station can communicate with the mobile terminal. In the traditional data collection method, in order to grasp more data and ensure the continuous updating of data, it is necessary to collect more data anytime and anywhere through the Internet of Things technology, but many Internet of Things devices often cannot receive strong base station signals, and the data of Internet of Things devices are often transmitted without protection and encryption. In this case, how to ensure that the Internet of Things devices can quickly and securely transmit data to the base station has become a very important technical problem. Summary of the invention
[0003] The present invention aims to solve the problem in the prior art that the data of IoT devices is too dependent on base stations, and it is difficult to ensure the security of data and the efficiency of data transmission when the base station signal is weak. The present invention provides a data collection method based on blockchain and IoT data aggregation gateway, and a data collection system based on blockchain and IoT data aggregation gateway.
[0004] In order to solve the above technical problems, the technical solution of the present invention is as follows:
[0005] A data collection method based on blockchain and IoT data aggregation gateway, comprising the following steps:
[0006] S1. Collect the original data from the source, encrypt the collected original data using the public key of the data aggregation gateway, sign the message using the private key, and then transmit the encrypted original data to the data aggregation gateway;
[0007] S2, the data aggregation gateway uses multi-factor authentication to verify the source of the received encrypted original data; after the verification, the encrypted original data is decrypted using the private key of the data aggregation gateway to obtain the original data;
[0008] S3. The data aggregation gateway encapsulates the decrypted original data into a request message, encrypts it using the public key of the blockchain node, and then signs it using the private key of the data aggregation gateway to obtain the encrypted request message, and sends a transaction on-chain request to the blockchain node directly connected to the data aggregation gateway;
[0009] S4. The blockchain node performs signature verification on the received request message, and decrypts the request message that passes the signature verification using the private key of the blockchain node to obtain the request message;
[0010] S5. The blockchain nodes use a high-speed consensus algorithm to reach a consensus on the decrypted request message to complete the storage or execution of the original data on the blockchain.
[0011] In this technical solution, a data aggregation gateway is added at the gathering point of IoT devices to encrypt the original data and transmit the encrypted data in the entire transmission link, so as to transform the data transmission mode of IoT from an unprotected state to trusted data collection through the blockchain IoT gateway. On the IoT data aggregation gateway, a multi-factor authentication method is used to authenticate the data source to ensure that the IoT collection information comes from a trusted IoT collection terminal that has been authenticated by the blockchain.
[0012] Furthermore, the present invention also proposes a data collection system based on blockchain and IoT data aggregation gateway, which is applied to the above-mentioned data collection method. The data collection system includes:
[0013] The IoT collection terminal is used to collect the original data from the source; the IoT collection terminal includes a CPU with a TEE trusted execution environment, a WiFi communication module, and a general input and output module;
[0014] Blockchain node, used to upload the original data collected by the source end to the blockchain network and save it after consensus; the blockchain node includes a CPU with a TEE trusted execution environment and an Ethernet communication module;
[0015] A data aggregation gateway is used to connect the Internet of Things collection terminal and the blockchain node; the data aggregation gateway includes a CPU with a TEE trusted execution environment, a WiFi communication module and an Ethernet communication module; the data aggregation gateway uses the WiFi communication module to receive the encrypted original data sent by the Internet of Things collection terminal, and the data aggregation gateway uses the Ethernet communication module to send a transaction on-chain request to the blockchain node directly connected to the data aggregation gateway.
[0016] Compared with the prior art, the beneficial effects of the technical solution of the present invention are as follows: the present invention changes the traditional IoT transmission mode from an unprotected transparent transmission state to a full-process data encryption transmission through the IoT data aggregation gateway by adding a data aggregation gateway between the source end and the blockchain node, thereby effectively ensuring the integrity and security of the IoT collected data during the transmission process; through the IoT data aggregation gateway, a multi-factor verification method is adopted to realize the source authentication of the IoT collected information, ensure that the IoT collected information comes from a trusted IoT terminal, and reduce the possibility of data falsification. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 This is a flow chart of the data collection method based on blockchain and IoT data aggregation gateway of Example 1.
[0018] Figure 2 This is a flow chart of using multi-factor authentication to verify the source of data in Example 2.
[0019] Figure 3 This is a flowchart of using a high-speed consensus algorithm to reach consensus on the decrypted request message in Example 2.
[0020] Figure 4 This is an architecture diagram of the data collection system based on blockchain and IoT data aggregation gateway in Example 3. DETAILED DESCRIPTION
[0021] The drawings are for illustrative purposes only and should not be construed as limiting the present patent;
[0022] It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.
[0023] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0024] Example 1
[0025] This embodiment proposes a data collection method based on blockchain and IoT data aggregation gateway, as shown in FIG1 , which is a flow chart of the data collection method based on blockchain and IoT data aggregation gateway of this embodiment.
[0026] The data collection method based on blockchain and IoT data aggregation gateway proposed in this embodiment includes the following steps:
[0027] S1. Collect the original data from the source, encrypt the collected original data using the public key of the data aggregation gateway, sign the message using the private key, and then transmit the encrypted original data to the data aggregation gateway.
[0028] S2. The data aggregation gateway uses multi-factor authentication to verify the source of the received encrypted original data; after the verification, the encrypted original data is decrypted using the private key of the data aggregation gateway to obtain the original data.
[0029] S3. The data aggregation gateway encapsulates the decrypted original data into a request message, encrypts it using the public key of the blockchain node, and then signs it using the private key of the data aggregation gateway to obtain the encrypted request message, and sends a transaction on-chain request to any blockchain node directly connected to the data aggregation gateway.
[0030] S4. The blockchain node performs signature verification on the received transaction on-chain request, and decrypts the transaction on-chain request that passes the signature verification using the private key of the blockchain node to obtain a request message.
[0031] S5. The blockchain nodes use a high-speed consensus algorithm to reach a consensus on the decrypted request message to complete the storage or execution of the original data on the blockchain.
[0032] In a specific implementation process, the collected source original data is encrypted in the TEE trusted execution environment; in the data aggregation gateway, the encrypted original data is verified for data source and encrypted and decrypted in the TEE trusted execution environment; in the blockchain node, the received request message is also verified and consensus is reached in the TEE trusted execution environment.
[0033] This embodiment adds a data aggregation gateway at the source of the Internet of Things, encrypts the collected original data in the data aggregation gateway, and transmits the encrypted data in the full transmission link of the blockchain network, thereby converting the data collection operation of the Internet of Things from an unprotected state to trusted data collection through the blockchain Internet of Things data aggregation gateway, thereby improving the security of data collection. Furthermore, in the data aggregation gateway, this embodiment uses multi-factor authentication to verify the source of data to ensure that the information collected by the Internet of Things comes from a trusted Internet of Things collection terminal that has passed blockchain authentication.
[0034] Example 2
[0035] This embodiment further limits the data collection method based on blockchain and IoT data aggregation gateway proposed in Embodiment 1.
[0036] The data collection method based on blockchain and IoT data aggregation gateway proposed in this embodiment includes the following steps:
[0037] S1. Collect the original data from the source, encrypt the collected original data using the public key of the data aggregation gateway, sign the message using the private key, and then transmit the encrypted original data to the data aggregation gateway.
[0038] In this embodiment, the collected original data is encrypted and signed in the TEE trusted execution environment.
[0039] S2. The data aggregation gateway uses multi-factor authentication to verify the source of the received encrypted original data; after the verification, the encrypted original data is decrypted using the private key of the data aggregation gateway to obtain the original data.
[0040] In this step, the steps of using multi-factor authentication to verify the source of the received encrypted original data include:
[0041] S2.1. The data aggregation gateway obtains the MAC Header in the CCMP (Counter CBC-MAC Protocol) frame of the encrypted original data based on the WPA2-PSK protocol, and obtains the corresponding device unique identifier ID1 through the MAC Header on the blockchain.
[0042] S2.2. The data aggregation gateway is in the TEE trusted execution environment, and searches for the public key of the source (message sender) in its memory, uses the public key of the source to sign and decrypt the encrypted original data, authenticates the source, and executes step S2.3 after obtaining the source identity information; if decryption is not possible, the uplink failure information is returned to the source, and the process jumps to step S1.
[0043] S2.3, the data aggregation gateway searches for the corresponding device unique identifier ID2 in the blockchain network according to the source identity information, and compares it with the device unique identifier ID1 obtained according to the MAC Header. If the comparison is consistent, it means that the data source verification has passed; otherwise, the data is discarded, the chain failure information is returned to the source, and the process jumps to step S1.
[0044] like Figure 2 As shown, it is a flowchart of using multi-factor authentication to verify the source of data in this embodiment.
[0045] This embodiment uses multi-factor authentication to verify the source of data, which can ensure that the IoT collection information comes from a trusted IoT collection terminal (source end) that has been authenticated by the blockchain.
[0046] S3. The data aggregation gateway encapsulates the decrypted original data into a request message, encrypts it using the public key of the blockchain node, and then signs it using the private key of the data aggregation gateway to obtain the encrypted request message, and sends a transaction on-chain request to the blockchain node directly connected to the data aggregation gateway.
[0047] In this step, the step of encapsulating the decrypted original data into a request message includes: calculating the data digest D(m) in the original data m, and encapsulating the original data m and its data digest D(m), and the data aggregation gateway signature into the request message Request.
[0048] S4. The blockchain node performs signature verification on the received request message Request to confirm the source of the message, and then decrypts the request message that passes the signature verification using the private key of the blockchain node to obtain an unencrypted request message Request.
[0049] S5. The blockchain nodes use a high-speed consensus algorithm to reach a consensus on the decrypted request message to complete the storage or execution of the original data on the blockchain.
[0050] In this step, the steps of using a high-speed consensus algorithm to reach consensus on the decrypted request message include:
[0051] S5.1. The blockchain node encapsulates the request message Request that has passed the signature verification into a Pre-prepare message, then signs the Pre-prepare message and broadcasts it to other secondary nodes, and adds the request message Request to the cache pool of the primary node of the current blockchain network.
[0052] The request messages Request stored in the master node buffer pool are sorted according to their numbers Seq. In this embodiment, only the master node has the authority to perform write and delete operations.
[0053] When the primary node and the secondary node receive the Pre-prepare message, they enter the Pre-prepare phase.
[0054] S5.2. After the master node updates the known consensus conditions, it performs a polling operation and selects a target secondary node n from the secondary nodes that received the Pre-prepare message. k .
[0055] When a polling operation is performed, the following steps are specifically included:
[0056] S5.2.1. The master node updates the known consensus conditions, which include the request message number Seq; the total number of slave nodes N-1, where N is the total number of nodes in the blockchain network; the slave node number i, where i = 1, 2, ..., N-1; the verification task queue length q of all slave nodes i ; The reference computing power of all secondary nodes h i ; Master node polling operation count j; Maximum system throughput T of blockchain network max .
[0057] The first piece of data uploaded by the source is numbered as Seq=1. After that, each time the source uploads a piece of data, Seq is incremented by 1, and the number is not cleared and reset; the secondary node number i is updated when the primary node is switched.
[0058] The length of the verification task queue of all secondary nodes q i It needs to be updated in real time and reported to the master node, while the calculation reference power of the slave node is h i It is a fixed attribute and is updated when the corresponding node joins the blockchain.
[0059] The initial value of the master node polling operation count j is set to 0. The data is incremented by 1 each time the master node performs a polling operation in sequence, and is cleared and reset after the master node is replaced.
[0060] The maximum system throughput of the blockchain network is T max Requires high configuration in blockchain settings.
[0061] S5.2.2. The master node determines the number i of the currently polled slave node according to the current polling operation count j. The expression is as follows:
[0062] i=j MOD(N-1)
[0063] Wherein, MOD() is the remainder operation function.
[0064] S5.2.3. The master node calculates the secondary node n i The processing load tq i =q i / h i .
[0065] S5.2.4, the master node will be the secondary node n i The execution efficiency and maximum system throughput T max Compare: If tq is satisfied i <1 / T max , then the current secondary node n i As the target secondary node n k If tq i ≥1 / T max , then calculate the processing load of other secondary nodes, and the master node selects the secondary node with the lowest processing load from other secondary nodes as the target secondary node n k ; Set the master node polling operation count j=j+1.
[0066] In addition, when there are multiple secondary nodes with the smallest processing load, select a secondary node number that satisfies ki>0 and use this secondary node as the target secondary node n. k .
[0067] S5.3. The master node randomly generates a verification string char, and adds the verification string char to the header of the request message numbered Seq.
[0068] S5.4, the master node encapsulates the request message number Seq and the verification string char into an access token T seq After that, the access token T seq Send to secondary node n k .
[0069] S5.5. Secondary node n k Based on the access token T seq The number Seq in the master node searches for the corresponding request message in the cache pool of the master node; if the request message is found to exist, the slave node n k The access token T seq The verification string char in is sent to the master node, and the master node verifies the consistency of the verification string. When the verification passes, the master node sends the complete request message to the secondary node n. k Otherwise, the illegal transaction is discarded, the failure information of uploading to the chain is returned to the source end, and the process jumps to step S1.
[0070] S5.6, secondary node n k After receiving the complete request message, the master node will provide feedback. After receiving the feedback, the master node will delete the corresponding request message in the cache pool.
[0071] In this step, the secondary node n k After receiving the complete request message, the master node replies with an ACK message. After receiving the ACK message, the master node deletes the data numbered Seq in the cache pool.
[0072] S5.7, secondary node n k The received request message is checked for consistency of data summary. After passing the consistency check, the check result is encapsulated as a Prepare message, signed and broadcasted to all nodes in the blockchain network. At this time, the secondary node n k Complete the verification of a transaction data, and then proceed to the Commit stage for confirmation.
[0073] Among them, the secondary node n k The step of performing consistency check on the data summary of the received request message includes: calculating the summary D′(m) in the request message numbered Seq obtained from the master node cache pool, and comparing it with the data summary D(m) in the Pre-prepare message. If the two are consistent, it is judged that the consistency check has passed; otherwise, the message is discarded, the chain failure information is returned to the source end, and the S1 step is jumped.
[0074] like Figure 3 As shown, it is a flowchart of the present embodiment of using a high-speed consensus algorithm to reach consensus on the decrypted request message.
[0075] Furthermore, in the Commit phase:
[0076] S5.8. When the master node and other slave nodes receive the Prepare message, the node verifies the signature of the Prepare message and performs a consistency check on the data digest in the Prepare message and the data digest in the Pre-prepare message. If the check fails, the message is discarded. If the check passes, the message is sent to the slave node n. k Returns a Prepare message encapsulating the verification result.
[0077] When the secondary node n k After receiving 2f+1 Prepare messages encapsulating verification, the Commit message is broadcast to the blockchain network. f represents the maximum number of failed nodes, faulty nodes, or malicious nodes that can be tolerated in the blockchain network; the Commit message includes data summary, original data, and node signature.
[0078] S5.9, when the master node and other slave nodes receive the Commit message, they also need to verify the signature of the Commit message first, and perform a consistency check on the data digest in the Commit message and the data digest in the Pre-prepare message. If the check fails, the message is discarded. If the check passes, the message is sent to the slave node n. k Returns a Commit message encapsulating the verification result.
[0079] When the secondary node n k When 2f+1 Commit messages encapsulating verification are received, it means that most of the nodes in the current blockchain network have reached a consensus. At this time, the corresponding request operation of the original data on the source side is executed, and a Reply message encapsulating the operation result is returned to the source side.
[0080] When the source receives f+1 Reply messages encapsulating the operation results, it means that the request initiated by the source has reached a consensus of the entire network; otherwise, the source determines whether to resend the request to the master node.
[0081] The trusted data collection is completed only after the Commit message is fed back.
[0082] This embodiment transforms the traditional IoT transmission mode from an unprotected transparent transmission state to a full-process data encryption transmission through the IoT data aggregation gateway, ensuring the integrity and security of IoT collected data during the transmission process. Through the IoT data aggregation gateway, a multi-factor verification method is adopted to realize the source authentication of IoT collected information, ensure that the IoT collected information comes from a trusted IoT terminal, and reduce the possibility of data falsification. The data transmitted through the IoT data aggregation gateway is further distributed and stored on the blockchain, and the integrity and traceability of the data are guaranteed by the tamper-proof characteristics of the blockchain. This embodiment can effectively ensure that the entire process from the original data collected at the source to the blockchain storage is credible and controllable, solve the problem that IoT collected data may be tampered with, solve the problem that blockchain technology cannot guarantee the authenticity of source data, and ensure the credible collection of IoT data.
[0083] Example 3
[0084] This embodiment proposes a data collection system based on blockchain and IoT data aggregation gateway, and applies a data collection method based on blockchain and IoT data aggregation gateway proposed in Embodiment 1 or Embodiment 2. Figure 4 , which is an architecture diagram of the data collection system based on blockchain and IoT data aggregation gateway proposed in this embodiment.
[0085] The data collection system based on blockchain and IoT data aggregation gateway proposed in this embodiment includes an IoT collection terminal, a blockchain node and a data aggregation gateway.
[0086] The Internet of Things acquisition terminal in this embodiment is used to collect original data from the source, including a CPU with a TEE trusted execution environment, a WiFi communication module and a general input and output module (GPIO), as well as other components (RAM, NAND, internal bus, etc.) that support the normal operation of the Internet of Things acquisition terminal.
[0087] The blockchain node in this embodiment is used to upload the original data collected by the source to the blockchain network and save it after consensus, including a CPU and Ethernet communication module with a TEE trusted execution environment.
[0088] In this embodiment, a data aggregation gateway is added between the IoT collection terminal and the blockchain node to connect the IoT collection terminal and the blockchain node, which includes a CPU with a TEE trusted execution environment, a WiFi communication module, and an Ethernet communication module.
[0089] The data aggregation gateway in this embodiment uses a WiFi communication module to receive the encrypted original data sent by the Internet of Things acquisition terminal, and the data aggregation gateway uses an Ethernet communication module to send a transaction on-chain request to the blockchain node directly connected to the data aggregation gateway.
[0090] In a specific implementation process, the collected raw data is transmitted to the IoT collection terminal through GPIO, and then transmitted to the CPU with TEE trusted execution environment in the IoT collection terminal through the internal bus of the IoT collection terminal for data processing. Specifically, the collected raw data is encrypted using the public key of the IoT data aggregation gateway, and then the message is signed using the private key of the IoT collection terminal itself, and then transmitted to the WiFi communication module through the internal bus of the IoT collection terminal, and the encrypted raw data is transmitted to the data aggregation gateway through the WiFi communication module.
[0091] The data aggregation gateway receives the encrypted original data sent by the IoT collection terminal through its WiFi communication module. The data aggregation gateway obtains the MAC Header in the CCMP frame through the WiFi authentication protocol WPA2-PSK, and obtains the corresponding device unique identifier ID1 through the MAC Header on the blockchain. The encrypted original data is transmitted to the TEE trusted execution environment in its CPU through the internal bus of the data aggregation gateway, and the encrypted original data is processed.
[0092] Specifically, the data aggregation gateway searches for the public key of the message sender in its TEE trusted execution environment, and uses the public key to sign and decrypt to verify the signature and confirm the identity of the message sender, thereby achieving identity authentication. The data aggregation gateway searches for the corresponding device unique identifier ID2 on the blockchain based on the source identity information, and compares it with the device unique identifier ID1. If the comparison is consistent, the data source verification is passed. After the identity authentication is passed, the encrypted message is decrypted using the private key of the data aggregation gateway to obtain the original data.
[0093] The data aggregation gateway encapsulates the decrypted original data into a request message in its TEE trusted execution environment, encrypts it using the public key of the blockchain node, and then signs it using the private key of the data aggregation gateway to obtain the encrypted request message, which is then transmitted to the Ethernet communication module of the data aggregation gateway via the internal bus. The Ethernet communication module transmits the encrypted request message via Ethernet to the blockchain node directly connected to the data aggregation gateway, and sends a transaction on-chain request to the blockchain node.
[0094] After receiving the encrypted request message, the Ethernet communication module in the blockchain node transmits the encrypted request message to the CPU of the TEE trusted execution environment through its internal bus for data processing. Specifically, the blockchain node verifies the signature of the request message in its TEE trusted execution environment to confirm the source of the message. The encrypted request message is then decrypted using the private key of the blockchain node to obtain the unencrypted request message. The blockchain node then uses a high-speed consensus algorithm to reach a consensus on the decrypted request message to complete the storage or execution of the original data on the blockchain.
[0095] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A data collection method based on blockchain and IoT data aggregation gateway, characterized in that: The following steps are involved: S1. Collect the original data from the source, encrypt the collected original data using the public key of the data aggregation gateway, sign the message using the private key, and then transmit the encrypted original data to the data aggregation gateway; S2. The data aggregation gateway uses multi-factor authentication to verify the source of the received encrypted original data; after the verification, the encrypted original data is decrypted using the private key of the data aggregation gateway to obtain the original data; wherein the step of using multi-factor authentication to verify the source of the received encrypted original data includes: S2.
1. The data aggregation gateway obtains the MAC Header in the CCMP frame of the encrypted original data based on the WPA2-PSK protocol, and obtains the corresponding device unique identifier through the MAC Header on the blockchain ID 1; S2.2, the data aggregation gateway is in the TEE trusted execution environment, and searches for the public key of the source in its memory, uses the public key of the source to sign and decrypt the encrypted original data, authenticates the source, and executes step S2.3 after obtaining the source identity information; if decryption is not possible, the uplink failure information is returned to the source, and the process jumps to step S1; S2.
3. The data aggregation gateway searches for the corresponding device unique identifier on the blockchain based on the source identity information. ID 2, and unique device identifier ID 1. Compare. If the comparison is consistent, the data source verification is passed; otherwise, the uplink failure information is returned to the source end and the process jumps to step S1; S3. The data aggregation gateway encapsulates the decrypted original data into a request message, encrypts it using the public key of the blockchain node, and then signs it using the private key of the data aggregation gateway to obtain the encrypted request message, and sends a transaction on-chain request to any blockchain node directly connected to the data aggregation gateway; S4. The blockchain node performs signature verification on the received transaction chain request, and decrypts the transaction chain request that passes the signature verification using the private key of the blockchain node to obtain a request message; S5. The blockchain nodes use a high-speed consensus algorithm to reach a consensus on the decrypted request message, and complete the storage or execution of the original data on the blockchain; wherein the step of using a high-speed consensus algorithm to reach a consensus on the decrypted request message includes: S5.
1. The blockchain node encapsulates the request message that has passed the signature verification into a Pre-prepare message, then signs the Pre-prepare message and broadcasts it to other nodes, and adds the request message to the cache pool of the master node of the current blockchain network; S5.
2. After the master node updates the known consensus conditions, it performs a polling operation and selects a target slave node from the slave nodes that received the Pre-prepare message. n k ; S5.
3. The master node randomly generates a verification string char , and the verification string char Adding to the header of the request message; S5.4, the master node sends the request message number Seq and the verification string char Encapsulated as an access token T seq After that, the access token T seq Send to secondary node n k ; S5.
5. Secondary Node n k Based on the access token T seq Number in Seq The corresponding request message is searched in the cache pool of the master node; if the request message is found to exist, the slave node n k Access token T seq Verification string in char The request is sent to the master node, which verifies the consistency of the verification string. If the verification is successful, the master node sends the complete request message to the slave node. n k ; Otherwise, return the link failure information to the source end and jump to step S1; S5.
6. Secondary Node n k After receiving the complete request message, the master node will provide feedback. After receiving the feedback, the master node will delete the corresponding request message in the cache pool. S5.7, Secondary Node n k Perform consistency check on the data summary of the received request message. After passing the consistency check, encapsulate the check result into a Prepare message, sign the Prepare message and broadcast it to all nodes in the blockchain network. S5.
8. When the master node and other slave nodes receive the Prepare message, they verify the signature of the Prepare message and perform a consistency check on the data digest in the Prepare message and the data digest in the Pre-prepare message. If the check fails, the message is discarded. If the check passes, the message is forwarded to the slave node. n k Returns a Prepare message encapsulating the verification result. When the secondary node n k Receive 2 f +1 Prepare message encapsulated with verification passed, then broadcast Commit message to the blockchain network; f Indicates the maximum number of failed nodes, faulty nodes, or malicious nodes that can be tolerated in the blockchain network; S5.9, when the master node and other slave nodes receive the Commit message, they verify the signature of the Commit message and perform a consistency check on the data digest in the Commit message and the data digest in the Pre-prepare message. If the check fails, the message is discarded. If the check passes, the message is forwarded to the slave node. n k Returns a Commit message encapsulating the verification result. When the secondary node n k Receive 2 f When +1 Commit message encapsulating the verification is received, the blockchain network reaches a majority consensus and returns a Reply message encapsulating the operation result to the source end.
2. The data collection method based on blockchain and IoT data aggregation gateway according to claim 1 is characterized in that: In the step S3, the step of encapsulating the decrypted original data into a request message includes: calculating the original data m Summary of data in D ( m ), the original data m And its data summary D ( m ), and the data aggregation gateway signature is encapsulated into the request information.
3. The data collection method based on blockchain and IoT data aggregation gateway according to claim 1 is characterized in that: The Commit message includes a data summary, original data and a node signature.
4. The data collection method based on blockchain and IoT data aggregation gateway according to claim 1 is characterized in that: The step S5 further includes the following steps: f +1 Reply message encapsulating the operation result, the request initiated by the source end reaches a consensus of the entire network; otherwise, the source end determines whether to resend the request to the master node.
5. The data collection method based on blockchain and IoT data aggregation gateway according to claim 1 is characterized in that: In step S5.2, the known consensus conditions updated by the master node include the number Seq of the request message; the total number of slave nodes N -1, where N The total number of nodes in the blockchain network; the sub-node number i ,in i =1,2,..., N -1; the length of the verification task queue of all slave nodes q i ; The reference computing power of all secondary nodes h i ; Master node polling operation count j ; Maximum system throughput of the blockchain network T max .
6. The data collection method based on blockchain and IoT data aggregation gateway according to claim 5 is characterized in that: In step S5.2, the steps of performing a polling operation after the master node updates the known consensus conditions include: S5.2.
1. The master node updates the known consensus conditions; S5.2.
2. The master node counts according to the current polling operation j Determine the number of the secondary node currently being polled i , which is expressed as follows: i = j FOR ( N -1); S5.2.
3. Master node calculation of slave node n i Processing load ; S5.2.
4. The master node will be the slave node n i Execution efficiency and maximum system throughput T max Compare: If it satisfies tq i < , then the current secondary node n i As target secondary node n k ;like tq i ≥ , then the processing load of other slave nodes is calculated, and the master node selects the slave node with the lowest processing load from other slave nodes as the target slave node n k ; Set the master node polling operation count j=j+ 1.
7. The data collection method based on blockchain and IoT data aggregation gateway according to claim 1 is characterized in that: In step S5.7, the secondary node n k The step of performing consistency check on the data digest of the received request message includes: calculating the number obtained from the master node cache pool Seq The summary of the request message , and compare it with the data digest in the Pre-prepare message D ( m ) are compared. If the two are consistent, it is judged that the consistency check has passed. Otherwise, the message is discarded, the uplink failure information is returned to the source end, and the process jumps to step S1.
8. A data collection system based on blockchain and IoT data aggregation gateway, applied to the data collection method according to any one of claims 1 to 7, characterized in that: include: IoT collection terminal, used to collect original data from the source; The IoT acquisition terminal includes a CPU with a TEE trusted execution environment, a WiFi communication module, and a general input and output module; Blockchain node, used to upload the original data collected by the source end to the blockchain network and save it after consensus; the blockchain node includes a CPU with a TEE trusted execution environment and an Ethernet communication module; A data aggregation gateway is used to connect the Internet of Things collection terminal and the blockchain node; the data aggregation gateway includes a CPU with a TEE trusted execution environment, a WiFi communication module and an Ethernet communication module; the data aggregation gateway uses the WiFi communication module to receive the encrypted original data sent by the Internet of Things collection terminal, and the data aggregation gateway uses the Ethernet communication module to send a transaction on-chain request to the blockchain node directly connected to the data aggregation gateway.
