Blockchain and ternary federal learning based data privacy protection method for internet of vehicles
By combining blockchain with ternary federated learning, the security and efficiency issues in protecting data privacy in the Internet of Vehicles (IoV) are solved. This approach enables distributed data processing and model optimization, reduces communication costs, and enhances data security and credibility.
Patent Information
- Application Number
- CN202410888759.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2044-07-04
AI Technical Summary
Vehicle-to-everything (V2X) data privacy protection faces challenges such as single point of failure attacks, privacy leaks, member inference attacks, and high communication overhead. Traditional federated learning also has security and efficiency issues.
By employing a blockchain-based and ternary federated learning approach, model training and validation are performed at edge nodes. Gaussian noise is used to protect data privacy, and ternary gradient and federated differential privacy protection technologies are introduced. Combined with smart contracts and consensus algorithms of edge nodes, distributed data processing and secure storage are achieved.
Effectively protect the privacy of vehicle network data, reduce communication costs, improve data security and credibility, enhance the continuous optimization capability of models, and prevent data tampering and theft.
Smart Images

Figure CN119046973B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of Internet of Vehicles data processing, and relates to an Internet of Vehicles data privacy protection method based on a blockchain and a ternary federated learning. BACKGROUND
[0002] In the era of rapid development of the automobile industry, the construction of intelligent transportation systems has become an inevitable trend. In this information age, it has become possible to use vehicle data to achieve intelligent traffic management and services. Internet of Vehicles (IoV) as a new technology is gradually popularizing and applying, such as Figure 1 As shown in the figure, vehicles transmit data obtained from advanced vehicle equipment to the cloud through edge nodes to better improve the level of vehicle-related services. Internet of Vehicles is not only an extension of vehicle networks, vehicle remote communication and intelligent transportation systems, but also provides various services for vehicles and transportation systems and people inside and outside vehicles by integrating vehicles, sensors and mobile devices into a global network;
[0003] It is also due to the continuous progress of Internet of Vehicles technology that information exchange and communication between vehicles, between vehicles and road infrastructure, and between vehicles and the cloud have become more convenient and efficient. However, when it is popularized and applied, the privacy protection problem of Internet of Vehicles data gradually emerges. Various data generated by vehicles, including vehicle trajectory, speed, acceleration, vehicle environment, vehicle photography images, electric motor operation information and other information, may reveal the personal privacy of the vehicle owner, and even be maliciously used to cause safety risks. Therefore, how to protect the privacy and security of Internet of Vehicles data has become one of the problems to be solved in the development process of intelligent transportation systems. Federated learning as a new data training technology has become one of the important methods to solve the problem of privacy and security of Internet of Vehicles data due to its distributed local training advantage. However, gathering a large amount of private data on the central server for training poses a major security and privacy challenge, and also increases communication costs. More specifically:
[0004] 1) Single point of failure attack, traditional federated learning usually relies on a central server to coordinate and integrate model updates of various devices. This centralized architecture is easy to become the target of attackers, and once the central server is attacked or fails, the whole system will face serious single point of failure problem, leading to system unavailability or data loss;
[0005] 2) Privacy problem, although federated learning keeps data on local devices for model training, there are still certain privacy risks. During the model update process, some private information may be leaked through model parameters to the central server or other devices, especially in the model parameter aggregation process, private information of individual devices may be exposed;
[0006] 3) Member inference attack, member inference attack in federated learning refers to that an attacker infers the information of local devices participating in training by observing the update of global model parameters. By analyzing the update of model parameters, the attacker may be able to infer the training data distribution or features of certain devices, thereby infringing the privacy of users;
[0007] 4) Communication overhead, the communication overhead between devices and the central server in federated learning is a challenge. Each round of model update requires devices to transmit local model parameters to the central server and receive updates of global model parameters, which will cause a large amount of communication overhead, especially in the case of a large number of devices and limited bandwidth. SUMMARY
[0008] The technical scheme adopted by the present application is: a vehicle networking data privacy protection method based on blockchain and ternary federated learning, which comprises the following steps: in the application layer, the data requester first publishes a task request, and after receiving the task, the local vehicle trains the local model locally, and adds Gaussian noise during training to prevent member inference attack. After training, the original gradient is converted into ternary gradient and uploaded to the server, the server aggregates the ternary gradient and returns the result to the client (each local vehicle), then the user delays the result to a floating point number, and updates the model copy for subsequent training;
[0009] In the blockchain layer, the edge node (RSU) refers to an edge node usually equipped with certain computing and communication resources. Due to its strong computing, communication and storage capabilities, the verification value and local model update are stored in the data block by the edge node verified through the consensus algorithm, and its local model is broadcast in the network through the P2P broadcast function in the blockchain, wherein the verification value is generated by the smart contract to verify the relevant information of the user. Finally, the vehicle downloads the latest local model update of all vehicles from the blockchain and aggregates the global model.
[0010] The vehicle networking data privacy protection method based on blockchain and ternary federated learning comprises the following specific steps:
[0011] Step one, the requester (Roadside Unit) publishes a training task, that is, the requester sends the model to be trained and the related parameters to the participants, and requires them to train the model on the local data; this step aims to promote the participants to train the model while protecting the data privacy, so as to realize the global improvement of the model;
[0012] Step 2: Each vehicle or participant uses its local data to train the model without sending data to a central server. Each participant performs model training based on its local dataset and updates its local model to adapt to its local environment. This distributed training method helps protect data privacy, reduces data transmission, and enables the model to better adapt to the specific circumstances of each participant.
[0013] Step 3: In the process of federated learning, in order to protect the data privacy of participants, a certain degree of Gaussian noise and the verification value generated for local vehicles in the blockchain are added to the model update. This helps to increase the obfuscation of data during the model training process, making it difficult for attackers to infer the specific data information of individual participants, thereby protecting the privacy of data.
[0014] Step 4: During federated learning, each participant validates its locally trained model to ensure its performance and accuracy. If the model performs well in local validation, the participants choose to update it in the global model, thereby collectively improving the overall system's model performance.
[0015] Step 5: After training the federated learning model, the training results are recorded on the blockchain. This ensures the immutability and transparency of the data, preventing tampering or theft. Simultaneously, blockchain technology provides a distributed data storage and verification mechanism, further enhancing data protection and security. This blockchain-based federated learning method offers an effective solution for protecting data privacy in the Internet of Vehicles (IoV), improving data credibility and security while ensuring data privacy.
[0016] Step Six: In this step, the blockchain system selects nodes from edge nodes (including roadside units, traffic signal controllers, surveillance cameras and sensors, smart streetlights, vehicle-mounted units, etc.) and vehicle nodes. These nodes are responsible for verifying transactions and packaging them into blocks to ensure the normal operation of the blockchain network. By selecting edge nodes, distributed data storage and processing can be achieved, while protecting data privacy and security.
[0017] Step 7: The smart contract verifies the transaction and writes the verification value into the blockchain. The verified block is then broadcast through the P2P network, thus ensuring the credibility of the transaction and the security of the network.
[0018] Step eight, in this step, the blockchain will aggregate the model updates collected from various participants into a global model, which will take into account updates from various participants to obtain a more accurate and comprehensive model. Through the aggregation of model updates, the advantages of federated learning can be effectively utilized and the shortcomings of aggregating models on a central server in the past can be overcome, that is, while protecting data privacy, realizing continuous optimization and improvement of the model.
[0019] The local model adopts a ternary federated learning model, which introduces TernGrad ternary gradient technology, quantizes the previous gradient from a floating point to three discrete values: -1, 0 and +1, and introduces hierarchical ternarization and gradient clipping technology. Hierarchical ternarization divides the gradient into multiple levels and quantizes and transmits them respectively, and the gradient clipping technology controls the size of the gradient.
[0020] Further, the ternary federated learning model training method is as follows:
[0021] Worker (client: vehicle node or edge node): i = 1, 2,..., N
[0022] 1) Input A partial mini-batch of a training sample (such as motor operation data, vehicle state data, sensor data, environmental and traffic data, driving behavior data, vehicle communication data, user and passenger data, etc.);
[0023] 2) Calculate the gradient under
[0024] 3) Gradient clipping is performed on the gradient
[0025] 4) The clipped gradient is ternarized hierarchically as:
[0026]
[0027] In hierarchical ternarization, a layer-by-layer scaler is used to ternarize the gradient in each layer independently;
[0028] 5) Push the ternarized to the server;
[0029] 6) Pull the average gradient
[0030] 7) Update the parameters where ω t+1 and ω t are the parameter weights at time points t+1 and t respectively; η is the learning rate;
[0031] Server (server side):
[0032] 8) Average ternary gradient:
[0033] Further, the method of converting the original gradient to ternary gradient is:
[0034] Let the ternary conversion function be, the quantized gradient is as follows:
[0035]
[0036] wherein, wherein, b t is a random binary vector, g t is the original gradient, s t is the scaler, is the Hadamard product, and sign(·) is the sign of each element;
[0037] The scaler s t Adopt a shared scaling factor: denotes the scaler of the ith gradient;
[0038] For a given g t and b t , each element of which is independently subject to a Bernoulli distribution:
[0039]
[0040] wherein, b tk and g tk are the kth elements in the randomly taken b t and g t , respectively, after ternary conversion, the client uploads g t instead of the original gradient g t to the server, and the server returns the result to the client after aggregating the ternary gradient.
[0041] Further, the method of introducing layer-by-layer ternarization and gradient clipping above limits the size of each gradient g i in g to:
[0042]
[0043] wherein, σ is the standard deviation of the gradient in the gradient g, c is a hyperparameter, and c best = 2.5.
[0044] Furthermore, the aforementioned data privacy protection method for the Internet of Vehicles based on blockchain and ternary federated learning also includes data privacy protection methods on both the client and server sides. Both methods employ a federated differential privacy algorithm. During local training on the client side, the parameters need to be pruned after each local iteration. For the server-side federated differential privacy, clients are randomly selected based on probability, and they are allowed to perform local model training. Upon receiving the model parameters from each client, the server performs an aggregation operation. Regarding noise addition, the variance of the Gaussian noise distribution is calculated, and noise data is generated using the Gaussian distribution. This noise data is then added to the global model aggregation operation to obtain new global model parameters. This process is repeated until the model converges.
[0045] Furthermore, when the aforementioned client performs local training for federated learning, the model is compressed using a layer-sensitivity-based model compression method. The layer sensitivity is defined as follows: Let the current model be represented as G = {g1, g2, ..., g...}. L In round t, client C j When performing federated learning and training locally, the model will be trained from G. t =G becomes
[0046] Let the change in the i-th layer be denoted as
[0047]
[0048] The mean change δ of the parameters at each layer is called the sensitivity. This refers to the mean of the parameter updates for the i-th layer after the t-th round of federated learning and local training; the model compression implementation process based on layer sensitivity is as follows: for any selected client c j After the model has finished local training, according to the formula Calculate the change at each layer of the model The algorithm sorts the changes in each layer from smallest to largest, and uploads the layer with the highest sensitivity, while the layers with low sensitivity are not uploaded.
[0049] Furthermore, the aforementioned smart contracts include the clientManager contract, the NetworkManager contract, and the VerifySignature contract;
[0050] Among them, the clientManager contract is used to realize the registration function of the client, each client calls the register function to register itself, and assigns a unique client ID; mapping data structure is used to map the client address to the client ID; a counter nextId is maintained to generate the next client ID; the NetworkManager contract is used to manage network participants and training result records in federated learning; the VerifySignature contract is used to provide functions of generating, saving and verifying digital signatures.
[0051] The beneficial effects of the present application are as follows compared with the prior art:
[0052] (1) A kind of federated learning blockchain-based car networking data communication method Fast-CFLB (Fast-CarFederated Learning Blockchain) is proposed, which replaces the center server in federated learning with blockchain, thereby solving the single-point attack existing in traditional federated learning;
[0053] (2) Federal differential privacy protection technology is introduced, which is used to defend against member inference attacks encountered in federated learning, which not only ensures the privacy security of each client's local data, but also ensures the information security between clients;
[0054] (3) Layer sensitivity-based model compression technology is introduced, which can reduce model parameter redundancy in the training process under the condition that the training effect is almost the same, and resist attackers from using global information to reverse attack and further deduce the original data, thereby improving the security and communication efficiency of the system;
[0055] (4) A ternary federated learning technology is proposed, which replaces the floating-point gradient in federated learning with ternary gradient from the training gradient, thereby greatly improving the communication efficiency and reducing the communication cost to further achieve the goal of low energy consumption and high efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0056] Figure 1 is a general structure diagram of car networking;
[0057] Figure 2 is a neighboring data set diagram;
[0058] Figure 3 is a user neighboring data set diagram;
[0059] Figure 4 is a Gaussian mechanism concept diagram;
[0060] Figure 5 is a car networking data sharing framework diagram;
[0061] Figure 6 Figure 3 is a ternary federated learning graph;
[0062] Figure 7 Figure 4 is a block mining process graph;
[0063] Figure 8 Figure 5 is a CNN SVHN model structure graph;
[0064] Figure 9 Figure 6 is a graph for comparing the accuracy of the federated differential privacy scheme with the traditional centralized differential privacy scheme;
[0065] Figure 10 Figure 7 is a graph for the training accuracy value of the federated differential privacy itself parameter;
[0066] Figure 11 Figure 8 is a graph for comparing the gradient size uploaded by the client to the server (ternary) and the gradient size sent by the server to the client for three data sets (MNIST handwritten data set, SVHN street number data set, Cifar10 object classification data set);
[0067] Figure 12 Figure 9 is a graph for comparing the model training effect of the random gradient descent with the ternary conversion added and the ordinary random gradient descent using the MNIST and SVHN data sets respectively;
[0068] Figure 13 Figure 10 is a graph for observing the influence of changing the transmission layer parameter on the training effect by taking the transmission ratio rate as 91%, 94%, 97%, and 100% as experimental variables;
[0069] Figure 14 Figure 11 is a graph for observing the convergence curve comparison of the model with and without blockchain. DETAILED DESCRIPTION
[0070] The application will be further described below in combination with specific embodiments.
[0071] First of all, it should be pointed out that the ternary gradient theory, federated differential privacy, the full text symbol introduction and see Table 1.
[0072] Table 1 symbol and its meaning
[0073]
[0074] Example 1: As shown in the figure, the vehicle networking architecture of the application is composed of a blockchain layer and an application layer. The blockchain layer includes on-chain mechanism and off-chain mechanism, and the application layer includes model training and updating, model aggregation and fusion, differential privacy protection, etc. Figures 1-14 As shown in the figure, the vehicle networking architecture of the application is composed of a blockchain layer and an application layer. The blockchain layer includes on-chain mechanism and off-chain mechanism, and the application layer includes model training and updating, model aggregation and fusion, differential privacy protection, etc.
[0075] Figure 5 As shown, the following is a detailed explanation and introduction of the architecture:
[0076] Local data: refers to the local vehicle in the process of running received such as motor operation data, camera shooting data, in-vehicle application data, user feedback data, etc., these local data for local training.
[0077] Local model: refers to the local model used by the local vehicle when training local data.
[0078] Gaussian noise: in the federal credit privacy protection mechanism, in order to prevent member inference attack, Gaussian noise is introduced, so that the attacker cannot infer the personal sensitive information or specific sensitive attribute by analyzing or querying the data.
[0079] Edge node refers to an edge node usually equipped with certain computing and communication resources, participating in the consensus process.
[0080] Verify signed smart contract: this contract is used to generate and verify digital signatures and related information. The client can call the generate_verifications function to generate verification information and save it in the contract. Then, other users can call the verifySignature function to verify whether the incoming digital signature, key, timestamp and client ID match the information saved in the contract.
[0081] The vehicle networking data privacy protection method based on blockchain and ternary federated learning of the application adds Gaussian noise to prevent member inference attack when training the local model.
[0082] In the blockchain layer, the edge node (RSU) refers to an edge node usually equipped with certain computing and communication resources. Due to its strong computing, communication and storage capabilities, the verification value and local model update are stored in the data block by the edge node verified through the consensus algorithm, and its local model is broadcast in the network through the P2P broadcast function in the blockchain, wherein the verification value is generated by the smart contract to verify the relevant information of the user, finally, the vehicle downloads all the latest local model updates of all vehicles from the blockchain, and aggregates the global model.
[0083] The vehicle networking data privacy protection method based on blockchain and ternary federated learning includes the following specific steps:
[0084] Step one, the requester (Roadside Unit) issues a training task, that is, the requester sends the model to be trained and related parameters to the participants, requiring them to train the model on local data; this step aims to encourage participants to jointly train the model while protecting data privacy, thereby achieving global improvement of the model;
[0085] Step two, each vehicle or participant uses its local data to train the model without sending data to the central server, each participant performs model training based on the local data set and updates its local model to adapt to its local environment; this distributed training method helps protect data privacy, reduces data transmission, and enables the model to better adapt to the specific circumstances of each participant;
[0086] Step three, in the process of federated learning, in order to protect the data privacy of participants, a certain degree of Gaussian noise is added to the model update and the verification value generated by the local vehicle in the blockchain; This helps to increase the confusion of data during model training, making it difficult for attackers to infer specific data information from individual participants, thereby protecting the privacy of data;
[0087] Step four, in the process of federated learning, each participant will verify the model trained locally to ensure its performance and accuracy. If the model performs well in local verification, the participant chooses to update it to the global model, thereby improving the model effect of the entire system;
[0088] Step five, after training the federated learning model, the training results are recorded on the blockchain, which can ensure the data's non-tamperability and transparency, preventing data from being tampered with or stolen. At the same time, the blockchain technology can also provide distributed data storage and verification mechanisms, further enhancing data protection and security. This blockchain-based federated learning method provides an effective solution for vehicle-to-everything data privacy protection, which can improve data credibility and security while protecting data privacy;
[0089] Step six, in this step, the blockchain system selects some nodes from the edge nodes (including roadside units, traffic signal controllers, surveillance cameras and sensors, intelligent street lamps, vehicle-mounted units, etc.) and vehicle nodes, which are responsible for verifying transactions and packaging them into blocks; To ensure the normal operation of the blockchain network. By selecting edge nodes, distributed storage and processing of data can be achieved while protecting the privacy and security of data;
[0090] Step seven, the smart contract verifies it and writes the verification value into the blockchain, and then broadcasts the verified block through the P2P network, achieving transaction credibility and network security;
[0091] Step eight, in this step, the blockchain will aggregate the model updates collected from various participants into a global model that will take into account updates from various participants to obtain a more accurate and comprehensive model. Through the aggregation of model updates, the advantages of federated learning can be effectively utilized and the shortcomings of aggregating models on a central server in the past can be overcome, that is, while protecting data privacy, continuous optimization and improvement of the model are realized.
[0092] The local model adopts a ternary federated learning model, which introduces the TernGrad ternary gradient technology. The gradient is quantized from a floating point to three discrete values: -1, 0 and +1. The hierarchical ternary quantization and gradient clipping techniques are introduced. The hierarchical ternary quantization divides the gradient into multiple levels and quantizes and transmits them respectively. The gradient clipping technique controls the size of the gradient.
[0093] In the past distributed training, the communication efficiency and high-cost network communication need to be improved, which has become a bottleneck. To solve this problem, the TernGrad ternary gradient technology is introduced, which quantizes the gradient from a floating point to three discrete values: -1, 0 and +1, to realize the sparsity of the gradient. This quantization method can significantly reduce the communication volume, because only the discrete representation of the gradient needs to be transmitted instead of the floating point number, thereby reducing the network transmission overhead. For the convergence problem existing in ternary gradient, hierarchical ternary quantization and gradient clipping techniques are introduced to improve its convergence. Hierarchical ternary quantization divides the gradient into multiple levels and quantizes and transmits them respectively, thereby improving the accuracy and efficiency of the gradient. And the gradient clipping technique can control the size of the gradient to prevent it from being too large or too small, thereby further improving the convergence and stability of the model. By adopting ternary federated learning technology, the communication overhead in distributed training can be effectively reduced, and the training efficiency and performance of the model can be improved. For ternary federated learning, the conceptual diagram is shown in Figure 6 , and the corresponding algorithm pseudocode is shown in Table 2.
[0094] Table 2 Algorithm pseudocode
[0095]
[0096] The ternary federated learning model training method is as follows:
[0097] Worker (client: vehicle node or edge node): i = 1, 2,..., N
[0098] 1) Input is a partial mini-batch of training samples;
[0099] 2) Calculate the gradient under
[0100] 3) Gradient clipping
[0101] 4) Clipped gradient Layer-wise ternarization is:
[0102]
[0103] In layer-wise ternarization, each layer's gradient is independently ternarized using a layer-wise scaler.
[0104] 5) Pushing ternarized to the server;
[0105] 6) Pulling average gradient
[0106] 7) Updating parameters
[0107] Server (server side):
[0108] 8) Average ternary gradient:
[0109] The gradient clipping used is a common technique in optimization algorithms to limit the size of the gradient to avoid the problem of gradient explosion. The basic idea of gradient clipping is to set a threshold, when the norm of the gradient (i.e. the length of the gradient) exceeds this threshold, the gradient is scaled to the specified range, thus limiting the size of the gradient, as shown. This can ensure the stability of the gradient update, prevent numerical overflow or unstable situations caused by too large gradients. Through gradient clipping, the range of gradients can be limited.
[0110] To perform gradient clipping, you can use the library provided by pytorch
[0111] torch.nn.utils.clip_grad_norm_(parameters, max_norm).
[0112] Layer-wise ternarization is a technique that decomposes the gradient into multiple layers and quantizes and transmits each layer separately. In this way, the accuracy and efficiency of the gradient can be improved.
[0113] In layer-wise ternarization, each layer's gradient is independently ternarized using a layer-wise scaler. More specifically, the gradient of the bias and weight in each layer is ternarized using formula 3-1. Where g t can represent the gradient of the bias or weight in each layer.
[0114] To get closer to the standard performance bound, the gradient can be divided into more buckets and each bucket is ternarized independently. However, this will introduce more floating-point scales and increase the communication overhead. When the size of the bucket is 1, this method degenerates to the floating-point gradient processing method.
[0115] Finally, the quantized gradient is transmitted to the server side for further processing and updating.
[0116] TernGrad ternary gradient belongs to gradient quantization, and its gradient ternarization is an orthogonal sparse method. Gradient quantization refers to reducing the precision or representation of the gradient by mapping the gradient value to a finite discrete set. In this case, TernGrad quantizes the gradient value to three discrete values: -1, 0 and +1 to achieve the sparsity of the gradient. Gradient ternarization is usually used to reduce the storage space and communication cost of the gradient, and helps to improve the efficiency of model training. The method of converting the original gradient to ternary gradient is:
[0117] Let the ternary conversion function be, and the quantized gradient is as follows:
[0118]
[0119] where, where b t is a random binary vector, g t is the original gradient, s t is the scaler, is the Hadamard product, and sign(·) is the sign of each element.
[0120] The scaler s t uses a shared scaling factor: denotes the scaler of the i-th gradient
[0121] For a given g t and b t , each element of which is independently subject to a Bernoulli distribution:
[0122]
[0123] where b tk and g tk are the k-th elements of b t and g t respectively, and after ternary conversion, the client uploads instead of the original gradient g t to the server, and the server returns the result to the client after aggregating the ternary gradient.
[0124] Compared with 32-bit floating-point numbers, two assumptions are made:
[0125] Assumption 1: Assume the number of transmissions of each gradient value is proportional to its bit number.
[0126] Assumption 2: Assume there are N gradient values to be transmitted.
[0127] For 32-bit floating point, each gradient value needs to be transmitted with 32 bits. While for ternary gradient, each gradient value only needs to be transmitted with 2 bits. Therefore, the reduction of transmission bits for ternary gradient is:
[0128]
[0129] And since each gradient value has 3 possible values (-1, 0, 1), we can use log23 to represent the number of bits each gradient value needs when using ternary coding. Therefore, the total reduction ratio is:
[0130]
[0131] That is, even if ternary gradient is encoded in 2 bits, it can still reduce the client-to-server traffic by 16 times.
[0132] When using ternary gradient technology, the gradient will be represented as {-1, 0, 1}, which means that the representation of the gradient is more compact to reduce the amount of communication transmitted to the server. However, when the ternarized gradient is uploaded from the client to the server, the server performs aggregation operations on it, which can cause another problem - the aggregation operation can cause the representation of the result to no longer be ternary, but more levels of possibility. This problem is particularly prominent when the worker nodes use different scaling factors. In order to minimize the number of levels, a solution of sharing scaling factors is proposed:
[0133]
[0134] This technology is named "Scaler Sharing". The sharing process requires an additional transmission of 2N floating-point scalers. By integrating parameter positioning and scaler sharing, the maximum level in the final average gradient is reduced to 2N+1. Therefore, the server-to-worker communication can be reduced by 32 / log2(1+2N) times, unless N≥2 30 .
[0135] Next, let's analyze the convergence of TernGrad ternary gradient. The loss function Q(·) is used to measure the performance of the current system with parameters ω and input z, and the minimization goal is to minimize the expected value of the loss as much as possible:
[0136]
[0137] The parameters ω will be updated according to the learning rate γ tUpdate:
[0138]
[0139] Therefore, from equation 3-1, equation 3-6 and equation 3-7, the parameter ω in TernGrad can be updated as:
[0140]
[0141] And for given z t , ω t , equation 3-3 can be equivalent as:
[0142]
[0143] Under the random given ω t , the expected value of ternary gradient will satisfy the following equation:
[0144]
[0145] This equation is also the minimum objective of equation five - unbiased gradient.
[0146] For the convergence analysis of ternary gradient, two assumptions are proposed.
[0147] Assumption 3, let C(ω) have a unique minimum ω * , and the descending gradient always points to ω * . That is, for any positive number ∈ > 0, when ω is close enough to ω * , it will satisfy:
[0148]
[0149] Where, ||ω-ω * || represents the Euclidean norm between ω and ω * , (ω-ω * ) T represents the transpose of vector ω-ω * , and represents the gradient of C(ω) to ω. Convexity is a subset of assumption 3, and non-convex functions that satisfy it can be easily found.
[0150] Assumption 4, let the learning rate γ t be a positive number and be subject to the following equation:
[0151]
[0152] With this constraint, it can be ensured that the descending speed of γ t is moderate.
[0153] Let parameter ω t be the difference between the minimum value ω * and ω
[0154]
[0155] where ||·|| is the l2 norm. Under Assumption 3 and Assumption 4, the following lemma can be obtained using Lyapunov process and Quasi-Martingales convergence theory:
[0156] Lemma 1 If there exist positive constants A and B such that the following formula holds:
[0157]
[0158] then the function C(z, ω) converges to the minimum value ω * , i.e. From which we can further assume the gradient.
[0159] Assumption 5 Let the gradient g be constrained as:
[0160] E{||g|| ∞ ||1}≤A+B||ω-ω * || 2 (3-17)
[0161] where A and B are positive numbers, and ||·||1 is the l1 norm. From Assumption 5 and Lemma 1, we can prove the following Theorem 1.
[0162] Theorem 1 When the system uses ternary gradients and updates in the following way:
[0163]
[0164] the gradient will converge to the minimum value ω * with high probability.
[0165] When the scalar s t in formula 3-1 and 3-3 is large, most of the gradients will be ternarized to 0, leaving only a few gradients with large amplitude values. This will cause a serious parameter update mode in which most parameters remain unchanged, while other parameters may be over-adjusted, which will introduce large training variance. To solve this problem, we introduce the per-layer ternarization and gradient clipping method to limit the size of each gradient g i in g to:
[0166]
[0167] where σ is the standard deviation of the gradients in g, and c is a hyperparameter.best = 2.5.
[0168] Further, the above-mentioned blockchain-based and federated learning-based data privacy protection method for Internet of Vehicles further includes a data privacy protection method for the client and the server, and the data privacy protection method adopts a federated differential privacy protection algorithm. The federated differential privacy protection algorithm needs to clip the parameters after each local iteration during local training of the client. For the federated differential privacy protection on the server side, the client is randomly selected according to a probability, and the client is allowed to perform local model training. After the server receives the model parameters of each client, the server performs an aggregation operation. In terms of noise addition, the variance of the Gaussian noise distribution is calculated, and noise data is generated by using the Gaussian distribution, so as to add noise data in the global model aggregation operation, so as to obtain new global model parameters. The above steps are repeated until the model converges.
[0169] Compared with the ordinary differential privacy, the federated differential privacy protection not only requires to ensure the local data privacy security of each client, but also requires to ensure the information security between the clients, that is, the user cannot infer which client uploads the local model received by the server, and cannot infer whether a certain client participates in the current training. In the application, the federated differential privacy protection algorithm is used on the client and the server to resist member attack reasoning. The client algorithm pseudo code is shown in Table 3, and the server algorithm pseudo code is shown in Table 4.
[0170] Table 3: Client federated differential privacy algorithm pseudo code
[0171]
[0172] The federated differential privacy protection algorithm needs to clip the parameters after each local iteration during local training of the client. The differential privacy algorithm on the client prevents an attacker from inferring the information of the uploaded client and the information of the training client by receiving the local model.
[0173] Table 4: Server federated differential privacy algorithm pseudo code
[0174]
[0175]
[0176] For the federated differential privacy protection on the server side, the client is randomly selected according to a probability, and the client is allowed to perform local model training. After the server receives the model parameters of each client, the server performs an aggregation operation. In terms of noise addition, the variance of the Gaussian noise distribution is calculated, and noise data is generated by using the Gaussian distribution, so as to add noise data in the global model aggregation operation, so as to obtain new global model parameters. The above steps are repeated until the model converges.
[0177] Compared with the general differential privacy mechanism, the federal differential privacy mechanism needs to consider not only the privacy security of data but also the security problem of users.
[0178] Definition 1 Adjacent data sets: Let there be two data sets D and D', if there is and only one data difference between them, then the data is called adjacent data sets.
[0179] For the security problem of users, the concept of user adjacent data sets is proposed.
[0180] Definition 2 User adjacent data sets: Let there be n clients and for any 0 < i ≤ n, make each client c i The corresponding local data set is d i D and D' are two user data sets, and D' is defined as user adjacent data sets when and only when D removes or adds the local data set d i of a client c i .
[0181] Adjacent data sets are shown in Figure 2 , and the user adjacent data set is shown in Figure 3 .
[0182] Definition 3 (ε, δ)-differential privacy: suppose a random algorithm For two user adjacent data sets D and D', and any output If and only if the algorithm satisfies:
[0183]
[0184] The random algorithm is called (ε, δ)-differential privacy protection. In the formula, ε represents the privacy budget, and δ represents the failure probability.
[0185] Definition 4 L2 global sensitivity: for a random algorithm And user adjacent data sets D and D', the L2 global sensitivity is defined as follows:
[0186]
[0187] Definition 5 Gaussian mechanism: for a given data set D, there is a function f(·), and its sensitivity is set as Δf (definition 4), for any:
[0188]
[0189] Then the random algorithm provides (ε, δ)-differential privacy protection, where L ~ Gaussian(0, σ 2) represents the probability density function of the added random noise, i.e., it follows the parameter...
[0190]
[0191] Gaussian distribution, its probability distribution function is:
[0192]
[0193] Gaussian mechanism concept diagram as follows Figure 4 As shown.
[0194] Both federated learning and centralized training are essentially based on deep learning to train models. Therefore, they both have a problem with model parameters—the problem of model parameter redundancy. In other words, in most deep network learning, fewer weights can achieve the same effect as training global information. Therefore, model compression can reduce transmission overhead and improve system security.
[0195] The code related to layer sensitivity transmission is shown in Tables 5 and 6.
[0196] Table 5 Partial Local Training Functions
[0197]
[0198] According to the formula Calculate the changes before and after training for each layer and sort them. After modifying the client, an aggregation operation needs to be performed on the server. Since the client uploads layer by layer, the aggregation operation also needs to be performed layer by layer.
[0199] Table 6 Model Aggregation Functions
[0200]
[0201] Furthermore, when the aforementioned client performs local training for federated learning, the model is compressed using a layer-sensitivity-based model compression method. The layer sensitivity is defined as follows: Let the current model be represented as G = {g1, g2, ..., g...}. L In round t, client C j When performing federated learning and training locally, the model will be trained from G. t =G becomes
[0202] Let the change in the i-th layer be denoted as
[0203] The mean change δ of the parameters at each layer is called the sensitivity. It refers to the mean of the parameter updates of the i-th layer after the t-th round of federated learning and local training.
[0204] This paper discusses how blockchain can be combined with federated learning, focusing on smart contracts and consensus mechanisms, and illustrates the important role of blockchain in distributed systems.
[0205] Smart contracts are a core component of blockchain technology, and they are a type of code-based automated execution contract that can execute and manage transactions without the need for intermediaries. In federated learning, smart contracts can be used to facilitate collaboration and data exchange among participants. Through smart contracts, participants can share model updates, verify data, and implement reward mechanisms in a secure and transparent manner, thereby facilitating the progress of federated learning.
[0206] The smart contract includes the clientManager contract, the NetworkManager contract, and the VerifySignature contract, as shown in Table 7.
[0207] The clientManager contract is used to implement the registration function of the client, and each client calls the register function to register itself and assigns a unique client ID. The client address is mapped to the client ID using a mapping data structure. A counter nextId is maintained to generate the next client ID.
[0208] The NetworkManager contract is used to manage network participants and training result records in federated learning. The FLMeta structure in the NetworkManager contract is used to save the metadata information of federated learning. The TrainResult structure in the NetworkManager contract is used to record the training results of the client. The mapping data structure is used to map the client address to the corresponding training result. The fl_init function in the NetworkManager contract is used to initialize the metadata information of federated learning, including the number of participating clients, the number of training rounds, and the federated learning algorithm. Only the owner of the contract can call this function. The is_duplicate_client function in the NetworkManager contract is used to check whether the specified client has been registered. The client_regist function in the NetworkManager contract allows the client to register itself and ensures that the client is not registered repeatedly. The upload_result function in the NetworkManager contract allows the client to upload the training results, and only the clients participating in federated learning can call this function.
[0209] The VerifySignature contract is used to provide functions of generating, saving and verifying digital signatures. The Verify structure in the VerifySignature contract is used to save digital signature information, including a signature, a key, a timestamp and a client ID, wherein a mapping type can map a user address to corresponding digital signature information; verifyBit and verificationThresho in the VerifySignature contract are used to specify the number of bits of the digital signature and the verification threshold; the generate_verifications function in the VerifySignature contract is used to generate digital signature information and save it; the getVerification function in the VerifySignature contract is used to obtain the digital signature information of a specified user; and the verifySignature function in the VerifySignature contract is used to verify the validity of the digital signature.
[0210] Table 7: Smart contract functions
[0211]
[0212]
[0213] In order to illustrate the effect of the present application, the following simulation experiment is carried out:
[0214] In the simulation training experiment, the model is built based on the PyTorch framework, mainly using the SVHN dataset (created by Google, the images in which are extracted from Google Street View pictures, containing various different styles, sizes and directions of numbers. The numbers in the SVHN dataset are annotated by real humans, so they have high quality and accuracy) to simulate the street view images captured by vehicles during driving. The dataset contains 73,257 training images and 26,032 test images, and is a public dataset for digital recognition tasks, mainly used for recognizing numbers in street view pictures. The main training model used in the experiment is CNN - three convolutional layers, three max pooling layers and two fully connected layers, as shown in Figure 8 .
[0215] In this experiment, the number of vehicles (clients) is set to 100, the batch_size is set to 32, the learning rate is 0.01, the local training rounds are 20, the global training rounds are 20, and the weight_decay is set to 0.001.
[0216] Federal differential privacy mechanism: the model of the application uses a differential privacy scheme, that is, noise is added before updating the local model on the vehicle node, and Gaussian noise is selected to protect the privacy of data sharing. However, unlike the traditional centralized differential privacy scheme, the application adopts federal differential privacy protection. Compared with the traditional centralized differential privacy scheme, the scheme needs to clip the parameters after each local iterative update, then perform local model training in randomly selected clients and upload the trained model parameters to the server, perform aggregation operation, and add noise data in the global model aggregation process to obtain new global model parameters.
[0217] In Figure 9 the application, the federal differential privacy scheme proposed by the application is compared with the traditional centralized differential privacy scheme, and the influence of the variation of σ on the accuracy and the advantage of the federal differential privacy scheme are obtained by comparing different Gaussian noise distribution variances σ (here, σ = 0.003 and σ = 0.005 are selected). The learning rate is set to 0.001 during training, and the batch size is set to 32. The experimental data set is randomly divided and allocated to each vehicle node as a local data set. By observing the accuracy under different variances in figures (a) and (b), it can be directly observed that the accuracy of the federal differential privacy scheme proposed by the application is closer to the accuracy of the non-privacy protection scheme than the traditional centralized differential privacy scheme.
[0218] In addition, the influence of the parameters of the federal differential privacy itself on the training accuracy is also explored. In the server part of the federal differential privacy algorithm (step 4.4 in algorithm code 3), it is mentioned that the value of Δ t is clipped:
[0219]
[0220] where C represents the clipping boundary value, so the corresponding training accuracy is measured by adjusting different clipping boundary values, so as to observe the influence of the parameters of the federal differential privacy itself on the training accuracy. In Figure 10 , it can be directly observed that when C > 1, the accuracy is basically stable, and among the five groups of data measured, C = 9 has the best effect during training, and C = 1 has the worst effect. Therefore, it is appropriate to take C > 1 as the clipping boundary value in the subsequent experiment.
[0221] Tri-federal learning test: according to the tri-federal gradient theory, the gradient after the tri-federal conversion function is For the original 32-bit floating-point number, the ternary gradient will be 16 times smaller than the original gradient. Therefore, in this section, we will use three datasets (MNIST handwritten digit dataset, SVHN street view number dataset, and Cifar10 object classification dataset) to compare the gradient size uploaded by the client to the server (after ternary transformation) and the gradient size sent by the server to the client (after decompression). Figure 11 As shown in Table 8, the reduction factor is approximately 16× for different datasets. Therefore, applying the ternary gradient to federated learning can significantly reduce the amount of model parameters transmitted, thereby reducing communication bandwidth and lowering communication costs.
[0222] Table 8 Gradient reduction factor for different datasets
[0223]
[0224] After comparing the transfer of model parameters between ternary gradients and ordinary floating-point numbers, the next step is to compare the training performance of stochastic gradient descent with added ternary transformations versus ordinary stochastic gradient descent. Comparisons were performed using the MNIST and SVHN datasets, and the results are as follows: Figure 12 As shown, Figure 12 In the table, (a) and (b) represent the loss and accuracy of the training dataset for the MNSIT dataset; (c) and (d) represent the loss and accuracy of the training dataset for the SVHN dataset.
[0225] During training, the learning rate was set to 0.005, with 20 training epochs. Each epoch selected 20 clients (representing vehicle edge nodes) for training, and 3 epochs were conducted locally. The batch size was set to 32. As shown in the figure, during training on the MNIST and SVHN datasets, TernarySGD, compared to regular SGD (stochastic gradient descent), exhibited higher initial accuracy and lower initial loss. Furthermore, it reached a stable accuracy level more quickly in later epochs. Although the accuracy tended to decrease slightly in later epochs, it did not affect the overall accuracy trend. Therefore, during training, ternary stochastic gradient descent achieved better communication efficiency without compromising the overall training performance.
[0226] Model compression verification based on layer-sensitive transfer
[0227] The compression process for layer-sensitive models is as follows: For any selected client c j After the model has finished local training, according to the formula Calculate the change at each layer of the model The change amount of each layer is sorted from small to large, and the larger the change, the more sensitive the layer. The algorithm will upload the layer with the highest sensitivity, and the low sensitivity will not be uploaded. Therefore, in this experiment, the transmission ratio rate is 91%, 94%, 97% and 100% as experimental variables to observe the influence of changing the transmission layer parameters on the training effect.
[0228] Figure 13 The model compression curve: the orange line represents the uncompressed transmission; the blue line represents the curve of the top 97% of the layer sorted by the change amplitude before transmission; the red line represents the curve of the top 94% of the layer sorted by the change amplitude before transmission; and the black line represents the curve of the top 91% of the layer sorted by the change amplitude before transmission.
[0229] In Figure 13 In the model, it can be seen intuitively that when the transmission is not compressed, the training effect is the best, although the accuracy of the other compressed transmission layers is slightly lower, but it does not affect the overall trend, and the accuracy is similar to the original network.
[0230] Blockchain and federated learning test: in the present application, the effectiveness of the blockchain scheme is evaluated by observing the loss of the model with and without blockchain.
[0231] From Figure 14 It can be seen intuitively from the model without blockchain that the convergence speed is faster than the model with blockchain. This is because the model without blockchain uses a centralized server, so it does not need to complete the model aggregation step, which will reduce the convergence speed. But the values of the two schemes are roughly the same. In addition, the model gets rid of the dependence on the center node by establishing a consortium blockchain, and can resist single point failure attacks, and has higher security under the condition of similar performance.
[0232] Simulation experiment summary: the present application proposes a vehicle networking data sharing model combining ternary federated learning and blockchain. In order to further solve the problem that federated learning may be subject to member reasoning attacks, a federated learning scheme based on federated differential privacy is proposed, and the experimental results show that the scheme has better performance than the traditional centralized differential privacy federated learning scheme. And add the model compression function based on the layer sensitivity in the model training, which can reduce the transmission overhead and improve the system security. In addition, in order to resist single point failure attacks and fake clients, the local model update verification is included in the blockchain consensus process, which can effectively improve the security of the model. In order to solve the problem of high communication cost and low communication efficiency caused by the combination of blockchain and federated learning, ternary federated learning is proposed by combining ternary gradient and federated learning, which greatly reduces the communication cost and improves the communication efficiency while ensuring the training accuracy.
[0233] Therefore, the advantages of the model of the present application are shown in Table 9.
[0234] Table 9 Effect comparison of blockchain and federated learning algorithm with other algorithms
[0235]
[0236] Document [4]: Chen, Y., Li, J., Wang, F., Yue, K., Li, Y., Xing, B.,... & Chen, L. (2021). DS2PM: Data sharing privacy protection model based on blockchain and federated learning. IEEE Internet of Things Journal, 10(14), 12112-12125.
[0237] Document [6]: Chen, H., Asif, S. A., Park, J., Shen, C. C., & Bennis, M. (2021). Robust blockchain federated learning leveraging model verification and proof-of-stake inspired consensus. arXiv preprint arXiv:2101.03300.
[0238] Document [7]: Li, J., Shao, Y., Wei, K., Ding, M., Ma, C., Shi, L.,... & Poor, H. V. (2021). Blockchain-aided decentralized federated learning (BLADE-FL): Performance analysis and resource allocation. IEEE Transactions on Parallel and Distributed Systems, 33(10), 2401-2415.
[0239] Document [8]: Che, C., Li, X., Chen, C., He, X., & Zheng, Z. (2022). Building a decentralized federated learning framework via committee mechanism with convergence guarantee. IEEE Transactions on Parallel and Distributed Systems, 33(12), 4783-4800.
[0240] Document
[11] : McMahan, H. B., Ramage, D., Talwar, K., & Zhang, L. (2017). Learning differentially private recurrent language models. arXiv preprint arXiv:1710.06963.
[0241] Document
[15] : Huang, X., Xu, C., Wang, P., & Liu, H. (2018). LNSC: A secure model for electric vehicle and charging pile management based on blockchain ecosystem. IEEE Access, 6, 13565-13574.
[0242] Document
[16] : Hatim, S. M., Elias, S. J., Ali, R. M., Jasmis, J., Aziz, A. A., & Mansor, S. (2020, December). Blockchain-based vehicular internet of things (biov): A method to realize smart city development. 2020 5th IEEE International Conference on Recent Advances and Innovations in Engineering (ICRAIE) (pp. 1-4). IEEE.
[0243] Document
[22] : Kim, H., Park, J., Bennis, M., & Kim, S. L. (2019). Blockchain device federated learning. IEEE Communications Letters, 24(6), 1279-1283.
[0244] Document
[24] Wen, W., Xu, C., Yan, F., Wu, C., Wang, Y., Chen, Y., & Li, H. (2017). Terngrad: A method to reduce communication in distributed deep learning. Advances in Neural Information Processing Systems, 30.
[0245] Document
[45] Dong, Y., Chen, X., Shen, L., & Wang, D. (2020). Eastfly: Efficient and secure ternary federated learning. Computers & Security, 94, 101824.
[0246] In summary, the federated learning-based vehicular Internet of Things technology plays an important role in solving data privacy and security compared to centralized training. However, the single-point failure attack, member inference attack, privacy problem, and communication cost caused by it still need to be further improved. This invention uses federated differential privacy protection to defend against member inference attacks, and combines blockchain technology to solve the single-point failure problem; introduces ternary gradient technology and model compression to further reduce communication costs. In the differential privacy experiment, by comparing different Gaussian noise distribution variances σ, it is concluded that compared with traditional differential privacy protection, federated differential privacy protection is closer to the accuracy of the no-privacy protection scheme, and the effect is best when C≥2; In the ternary gradient experiment, the training gradient of the three data sets was reduced by 14.99x, 15.54x, and 15.97x, respectively, indicating that ternary gradient can better reduce communication costs; In the layer sensitivity experiment, it is measured that when top = 97%, 94%, and 91%, the accuracy is almost the same as that of top = 100% (uncompressed); In the blockchain experiment, we measured that since the blockchain needs to complete model aggregation, although the convergence speed of the model without blockchain is faster than that of the model with blockchain, the training effect and overall trend are roughly the same.
Claims
1. A data privacy protection method for vehicle-to-everything (V2X) networks based on blockchain and ternary federated learning, characterized by: The method is as follows: In the application layer, the data requester first issues a task request. After receiving the task, the local vehicle will train the local model locally. Gaussian noise is added during training. After training is completed, the original gradient is converted into a ternary gradient and uploaded to the server. The server performs an aggregation operation on the ternary gradient and returns the result to the client. The user then converts the result into a floating-point number and updates the model copy for subsequent training. At the blockchain layer, verification values and local model updates are stored in data blocks by edge nodes that have been verified through a consensus algorithm. Their local models are broadcast across the network through the P2P broadcast function in the blockchain. The verification values are generated by smart contracts to verify the user's relevant information. Finally, the vehicle downloads the latest local model updates for all vehicles from the blockchain and aggregates the global model. The training method for the ternary federated learning model is as follows: Client: i = 1, 2, ..., N 1) Input A partial mini-batch of a training sample; 2) Calculation in gradient 3) Perform gradient clipping. 4) Clip the gradient Layered ternary transformation into: In hierarchical ternary scaling, a layer-by-layer scaler is used to independently ternaryize the gradient in each layer. 5) Pushing a three-dimensional approach To the server; 6) Pull the average ternary gradient from the server. 7) Update parameters Where ω t+1 and ω t These are the parameter weights at time points t+1 and t, respectively; η is the learning rate; Server-side: 8) Average ternary gradient: The method for transforming the original gradient into a ternary gradient is as follows: Let the ternary transformation function be , and its quantized gradient be as follows: Among them, b t g is a random binary vector. t For the original gradient, s t For scalers, It is the Hadamard product, and sign(·) is the sign of each element; Scalers t Use a shared scaling factor: Represents the scaler for the i-th gradient; For a given g t and b t Each of its elements independently follows a Bernoulli distribution: Among them, b tk and g tk b are randomly selected respectively t and g t The k-th element in the matrix, after ternary transformation, will be... Replace the original gradient g t The data is uploaded to the server, which then aggregates the ternary gradients and returns the result to the client. When the client performs federated learning local training, the model is compressed using a layer-sensitivity-based model compression method. Layer sensitivity is defined as follows: Let the current model be represented as G = {g1, g2, ..., g...}. L In round t, client C j When performing federated learning and training locally, the model will be trained from G. t =G becomes: The change in the i-th layer is denoted as: The mean change δ of the parameters at each layer is called the sensitivity. It refers to the mean of the parameter updates of the i-th layer after the t-th round of federated learning and local training; The layer-sensitive model compression implementation process is as follows: for any selected client C j After the model has finished local training, according to the formula Calculate the change at each layer of the model The algorithm sorts the changes in each layer from smallest to largest, and uploads the layer with the highest sensitivity, while the layers with low sensitivity are not uploaded.
2. The method for protecting vehicle network data privacy based on blockchain and ternary federated learning according to claim 1, characterized in that: The method includes the following specific steps: Step 1: The requesting party publishes the training task, that is, the requesting party sends the model to be trained and related parameters to the participants, requesting them to train the model on local data. Step 2: Each vehicle or each participant uses its local data to train the model. Each participant performs model training based on its local dataset and updates its local model to adapt to its local environment. Step 3: During the federated learning process, Gaussian noise and the verification values generated for local vehicles in the blockchain are added to the model update. Step 4: During the federated learning process, each participant will validate the model trained locally. If the model performs well in the local validation, the participant will choose to update it to the global model. Step 5: After training the federated learning model, the training results are recorded on the blockchain. At the same time, blockchain technology also provides a distributed data storage and verification mechanism. Step Six: In this step, the blockchain system selects some nodes from the edge nodes and vehicle nodes. These nodes are responsible for verifying transactions and packaging them into blocks. Step 7: The smart contract verifies the block and writes the verification value into the blockchain. The block that has passed the verification is then broadcast through the P2P network. Step 8: In this step, the blockchain will aggregate the model updates collected from each participant into a global model. This global model will comprehensively consider the updates from each participant, that is, while protecting data privacy, it will achieve continuous optimization and improvement of the model.
3. The method for protecting vehicle network data privacy based on blockchain and ternary federated learning according to claim 1, characterized in that: The local model adopts the ternary federated learning model, which introduces the TernGrad ternary gradient technique to quantize the gradient from floating point to three discrete values: -1, 0 and +1. It also introduces hierarchical ternary quantization and gradient clipping techniques. Hierarchical ternary quantization divides the gradient into multiple levels and quantizes and transmits them separately. Gradient clipping technique controls the magnitude of the gradient.
4. The method for protecting vehicle network data privacy based on blockchain and ternary federated learning according to claim 2, characterized in that: In the introduction of layer-by-layer ternary reduction and gradient clipping methods, each gradient g in g is... i Size limit: Where σ is the standard deviation of the gradient in gradient g, and c is the hyperparameter.
5. The method for protecting vehicle network data privacy based on blockchain and ternary federated learning according to claim 2, characterized in that: It also includes data privacy protection methods on both the client and server sides. All data privacy protection methods adopt the federated differential privacy protection algorithm. When the federated differential privacy is trained locally on the client, the parameters need to be pruned after each local iteration. For federated differential privacy on the server side, clients are randomly selected based on probability and allowed to perform local model training. After receiving the model parameters from each client, the server performs an aggregation operation. In terms of noise addition, the variance of the Gaussian noise distribution is calculated, and noise data is generated using the Gaussian distribution. This noise data is then added to the global model aggregation operation to obtain new global model parameters. This process is repeated until the model converges.
6. The method for protecting vehicle network data privacy based on blockchain and ternary federated learning according to claim 2, characterized in that: Smart contracts include the clientManager contract, the NetworkManager contract, and the VerifySignature contract; The clientManager contract is used to implement the client registration function. Each client calls the register function to register itself and is assigned a unique client ID. The client address is mapped to the client ID using a mapping data structure. A counter nextId is maintained to generate the ID of the next client. The NetworkManager contract is used to manage network participants and training result records in federated learning. The VerifySignature contract is used to provide functions for generating, saving and verifying digital signatures.