Methods for establishing a two-layer blockchain architecture supporting trusted machine learning in the Internet of Vehicles
By constructing a dynamic sharding consensus mechanism and a two-layer blockchain architecture in the Internet of Vehicles (IoV), the problem of machine learning models being susceptible to malicious data has been solved, enabling trusted data transmission and storage, and improving the security and intelligence level of the IoV.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-15
- Publication Date
- 2026-03-13
AI Technical Summary
Machine learning models in the Internet of Vehicles are susceptible to malicious data, leading to inaccurate learning results. Furthermore, the low coupling efficiency between blockchain technology and machine learning affects traffic safety.
A dynamic sharding consensus mechanism is adopted, which divides the data into shards based on geographical location, selects active nodes to form consensus groups and elects master nodes, and combines practical Byzantine fault-tolerant consensus and delegated proof-of-stake consensus to build a two-layer blockchain architecture to achieve trusted data transmission and storage.
This improved data security and the reliability of machine learning models, increased throughput, reduced consensus failure probability, and ensured the safety and intelligence of the transportation system.
Smart Images

Figure CN116743777B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of vehicle networking technology, and in particular to a method for establishing a two-layer blockchain architecture that supports trusted machine learning in vehicle networking. Background Technology
[0002] Vehicle-to-everything (V2X) technology connects traffic entities such as vehicles, roadside units, and infrastructure, improving traffic efficiency and safety. In V2X systems, these entities collect and share traffic data such as vehicle speed, location, and road conditions, enabling safer and smarter driving. Furthermore, by introducing machine learning techniques, the massive amounts of data within the V2X can be effectively utilized. V2X systems can train specific machine learning models using traffic data to address different scenarios and needs, enabling functions such as traffic prediction, route planning, and vehicle dispatching, thus making V2X more intelligent and convenient.
[0003] However, machine learning, as a data-driven method, is susceptible to malicious data during training, leading to inaccurate learning models and affecting practical results. Furthermore, vehicle data sharing in the Internet of Vehicles (IoV) has a degree of autonomy; if erroneous or malicious data is uploaded for model training, it will have a significant impact on the results, seriously affecting traffic safety. Although blockchain technology, with its tamper-proof and distributed storage characteristics, can ensure the security and trustworthiness of data in the IoV, it also suffers from inefficiency and poor coupling with machine learning. Therefore, researching an efficient two-layer blockchain architecture that supports trusted machine learning in the IoV is of great significance for the intelligentization of the IoV. Summary of the Invention
[0004] To address the aforementioned issues, this invention proposes a method for establishing a two-layer blockchain architecture that supports trusted machine learning in the Internet of Vehicles, effectively improving data security and the credibility of machine learning model outputs.
[0005] To achieve the above objectives, the technical solution of the present invention is as follows: a method for establishing a two-layer blockchain architecture supporting trusted machine learning in the Internet of Vehicles, comprising the following steps:
[0006] A. Dynamic consensus within shards:
[0007] A1. The sharding is based on the geographical location of the traffic area. Each shard includes several Roadside Units (RSUs) and the vehicles within their coverage area. The consensus scheme operates on an epoch-based basis, where an epoch is a fixed number of intra-shard transaction consensus rounds or a fixed duration.
[0008] A2. At the beginning of each era, identify the active node graph g within the partition. i =(V i E i It satisfies the following formula:
[0009]
[0010] st|V i |=max{|V1|,…,|V n |},
[0011]
[0012]
[0013] Where G=(V,E)={g1,…,g i ,…,g n} represents the node graph within the partition, g i Let G be a subgraph of G, V be the set of all nodes within the partition, and E ∈ [0,1]. n×n V is the set of edges between nodes. i It is a subset of V, E i It is a subset of E. If node v i and v j There is communication between them, e ij =1,e ij ∈E, otherwise 0, |V i | represents the number of nodes in the set, v j →v k Represents node v j to v k The path, where n represents the maximum value in the subscript, j∈[1,n], k∈[1,n], m∈[1,n] represent three integers in the interval [1,n]. V i This is the set of active nodes.
[0014] A3. Calculate the set of active nodes V i The reputation weight ω of the middle node is shown in formula (2):
[0015]
[0016] Where ω(n) represents node v n ∈V i The reputation weight, D(i) is the counter, and the count node v is the number of nodes. n Honest behavior in block i, k = |V i | represents set V i The number of elements in the node. l is the primary node factor, if node v n If node v is the master node in block i, then l = 1; otherwise, l = 0. p ∈ {-1, 1} is the penalty factor; if node v... n If Byzantine behavior is exhibited in block i, then p = -1; otherwise, p = 1.
[0017] A4. In the active node set V i A subset of nodes are selected to form a consensus group C = {c1, c2, ..., c...} j}, so that it satisfies formula (3):
[0018]
[0019] Where ω(i) is the node c i Reputation weight, |C| represents the number of elements in set C, and P(X|Y) is the conditional probability, which represents the probability of event X occurring under condition Y.
[0020] A5. Normalize the weights of each node in consensus group C, and divide the interval into (0,1] according to the weight ratio to obtain node c. i weight range The calculation is shown in formula (4):
[0021]
[0022] in, α i For the interval α i The lower bound, For the interval α i The upper boundary.
[0023] A6. Determine the principal node L such that it satisfies formula (5):
[0024]
[0025] Where VRF(·) is a verifiable random function and x is the seed.
[0026] A7. The master node L initiates the Practical Byzantine Fault Tolerance (PBFT) consensus within the consensus group C and verifies the transactions, as shown in formula (6):
[0027]
[0028] Among them, H d =SHA( <m>) represents the hash value of the transaction data. <m>The transaction contains detailed data; SHA(·) is a secure hash function; t i Represents a timestamp. Indicates vehicle n i The signature.
[0029] B. Establish a two-layer blockchain architecture
[0030] B1. The vehicle uses the collected data for local training, where the loss function is L(f x Therefore, vehicle n i The local model is shown in equation (7):
[0031]
[0032] Wherein, L(f) x )=F( <m>(,ε) is a model with parameter ε on the dataset. <m>The loss function generated by the instance in.
[0033] B2, Vehicle n i The training results are sent to nearby roadside units in the form of transactions. The transaction format is shown in formula (8):
[0034]
[0035] Among them, H V For transaction hash, The hash value of the transaction data, a tuple Detailed data on vehicle transactions. Indicates local model parameters, t represents the local training loss. i Looking at the timestamp of the current transaction publication, Indicates vehicle n i The signature.
[0036] B3, Roadside Unit Receives Transaction T V Then, the transaction is sent to the master node L selected by the consensus algorithm within the dynamic sharding, and the Practical Byzantine Fault-Tolerant Consensus Algorithm is used to process T. V Verify and package into block S i Stored in the sharded chain, as shown in formula (9):
[0037]
[0038] Where r∈{0,1} is the consensus result, if transaction T V If the verification passes, r = 1; otherwise, r = 0, resulting in a triplet. <H i-1 H M ,t i >For block S i The block header, H i-1 H represents the hash value of the previous block. M The hash value of the Merkle root of the block body, ti represents the timestamp, and the tuple is... This represents the block body, which records block S. i All transactions packaged together.
[0039] B4. The roadside unit uses the collected model parameters and its own collected data to perform secondary training to obtain model parameters. Then the parameters are set to the transaction T. R The data is sent to the base station in the form shown in formula (10):
[0040]
[0041] in, H is the loss function for secondary training. R For transaction hash, The hash value of the transaction data, a tuple Detailed data for RSU transactions. This represents the model parameters after secondary training. This indicates the loss during secondary training.
[0042] B5. When the base station receives T R Afterwards, initiate the Delegated Proof-of-Stake (DPoS) consensus mechanism. Verify and broadcast the consensus results, as shown in formula (11):
[0043] (0,1)←DPoS(T R (11)
[0044] B6. The base station successfully achieved consensus. Packaged into block B i And recorded on the global blockchain. Block B i As shown in formula (12):
[0045]
[0046] Among them, triplet <H i-1 H M ,t i For block B i Block header, multi-group This represents the block body, which records block B. i All transactions packaged in the middle.
[0047] Compared with the prior art, the present invention has the following beneficial effects:
[0048] 1. This invention proposes a dynamic intra-shard consensus mechanism. Step A involves electing nodes with high stability and reliability in each shard to form a consensus group. An unpredictable master node is then selected based on the node's reliability weight, and consensus is initiated. Verified data is packaged into blocks and stored in each shard, thus ensuring data trustworthiness and immutability. Based on state sharding, this invention employs a practical Byzantine fault-tolerant algorithm. By selecting nodes with higher reliability to form consensus groups, it effectively improves the consensus success rate and weakens the influence of Byzantine nodes, thereby ensuring the accuracy and trustworthiness of on-chain data. In the case of 8 shards, the throughput of this invention is 167% higher than PBFT, and the consensus failure probability is less than 0.2% when the proportion of Byzantine nodes in a shard is 30%.
[0049] 2. This invention couples a two-layer blockchain architecture with machine learning to construct a blockchain system that supports trusted machine learning. Vehicles in the shards use collected data for local training and send the training parameters to roadside units, which then generate blocks and store them on the shard chain. Simultaneously, the roadside units perform secondary training using the received parameters and their own collected data, and send the training results to the base station in the form of transactions. The base station stores the final training results on the global chain. Through two-stage training and consensus, this invention ensures the trustworthiness of the machine learning results. With the training set and test set comprising 80% and 20% respectively, taking the prediction of road conditions within 15 minutes as an example, the accuracies of the machine learning models of this invention—the convolutional neural network, the gated recurrent unit, and the temporal convolutional neural network—are 0.867, 0.911, and 0.913, respectively. Attached Figure Description
[0050] This invention has a total of appendices Figure 4 Zhang, of which:
[0051] Figure 1 This is a flowchart of the present invention.
[0052] Figure 2 This is an overall architecture diagram of the present invention.
[0053] Figure 3 This is a throughput comparison chart.
[0054] Figure 4 This is a chart comparing the probability of consensus failure. Detailed Implementation
[0055] The invention will now be further described with reference to the accompanying drawings. Figure 1 The process shown involves collecting and training traffic data. First, the data is divided into zones based on the geographical location of vehicles and roadside units, such as... Figure 2 As shown, vehicles collect data and perform local training on the data, then send the training results to nearby roadside units in the form of transactions. Each roadside unit in each shard, following step A of this invention, constructs a consensus group and elects a master node. The master node then initiates consensus to verify the collected transactions, broadcasts the consensus result to other nodes, and adds the block to the shard chain. Subsequently, following step B of this invention, the roadside unit uses the collected model parameters and its own collected data to perform secondary training on the model, and then sends the training results... The data is sent to the base station, which initiates a delegated proof-of-stake mechanism to verify the collected model parameters and broadcasts the consensus results. Finally, transactions that have successfully reached consensus are packaged into blocks and stored on the global blockchain.
[0056] Figure 3 This is a comparison chart of the throughput of vehicle-to-everything (V2X) systems employing this invention and the Practical Byzantine Fault-Tolerant Algorithm (PBFT). To verify the throughput advantage of this invention, the number of shards in this invention was set to 4, 6, and 8, respectively, and the transaction generation rate per second was set to increase from 500 transactions / second to 1000 transactions / second. Figure 4 As can be seen, as the number of transactions generated per second increases, the throughput of the vehicle network system using the PBFT consensus algorithm (marked as PBFT in the figure) remains at a low level, while the throughput of the present invention increases with the increase of the number of transactions generated per second. Finally, with 8 shards (marked as 8 shards in the figure), the throughput of the present invention is 1.69 times higher than that of the vehicle network system using the PBFT consensus.
[0057] Figure 4 This diagram compares the consensus failure probability of a vehicle-to-everything (V2X) system using this invention with other sharding methods. To verify the reliability advantage of this invention when facing Byzantine nodes, the proportion of Byzantine nodes was set to increase from 10% to 30% in the simulation, with 60 and 90 nodes per shard. In a V2X system using random sharding (marked as random allocation in the diagram), the sharding failure probability increases with the proportion of Byzantine nodes. When the proportion of Byzantine nodes is 30%, the consensus failure probability of random sharding is as high as 0.23. In contrast, this invention maintains a consensus failure probability of less than 0.23 even with a high proportion of Byzantine nodes, and the probability of consensus failure decreases with the increase of nodes per shard.
[0058] This invention is not limited to this embodiment. Any equivalent concept or modification within the technical scope disclosed in this invention shall be included within the protection scope of this invention.< / m> < / m> < / m> < / m>
Claims
1. A method for establishing a two-layer blockchain architecture supporting trusted machine learning in the Internet of Vehicles, characterized by: Includes the following steps: A. Dynamic consensus within shards: A1. The segments are divided according to the geographical location of the traffic area. Each segment includes several roadside units (RSUs) and the vehicles within their coverage area. The consensus scheme operates on an epoch basis, where an epoch is a fixed number of intra-segment transaction consensus rounds or a fixed length of time. A2. At the beginning of each era, identify the active node graph g within the partition. i =(V i E i It satisfies the following formula: s.t.|V i |=max{|V1|,…,|V n |}, Where G = (V, E) = {g1, ..., g} i , ..., g n } represents the node graph within the partition, g i Let G be a subgraph of G, V be the set of all nodes within the partition, and E ∈ [0, 1]. n×n V is the set of edges between nodes. i It is a subset of V, E i It is a subset of E; if node v i and v j There is communication between them, e ij =1,e ij ∈E, otherwise 0, |V i | represents the number of nodes in the set, v j →v k Represents node v j to v k The path, where n represents the maximum value in the subscript, j∈[1,n], k∈[1,n], and m∈[1,n] represent three integers in the interval [1,n]; V i A set of active nodes; A3. Calculate the set of active nodes V i The reputation weight ω of the middle node is shown in formula (2): Where ω(n) represents node v n ∈V i The reputation weight, D(i) is the counter, and the statistical node v is the number of nodes. n Honest behavior in block i, k = |V i | represents set V i The number of elements in the middle; l is the primary node factor, if node v n If node v is the master node in block i, then l = 1; otherwise, l = 0. p ∈ {-1, 1} is the penalty factor. n If Byzantine behavior is exhibited in block i, then p = -1; otherwise, p = 1. A4. In the active node set V i A subset of nodes are selected to form a consensus group C = {c1, c2, ..., c...} j }, so that it satisfies formula (3): Where ω(i) represents node c i Reputation weight, |C| represents the number of elements in set C, and P(X|Y) is the conditional probability, which represents the probability of event X occurring under condition Y. A5. Normalize the weights of each node in consensus group C, and divide the interval into (0, 1] according to the weight ratio to obtain node c. i weight range The calculation is shown in formula (4): in, α i For the interval α i The lower bound, For the interval α i The upper bound; A6. Determine the principal node L such that it satisfies formula (5): Where VRF(·) is a verifiable random function, and x is the seed; A7. The master node L initiates the Practical Byzantine Fault Tolerance (PBFT) consensus within the consensus group C and verifies the transactions, as shown in formula (6): Among them, H d =SHA( <m>) represents the hash value of the transaction data. <m>The transaction contains detailed data; SHA(·) is a secure hash function; t i Represents a timestamp. Indicates vehicle n i The signature;< / m> < / m> B. Establish a two-layer blockchain architecture B1. The vehicle uses the collected data for local training, where the loss function is L(f x Therefore, vehicle n i The local model is shown in equation (7): Wherein, L(f) x )=F( <m>(ε) is a model with parameter ε on the dataset. <m> The loss function generated by the instances in;< / m> < / m> B2, Vehicle n i The training results are sent to nearby roadside units in the form of transactions; the transaction format is shown in formula (8): Among them, H V For transaction hash, The hash value of the transaction data, a tuple Detailed data on vehicle transactions. Indicates local model parameters, t represents the local training loss. i Looking at the timestamp of the current transaction publication, Indicates vehicle n i The signature; B3, Roadside Unit Receives Transaction T V Then, the transaction is sent to the master node L selected by the consensus algorithm within the dynamic sharding, and the Practical Byzantine Fault-Tolerant Consensus Algorithm is used to process T. V Verify and package into block S i Stored in the sharded chain, as shown in formula (9): Where r∈{0,1} is the consensus result, if transaction T V If the verification passes, r = 1; otherwise, r = 0, resulting in a triplet. <H i-1 H M , t i For block S i The block header, H i-1 H represents the hash value of the previous block. M The hash value of the Merkle root of the block body, t i Represents timestamps, plural groups This represents the block body, which records block S. i All transactions in the package; B4. The roadside unit uses the collected model parameters and its own collected data to perform secondary training to obtain model parameters. Then the parameters are set to the transaction T. R The data is sent to the base station in the form shown in formula (10): in, H is the loss function for secondary training; R For transaction hash, The hash value of the transaction data, a tuple Detailed data for RSU transactions. This represents the model parameters after secondary training. Indicates the second training loss; B5. When the base station receives T R Afterwards, initiate the Delegated Proof-of-Stake (DPoS) consensus mechanism. Verify and broadcast the consensus results, as shown in formula (11): (0,1)←DPoS(T R ), (11) B6. The base station successfully achieved consensus. Packaged into block B i And recorded on the global chain; Block B i As shown in formula (12): Among them, triplet <H i-1 H M , t i For block B i Block header, multi-group This represents the block body, which records block B. i All transactions packaged in the middle.
Citation Information
Patent Citations
Vehicular ad-hoc network data security sharing and storage system based on blockchain technology
CN109451467A
Federal learning architecture construction method fusing block chain state fragmentation and reputation mechanism
CN115426353A