Data sharing and federal learning method based on block chain

The blockchain-based data sharing and federated learning method addresses security and fairness issues by using digital envelopes, accumulators, and smart contracts to ensure secure and transparent transactions, improving data integrity and model accuracy while promoting cooperation.

CN119150266APending Publication Date: 2024-12-17LIAONING UNIVERSITY OF TECHNOLOGY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411361782.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-27
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

Existing data sharing and federated learning systems face challenges such as single point failures, data privacy leakage, malicious attacks, and lack of fair incentive mechanisms, which hinder the secure and efficient sharing of data and resources.

Method used

A blockchain-based data sharing and federated learning method using digital envelope technology, accumulator algorithms, and smart contracts to ensure secure, fair, and transparent transactions, along with a node behavior management mechanism to reward honest participants and punish malicious ones.

Benefits of technology

This method enhances data integrity, accuracy, and fairness in federated learning by automating transactions, resisting malicious attacks, and promoting a virtuous cycle of cooperation among participants.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119150266A_ABST
    Figure CN119150266A_ABST
Patent Text Reader

Abstract

The invention discloses a data sharing and federal learning method based on a block chain, and relates to the technical field of block chain big data. The invention provides a data sharing and federated learning method based on a block chain, and the method comprises a data sharing module and a federated learning module: in the data sharing module, a data owner and a data purchaser perform fair transaction through a digital envelope technology and an accumulator; and in the federation learning module, the optimized storage model is utilized, and through a node behavior management mechanism, all nodes obtain fair rewards and earnings. Therefore, by adopting the data sharing and federated learning method based on the block chain, behaviors of participating nodes in federated learning can be supervised, attacks of malicious nodes can be resisted, honest participants can be stimulated, the malicious nodes can be punished, virtuous circle in the federated learning process can be promoted, balance between privacy protection and resource sharing can be ensured, and user experience can be improved. Therefore, more people are willing to share data and resources and participate in federal learning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain big data technology, and in particular to a blockchain-based data sharing and federated learning method. Background Art

[0002] With the widespread popularity of cloud computing and the Internet of Things, the amount of global data is growing exponentially. Traditional cloud storage solutions are usually based on a centralized server architecture, where users upload data to the cloud and access and manage the data through the network. This approach allows large amounts of data to be managed and stored quickly and efficiently, but it also limits users' control over their data, accompanied by the potential risk of data privacy leakage and single point failure.

[0003] Currently, distributed cloud storage solutions based on blockchain technology have emerged, which support the encrypted storage of large amounts of data in distributed storage frameworks such as Inter-Planetary File System (IPFS) and Swarm. Importantly, fee payments and data transmission can be paid and recorded in smart contracts, allowing data owners to better control the use of data. However, due to the open and transparent nature of blockchain, it is difficult to securely transmit secret information.

[0004] On the other hand, big data is the cornerstone of the development of artificial intelligence. Using high-value data to train models can unleash the potential of data. For example, intelligent customer service uses chatbots to provide instant question-and-answer services to assist customers in faster business processing; intelligent transportation systems use artificial intelligence algorithms to optimize traffic flow, reduce congestion, and improve the efficiency of transportation networks; in the field of healthcare, artificial intelligence can achieve advanced diagnosis, personalized medicine, and even new drug discovery. If traditional centralized machine learning algorithms are used, the entire data set needs to be sent to a central server for model aggregation. This not only consumes a lot of bandwidth and storage resources, but also compromises the confidentiality and integrity of the data, increasing the risk of privacy leakage. Equally important, given the lack of data sharing infrastructure across systems, departments, and regions, this may lead to serious "data island" problems. In addition, the lack of data sharing will also hinder the development of these industries, so the federated learning solution came into being. It can ensure data privacy while promoting the maximization of data value, which is especially important for those application scenarios that require a high degree of protection of personal privacy or trade secrets.

[0005] However, in the process of federated learning, malicious participants may attempt to manipulate or disrupt the learning process to obtain improper benefits. They may deliberately provide incorrect model updates or tamper with other participants' model data, thereby endangering the effectiveness and security of the entire system. At the same time, honest participants may worry that sharing their data, especially sensitive data, will be abused or leaked by other participants. These concerns will affect their willingness to participate.

[0006] Therefore, there is an urgent need for a fair and open data sharing method and a secure and transparent model training mechanism to build a decentralized trusted platform to provide a reference for helping more devices participate in federated learning. Summary of the invention

[0007] The purpose of the present invention is to provide a data sharing and federated learning method based on blockchain, which can effectively improve the single point failure, poisoning attack and lack of fair incentive mechanism problems in federated learning, maximize the value of data and remaining computing resources, and ensure the balance between privacy protection and resource sharing, so that more people are willing to share data and resources and participate in federated learning.

[0008] To achieve the above objectives, the present invention provides a data sharing and federated learning method based on blockchain, including a data sharing module and a federated learning module:

[0009] In the data sharing module, digital envelope technology and accumulator algorithm are used to enable fair transactions between data owners and data buyers.

[0010] In the federated learning module, an optimized storage model is used, and a node behavior management mechanism is adopted to ensure that all nodes receive fair rewards and benefits.

[0011] Preferably, the optimized storage model includes compatible solutions and customized solutions:

[0012] The compatible solution encapsulates the global model in a transaction and submits it to the blockchain;

[0013] Customized solution A dedicated blockchain designed specifically for federated learning. Each block stores the global model to be distributed in the current round and serves as the genesis block of each side chain. Then a directed acyclic graph side chain is constructed to store the local model updates of this round.

[0014] Preferably, the node behavior management mechanism includes updating the verification results according to the local model, establishing an incentive mechanism, giving corresponding rewards to actively participating nodes, and punishing malicious nodes.

[0015] Preferably, the training nodes are rewarded or punished according to their contribution scores, as follows:

[0016]

[0017] Among them, Con is the contribution score of the training node, sta is the minimum standard set by the committee for the reputation score of the training node for federated learning, rep is the reputation score of the training node, EID is the current global training round of federated learning, sf is the scaling factor, and rej is the number of models rejected for aggregation.

[0018] Preferably, the data sharing module includes:

[0019] The data owner encrypts the dataset using a symmetric encryption algorithm, uploads the encrypted dataset to the Interstellar File System, and returns the address of the encrypted dataset;

[0020] Data buyers register and join the system, publicly disclose the type of data they wish to purchase and their public key;

[0021] Data owners register and join the system, publishing the type of data they own and the expected price of the data;

[0022] The data buyer takes the desired data type as input and returns the addresses of all data owners that have that data type;

[0023] The data buyer enters the address of the data owner and requests to purchase the data, and transfers funds higher than or equal to the data price to the smart contract for temporary storage;

[0024] After receiving the purchase request from the data buyer, the data owner obtains the public key of the data buyer and uses the public key to encrypt the symmetric key;

[0025] The data owner uploads the address of the encrypted dataset, the encrypted symmetric key, and the accumulator value of the ciphertext to the smart contract, transfers a deposit higher than the dataset price to the smart contract, and transfers the purchase funds in the smart contract to the data owner;

[0026] The data buyer obtains the InterPlanetary File System address, encrypted symmetric key, and accumulator value of the ciphertext of the required data set based on the address of the data owner;

[0027] The data buyer checks the type of data purchased. If it does not meet the requirements, the data buyer or data owner can appeal using the accumulator within the appeal period. Based on the appeal result, the data buyer or data owner will be compensated.

[0028] After the appeal period, if the data owner has not been complained about, the deposit will be refunded.

[0029] Preferably, the federated learning module includes:

[0030] Register the devices applying to participate in federated learning as training nodes or committee nodes and join the system. Committee nodes include verification nodes and aggregation nodes. After registration, their identities are temporarily set as candidate participants and they need to be verified before they can participate in federated learning.

[0031] The committee initializes the initial global model according to the task requirements and uploads it to the blockchain. At the same time, it calls the smart contract to initialize the training nodes, committee members, and the public and private key pairs of the committee;

[0032] The training node retrieves the global model and committee public key of the round according to the round number and the address of the aggregation node.

[0033] The training node uses the global model for local training, encrypts the local model update using a symmetric encryption algorithm, uploads it to the InterPlanetary File System and returns the address;

[0034] The verification node obtains the encrypted symmetric key based on the address of the training node that needs to be verified;

[0035] The training node encrypts the symmetric key with the committee’s public key, uploads it to the blockchain, and marks the verification node as a model validator;

[0036] The verification node uses the committee’s private key to decrypt the local model update based on the training node address of the local model update that needs to be verified, and obtains the local model update;

[0037] The verification node verifies the local model and determines whether it has the possibility of damaging the global model;

[0038] If the training node is not satisfied with the verification result, it will file an appeal;

[0039] The committee sends the appealed local model update to all verification nodes for cross-verification, confirms the final verification result and uploads it, and updates the reputation values ​​of the verification nodes and training nodes at the same time;

[0040] The aggregation node waits for the local model to be updated to meet the aggregation requirements, or until the end of the current round, performs model aggregation, and uploads the aggregated global model to the blockchain. At the same time, based on the performance of the committee members, the public-private key pairs of the committee members and the committee are updated;

[0041] The committee sets new requirements for the next round, i.e. the number of training nodes and the minimum reputation value, updates the training node list and starts a new round of training;

[0042] Repeat the above process until a global model that meets the requirements is obtained.

[0043] Therefore, the present invention adopts the above-mentioned blockchain-based data sharing and federated learning method, which has the following technical effects:

[0044] (1) A fair data sharing scheme is adopted, including functions such as identity authentication, key delivery, and transaction appeal. By combining digital envelope technology and one-way accumulator algorithm with smart contracts to automate the data sharing process without the need for a trusted third party, it simplifies the transaction process, reduces transaction costs, ensures the integrity and authenticity of the data, and protects the rights and interests of both parties to the shared data.

[0045] (2) Combining the characteristics of federated learning model aggregation, a new model storage method is proposed to help participants obtain the latest global model more quickly, thereby improving model accuracy and speeding up the training process; at the same time, smart contracts are introduced for access control to ensure the security of model update propagation.

[0046] (3) Through the incentive algorithm based on the behavior of participants, it is possible to be tolerant to honest participants and strict to malicious participants. At the same time, it is combined with the committee-based consensus mechanism to enhance the credibility and fairness of the committee.

[0047] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 is a framework diagram of a system in an embodiment of a blockchain-based data sharing and federated learning method;

[0049] Figure 2 It is a compatible and customized solution for the blockchain storage structure in the implementation of the blockchain-based data sharing and federated learning method. Figure 2 (a) is a compatible solution for the blockchain storage structure. Figure 2 (b) is a customized solution for blockchain storage structure;

[0050] Figure 3 It is a workflow diagram of a data sharing module in an embodiment of a data sharing and federated learning method based on blockchain;

[0051] Figure 4 A workflow diagram of a federated learning module in an embodiment of a data sharing and federated learning method based on blockchain;

[0052] Figure 5 is a reputation score of a training node in an embodiment of a blockchain-based data sharing and federated learning method;

[0053] Figure 6 is a contribution score of a training node in an embodiment of a blockchain-based data sharing and federated learning method;

[0054] Figure 7It is the accuracy of the global model test on the MNIST data set in an embodiment of a blockchain-based data sharing and federated learning method;

[0055] Figure 8 is a loss value of a global model test on the MNIST dataset in an embodiment of a blockchain-based data sharing and federated learning method;

[0056] Fig. 9 It is a comparison of the accuracy of different schemes tested on the MNIST dataset in an embodiment of a blockchain-based data sharing and federated learning method;

[0057] Fig.10 It is a comparison of the loss values ​​of different schemes tested on the MNIST dataset in an embodiment of a blockchain-based data sharing and federated learning method;

[0058] Fig.11 It is the accuracy of global model testing on the CIFAR-10 dataset in an embodiment of a blockchain-based data sharing and federated learning method;

[0059] Fig.12 is a loss value of a global model test on a CIFAR-10 dataset in an embodiment of a data sharing and federated learning method based on blockchain;

[0060] Fig.13 It is a comparison of the accuracy of different schemes tested on the CIFAR-10 dataset in an embodiment of a blockchain-based data sharing and federated learning method;

[0061] Fig.14 It is a comparison of the loss values ​​of different schemes tested on the CIFAR-10 dataset in an embodiment of a blockchain-based data sharing and federated learning method;

[0062] Fig.15 It is the smart contract gas cost of the data sharing module in the embodiment of the data sharing and federated learning method based on blockchain;

[0063] Fig.16 It is the smart contract gas cost of the federated learning module in the implementation scheme of the data sharing and federated learning method based on blockchain. DETAILED DESCRIPTION

[0064] The present invention can be explained in more detail by the following examples. The purpose of disclosing the present invention is to protect all changes and improvements within the scope of the present invention. The present invention is not limited to the following examples.

[0065] See also Figure 1The present invention provides a data sharing and federated learning method based on blockchain, referred to as DSFL method, including a data sharing module and a federated learning module:

[0066] In the data sharing module, the data owner first symmetrically encrypts the collected data. The encrypted data set adopts an offline storage solution, using IPFS instead of the traditional distributed storage solution; then the data buyer’s public key PK is used to p Encrypt the symmetric key SYK to obtain SYK pk , and use digital envelope technology to transmit SYK pk ; Then, the data owner registers on the blockchain and publishes the descriptive information of the data set to wait for the model trainer to apply for use, providing a fair, secure and decentralized blockchain-based sharing solution for devices that participate in federated learning but lack qualified data sets. At the same time, in the federated learning module, some devices that are willing to participate in federated learning tasks but do not have data that meets the requirements can also register and publish their public keys on the blockchain, and pay to obtain access to the data set in the data sharing module through the smart contract algorithm, achieving more efficient blockchain performance and a fairer supervision mechanism, and ensuring that all nodes can obtain fair rewards and benefits. Importantly, the sharing process also uses blockchain smart contracts instead of trusted third parties, and the use of RSA accumulators also ensures the integrity and authenticity of the data set, providing a verification basis for the implementation of transaction appeals in smart contracts.

[0067] The roles included in the above framework are described as follows:

[0068] Data owners: IoT devices with data collection capabilities, which often face limitations in storage capacity and computing power and cannot directly participate in federated learning.

[0069] Data buyers: Some devices have excess computing resources but lack the necessary data to participate in federated learning tasks. These devices hope to contribute their excess computing resources and turn them into value.

[0070] Training nodes: Consisting of data buyers or devices with many datasets and computing resources, they participate in federated learning to earn rewards by submitting updates to local training models.

[0071] Committee nodes: There are two types of nodes, namely verification nodes and aggregation nodes. Verification nodes are responsible for verifying local model updates submitted by training nodes, and aggregation nodes are responsible for global model aggregation.

[0072] Blockchain: Blockchain realizes the traceability and immutability of the data transaction process and the federated learning process, and intelligently ensures that the operations involved in the blockchain-based data sharing and federated learning method (DSFL method) can be automated without the need for a trusted third party.

[0073] IPFS: It works on two modules, storing encrypted data sets in the data sharing module and generating local model updates and global models in the federated learning module.

[0074] DAPP users: They are both users of the model and verifiers of the model quality, that is, DSFL can adjust the federated learning module based on their feedback in order to train a more effective model.

[0075] In the process of data sharing, trust is one of the key issues that need to be addressed. Data owners worry that data buyers may not pay after receiving the data, while data buyers worry about receiving false data. Fair payment, as a potential solution, provides the possibility of fair transactions for both parties. However, most existing solutions rely on trusted third parties to guarantee fairness, such as requiring them to verify the authenticity of the data set. This not only makes transactions more cumbersome, but also increases the risk of privacy leakage.

[0076] To address these issues, this embodiment uses smart contracts instead of trusted third parties to implement a decentralized verification mechanism that verifies the authenticity of data sets by using accumulators based on cryptographic primitives (RSA). Among them, RSA accumulators provide non-membership proofs for any element in the set, and these proofs are publicly verifiable, making it possible to use them in a blockchain environment. Based on the proofs provided by the RSA accumulator, a complaint mechanism is designed for data buyers, allowing buyers to raise questions or disputes about the quality and accuracy of the purchased data to prevent data owners from providing unqualified data. By incorporating an appeal process, transparency and accountability in the data sharing process can be ensured, thereby promoting trust among the relevant parties.

[0077] In order to achieve fast distribution of global models and asynchronous upload of local model updates while ensuring that transactions are not tampered with, this embodiment designs two different solutions to store global models and local updates. Please refer to Figure 2 To make it easier to understand, Figure 2 Only the model type is marked in the block. In fact, the block also contains some other information, such as signature, timestamp, etc.

[0078] For better compatibility, this embodiment proposes two hypothetical methods for implementing on-chain models: "compatible solution" and "customized solution". Among them, the "compatible solution" encapsulates the global model in a transaction and submits it to an existing popular blockchain; the "customized solution" is a blockchain specially designed for federated learning, and each block stores the global model to be distributed in the current round, and uses this block as the genesis block of each side chain, and then builds a directed acyclic graph (DAG) side chain to store the local model updates of this round.

[0079] When training starts, the training node accesses the current global model on the main chain and performs local training. After local training is completed, the training node submits the model update to the committee, verifies it with the verification node and packages it for storage on the side chain for the current round. Once the aggregated local model updates meet the aggregation requirements, the aggregation nodes in the committee begin to aggregate the model of the current round and upload it to the main chain as the initial model for the next round. Compared with the traditional blockchain structure, the DAG side chain can confirm transactions faster and process multiple transactions at the same time, with higher throughput to meet high concurrency scenarios.

[0080] During the federated learning process, there may be malicious training nodes that deliberately submit poisonous model updates, thereby disrupting the entire training process. More commonly, some training nodes do not contribute their own local data or computing resources, but directly submit global models as model updates to fraudulently obtain incentives. This lazy behavior leads to a decrease in the willingness to cooperate of other honest participating nodes, reducing the collaborative efficiency and fairness of the entire system. In order to resist poisoning and free-rider attacks, this embodiment designs a training node management mechanism. According to the model update verification results, an incentive mechanism is established to give corresponding rewards to actively participating nodes and punish malicious nodes to increase the node participation and willingness to cooperate, thereby promoting the collaborative efficiency and fairness of the federated learning system. The specific operations are as follows:

[0081] After the training node submits the local model update, the verification node verifies it using the test data set to evaluate their effectiveness and identify malicious behavior. After verification, the results are uploaded to the blockchain, triggering the reputation calculation function in the smart contract and automatically updating the reputation score of the corresponding training node.

[0082] The reputation score is calculated as follows:

[0083]

[0084] Among them, EID is the current global training round of federated learning, sf is the scaling factor that controls the scaling accuracy, and rej is the number of models that are rejected for aggregation.

[0085] After the model training is completed, we calculate the contribution score of each training node and provide rewards based on their contribution. It is worth noting that in the actual training process, each participant has unique local data and network environment. Therefore, even honest participants may occasionally submit flawed models. In this case, it is crucial to maintain tolerance and understanding, but malicious nodes that affect the process multiple times must be severely punished. Striking a balance between tolerance and responsibility is crucial to creating a fair and effective federated learning environment.

[0086] The calculation of contribution score Con is as follows:

[0087]

[0088] Among them, sta is the minimum standard set by the committee for the reputation score of training nodes for federated learning.

[0089] Under the above-mentioned conditions, in this embodiment, a DSFL framework structure is constructed through multiple smart contracts, as follows:

[0090] See also Figure 3 In the data sharing module, the data owner (data collection device) and the data buyer are guaranteed to trade fairly. First, the data owner encrypts the data set using a symmetric encryption algorithm, uploads the encrypted data to IPFS, and returns the IPFS address of the data; then the following functions are called in sequence to complete the fair transaction of data.

[0091] The data buyer calls registerDP(dataType,PK p ) function, registers and joins the system, while publicly disclosing the type of data he wishes to purchase and his public key.

[0092] Data owners (such as sensors or mobile devices) call the registerDO(dataType, price) function to register and join the system. The registration process may involve identity authentication and device certification to ensure that only legitimate devices participate in data transactions. In addition, data owners publish the type of data they own and the expected price of the data.

[0093] The data buyer calls the queryData(dataType) function with the desired data type as input and returns the addresses of all data owners that have that data type.

[0094] The data buyer calls the requestData(DOaddress) function, enters the address of the data owner, and requests to purchase the data. At the same time, he needs to transfer funds that are higher than or equal to the purchase price of the data, and temporarily store these funds in the smart contract.

[0095] The data owner calls requestPK p (DPaddress) function, after receiving a purchase request from a data buyer, the data owner enters the data buyer's address to obtain their corresponding public key and uses it to encrypt the symmetric key.

[0096] The data owner calls uploadInformation(SYK pk ,HD,h) function, uploads the IPFS address of the encrypted dataset, the encrypted symmetric key, and the accumulator value of the ciphertext to the smart contract. In addition, the data owner needs to transfer a deposit higher than the dataset price to the smart contract to prevent them from providing false data or data that does not meet the pre-declared requirements. Finally, the function transfers the purchase funds in the smart contract to the data owner.

[0097] The data buyer calls the getInformation(DOaddress) function, inputs the address of the data owner, and receives the IPFS address of the purchased data, the encrypted symmetric key, and the accumulator value of the ciphertext.

[0098] The data buyer calls the appeal(DOaddesses,c,proof) function. If some of the purchased data is found to be inconsistent with the description, the data buyer can use the accumulator to appeal within the appeal period. c is the encrypted data that the buyer appeals against and does not meet the requirements. Proof is the accumulator value of the remaining encrypted data excluding c, which is used to ensure that the disputed data belongs to the data owner, rather than being fabricated by the data buyer for malicious reporting. If the appeal is successful and proves that the data buyer was indeed deceived, the smart contract will transfer the data owner's deposit to the buyer as compensation; otherwise, the smart contract will transfer the data buyer's deposit to the data owner as compensation.

[0099] After the appeal period, if the data owner has not been complained about, he can call the deposit(DPaddress) function to get his deposit returned.

[0100] See also Figure 4 In the federated learning module, smart contracts are used to implement model distribution, node management, contribution rewards, etc. The specific steps are as follows:

[0101] Nodes applying to participate in Federated Learning (FL) call the register(nodeType) function and register to join the system. They can register as training nodes or committee nodes, but not both at the same time. After registration, their identities are temporarily set as candidate participants and need to be verified before they can participate in federated learning.

[0102] The committee calls initFL(HD g ,Tn num ,Vn num ,PK c ) function, initializes the initial global model according to the task requirements and uploads it to the blockchain. At the same time, the smart contract is called to initialize the training nodes, committee members and committee public and private key pairs, and the training begins.

[0103] The training node calls the getGobalModel(EID, aggregator) function, inputting the round number it is participating in and the address of the model aggregator node to retrieve the global model and committee public key for that round.

[0104] The training node calls uploadLocalUpdate(EID,HD l ) function, uses the global model for local training, encrypts the local model update using a symmetric encryption algorithm, uploads it to IPFS, and then uploads the returned hash address.

[0105] The validator node calls the requestTask(EID,Tn) function, inputting the address of the training node it wants to verify and requesting the encrypted symmetric key.

[0106] The training node calls AssignTask(EID,Vn,SYK pk ) function, encrypts the symmetric key with the committee's public key, uploads it to the blockchain, and marks the verification node as a modeler. This prevents other verification nodes from maliciously seizing the role and is also beneficial for future traceability.

[0107] The validator node calls the getLocalUpdate(EID,Tn) function, inputs the address of the training node whose local model update it wants to verify, and decrypts the local model update using the committee’s private key to obtain the local model update.

[0108] The verification node calls the validate(EID, Tn, result) function to verify the local model. If the verification result proves that the submitted local model update will not cause damage to the global model, the specified result result is true, otherwise it is false.

[0109] The training node calls the claim(EID,Vn) function. If the training node is not satisfied with the verification result, it can file an appeal.

[0110] The committee calls the claimRespond(EID, Tn, Vn, result) function to send the appealed model update to all verification nodes for cross-validation, confirm the final verification result, and upload the result to update the reputation of the verification nodes and training nodes.

[0111] The aggregation node in the committee calls UploadGlobalModel(EID,HD g ,aggregator) function, waiting for the local model to be updated to meet the aggregation requirements, or until the end of the current round. Then, the aggregation node performs model aggregation and uploads the aggregated global model to the blockchain. In addition, based on the performance of the committee members, the public-private key pairs of the committee members and the committee are updated.

[0112] The committee calls newFlEpoch(PK c ,reputation) function, which sets new requirements for the next round, such as the number of training nodes and the minimum reputation value. It updates the training node list and starts a new round of training.

[0113] Repeat the above process until a global model that meets the requirements is obtained.

[0114] By combining the above two modules, the DSFL architecture achieves fair and secure data sharing, while promoting collaborative model training through federated learning. At the same time, the use of smart contracts ensures transparency, immutability and high trust among participants, ultimately achieving a virtuous cycle of data value realization environment.

[0115] Experimental verification

[0116] In this embodiment, the experiment was conducted on Ubuntu 18.04LTS, and the FISCO-BCOS blockchain system was used on Intel(R)Xeon(R)Gold5218CPU@2.30GHz. The implementation of federated learning used Python3.9.7 and PyTorch 1.13.1 to run simulations on GeForce RTX 3080GPU.

[0117] (1) Verify the effectiveness of the incentive mechanism

[0118] In order to verify the effectiveness of the reputation-based incentive mechanism, this example assumes that sf = 100 and sta = 500. Figure 5 ,The training is conducted in multiple global rounds, and it can be observed that the reputation scores of ,training nodes that continuously submit qualified local model updates increase at a faster rate. On the ,conversely, the reputation scores of malicious participants grow ,slowly.

[0119] See also Figure 6,After aggregating the global models of 20 global rounds, it can be observed that the system is tolerant to nodes with reputation scores above 500, and the contribution scores of these nodes show the smallest change and are close to 100; however, once the reputation score drops below 500, the contribution score drops rapidly, indicating that the node is judged as malicious, and its contribution score drops rapidly and approaches 0.

[0120] The experimental results show that the method implemented can indeed achieve tolerance for honest training nodes and severe punishment for malicious nodes, thereby maximizing the efficiency and fairness of the entire system. At the same time, it ensures that nodes actively and voluntarily participate in federated learning and promotes long-term cooperative relationships.

[0121] (2) Performance verification against malicious attacks

[0122] A. Experiments were conducted on the MNIST dataset, which consists of 70,000 images (60,000 for training and 10,000 for testing). The handwritten image samples are 28×28 grayscale images representing handwritten digits between 0 and 9. These are used to represent independent and identically distributed (IID) data, and these data categories are evenly distributed among the clients. This embodiment uses a convolutional neural network (CNN) model as the global model and randomly selects 10 training nodes for each round of local training, so each device randomly has 6,000 training samples. During the training process, each device performs 1-7 rounds (local-epoch) of local training in sequence, with the learning rate set to 0.01, and obtains the training accuracy and loss value (Test accurancy and Testloss), please refer to Figure 7 and Figure 8 .

[0123] Malicious nodes are defined as participants who submit incorrect data to intentionally reduce model accuracy, and participants who refuse to perform local training to save resources. Based on the experimental results of the global model, in the experiment of resisting malicious nodes, it is stipulated that 10 training nodes are randomly selected for local training in each round, each trainer performs 2 rounds of local training, and the global training is 50 rounds. Malicious nodes do not train the global model that is directly submitted for distribution.

[0124] In the DSFL method provided in this embodiment, malicious model updates are removed by verifying nodes. In the comparative experiment, no verification is performed and all local model updates are directly aggregated to test the accuracy and loss value of the global model in each round under different malicious node ratios. Fig. 9 and Fig.10. It can be seen that as the proportion of malicious nodes increases, both the DSFL method of this embodiment and the conventional FL method experience a decline in global model performance. However, the accuracy of the global model of the DSFL method of this embodiment is higher than that of the conventional FL. Since the test data set follows the assumption of independent and identical distribution, under the DSFL method of this embodiment, even if more nodes directly use the distributed global model as their own model update for lazy behavior, the accuracy of the final global model of the DSFL method is still better than the model accuracy under the same parameter conditions in the conventional FL method.

[0125] B. The validation was performed on the CIFAR-10 dataset, which consists of 60,000 images (50,000 for training and 10,000 for testing) of size 32×32×3, and these data categories are evenly distributed among the clients. To further enhance the persuasiveness of the experiment, this example also trained a ResNet-18 model, which consists of four convolutional layers. Each convolutional layer uses a 3x3 convolution kernel and a ReLU activation function to extract local features from the image, which can effectively train deep networks and improve model performance and convergence speed. Please refer to Fig.11 and Fig.12 In each round, 10 training nodes are randomly selected for local training, and each device has 5000 training samples; during the training process, each device performs 1-7 rounds of local training, and the learning rate is set to 0.001.

[0126] In the experiment of defending against malicious nodes, 10 training nodes were randomly selected, each training node performed 3 rounds of local training and 20 rounds of global training. The malicious nodes did not perform any training and directly submitted the distributed global model. The DSFL method removes malicious models by verifying the malicious models through verification nodes. In the comparative experiment, all local model updates were directly aggregated without any verification, and the accuracy and loss values ​​of the global model were tested in each round under different malicious node ratios. Please refer to Fig.13 and Fig.14 The experiment once again proves that the solution of this embodiment is superior to the common federated learning solution in terms of accuracy and can resist poisoning attacks by malicious nodes to a certain extent.

[0127] (3) Performance verification of smart contracts

[0128] In this example, a smart contract was developed using Solidity, a programming language used to develop smart contracts on Ethereum, and Remix was used to implement the prototype of the smart contract. The specific configuration includes a compiler (0.8.18+commit.87f61d96), a language (Solidity), and a deployment environment (JavaScript virtual machine). Based on the above settings, this example deploys a smart contract in Remix to test the gas cost of each function, which is a unit of measurement of the computing resources required to perform various operations on the blockchain.

[0129] In the data sharing module, deploying a smart contract consumes approximately 4500851 gas, but this operation only needs to be performed once. Fig.15 ,The gas consumption of calling different functions is within an acceptable range.

[0130] Similarly, in the federated learning module, deploying the contract resulted in the highest gas cost of 5573241, see Fig.16 ,Compared with the deployment, the rest of the functions in the contract consume much less gas.,This shows that the smart contract designed in this embodiment can effectively reduce transaction costs,,achieve fair and secure data sharing without the participation of a trusted third party,,while simplifying the transaction process.

[0131] Therefore, the present invention adopts the above-mentioned blockchain-based data sharing and federated learning method, which can effectively supervise the behavior of participating nodes in federated learning, resist attacks from malicious nodes, motivate honest participants, punish malicious nodes, and promote a virtuous cycle in the federated learning process.

[0132] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that they can still modify or replace the technical solution of the present invention with equivalents, and these modifications or equivalent replacements cannot cause the modified technical solution to deviate from the spirit and scope of the technical solution of the present invention.

Claims

1. A data sharing and federated learning method based on blockchain, characterized in that: Including data sharing module and federated learning module: In the data sharing module, data envelope technology and accumulator algorithm are used to enable fair transactions between data owners and data buyers; In the federated learning module, an optimized storage model is used, and a node behavior management mechanism is adopted to ensure that all nodes receive fair rewards and benefits.

2. According to claim 1, a blockchain-based data sharing and federated learning method is characterized in that: The optimized storage models include compatible solutions and customized solutions: The compatible solution encapsulates the global model in a transaction and submits it to the blockchain; Customized solution The blockchain is specially designed for federated learning. Each block stores the global model to be distributed in the current round and serves as the genesis block of each side chain. Then a directed acyclic graph side chain is constructed to store the local model updates of this round.

3. A blockchain-based data sharing and federated learning method according to claim 2, characterized in that: The node behavior management mechanism includes updating the verification results according to the local model, establishing an incentive mechanism, giving corresponding rewards to actively participating nodes, and punishing malicious nodes.

4. A blockchain-based data sharing and federated learning method according to claim 3, characterized in that: The training nodes are rewarded or punished according to their contribution scores, as follows: Among them, Con is the contribution score of the training node, sta is the minimum standard set by the committee for the reputation score of the training node for federated learning, rep is the reputation score of the training node, EID is the current global training round of federated learning, sf is the scaling factor, and rej is the number of models rejected for aggregation.

5. A blockchain-based data sharing and federated learning method according to claim 4, characterized in that: Data sharing module, including: The data owner encrypts the dataset using a symmetric encryption algorithm, uploads the encrypted dataset to the Interstellar File System, and returns the address of the encrypted dataset; Data buyers register and join the system, publicly disclose the type of data they wish to purchase and their public key; Data owners register and join the system, publishing the type of data they own and the expected price of the data; The data buyer takes the desired data type as input and returns the addresses of all data owners that have that data type; The data buyer enters the address of the data owner and requests to purchase the data, and transfers funds higher than or equal to the data price to the smart contract for temporary storage; After receiving the purchase request from the data buyer, the data owner obtains the public key of the data buyer and uses the public key to encrypt the symmetric key; The data owner uploads the address of the encrypted dataset, the encrypted symmetric key, and the accumulator value of the ciphertext to the smart contract, transfers a deposit higher than the dataset price to the smart contract, and transfers the purchase funds in the smart contract to the data owner; The data buyer obtains the InterPlanetary File System address, encrypted symmetric key, and accumulator value of the ciphertext of the required data set based on the address of the data owner; The data buyer checks the type of data purchased. If it does not meet the requirements, the data buyer or data owner can appeal using the accumulator within the appeal period. Based on the appeal result, the data buyer or data owner will be compensated. After the appeal period, if the data owner has not been complained about, the deposit will be refunded.

6. A blockchain-based data sharing and federated learning method according to claim 5, characterized in that: Federated learning modules, including: Register the devices applying to participate in federated learning as training nodes or committee nodes and join the system. Committee nodes include verification nodes and aggregation nodes. After registration, their identities are temporarily set as candidate participants and they need to be verified before they can participate in federated learning. The committee initializes the initial global model according to the task requirements and uploads it to the blockchain. At the same time, it calls the smart contract to initialize the training nodes, committee members, and the public and private key pairs of the committee; The training node retrieves the global model and committee public key of the round according to the round number and the address of the aggregation node. The training node uses the global model for local training, encrypts the local model update using a symmetric encryption algorithm, uploads it to the InterPlanetary File System and returns the address; The verification node requests the encrypted symmetric key based on the address of the training node to be verified; The training node encrypts the symmetric key with the committee’s public key, uploads it to the blockchain, and marks the verification node as a model validator; The verification node uses the committee’s private key to decrypt the local model update based on the training node address of the local model update that needs to be verified, and obtains the local model update; The verification node verifies the local model update and determines whether it has the potential to damage the global model; If the training node is not satisfied with the verification result, it will file an appeal; The committee sends the appealed local model update to all verification nodes for cross-verification, confirms the final verification result and uploads it, and updates the reputation values ​​of the verification nodes and training nodes at the same time; The aggregation node waits for the local model to be updated to meet the aggregation requirements, or until the end of the current round, performs model aggregation, and uploads the aggregated global model to the blockchain. At the same time, based on the performance of the committee members, the public-private key pairs of the committee members and the committee are updated; The committee sets new requirements for the next round, i.e. the number of training nodes and the minimum reputation value, updates the training node list and starts a new round of training; Repeat the above process until a global model that meets the requirements is obtained.