Data security circulation and updating method based on block chain and federal learning
By combining blockchain technology with the Federal Learning framework, a decentralized model parameter circulation mechanism has been constructed, and data security and transparency in federal learning have been solved, and efficient and secure model parameter transmission and sharing have been achieved.
Patent Information
- Application Number
- CN202411466779.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-01-21
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing federated learning architecture relies on centralized parameter servers, which have security risks such as single point of failure and data tampering, and lacks effective mechanisms to ensure the transparency and security of the data flow process.
By combining blockchain technology with a federated learning framework, a decentralized, transparent and efficient model parameter transfer mechanism is constructed. The model publisher uploads the initial model parameters to the blockchain. After local training, each end user encrypts the updated parameters through a hash algorithm and uploads them to the blockchain. The decentralization and non-tamperability of the blockchain ensures the data security and transparency.
It realizes the safe transmission and sharing of model parameters in federated learning, improves the integrity, security and transparency of data, solves the single point of failure and data security issues in traditional architecture, and improves the efficiency and credibility of model training. Spend.
Smart Images

Figure CN119336848A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of federated learning and blockchain technology, and in particular to a data security circulation and updating method based on blockchain and federated learning. Background Art
[0002] With the development of artificial intelligence and big data technology, federated learning has received widespread attention as a distributed learning method to protect data privacy. Federated learning solves the problem of data privacy leakage in centralized training by distributing model training tasks to various terminal devices and only uploading parameters after local model training without sharing original data.
[0003] However, the existing federated learning architecture relies on centralized parameter servers, which have security risks such as single point failure and data tampering, and lacks an effective mechanism to ensure the transparency and security of the data flow process. Especially in multi-party collaboration, it is difficult to achieve the credibility and traceability of parameter updates; on the other hand, each participating terminal continuously uploads and updates model parameters during the federated learning process. The existing transmission mechanism lacks sufficient security protection and is vulnerable to network attacks and data leakage, affecting the training effect of the model and the privacy security of user data; therefore, how to ensure the integrity, security and transparency of data in the multi-party data flow of federated learning has become a problem that needs to be solved urgently.
[0004] As a decentralized distributed ledger, blockchain technology uses chain data structure and encryption algorithm to ensure the immutability and traceability of data, providing a new solution for the transmission and sharing of model parameters in federated learning.
[0005] By recording the parameter update transactions of federated learning on the blockchain, the single point failure risk of traditional centralized servers can be effectively avoided, and the transparency and security of data can be guaranteed. In addition, by using blockchain for distributed storage of model parameters, federated learning can achieve higher transparency and traceability. In the traditional federated learning architecture, the update and storage of model parameters are managed by centralized servers, and it is difficult for external participants to effectively verify the legitimacy of model updates and the authenticity of data sources. However, through blockchain, each update of model parameters will be regarded as a transaction recorded on the chain, and all participants can view these transactions, ensuring that every link of the data flow is open, transparent and cannot be tampered with. This mechanism not only improves the security of federated learning, but also provides a reliable trust foundation for multi-party collaboration.
[0006] Therefore, federated learning and blockchain technology not only solve the single point failure and data security problems in the traditional architecture, but also improve the efficiency and transparency of model training; based on this, the present invention proposes a data security circulation and update method based on blockchain and federated learning, introduces the federated learning architecture through blockchain technology, realizes the secure transmission, storage and update of model parameters, and ensures the integrity of data circulation and the collaborative efficiency of the system. Summary of the invention
[0007] In order to solve the above technical problems, the present invention provides a data security circulation and update method based on blockchain and federated learning, which aims to solve the data security risks, single point failure problems and data flow opacity problems caused by the centralized architecture in the federated learning process. By combining blockchain technology with the federated learning framework, a decentralized, transparent and efficient model parameter circulation mechanism is constructed to ensure that participants in federated learning can safely share and update model parameters, thereby improving the security, privacy protection and performance of the overall system.
[0008] Data security transfer and update methods based on blockchain and federated learning include:
[0009] Step 1: The model publisher publishes the trained model parameters to the blockchain;
[0010] In the scenario of federated learning, the model publisher generates an initial model and publishes the initial model and initial model parameters to the blockchain so that all end users can use the initial model and initial model parameters to perform local model training;
[0011] The specific operation process is designed as follows:
[0012] The model publisher defines a neural network model, and the initial model parameters are represented as a vector θ0. To ensure the integrity and security of the initial model parameters, the model publisher uses a hash algorithm to encrypt the initial model parameters before publishing them, generates a unique hash value H(θ0), and uploads it to the blockchain together with the initial model parameters to be stored as part of the transaction record.
[0013] As an example, the model publisher refers to: a central node or an entity responsible for training and managing the global model.
[0014] As an example, the initial model parameters include: weight W and bias b of the neural network.
[0015] As an example, the initial model is: a neural network model;
[0016] Each layer of the neural network model includes several neurons. The connection between the neurons is determined by the weight W of the neural network. At the same time, the output of each neuron needs to be added with a bias b. The output of each layer can be expressed as:
[0017] Z (l) =W (l) A (l-1) +b (l) Formula 1
[0018] Among them, Z (l) represents the linear combination result of the lth layer, W (l) is the weight matrix of the lth layer, A (l-1) is the activation value of the l-1th layer, that is, the output value of the previous layer, b (l) is the bias vector of the lth layer;
[0019] The weight W of the neural network represents the connection between the neurons in each layer of the neural network and the neurons in the previous layer; each connection has a weight, so the weight matrix W of the lth layer (l) The dimension is [n (l) , n (l-1) ], where n (l) is the number of neurons in layer l, n (l-1) is the number of neurons in the previous layer;
[0020] Bias b means that each neuron usually adds a bias, bias vector b (l) The dimension is [n (l) , 1], that is, the number of neurons in the lth layer; therefore, the parameters of the entire neural network model can be expressed as:
[0021] θ0={W0 (1) , b0 (1) , W0 (2) , b0 (2) , ..., W0 (L) , b0 (L)} Formula 2
[0022] Wherein: L represents the total number of layers of the neural network model, θ0 is the set of weights and biases of the neural network including all layers, that is, the initial model parameters; the vector θ0 is the content generated and published by the model publisher in the initial stage.
[0023] As an example, the hash value is used to ensure the integrity of the initial model parameters. During the data upload and storage process, any tampering with the initial model parameters will cause the hash value to change, which will be detected by the system. The distributed consensus mechanism of the blockchain ensures the integrity and publicity of the initial model parameters. The hash algorithm formula is designed as follows:
[0024] H(θ0)=Hash(θ0); Formula 3
[0025] Among them, Hash(θ0) represents the encryption processing of the initial model parameters.
[0026] As an example, the initial model parameters uploaded to the blockchain can be expressed as a transaction record: T0 = (θ0, H(θ0)); Formula 4
[0027] Among them, T0 is the transaction record of the initial model parameters, ensuring that all participants obtain consistent and untampered parameters from the blockchain.
[0028] Step 2: Each end user obtains the corresponding initial model parameters from the blockchain and trains new parameters through local machine learning;
[0029] Each end user obtains the initial model parameters by accessing the blockchain, and then uses his own dataset D on his local terminal device. i Conduct local model training; each end user’s data is private and will not be uploaded to the blockchain to protect their privacy;
[0030] The specific process design is as follows:
[0031] Download the initial model parameters, i.e., vector θ0, from the blockchain and apply it to your local data;
[0032] Each end user will be based on the loss function L(θ; D i ) to adjust the global model parameters θ, the loss function L(θ; D i ) measures the model's performance in the dataset D i The prediction error on ; for classification problems, the cross entropy loss function measures the prediction probability and the true label y j The difference between them is used to evaluate the performance of the model; the loss function is defined as:
[0033]
[0034] Among them, θ refers to the global model parameters after local training optimization (including weight W and bias b), D i is the local dataset of user i, containing m samples, y j is the true label of the jth sample, is the predicted probability of the model (based on the global model parameters θ), and m is the number of samples in the dataset.
[0035] As an example, assume that each end user's dataset D iThe training process and model parameters after training will also be different.
[0036] During the training process, users are based on the loss function L(θ; D i ) to optimize the local model; the gradient descent method is used to update the model parameters, and the formula is:
[0037]
[0038] in, represents the model parameters of user i in round t; η is the learning rate; is the gradient of the loss function to the model parameters; after several rounds of local training, each end user independently trains the local model and obtains the updated model parameters θ i ; Due to the different data distribution of each end user, the model parameters obtained by each end user are also different.
[0039] As an example, the local terminal device includes: a mobile phone, a tablet computer or a computer.
[0040] Step 3: Upload the locally trained parameters to the blockchain securely and efficiently through the network;
[0041] After local training is completed, the end user needs to update the model parameters θ i Upload to the blockchain for global model parameter update; to ensure the integrity and security of the data during the upload process, the end user uses a hash algorithm to update the updated model parameters θ i Encrypt and generate a unique hash value H(θ i ), which is used to ensure the integrity of the data during the upload process. Any modification of the model parameters will change the hash value H(θ i ), so that the system can detect potential tampering; the end user will include the updated model parameters θ i And its corresponding hash value H(θ i )’s transaction records are uploaded to the blockchain through the network.
[0042] As an example, the network is a 5G network. The introduction of the 5G network ensures that the updated model parameter θ i The high bandwidth and low latency of upload improve the overall training efficiency of federated learning.
[0043] As an example, a transaction record uploaded to the blockchain is represented as:
[0044] T i =(θ i ,H(θ i )); Formula 7
[0045] Among them, T i is the model parameter transaction record of user i, including the updated model parameter θ i and its hash value H(θ i );Nodes in the blockchain update the model parameters θ after these uploads i Verification is performed by comparing the hash values of the parameters to confirm whether the data has been tampered with. Only verified transactions will be stored on the blockchain.
[0046] As an example, the verification means that the node recalculates the uploaded updated model parameters θ i The hash value is compared with the hash value H(θ i ) for comparison. If the two match, it means that the uploaded data has not been tampered with, and the transaction has been verified and recorded in the blockchain.
[0047] Step 4: The blockchain treats each training model parameter as a transaction and packages the transaction into a block when the model converges;
[0048] After each end user uploads the updated model parameters θ i After that, the nodes in the blockchain record these model parameters as a transaction. Each transaction record includes: the updated model parameters θ i and the corresponding hash value;
[0049] In the blockchain, transaction records are verified through a consensus mechanism to ensure that the uploaded updated model parameters θ i and its hash value H(θ i ) to ensure that the data has not been tampered with;
[0050] The specific process design is:
[0051] When multiple end users upload updated model parameters θ i Afterwards, these transaction records will be collected and packaged into a block B j ; Block B j Contains all verified transaction records and ensures that all nodes reach consensus on the legitimacy of the transaction through a consensus mechanism;
[0052] As an example, the block B j The packaging formula is designed as follows:
[0053] B j =Block(T1, T2, ..., T n ) Formula 8
[0054] Among them, T1, T2, ..., T nIt is the transaction records uploaded by all users in this round of training;
[0055] Once block B j Successfully generated, block B j It will be added to the blockchain and become part of the chain structure.
[0056] As an example, the chain structure of the blockchain is used to ensure that each block B j The transaction records in the blockchain are open, transparent, and cannot be tampered with; each newly generated block B j All transactions are broadcast to the entire network, ensuring that the ledgers of all participants remain synchronized.
[0057] Step 5: The model publisher takes out the updated model parameters θ from the blockchain i , repeat the training continuously to obtain new model parameters, and repeat this process until the model reaches a convergence state;
[0058] As an example, all verified model parameters stored in the blockchain can be extracted by the model publisher at any time for fusion and update; the fused global model parameters will be published to the blockchain again for all end users to download and use for the next round of local training.
[0059] Through the open and transparent nature of blockchain, each end user can ensure that the global parameters are integrated based on the data uploaded by themselves and other users, and the entire process has not been tampered with.
[0060] As an example, in order to improve the accuracy of the global model, the model publisher needs to perform a weighted average of the model parameters uploaded by multiple end users; use the FedAvg algorithm to fuse these model parameters to obtain the globally updated model parameters; the formula of FedAvg is as follows:
[0061]
[0062] Among them, θ is the global model parameter; θ i is the local model parameter uploaded by the i-th user, that is, the updated model parameter θ i , n is the number of users participating in the training;
[0063] Through this algorithm, the model publisher can integrate the training results of multiple users to obtain a new global model parameter.
[0064] The whole process is repeated continuously. The end user obtains the global model parameters and performs training locally. After updating the parameters, it is uploaded to the blockchain. The model publisher then integrates and updates the parameters until the model reaches a convergence state, that is, the changes in the model parameters are very small or the performance indicators of the model on the verification data set tend to be stable.
[0065] As an example, the standard definition of the convergence state is:
[0066] ||θ (t+1) -θ (t) ||<∈ Formula 10
[0067] Among them, θ (t+1) and θ (t) They represent the global model parameters of the t+1th and tth iterations respectively. ∈ is a preset threshold, usually a very small positive number, which is used to determine whether the change in model parameters is small enough, indicating that the model has converged.
[0068] Beneficial effects of the present invention:
[0069] 1. Improved data privacy protection and security;
[0070] Different from the traditional centralized machine learning architecture, the present invention effectively solves the problem of user privacy leakage by combining federated learning with blockchain technology. In the present invention, the user's local data does not need to be uploaded to the server, and all training data is retained on the terminal device, protecting the user's sensitive information. At the same time, the model parameters are encrypted by the hash algorithm to ensure the security and integrity of the parameters during transmission. The decentralization and immutability of the blockchain further enhance the security of the data, making the entire system perform well in preventing data tampering, protecting privacy, and avoiding data leakage.
[0071] 2. Transparency and traceability of the system
[0072] By uploading the model parameters in federated learning to the blockchain, the transparency and traceability of the data flow process are achieved. Each update of the model parameters will be recorded on the blockchain, and all participants can view and verify these update records to ensure the legitimacy of data flow. This open and transparent recording method avoids the problem of information opacity in centralized systems, and at the same time uses the distributed characteristics of the blockchain to ensure the authenticity and non-tamperability of data during transmission and storage, increasing the credibility and security of the system.
[0073] 3. Efficient model training and collaborative optimization
[0074] In the present invention, the training tasks of the model are distributed to the local devices of each user through federated learning, which greatly reduces the load pressure on the server and improves the efficiency of overall model training. After each user trains the model locally, the updated parameters are uploaded to the blockchain, and the model publisher integrates and optimizes the global model through the federated averaging algorithm. Through multiple rounds of iterations, the present invention can optimize the performance of the global model while maintaining data privacy, so that it performs well on the data of different users, and finally achieves efficient collaborative learning and accurate model updates. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] Figure 1 This is a schematic diagram of the overall architecture of the data security circulation and update method based on blockchain and federated learning of the present invention.
[0076] Figure 2 This is a framework diagram of the Federated Average Algorithm (FedAvg) of the data security circulation and update method based on blockchain and federated learning in the present invention. DETAILED DESCRIPTION
[0077] Below, reference Figure 1 to Figure 2 As shown in the figure, the data security circulation and update method based on blockchain and federated learning includes:
[0078] Step 1: The model publisher publishes the trained model parameters to the blockchain;
[0079] In the scenario of federated learning, the model publisher generates an initial model and publishes the initial model and initial model parameters to the blockchain so that all end users can use the initial model and initial model parameters to perform local model training;
[0080] The specific operation process is designed as follows:
[0081] The model publisher defines a neural network model, and the initial model parameters are represented as a vector θ0. To ensure the integrity and security of the initial model parameters, the model publisher uses a hash algorithm to encrypt the initial model parameters before publishing them, generates a unique hash value H(θ0), and uploads it to the blockchain together with the initial model parameters to be stored as part of the transaction record.
[0082] As an example, the model publisher refers to: a central node or an entity responsible for training and managing the global model.
[0083] As an example, the initial model parameters include: weight W and bias b of the neural network.
[0084] As an example, the initial model is: a neural network model;
[0085] Each layer of the neural network model includes several neurons. The connection between the neurons is determined by the weight W of the neural network. At the same time, the output of each neuron needs to be added with a bias b. The output of each layer can be expressed as:
[0086] Z (l) =W (l) A (l-1) +b (l) Formula 1
[0087] Among them, Z (l) represents the linear combination result of the lth layer, W (l) is the weight matrix of the lth layer, A (l-1) is the activation value of the l-1th layer, that is, the output value of the previous layer, b (l) is the bias vector of the lth layer;
[0088] The weight W of the neural network represents the connection between the neurons in each layer of the neural network and the neurons in the previous layer; each connection has a weight, so the weight matrix W of the lth layer (l) The dimension is [n (l) , n (l-1) ], where n (l) is the number of neurons in layer l, n (l-1) is the number of neurons in the previous layer;
[0089] Bias b means that each neuron usually adds a bias, bias vector b (l) The dimension is [n (l) , 1], that is, the number of neurons in the lth layer; therefore, the parameters of the entire neural network model can be expressed as:
[0090] θ0={W0 (1) , b0 (1) , W0 (2) , b0 (2) , ..., W0 (L) , b0 (L)} Formula 2
[0091] Wherein: L represents the total number of layers of the neural network model, θ0 is the set of weights and biases of the neural network including all layers, that is, the initial model parameters; the vector θ0 is the content generated and published by the model publisher in the initial stage.
[0092] As an example, the hash value is used to ensure the integrity of the initial model parameters. During the data upload and storage process, any tampering with the initial model parameters will cause the hash value to change, which will be detected by the system. The distributed consensus mechanism of the blockchain ensures the integrity and publicity of the initial model parameters. The hash algorithm formula is designed as follows:
[0093] H(θ0)=Hash(θ0); Formula 3
[0094] Among them, Hash(θ0) represents the encryption processing of the initial model parameters.
[0095] As an example, the initial model parameters uploaded to the blockchain can be expressed as a transaction record: T0 = (θ0, H(θ0)); Formula 4
[0096] Among them, T0 is the transaction record of the initial model parameters, ensuring that all participants obtain consistent and untampered parameters from the blockchain.
[0097] Step 2: Each end user obtains the corresponding initial model parameters from the blockchain and trains new parameters through local machine learning;
[0098] Each end user obtains the initial model parameters by accessing the blockchain, and then uses his own dataset D on his local terminal device. i Conduct local model training; each end user’s data is private and will not be uploaded to the blockchain to protect their privacy;
[0099] The specific process design is as follows:
[0100] Download the initial model parameters, i.e., vector θ0, from the blockchain and apply it to your local data;
[0101] Each end user will be based on the loss function L(θ; D i ) to adjust the model parameters θ, the loss function L(θ; D i ) measures the model's performance in the dataset D i The prediction error on ; for classification problems, the cross entropy loss function measures the prediction probability and the true label y j The difference between them is used to evaluate the performance of the model; the loss function is defined as:
[0102]
[0103] Among them, θ refers to the global model parameters (including weight W and bias b) after local training optimization, D i is the local dataset of user i, containing m samples, y j is the true label of the jth sample, is the predicted probability of the model (based on the global model parameters θ), and m is the number of samples in the dataset.
[0104] As an example, assume that each end user's dataset D iThe training process and model parameters after training will also be different.
[0105] During the training process, users are based on the loss function L(θ; D i ) to optimize the local model; the gradient descent method is used to update the model parameters, and the formula is:
[0106]
[0107] in, represents the model parameters of user i in round t; η is the learning rate; is the gradient of the loss function to the model parameters; after several rounds of local training, each end user independently trains the local model and obtains the updated model parameters θ i ; Due to the different data distribution of each end user, the model parameters obtained by each end user are also different.
[0108] As an example, the local terminal device includes: a mobile phone, a tablet computer or a computer.
[0109] Step 3: Upload the locally trained parameters to the blockchain securely and efficiently through the network;
[0110] After local training is completed, the end user needs to update the model parameters θ i Upload to the blockchain for global model parameter update; to ensure the integrity and security of the data during the upload process, the end user uses a hash algorithm to update the updated model parameters θ i Encrypt and generate a unique hash value H(θ i ), which is used to ensure the integrity of the data during the upload process. Any modification of the model parameters will change the hash value H(θ i ), so that the system can detect potential tampering; the end user will include the updated model parameters θ i And its corresponding hash value H(θ i )’s transaction records are uploaded to the blockchain through the network.
[0111] As an example, the network is a 5G network. The introduction of the 5G network ensures that the updated model parameter θ i The high bandwidth and low latency of upload improve the overall training efficiency of federated learning.
[0112] As an example, a transaction record uploaded to the blockchain is represented as:
[0113] T i =(θ i ,H(θ i )); Formula 7
[0114] Among them, T i is the model parameter transaction record of user i, including the updated model parameter θ i and its hash value H(θ i );Nodes in the blockchain update the model parameters θ after these uploads i Verification is performed by comparing the hash values of the parameters to confirm whether the data has been tampered with. Only verified transactions will be stored on the blockchain.
[0115] As an example, the verification means that the node recalculates the uploaded updated model parameters θ i The hash value is compared with the hash value H(θ i ) for comparison. If the two match, it means that the uploaded data has not been tampered with, and the transaction has been verified and recorded in the blockchain.
[0116] Step 4: The blockchain treats each training model parameter as a transaction and packages the transaction into a block when the model converges;
[0117] After each end user uploads the updated model parameters θ i After that, the nodes in the blockchain record these model parameters as a transaction. Each transaction record includes: the updated model parameters θ i and the corresponding hash value;
[0118] In the blockchain, transaction records are verified through a consensus mechanism to ensure that the uploaded updated model parameters θ i and its hash value H(θ i ) to ensure that the data has not been tampered with;
[0119] The specific process design is:
[0120] When multiple end users upload updated model parameters θ i Afterwards, these transaction records will be collected and packaged into a block B j ; Block B j Contains all verified transaction records and ensures that all nodes reach consensus on the legitimacy of the transaction through a consensus mechanism;
[0121] As an example, the block B j The packaging formula is designed as follows:
[0122] B j =Block(T1, T2, ..., T n ) Formula 8
[0123] Among them, T1, T2, …, T nIt is the transaction records uploaded by all users in this round of training;
[0124] Once block B j Successfully generated, block B j It will be added to the blockchain and become part of the chain structure.
[0125] As an example, the chain structure of the blockchain is used to ensure that each block B j The transaction records in the blockchain are open, transparent, and cannot be tampered with; each newly generated block B j All transactions are broadcast to the entire network, ensuring that the ledgers of all participants remain synchronized.
[0126] Step 5: The model publisher takes out the updated model parameters θ from the blockchain i , repeat the training continuously to obtain new model parameters, and repeat this process until the model reaches a convergence state;
[0127] As an example, all verified model parameters stored in the blockchain can be extracted by the model publisher at any time for fusion and update; the fused global model parameters will be published to the blockchain again for all end users to download and use for the next round of local training.
[0128] Through the open and transparent nature of blockchain, each end user can ensure that the global parameters are integrated based on the data uploaded by themselves and other users, and the entire process has not been tampered with.
[0129] As an example, in order to improve the accuracy of the global model, the model publisher needs to perform a weighted average of the model parameters uploaded by multiple end users; use the FedAvg algorithm to fuse these model parameters to obtain the globally updated model parameters; the formula of FedAvg is as follows:
[0130]
[0131] Among them, θ is the global model parameter; θ i is the local model parameter uploaded by the i-th user, that is, the updated model parameter θ i , n is the number of users participating in the training;
[0132] Through this algorithm, the model publisher can integrate the training results of multiple users to obtain a new global model parameter.
[0133] The whole process is repeated continuously. The end user obtains the global model parameters and performs training locally. After updating the parameters, it is uploaded to the blockchain. The model publisher then integrates and updates the parameters until the model reaches a convergence state, that is, the changes in the model parameters are very small or the performance indicators of the model on the verification data set tend to be stable.
[0134] As an example, the standard definition of the convergence state is:
[0135] ||θ (t+1) -θ (t) ||<∈ Formula 10
[0136] Among them, θ (t+1) and θ (t) They represent the global model parameters of the t+1th and tth iterations respectively. ∈ is a preset threshold, which is a very small positive number (such as 1), used to determine whether the change in model parameters is small enough, indicating that the model has converged.
[0137] In order to better illustrate the principle architecture of the present invention, a brief introduction is now given and sorted out again as follows:
[0138] The present invention aims to solve the security issues of data transmission and model updating in the process of federated learning. This method realizes the secure transmission and sharing of model parameters in federated learning by combining the decentralization and tamper-proof characteristics of blockchain.
[0139] First, federated learning participants perform local training on their respective terminal devices and generate model parameters.
[0140] Secondly, through the blockchain platform, these model parameters are uploaded in the form of transactions, and the integrity and security of the data are guaranteed through the hash algorithm.
[0141] Then, each update process of the model parameters will be recorded on the blockchain to ensure the transparency and traceability of the data flow process.
[0142] Finally, the model publisher can extract the latest training parameters from the blockchain and continuously conduct collaborative training until the model converges; this method effectively solves the data security and privacy issues caused by the centralized architecture in the existing federated learning system, and ensures the security of data during transmission and storage through the blockchain. This solution is suitable for large-scale distributed federated learning scenarios and improves the efficiency and security of model training.
[0143] Different from the traditional centralized machine learning architecture, the present invention effectively solves the problem of user privacy leakage by combining federated learning with blockchain technology. In the present invention, the user's local data does not need to be uploaded to the server, and all training data is retained on the terminal device, protecting the user's sensitive information. At the same time, the model parameters are encrypted by the hash algorithm to ensure the security and integrity of the parameters during transmission. The decentralization and immutability of the blockchain further enhance the security of the data, making the entire system perform well in preventing data tampering, protecting privacy, and avoiding data leakage.
[0144] By uploading the model parameters in federated learning to the blockchain, the transparency and traceability of the data flow process are achieved. Each update of the model parameters will be recorded on the blockchain, and all participants can view and verify these update records to ensure the legitimacy of data flow. This open and transparent recording method avoids the problem of information opacity in centralized systems, and at the same time uses the distributed characteristics of the blockchain to ensure the authenticity and non-tamperability of data during transmission and storage, increasing the credibility and security of the system.
[0145] In the present invention, the training tasks of the model are distributed to the local devices of each user through federated learning, which greatly reduces the load pressure on the server and improves the efficiency of overall model training. After each user trains the model locally, the updated parameters are uploaded to the blockchain, and the model publisher integrates and optimizes the global model through the federated averaging algorithm. Through multiple rounds of iterations, the present invention can optimize the performance of the global model while maintaining data privacy, so that it performs well on the data of different users, and finally achieves efficient collaborative learning and accurate model updates.
[0146] The above are only preferred embodiments of the present invention. It should be understood that the description of the above embodiments is only used to help understand the method and core ideas of the present invention, and is not used to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, etc. made within the ideas and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A data security transfer and update method based on blockchain and federated learning, characterized in that: include: Step 1: The model publisher publishes the trained model parameters to the blockchain; In the scenario of federated learning, the model publisher generates an initial model and publishes the initial model and initial model parameters to the blockchain so that all end users can use the initial model and initial model parameters to perform local model training; Step 2: Each end user obtains the corresponding initial model parameters from the blockchain and trains new parameters through local machine learning; Each end user obtains the initial model parameters by accessing the blockchain, and then uses his own dataset D on his local terminal device. i Conduct local model training; each end user’s data is private and will not be uploaded to the blockchain to protect their privacy; Step 3: Upload the locally trained parameters to the blockchain securely and efficiently through the network; After local training is completed, the end user needs to update the model parameters θ i Upload to the blockchain for global model parameter update; to ensure the integrity and security of the data during the upload process, the end user uses a hash algorithm to update the updated model parameters θ i Encrypt and generate a unique hash value H(θ i ), which is used to ensure the integrity of the data during the upload process. Any modification of the model parameters will change the hash value H(θ i ), so that the system can detect potential tampering; the end user will include the updated model parameters θ i And its corresponding hash value H(θ i )’s transaction records are uploaded to the blockchain through the network; Step 4: The blockchain treats each training model parameter as a transaction and packages the transaction into a block when the model converges; After each end user uploads the updated model parameters θ i After that, the nodes in the blockchain record these model parameters as a transaction. Each transaction record includes: the updated model parameters θ i and the corresponding hash value; In the blockchain, transaction records are verified through a consensus mechanism to ensure that the uploaded updated model parameters θ i and its hash value H(θ i ) to ensure that the data has not been tampered with; Step 5: The model publisher takes the updated model parameters θ from the blockchain i , repeat the training continuously to obtain new model parameters, and repeat this process until the model reaches a convergence state.
2. According to claim 1, the data security circulation and update method based on blockchain and federated learning is characterized in that: The model publisher defines a neural network model, and the initial model parameters are represented as a vector θ0. To ensure the integrity and security of the initial model parameters, the model publisher uses a hash algorithm to encrypt the initial model parameters before publishing them, generates a unique hash value H(θ0), and uploads it to the blockchain together with the initial model parameters to be stored as part of the transaction record. The model publisher refers to: a central node or an entity responsible for training and managing the global model; The initial model parameters include: weight W and bias b of the neural network; The initial model is: a neural network model.
3. According to claim 2, the data security circulation and update method based on blockchain and federated learning is characterized in that: Each layer of the neural network model includes several neurons. The connection between the neurons is determined by the weight W of the neural network. At the same time, the output of each neuron needs to be added with a bias b. The output of each layer can be expressed as: Z (l) =W (l) A (l-1) +b (l) Formula 1 Among them, Z (l) represents the linear combination result of the Ith layer, W (l) is the weight matrix of the lth layer, A (l-1) is the activation value of the l-1th layer, that is, the output value of the previous layer, b (l) is the bias vector of the lth layer; The weight W of the neural network represents the connection between the neurons in each layer of the neural network and the neurons in the previous layer; each connection has a weight, so the weight matrix W of the lth layer (l) The dimension is [n (l) , n (l-1) ], where n (l) is the number of neurons in layer l, n (l-1) is the number of neurons in the previous layer; Bias b means that each neuron usually adds a bias, bias vector b (l) The dimension is [n (l) , 1], that is, the number of neurons in the lth layer; therefore, the parameters of the entire neural network model can be expressed as: θ0={W0 (1) , b0 (1) W0 (2) , b0 (2) , ..., W0 (L) , b0 (L) Formula 2 Wherein: L represents the total number of layers of the neural network model, θ0 is the set of weights and biases of the neural network including all layers, that is, the initial model parameters; the vector θ0 is the content generated and published by the model publisher in the initial stage.
4. The data security circulation and updating method based on blockchain and federated learning according to claim 2 is characterized in that: The hash value is used to ensure the integrity of the initial model parameters. During the process of data uploading and storage, any tampering with the initial model parameters will cause the hash value to change, which will be detected by the system. The distributed consensus mechanism of the blockchain ensures the integrity and publicity of the initial model parameters. The formula of the hash algorithm is designed as follows: H(θ0)=Hash(θ0); Formula 3 Among them, Hash(θ0) represents the encryption processing of the initial model parameters; The initial model parameters uploaded to the blockchain can be represented as a transaction record: T0=(θ0,H(θ0)); Formula 4 Among them, T0 is the transaction record of the initial model parameters, ensuring that all participants obtain consistent and untampered parameters from the blockchain.
5. According to claim 1, the data security circulation and update method based on blockchain and federated learning is characterized in that: Download the initial model parameters, i.e., vector θ0, from the blockchain and apply it to your local data; Each end user will be based on the loss function L(θ; D i ) to adjust the global model parameters θ, the loss function L(θ; D i ) measures the model's performance in the dataset D i The prediction error on ; for classification problems, the cross entropy loss function measures the prediction probability and the true label y j The difference between them is used to evaluate the performance of the model; the loss function is defined as: Among them, θ refers to the global model parameters after local training optimization, D i is the local dataset of user i, containing m samples, y j is the true label of the jth sample, is the predicted probability of the model, and m is the number of samples in the dataset.
6. The data security circulation and updating method based on blockchain and federated learning according to claim 5 is characterized in that: Assume that each end user’s dataset D i The training process and model parameters after training will also be different; During the training process, users are based on the loss function L(θ; D i ) to optimize the local model; the gradient descent method is used to update the model parameters, and the formula is: in, represents the model parameters of user i in round t; η is the learning rate; is the gradient of the loss function to the model parameters; after several rounds of local training, each end user independently trains the local model and obtains the updated model parameters θ i ; Due to the different data distribution of each end user, the model parameters obtained by each end user are also different; The local terminal device includes: a mobile phone, a tablet computer or a computer.
7. The data security circulation and updating method based on blockchain and federated learning according to claim 1 is characterized in that: The network is a 5G network. The introduction of the 5G network ensures that the updated model parameters θ i The high bandwidth and low latency of upload improve the overall training efficiency of federated learning.
8. The data security circulation and update method based on blockchain and federated learning according to claim 1 is characterized in that: The transaction record uploaded to the blockchain is represented as: T i =(θ i , H(θ i )); Formula 7 Among them, T i is the model parameter transaction record of user i, including the updated model parameter θ i and its hash value H(θ i );Nodes in the blockchain update the model parameters θ after these uploads i Verify whether the data has been tampered with by comparing the hash value of the parameters. Only transactions that pass the verification will be stored on the blockchain. The verification means that the node will recalculate the uploaded updated model parameters θ i The hash value is compared with the hash value H(θ i ) for comparison. If the two match, it means that the uploaded data has not been tampered with, and the transaction has been verified and recorded in the blockchain.
9. The data security circulation and updating method based on blockchain and federated learning according to claim 1 is characterized in that: When multiple end users upload updated model parameters θ i Afterwards, these transaction records will be collected and packaged into a block B j ; Block B j Contains all verified transaction records and ensures that all nodes reach consensus on the legitimacy of the transaction through a consensus mechanism; The block B j The packaging formula is designed as follows: B j =Block(T1, T2, ..., T n ) Formula 8 Among them, T1, T2, ..., T n It is the transaction records uploaded by all users in this round of training; Once block B j Successfully generated, block B j It will be added to the blockchain and become part of the chain structure; The chain structure of blockchain is used to: ensure that each block B j The transaction records in the blockchain are open, transparent, and cannot be tampered with; each newly generated block B j All transactions are broadcast to the entire network, ensuring that the ledgers of all participants remain synchronized.
10. The data security circulation and updating method based on blockchain and federated learning according to claim 1 is characterized in that: All verified model parameters stored in the blockchain can be extracted by the model publisher at any time for fusion and update; the fused global model parameters will be published to the blockchain again for all end users to download and use for the next round of local training; In order to improve the accuracy of global model parameters, the model publisher needs to perform weighted averaging on the model parameters uploaded by multiple end users; use the federated averaging algorithm to fuse these model parameters to obtain globally updated model parameters; the formula is as follows: Among them, θ is the global model parameter; θ i is the local model parameter uploaded by the i-th user, that is, the updated model parameter θ i , n is the number of users participating in the training; Through this algorithm, the model publisher can integrate the training results of multiple users to obtain a new global model parameter; The whole process is repeated continuously. The end user obtains the global model parameters and then trains locally. After updating the parameters, it is uploaded to the blockchain. The model publisher then merges and updates the parameters until the model reaches a convergence state, that is, the changes in the model parameters are very small or the performance indicators of the model on the validation data set tend to be stable. The standard definition of the convergence state is: ||θ (t+1) -θ (t) ||∈ Formula 10 Among them, θ (t+1) and θ (t) They represent the global model parameters of the t+1th and tth iterations respectively, and ∈ is a preset threshold of 1, which is used to determine whether the change in model parameters is small enough, indicating that the model has converged.
Citation Information
Patent Citations
Federal learning gradient attack resistant privacy protection method and system based on block chain
CN116340986A
Industrial internet data security sharing method and system based on block chain and federal learning
CN118551415A
Cited By
Bidirectional authentication-based federal learning method in industrial internet edge computing environment
CN120768650A
Supply chain payment system based on artificial intelligence and block chain
CN120851872A