A blockchain-based federated learning method for internet of vehicles
By introducing blockchain technology into the model verification and incentive mechanism of connected vehicle federated learning, the problems of malicious client poisoning attacks and unfairness are solved, the security and fairness of the global model are achieved, the participation of benign clients is encouraged, and the collaborative modeling of connected vehicles is protected.
Patent Information
- Application Number
- CN202410588289.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-13
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2044-05-13
AI Technical Summary
There are security and fairness issues in federated learning in vehicle-to-everything (V2X) systems. Malicious clients may disrupt the global model through poisoning attacks, and dishonest clients may unfairly profit, which may discourage the participation of benign clients.
The system employs a blockchain-based model verification and incentive mechanism, coordinates vehicle client collaboration through smart contracts, identifies and punishes malicious clients, encourages the participation of benign clients, and uses a virtual currency incentive mechanism to evaluate contributions, thereby achieving fairness.
It effectively prevents malicious client poisoning attacks, protects the performance of the global model, ensures the security and fairness of vehicle network collaborative modeling, encourages the participation of benign clients, and achieves fair incentive distribution.
Smart Images

Figure CN118488075B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent transportation, and more specifically to a blockchain-based federated learning method for vehicle networks. Background Technology
[0002] With the rapid development of vehicle-to-everything (V2X) technology, vehicles are using increasingly advanced sensors and computing devices to collect and process massive amounts of data. To train models using multiple vehicle datasets while protecting user data privacy, federated learning has been introduced into V2X. Data sharing between vehicles increases the amount of data and covers more scenarios, thereby improving the generalization performance of models and better serving tasks such as vehicle health monitoring and traffic congestion prediction.
[0003] When federated learning is applied to connected vehicles (V2V), it faces challenges related to both security and fairness. Regarding security, a malicious central server may exhibit client bias or launch poisoning attacks to disrupt the global model; malicious vehicle clients can collude to poison data or the model, ultimately causing the global model to fail and posing a significant security risk to the V2V. In terms of fairness, dishonest clients contribute only a small amount of data and computing resources, thus unfairly profiting from V2V collaboration. This unfairness diminishes the incentive for benign vehicle clients to participate in federated learning. Summary of the Invention
[0004] To address the shortcomings of existing technologies, this invention proposes a blockchain-based federated learning method for vehicle-to-everything (V2X) networks. The specific technical solution is as follows:
[0005] A blockchain-based federated learning method for connected vehicles includes the following steps:
[0006] S1: A blockchain network is built through the Internet of Vehicles (IoV), with each node in the blockchain network acting as a vehicle client. Before training the federated learning model, each vehicle client uploads a predetermined amount of virtual currency to the smart contract to purchase the right to use the trained federated learning model.
[0007] S2: Each vehicle client acquires historical data through onboard sensors and preprocesses the historical data; each vehicle client downloads the initialized federated learning model and training parameters from the blockchain, inputs the preprocessed historical data into the federated learning model for training, and obtains the parameters of the local model; finally, the local model parameters are digitally signed and encapsulated, and uploaded to the blockchain network in the form of a transaction.
[0008] S3: After all vehicle clients have completed uploading or the scheduled time has arrived, model verification is performed. That is, all vehicle clients download the local model parameters uploaded by other clients, perform cross-validation on the local dataset, obtain the model's verification accuracy, and upload it to the blockchain in the form of a transaction. After all clients have completed uploading or the scheduled time has arrived, the smart contract estimates the global verification accuracy of each local model based on the cross-validation results, and then determines the malicious poisoning client.
[0009] S4: The smart contract evaluates the contribution of all clients in this round of federated learning based on the global verification accuracy of each local model and the update range of model parameters, and gives corresponding incentive weights in virtual currency, thereby encouraging vehicle clients participating in federated learning to provide data and computing power, and punishing malicious clients that carry out poisoning attacks or free-riding.
[0010] S5: The smart contract uses the FedAvg algorithm to aggregate the parameters of the local model determined to be non-malicious clients, obtain the global model and its parameters, and record the global model parameters to the blockchain; the vehicle client downloads the global model parameters from the blockchain and updates them locally, returns to S2, until the preset training rounds are reached or the global model converges, and then executes S6;
[0011] S6: The smart contract distributes virtual currency incentives to each client based on the incentive weight allocation results of each round.
[0012] Furthermore, step three includes the following steps:
[0013] S3.1: For vehicle client k, cross-validate the local models of all other clients using the local dataset to obtain the validation accuracy dataset of vehicle client k against each local model.
[0014] Where t represents the round of federated learning, and K represents the total number of vehicle clients participating in federated learning. This represents the validation accuracy of the local model uploaded by vehicle client K on the local dataset of vehicle client K in the t-th round of federated learning.
[0015] S3.2: Cross-validation accuracy of the local model uploaded by the smart contract from the vehicle client k Choose one of the subsets S a And calculate S a mean The global validation accuracy of the local model of client k is used as the basis for the following:
[0016]
[0017] S a Satisfy size is And with the smallest variance:
[0018]
[0019] The calculation formula is as follows:
[0020]
[0021] (3.3) Smart contracts will globally verify the highest accuracy Each local model is identified as a benign local model, and the mean global validation accuracy 'a' of the benign local models is calculated. t and standard deviation σ t , used to represent the average magnitude of the verification accuracy of benign local models; smart contracts use the z-score algorithm to identify malicious models as follows:
[0022]
[0023] Where k1 is a pre-set constant.
[0024] Furthermore, step four includes the following sub-steps:
[0025] S4.1: Smart contract contribution score for each client This represents the client's contribution to this round of federated learning and is initialized to the global validation accuracy of the client's local model. For malicious clients identified as launching poison attacks, their contribution score is set to 0;
[0026] S4.2: For each local model, the smart contract uses the L1 norm to measure and normalize the update magnitude of the model before and after local training, and calculates the score coefficient.
[0027]
[0028] Where k2 is a preset constant, representing the importance of the model update magnitude metric in evaluating the client's contribution; w t-1 This represents the global model obtained in the (t-1)th round of federated learning;
[0029] S4.3: For For clients with a value of 0, the incentive weight is 0; for For clients with non-zero values, according to Calculate incentive weights for ranking from largest to smallest.
[0030]
[0031] Furthermore, step six includes the following sub-steps:
[0032] (6.1) Smart contracts allocate weights based on incentives. The average incentive allocation weight r for client k is calculated using the following formula. k :
[0033]
[0034] Where t represents the training round of federated learning;
[0035] (6.2) The smart contract calculates and allocates the incentive amount, and the client k is finally allocated the incentive amount m. k for:
[0036] m k =MKr k
[0037] Where M is the virtual currency prepaid by each client, and MK is the total amount of incentive bonuses.
[0038] A blockchain-based connected vehicle federated learning system includes one or more processors for implementing a blockchain-based connected vehicle federated learning method.
[0039] A computer-readable storage medium having a program stored thereon that, when executed by a processor, implements a blockchain-based federated learning method for connected vehicles.
[0040] The beneficial effects of this invention are as follows:
[0041] This invention addresses the security and fairness issues in vehicular network (V2V) federated learning by introducing a blockchain-based model verification and incentive mechanism. Regarding security, by introducing blockchain technology into V2V federated learning and utilizing smart contracts to coordinate collaboration among vehicle clients, the invention eliminates the dependence on centralized servers and avoids security threats originating from dishonest centralized servers. Furthermore, by verifying the local models uploaded by clients, malicious clients uploading poisoned models are identified and excluded, thus protecting the overall model performance. Regarding fairness, a blockchain-based virtual currency is introduced as an incentive mechanism. The contribution of vehicle clients to federated learning is evaluated based on both local model accuracy and model update frequency, encouraging benign clients to invest local data and computing resources. Malicious clients that launch poisoned attacks or free-ride are punished, thereby maintaining fairness in collaborative modeling within the V2V network. Attached Figure Description
[0042] Figure 1 This is a diagram of the blockchain-based federated learning system architecture for the Internet of Vehicles (IoV) of this invention.
[0043] Figure 2 A graph showing the impact of the model validation mechanism on the test accuracy of the global model when a malicious client performs a label-flipping attack.
[0044] Figure 3 A graph showing the impact of the model validation mechanism on the test accuracy of the global model when a gradient flip attack is performed on a malicious client.
[0045] Figure 4 This is a bar chart showing the total incentive amount for each client group when incentives are divided based on the validation accuracy of each client's local model.
[0046] Figure 5 This is a bar chart showing the total incentive amount for each client group when dividing incentives according to the incentive mechanism proposed in this invention. Detailed Implementation
[0047] The present invention will be described in detail below with reference to the accompanying drawings and preferred embodiments. The purpose and effects of the present invention will become clearer. It should be understood that the specific embodiments described herein are merely for explaining the present invention and are not intended to limit the present invention.
[0048] like Figure 1 As shown, the blockchain-based federated learning method for connected vehicles in this embodiment includes the following steps:
[0049] Step 1: Construct a blockchain network through the Internet of Vehicles (IoV), where each node in the blockchain network is a vehicle client. Before training the federated learning model, each vehicle client uploads a predetermined amount of virtual currency to the smart contract to purchase the right to use the trained federated learning model.
[0050] The target tasks, model structures, and initial model parameters differ, and these can be negotiated and confirmed by the vehicle client. All virtual currency paid by the vehicle client constitutes a prize pool, serving as the source of bounties to incentivize the client.
[0051] Step 2: Each vehicle client acquires historical data through onboard sensors and preprocesses the historical data; each vehicle client downloads the initialized federated learning model and training parameters from the blockchain, inputs the preprocessed historical data into the federated learning model for training, and obtains the parameters of the local model; finally, the local model parameters are digitally signed and encapsulated, and uploaded to the blockchain network in the form of a transaction.
[0052] The historical data acquired through vehicle-mounted sensors includes environmental data such as road type, road conditions, and congestion, as well as operating condition data such as engine status and motor status. Preprocessing of the historical data includes missing value imputation, outlier removal, dimensionality transformation, and data standardization.
[0053] Step 3: After all vehicle clients have completed uploading or the predetermined time has elapsed, model verification is performed. This involves all vehicle clients downloading the local model parameters uploaded by other clients, performing cross-validation on their local datasets to obtain the model's verification accuracy, and uploading this information to the blockchain in the form of a transaction. After all clients have completed uploading or the predetermined time has elapsed, the smart contract estimates the global verification accuracy of each local model based on the cross-validation results, thereby identifying malicious poisoning clients. Step 3 specifically includes the following sub-steps:
[0054] (3.1) The client downloads local models from other clients and performs cross-validation:
[0055] In the t-th round of federated learning, for vehicle client k, the local dataset is used to train each local model. Perform cross-validation to obtain the validation accuracy of each local model. Where K represents the total number of vehicle clients participating in federated learning. This represents the validation accuracy of the local model uploaded by vehicle client K on the local dataset of vehicle client K.
[0056] (3.2) The smart contract calculates the global validation accuracy of the local model based on the cross-validation results;
[0057] For the local model uploaded by vehicle client k, there is cross-validation accuracy. Smart contracts select cross-validation precision One of the subsets S a S is required a Size is And satisfy S a Minimum variance:
[0058]
[0059] S a mean Global validation accuracy as the local model of client k:
[0060]
[0061] (3.3) Smart Contract Poisoning Detection Model
[0062] Smart contracts will globally verify the highest accuracy Each local model is identified as a benign local model, and the mean global validation accuracy 'a' of the benign local models is calculated. t and standard deviation σ t , used to represent the average verification accuracy of benign local models. The smart contract uses the z-score algorithm to identify malicious models as follows:
[0063]
[0064] Where k1 is a pre-set constant, which is 3 by default in this embodiment. In the t-th round of federated learning, the set of benign clients is denoted as S. t .
[0065] Step 4: The smart contract evaluates the contribution of all clients in this round of federated learning based on the global verification accuracy of each local model and the magnitude of model parameter updates, and assigns corresponding virtual currency incentive weights to encourage participating vehicle clients to provide data and computing power, while punishing malicious clients that carry out poisoning attacks or free-riding.
[0066] Step four includes the following sub-steps:
[0067] (4.1) Smart Contract Initialization Client Contribution Scoring
[0068] Smart contracts use contribution scores for each client. This represents the client's contribution to this round of federated learning and is initialized to the global validation accuracy of the client's local model.
[0069]
[0070] For malicious clients identified as poisoning attackers in step (3.3), their contribution score is set to 0, thereby punishing the malicious clients that launched the poisoning attack.
[0071] (4.2) Smart contracts punish dishonest clients who free-ride.
[0072] For each local model, the smart contract uses the L1 norm to measure and normalize the update magnitude of the model before and after local training, and calculates the score coefficient.
[0073]
[0074] Where k2 is a preset constant, representing the importance of the model update magnitude metric in evaluating the client's contribution; w t-1 Let represent the global model obtained in the (t-1)th round of federated learning.
[0075] (4.3) Smart contract calculation of incentive weights
[0076] for For clients with a value of 0, the incentive weight is 0; for For clients with non-zero values, according to Calculate incentive weights for ranking from largest to smallest.
[0077]
[0078] Step 5: The smart contract uses the FedAvg algorithm to aggregate the parameters of the local model determined to be non-malicious clients, obtain the global model and its parameters, and record the global model parameters to the blockchain; the vehicle client downloads the global model parameters from the blockchain and updates them locally, then returns to Step 2, until the preset training rounds are reached or the global model converges, then proceeds to Step 6.
[0079] Step Six: The smart contract distributes the virtual currency incentives to each client based on the incentive weight allocation results of each round. Step Six includes the following sub-steps:
[0080] (6.1) Smart contracts allocate weights based on incentives. The average incentive allocation weight r for client k is calculated using the following formula. k :
[0081]
[0082] Where t represents the training round of federated learning.
[0083] (6.2) The smart contract calculates and allocates the incentive amount, and the client k is finally allocated the incentive amount m. k for:
[0084] m k =MKr k
[0085] In this system, M represents the virtual currency pre-paid by each client, and MK represents the total amount of incentive bonuses. The smart contract distributes the virtual currency to the clients through transactions and writes it into the blockchain.
[0086] This invention provides a blockchain-based connected vehicle federated learning system, which includes one or more processors for implementing the blockchain-based connected vehicle federated learning method described in the above embodiments.
[0087] The embodiments of the blockchain-based connected vehicle federated learning system of this invention can be applied to any device with data processing capabilities, such as a computer. The device embodiments can be implemented through software, hardware, or a combination of both. Taking software implementation as an example, as a logical system, it is formed by the processor of the device with data processing capabilities reading the corresponding computer program instructions from non-volatile memory into memory and executing them. From a hardware perspective, in addition to the processor, memory, network interface, and non-volatile memory, the device with data processing capabilities in the embodiments may also include other hardware depending on its actual functions; these will not be elaborated further.
[0088] The implementation process of the functions and roles of each unit in the above system is detailed in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0089] For the system embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of the present invention according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0090] This invention also provides a computer-readable storage medium storing a program thereon, which, when executed by a processor, implements the blockchain-based connected vehicle federated learning method described in the above embodiments.
[0091] The computer-readable storage medium can be an internal storage unit of any data processing device described in any of the foregoing embodiments, such as a hard disk or memory. The computer-readable storage medium can also be an external storage device, such as a plug-in hard disk, smart media card (SMC), SD card, flash card, etc., equipped on the device. Furthermore, the computer-readable storage medium can include both internal storage units of any data processing device and external storage devices. The computer-readable storage medium is used to store the computing program and other programs and data required by the data processing device, and can also be used to temporarily store data that has been output or will be output.
[0092] The following numerical example illustrates the security and fairness of the invented blockchain-based federated learning model verification and incentive method for vehicle networking.
[0093] In terms of security, nine vehicle clients were set up, four of which were malicious clients that colluded with each other to poison the model during local training. The poisoning attack methods included label flipping attacks and gradient flipping attacks. Figure 2 This demonstrates the impact of the model validation mechanism on the test accuracy of the global model when a malicious client performs a label-flipping attack. Figure 3 This demonstrates the impact of model validation mechanisms on the test accuracy of the global model when a malicious client performs a gradient flip attack. From... Figure 2 and Figure 3 As can be seen, the model verification mechanism can effectively defend against malicious client poisoning attacks and protect the testing accuracy of the global model.
[0094] To ensure fairness, collaborative training was conducted using different types of vehicle clients, including normal clients, malicious clients attempting poisoning attacks, and dishonest clients free-riding. Within the normal client group, three groups were further divided based on the amount of local training data: 1x, 5x, and 10x the amount of data. Figure 4 This demonstrates the final incentive amount received by each client group when incentive allocation is based solely on the validation accuracy of the local models uploaded by each client. Figure 4 As can be seen, malicious clients that launch poisoning attacks can still receive a small amount of incentive, while dishonest clients that free-ride receive even higher incentives than normal clients, indicating an unfair situation. Figure 5 This demonstrates the final incentive amount received by each client group when incentives are allocated according to the incentive mechanism proposed in this invention. Figure 5 As can be seen, malicious clients that launch poisoning attacks and dishonest clients that free-ride are not incentivized, while normal clients receive more incentives for contributing more data, thus achieving fairness in incentive distribution.
[0095] It will be understood by those skilled in the art that the above descriptions are merely preferred examples of the invention and are not intended to limit the invention. Although the invention has been described in detail with reference to the foregoing examples, those skilled in the art can still modify the technical solutions described in the foregoing examples or make equivalent substitutions for some of the technical features. All modifications and equivalent substitutions made within the spirit and principles of the invention should be included within the scope of protection of the invention.
Claims
1. A blockchain-based federated learning method for vehicle-to-everything (V2X) networks, characterized in that, Includes the following steps: S1: A blockchain network is built through the Internet of Vehicles (IoV), with each node in the blockchain network acting as a vehicle client. Before training the federated learning model, each vehicle client uploads a predetermined amount of virtual currency to the smart contract to purchase the right to use the trained federated learning model. S2: Each vehicle client acquires historical data through onboard sensors and preprocesses the historical data; each vehicle client downloads the initialized federated learning model and training parameters from the blockchain, inputs the preprocessed historical data into the federated learning model for training, and obtains the parameters of the local model; finally, the local model parameters are digitally signed and encapsulated, and uploaded to the blockchain network in the form of a transaction. S3: After all vehicle clients have completed uploading or the scheduled time has arrived, model verification is performed. That is, all vehicle clients download the local model parameters uploaded by other clients, perform cross-validation on the local dataset, obtain the model's verification accuracy, and upload it to the blockchain in the form of a transaction. After all clients have completed uploading or the scheduled time has arrived, the smart contract estimates the global verification accuracy of each local model based on the cross-validation results, and then determines the malicious poisoning client. S4: The smart contract evaluates the contribution of all clients in this round of federated learning based on the global verification accuracy of each local model and the update range of model parameters, and gives corresponding incentive weights in virtual currency, thereby encouraging vehicle clients participating in federated learning to provide data and computing power, and punishing malicious clients that carry out poisoning attacks or free-riding. S5: The smart contract uses the FedAvg algorithm to aggregate the parameters of the local model determined to be non-malicious clients, obtain the global model and its parameters, and record the global model parameters to the blockchain; the vehicle client downloads the global model parameters from the blockchain and updates them locally, returns to S2, until the preset training rounds are reached or the global model converges, and then executes S6; S6: The smart contract distributes virtual currency incentives to each client based on the incentive weight allocation results of each round.
2. The blockchain-based federated learning method for vehicle networks according to claim 1, characterized in that, Step three includes the following steps: S3.1: For vehicle client k, cross-validate the local models of all other clients using the local dataset to obtain the validation accuracy dataset of vehicle client k against each local model. Where t represents the round of federated learning, and K represents the total number of vehicle clients participating in federated learning. This represents the validation accuracy of the local model uploaded by vehicle client K on the local dataset of vehicle client K in the t-th round of federated learning. S3.2: Cross-validation accuracy of the local model uploaded by the smart contract from the vehicle client k Choose one of the subsets S a And calculate S a mean The global validation accuracy of the local model of client k is used as the basis for the following: S a Satisfy size is And with the smallest variance: The calculation formula is as follows: (3.3) Smart contracts will globally verify the highest accuracy Each local model is identified as a benign local model, and the mean global validation accuracy 'a' of the benign local models is calculated. t and standard deviation σ t , used to represent the average magnitude of the verification accuracy of benign local models; smart contracts use the z-score algorithm to identify malicious models as follows: Where k1 is a pre-set constant.
3. The blockchain-based federated learning method for vehicle networks according to claim 1, characterized in that, Step four includes the following sub-steps: S4.1: Smart contract contribution score for each client This represents the client's contribution to this round of federated learning and is initialized to the global validation accuracy of the client's local model. For malicious clients identified as launching poison attacks, their contribution score is set to 0; S4.2: For each local model, the smart contract uses the L1 norm to measure and normalize the update magnitude of the model before and after local training, and calculates the score coefficient. Where k2 is a preset constant, representing the importance of the model update magnitude metric in evaluating the client's contribution; w t-1 This represents the global model obtained in the (t-1)th round of federated learning; S4.3: For For clients with a value of 0, the incentive weight is 0; for For clients with non-zero values, according to Calculate incentive weights for ranking from largest to smallest.
4. The blockchain-based federated learning method for vehicle networks according to claim 1, characterized in that, Step six includes the following sub-steps: (6.1) Smart contracts allocate weights based on incentives. The average incentive allocation weight r for client k is calculated using the following formula. k : Where t represents the training round of federated learning; (6.2) The smart contract calculates and allocates the incentive amount, and the client k is finally allocated the incentive amount m. k for: m k =MKr k Where M is the virtual currency prepaid by each client, and MK is the total amount of incentive bonuses.
5. A blockchain-based connected vehicle federated learning system, characterized in that, It includes one or more processors for implementing the blockchain-based connected vehicle federated learning method according to any one of claims 1 to 4.
6. A computer-readable storage medium, characterized in that, It stores a program that, when executed by a processor, implements the blockchain-based connected vehicle federated learning method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Block chain-based internet of vehicles information sharing excitation method
CN109978623A
Federated learning management method and apparatus, and computer device and storage medium
WO2023071106A1