Decentralized machine learning method based on Byzantine fault tolerance and privacy protection
By adopting blockchain, Byzantine consensus and Byzantine gradient aggregation rules in decentralized machine learning combined with differential privacy technology, the shortcomings in Byzantine nodes and privacy protection in the existing technology are solved, and a secure, privacy-protected and efficient decentralized machine learning training process is achieved.
Patent Information
- Application Number
- CN202210183917.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-28
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2042-02-28
AI Technical Summary
The existing decentralized machine learning solutions have shortcomings in handling Byzantine nodes and privacy protection, and it is difficult to ensure the security, privacy and efficiency of the learning process at the same time.
A decentralized machine learning framework is built using blockchain, Byzantine consensus and Byzantine gradient aggregation rules (BFT GAR) combined with differential privacy (DP) technology. The framework records machine learning processes through blockchain, uses Byzantine consensus to ensure model consistency, detects and filters Byzantine gradient aggregation rules, and protects data privacy through differential privacy.
It realizes a secure, privacy-protected and efficient machine learning training process in a decentralized network, avoiding the problem of model non-convergence and training interruption caused by Byzantine nodes, while ensuring the privacy and transparency of data.
Smart Images

Figure CN114595836B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of blockchain and machine learning, and in particular to a decentralized machine learning method and system based on Byzantine fault tolerance and privacy protection. Background Art
[0002] As the amount of data increases and the complexity of machine learning models grows, there are rigid requirements for the utilization of computing hardware and storage owned by various entities in the distributed network. Distributed learning involves training machine learning models on remote mobile devices, edge servers, or cloud servers while keeping data local. The most advanced decentralized machine learning solutions use three main network topologies, such as Figure 1 As shown in Figure 2, federated learning utilizes an efficient centralized network, such as Figure 1 As shown in (a), one of the parameter servers aggregates the gradients calculated by distributed devices and updates the global model for them while preserving privacy because the devices calculate locally without communicating with each other. The vulnerability of the centralized network topology is that the centralized parameter server faces a single point of failure problem (the server may crash or become a Byzantine server). To solve the problem of single point of failure, some people have proposed Figure 1 The architecture shown in (b) in the figure shows parameter servers in red. These servers are Byzantine fault-tolerant. However, none of the above structures can guarantee the privacy of the parameters of each node during the learning process. Therefore, we propose an architecture based on a distributed learning architecture, such as Figure 1 As shown in (c). Although many studies have demonstrated the feasibility of preserving privacy, improving training performance, or introducing Byzantine resilience, no study has considered all of these issues at the same time.
[0003] Decentralized learning faces the following challenges: 1) Without a fully trusted centralized custodian, in a decentralized network, users have no motivation to participate in the learning process due to lack of trust. As a result, there is a problem of insufficient data to train a reliable model. 2) In decentralized learning, a Byzantine node that can behave arbitrarily (such as crashing or launching an attack) may prevent the model from converging or interrupt the training process. 3) It is a challenge to balance privacy, security, and efficiency and achieve frictionless data sharing while ensuring privacy and transparency. Summary of the invention
[0004] In order to solve the problems existing in the prior art, the present invention proposes a new solution to provide a decentralized learning framework that uses blockchain (as an immutable distributed ledger), Byzantine consensus and Byzantine gradient aggregation rule (BFT GAR) to ensure strong security and maintain privacy using local gradient calculation and differential privacy (DP). As a key component, blockchain maintains a complete, immutable and traceable record of the machine learning process, including user registration, round-by-round gradients and model parameters. Using blockchain, users can identify illegal and Byzantine peers and update their local models without worry. The Byzantine consensus algorithm ensures the consistency of multiple rounds of model transformation, while the Byzantine gradient aggregation rule provides an effective method to detect and filter Byzantine gradients in each round. Nodes calculate gradients using local training data and only share perturbed gradients with other nodes, providing strong privacy protection.
[0005] The technical solution adopted by the present invention is: a decentralized machine learning method based on Byzantine fault tolerance and privacy protection, comprising:
[0006] Initialization phase: Each node generates a key pair (pk, vk) and a unique identifier id, and all nodes establish a connection; each node initializes its reputation value w, learning rate γ, total number of rounds T, gradient, and learning parameters;
[0007] Training phase: All nodes start training with the same initial parameters. Each round of training includes a gradient calculation process and a blockchain consensus process. In each round of training, the leader node elected in that round is responsible for the consensus process of that round.
[0008] Furthermore, the leader node is elected through the following steps:
[0009] (1) Each node uses its own private key and a verifiable random number function to generate a random number and a proof, (h, π) = VRF(sk, seed), where h is the generated random number, π is the proof, sk is the node’s private key, and seed is the random seed used to generate the random number;
[0010] (2) The node i participating in the competition will i , π i ) is broadcast to the network and received from other nodes j (h j , π j ) and then verify. If the verification is successful, node i will (h j , π j , id j ) is inserted into its local candidate list L i middle;
[0011] (3) After the election time limit is reached, all nodes select the largest random number h from the candidate list. max , and its corresponding node will become the leader node of this round of training.
[0012] Furthermore, in the gradient calculation process, each node has a random gradient and a Gaussian noise perturbation gradient; each node broadcasts its perturbation gradient to other nodes in the blockchain network, specifically including:
[0013] (1) Node i calculates the local stochastic gradient in For the local dataset D i Random sampling in; t represents the round, t∈T; i=1, 2, ..., n, n is the number of nodes;
[0014] (2) Generate a random Gaussian noise The variance of the Gaussian noise is represented by the input variable σ,
[0015] (3) The Gaussian noise Add to the shared local gradient to get the perturbed gradient:
[0016] (4) Node i will perturb the gradient Broadcast it out and accept the perturbation gradients broadcast by other nodes at the same time.
[0017] Further, the blockchain consensus process includes: using the Byzantine Fault Tolerance protocol as the consensus protocol of the system, including four steps: RE-PREPARE, PREPARE, COMMIT and DECIDE;
[0018] (1) In the PRE-PREPARE phase, the leader node uses the Byzantine gradient aggregation rule function (e.g., Krum function) to calculate the aggregate gradient Forming a record aggregation gradient Δ (t) New Block After that, the leader node broadcasts the pre-prepare message
[0019] (2) In the PREPARE phase, all follower nodes calculate based on the local perturbation gradient After receiving the pre-prepare message from the leader node, the follower node verifies Is it true? If the verification is successful, the follower node broadcasts the preparation message
[0020] (3) In the COMMIT phase, if a node receives 2f+1 prepare messages, the node broadcasts a decision message And the node enters the decision-making stage; where f is the number of Byzantine nodes;
[0021] (4) In the DECIDE phase, if a node receives 2f+1 decision information, the node sends the decision information to the local blockchain. Append a new block Each node uses blocks The aggregation gradient Δ (t) Update its local gradient
[0022] Furthermore, in the DECIDE phase, when the difference between the random gradient of a node and the aggregate gradient is greater than When , update its reputation value: Wherein c is a certain constant, which can be adjusted according to the situation, for example, it can be set to 0.1.
[0023] Furthermore, when the consensus time exceeds the set time, each node broadcasts a change message If a node receives 2f+1 change messages, it abandons this round of training.
[0024] Furthermore, all nodes have the same initial reputation value.
[0025] Furthermore, nodes with a reputation value of 0 cannot participate in the election of leadership nodes.
[0026] Furthermore, the present invention also provides a decentralized machine learning system based on Byzantine fault tolerance and privacy protection, which can implement the above-mentioned decentralized machine learning method steps when running the system.
[0027] Compared with the prior art, the present invention has the following beneficial effects:
[0028] 1. For the first time, a secure and privacy-preserving decentralized network machine learning solution is proposed, in which the learning process is not affected by the trusted parameter server;
[0029] 2. The system uses differential privacy protection for data privacy protection, and seamlessly embeds Byzantine fault-tolerant consensus and Byzantine gradient aggregation rules into the blockchain system, while maintaining high efficiency and benefiting from model training with Byzantine fault tolerance, transparency and traceability. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 (a), (b), and (c) are three existing distributed learning systems with different architectures.
[0031] Figure 2 The overall architecture and process of the decentralized machine learning method based on Byzantine fault tolerance and privacy protection provided by the present invention. DETAILED DESCRIPTION
[0032] In order to facilitate the understanding of the present invention, the present invention is described in more detail below in conjunction with the accompanying drawings and specific embodiments. Preferred embodiments of the present invention are provided in the accompanying drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described in this specification. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present invention more thorough and comprehensive.
[0033] Embodiment 1 The decentralized machine learning method based on Byzantine fault tolerance and privacy protection provided in this embodiment includes the following steps:
[0034] Step 1: Initialization Process
[0035] In this step, all modules in the system must be initialized. Specifically:
[0036] Step (101): Each node will initialize its own key pair (pk, vk), where pk represents the public key and vk represents the private key. The node will generate a 256-bit unique identifier based on its public key, recorded as id.
[0037] Step (102): The node broadcasts its public key pk and unique identifier id through the network.
[0038] Step (103): When the blockchain creates the genesis block, the node information of all nodes participating in the blockchain will be saved on the chain. When a new node joins the blockchain network, the node's pk, id and IP address are all recorded on the blockchain.
[0039] Step (104): At initialization, all nodes have the same initial reputation value, i.e., w i =ω,ω∈[0,1].
[0040] Step (105): All nodes initialize their own learning rate γ and total number of rounds T, and the variance perturbation gradient of Gaussian noise.
[0041] Step (106): For the simplicity and consistency of iteration, all nodes are set to have the same initial parameters. Start the learning process.
[0042] Step 2: Leader Node Election
[0043] Before each round of training begins, a leader node election is conducted. The elected leader node is responsible for the training process of this round. The specific election method is:
[0044] Step (201): Each node uses its own private key and verifiable random number function to generate a random number and a certificate. i , π i )=VRF(sk i , seed), where h i is the random number generated, π i To generate proof, sk i is the private key of the node, and seed is the random seed used to generate random numbers.
[0045] Step (202): The reputation value of all nodes w∈[0,1], if the reputation value of a node w i = 0, the node cannot participate in the leader node election of this round of training. Each node i participating in the competition must change its (h i , π i ) is broadcast to the network, and node i also needs to receive (h, π) broadcast by other nodes in the network.
[0046] Step (203): When a node i receives (h j , π j ), node i will run VerifyVRF(pk, h j , π j , seed), the output result is 1, then the verification is passed, and node i puts (h j , π j , id j ) is inserted into the local candidate list L i middle.
[0047] Step (204): There is a time limit for electing a leader node, and it is set that after the start+δ1 time, the node will no longer accept election information.
[0048] Step (205): After the election time limit is reached, all nodes will select the largest random number h from their respective candidate lists. max , and its corresponding node will become the leader node of this round.
[0049] Step 3: Training process
[0050] After completing the leader node election, the nodes will undergo a basic training process. Each round of training consists of gradient calculation and blockchain consensus. In each round, node i will calculate a true stochastic gradient and a perturbation gradient And broadcast the perturbation gradient to the network.
[0051] 1. Gradient calculation process:
[0052] Step (301): Node i calculates the local stochastic gradient in For the local dataset D i Random sampling in; t represents the round, t∈T; i represents a node, i=1, 2,…, n;
[0053] Step (302): Generate a random Gaussian noise The variance of this noise is represented by the input variable σ, Taking Python language as an example, the np.random.normal(0, σ) function can generate a Gaussian noise with a mean of 0 and a variance of σ (the so-called Gaussian noise is a random number that conforms to the Gaussian distribution).
[0054] Step (303): The noise Added to the shared local gradient, we have
[0055] Step (304): Node i will perturb the gradient Broadcast to the network and receive perturbation gradients sent by other nodes on the network
[0056] 2. Blockchain consensus process
[0057] The present invention adopts the Byzantine fault-tolerant protocol as the consensus protocol of the system, and divides the consensus process into four steps, namely RE-PREPARE, PREPARE, COMMIT and DECIDE; specifically:
[0058] Step (401): Calculation of aggregation gradient
[0059] Leader node uses aggregate function in is a (b, α) Byzantine gradient aggregation rule function. The core idea of the gradient aggregation rule function is to remove the elements in the set that are significantly different from most of the data. The present invention uses the Euclidean distance to measure the distance between two perturbation gradients.
[0060] Define near(i) as the closest The set of nf-2 gradients, where f is the number of Byzantine nodes, and the role of the gradient aggregation rule algorithm is to find the element closest to the surrounding gradients That is the aggregate gradient Δ(t). The output of the gradient aggregation rule algorithm is one of the input gradients of the function, and the criteria that this gradient needs to meet are:
[0061] Step (402): PRE-PREPARE phase
[0062] The MSGB function aggregates the gradient Δ (t) As input, form a record Δ (t) New Block The leader node then broadcasts a pre-prepare message: in, For digital signature.
[0063] Step (403): PREPARE phase
[0064] All follower nodes (non-leader nodes) calculate based on their shared local perturbation gradients The nodes then wait for the prepare message.
[0065] Step (405): After receiving the pre-prepare message broadcast by the leader node, the follower node will first verify the digital signature And the block (block height, block hash, etc.). Then, the follower node will verify Is it established? It aims to prove Is it true? δ is a very small quantity, for example: δ is 10 -6 . This condition states that the follower nodes have similar "opinions" as the leader node.
[0066] If the verification passes, the follower node will broadcast a prepare message:
[0067] Step (408): COMMIT phase
[0068] If a node receives 2f+1 prepare messages, it broadcasts a decision message: And the node enters the decision-making stage.
[0069] Step (409): DECIDE phase
[0070] If a node receives 2f+1 decision messages, it will send the decision message to the local blockchain. Add a new block to New Block Contains the aggregation gradient Δ (t) .
[0071] Nodes utilize aggregated gradient Δ (t) , update its local gradient
[0072] When the gradient of a node differs from the aggregate gradient by more than When , its reputation will decrease, and the reputation value will be updated by the following formula:
[0073]
[0074] Among them, c is a certain constant, which can be set according to the specific situation, for example, it can be set to 0.1.
[0075] In order to avoid deadlock in the system, for example, if the leader node is a Byzantine node, the present invention sets a time limit in the blockchain consensus process. When the consensus time exceeds the set time start+δ2, each node broadcasts a change message: If a node receives 2f+1 change messages, the node needs to abandon this round of training.
[0076] Embodiment 2 This embodiment takes a distributed learning system composed of five nodes as an example. Figure 2 As shown, the process of the method of the present invention is further described in detail.
[0077] 1. Initialization process
[0078] 1. The node set is represented as: node = {node1, node2, node3, node4}.
[0079] 2. Each node is initialized and generates its own key pair and unique identifier id. The key set is recorded as sk = {(pk1, vk1), (pk2, vk2), (pk3, vk3), (pk4, vk4)}; the unique identifier set of each node is recorded as id = {id1, id2, id3, id4}, and each node broadcasts its own pk and id through the network.
[0080] 3. When the blockchain is initialized, the information of each node participating in the blockchain (including private keys, unique identifiers, addresses, etc.) will be recorded on the genesis block. If a new node joins the blockchain network, the node in the system will send a transaction Tx new ={pk new , id new , IP new} to record the information of the newly joined node on the blockchain.
[0081] 4. All nodes perform reputation value ω, learning rate γ, total number of learning rounds T, and variance perturbation gradient of Gaussian noise. The initial reputation value of all nodes is the same by default, denoted as w1=w2=w3=w4=ω, the learning rate of each node is denoted as γ={γ1,γ2,γ3,γ4}, and the total learning cycle is denoted as T={T1,T2,T3,T4}. The initial parameters of all nodes are set to be the same, that is,
[0082] 5. Each node uses its own private key and verifiable random number function to generate a random number and a certificate. The random number and certificate generated by each node are recorded as:
[0083] (h, π)={(h1, π1), (h2, π2), (h3, π3), (h4, π4)}.
[0084] 2. Leader Node Election
[0085] 6. Nodes with a reputation value of w = 0 will be excluded from the election candidates. Each node will broadcast its own (h i , π i , id i ), after receiving the broadcast from other nodes, the node will run the verifiable random number verification function to verify the legitimacy of the random number in the message, that is, VerifyVRF(pk2, h2, π2, seed). Only after the verification is passed can it be added to the candidate pool. For example, node1 receives the legitimate broadcast from the other three nodes, then the candidate list of node1 is recorded as:
[0086] L1={(h1, π1, id1), (h2, π2, id2), (h3, π3, id3), (h4, π4, id4)}.
[0087] 7. After reaching the set election time start+δ1, all nodes select a largest random number from their candidate lists, and the node corresponding to the largest random number will become the leader node. Here, it is assumed that the selected leader node is node1.
[0088] 3. Training Process
[0089] 8. Each node starts to calculate the local stochastic gradient, The local gradient of each node is Each node generates a Gaussian noise Recorded as; The system adds the generated Gaussian noise to the local stochastic gradient Get the perturbation gradient Nodes will broadcast the perturbation gradient g to each other (t) .
[0090] 9. The leader node node1 uses the aggregate function to calculate Use the Byzantine gradient aggregation rule function to find the element closest to the surrounding gradient and the aggregation gradient Δ (t) .
[0091] 10. The MSGB function aggregates the gradient Δ (t) As input, form a record Δ(t) New Block The leader node then broadcasts a pre-prepare message:
[0092] 11.node2, node3, node4, node5 act as follower nodes and will be calculated based on the local perturbation gradient The nodes then wait for the prepare message.
[0093] 12. After receiving the pre-prepare message broadcast by the leader node, the follower node will first verify the digital signature σ and the block, and then the follower node will verify Is it true to determine whether it has the same "opinion" as the leader node node1? If the verification is successful, the follower node will broadcast a preparation message:
[0094] 13. If the node receives 2f+1 prepare messages, the node broadcasts a decision message: And the node enters the decision-making stage.
[0095] Assuming that node3 is a Byzantine node in the system and f=1, when node2 receives the prepare message from node1 and node4, node2 will broadcast a decision message (node2 itself is also considered an honest node).
[0096] 14. Similarly, if the node receives 2f+1 decision messages, then the node believes that it can produce a block and sends it to the local blockchain. Append a new block For example, when node2 receives decision information from node1 and node4, node2 will add a new block to its locally maintained blockchain, which contains the aggregate gradient Δ (t) .
[0097] 15. After the block is produced, all nodes update their local gradients:
[0098] The node's reputation will then be updated. When the gradient of a node differs from the aggregate gradient by more than When , its reputation will decrease. The reputation value is updated by the following formula:
[0099]
[0100] Among them, c is a certain constant, which can be set according to the specific situation, for example, it can be set to 0.1.
[0101] This completes this round of training.
[0102] In particular, in order to prevent the system from deadlocking and being unable to reach consensus, a timeout is set in the consensus phase. Assuming that the leader node node1 is a Byzantine node and the other nodes are normal nodes, after the consensus timeout, each node broadcasts a change message. When node2 receives the change message from node3 and node4, node2 can choose to give up this round of training, and the same applies to other nodes.
Claims
1. A distributed machine learning method based on Byzantine fault tolerance and privacy protection, characterized in that: include: Initialization phase: Each node generates a key pair and unique identifier ,in represents the public key, Represents the private key; all nodes establish a connection; nodes send their public keys through the network and unique identifier Broadcast it out; The blockchain stores the node information of all nodes participating in the blockchain on the chain; when a new node joins the blockchain network, the node and IP addresses are recorded on the blockchain; at initialization, all nodes have the same initial reputation value, i.e. , ; All nodes initialize their own learning rate And the total number of rounds , and the variance perturbed gradient of Gaussian noise; Training phase: Before each round of training begins, a leader node is elected, and the elected leader node is responsible for the training process of this round; Each round of training consists of gradient calculation and blockchain consensus; in each round, nodes A true stochastic gradient is calculated. and a perturbation gradient , and broadcast the perturbation gradient to the network.
2. The distributed machine learning method based on Byzantine fault tolerance and privacy protection according to claim 1, characterized in that: The leader node is elected through the following steps: (1) Each node uses its own private key and verifiable random number function to generate random numbers and proofs. ,in is the random number generated, To prove, is the private key of the node, A random seed for generating random numbers; (2) Nodes participating in the competition Make it Broadcast to the network and receive from other nodes of After verification, if the verification passes, the node Will Insert into its local list of candidates middle; (3) After the election time limit is reached, all nodes select the largest random number from the candidate list , and its corresponding node will become the leader node of this round of training.
3. The distributed machine learning method based on Byzantine fault tolerance and privacy protection according to claim 1, characterized in that: In the gradient calculation process, each node has a random gradient and a Gaussian noise perturbation gradient, which specifically includes: (1) Node Compute the local stochastic gradient ,in For local datasets Random sampling in Indicates rounds, ; , is the number of nodes; (2) Generate a random Gaussian noise , the variance of the Gaussian noise is expressed as the input variable To indicate that there is ; (3) The Gaussian noise Add to shared local gradients On the top, we get the perturbation gradient: ; (4) Node The perturbation gradient Broadcast it out and accept the perturbation gradients broadcast by other nodes at the same time.
4. The distributed machine learning method based on Byzantine fault tolerance and privacy protection according to claim 3 is characterized in that: The blockchain consensus adopts the Byzantine Fault Tolerance protocol as the consensus protocol of the system, which includes four steps: (1) Phase: The leader node calculates the aggregate gradient using the Byzantine Krum function , forming a record aggregation gradient New Block , after which the leader node broadcasts the pre-prepare message ; (2) Stage: All follower nodes calculate based on local perturbation gradients ; After receiving the pre-prepare message from the leader node, the follower node verifies Is it true? If the verification is successful, the follower node broadcasts the preparation message ; (3) Phase: If the node receives Prepare information, the node broadcasts a decision message , and the node enters the decision-making stage; in is the number of Byzantine nodes; (4) Phase: If the node receives The node sends a decision message to the local blockchain. Append a new block ; Nodes use blocks Aggregate gradient in Update its local gradient .
5. The distributed machine learning method based on Byzantine fault tolerance and privacy protection according to claim 4 is characterized in that: exist In the stage, when the difference between the random gradient of the node and the aggregate gradient is greater than When , update its reputation value: ,in, is the initial reputation value.
6. The distributed machine learning method based on Byzantine fault tolerance and privacy protection according to claim 4, characterized in that: When the consensus time exceeds the set time, each node broadcasts a change message If a node receives If a change message is received, the current round of training will be abandoned.
7. The distributed machine learning method based on Byzantine fault tolerance and privacy protection according to any one of claims 1 to 6, characterized in that: All nodes have the same initial reputation value.
8. The distributed machine learning method based on Byzantine fault tolerance and privacy protection according to any one of claims 2 to 6, characterized in that: Nodes with a reputation value of 0 cannot participate in the election of the leader node in this round.
9. A distributed machine learning system based on Byzantine fault tolerance and privacy protection, characterized by: Running the system can implement the method steps according to any one of claims 1 to 6.
Citation Information
Patent Citations
Practical Byzantine fault-tolerant blockchain consensus method and system based on multiple leader nodes
CN109246194A
Election type Byzantine fault-tolerant consensus algorithm based on proof of work
CN111082924A