+

CN114372588B - A method for selecting a consensus node and related device - Google Patents

A method for selecting a consensus node and related device

Info

Publication number
CN114372588B
CN114372588B CN202111651030.5A CN202111651030A CN114372588B CN 114372588 B CN114372588 B CN 114372588B CN 202111651030 A CN202111651030 A CN 202111651030A CN 114372588 B CN114372588 B CN 114372588B
Authority
CN
China
Prior art keywords
round
node
slave
consensus
current
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111651030.5A
Other languages
Chinese (zh)
Other versions
CN114372588A (en
Inventor
程晗蕾
鲁静
黄昭慈
王超
向智宇
宋斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Yuanguang Software Co Ltd
Original Assignee
Yuanguang Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Yuanguang Software Co Ltd filed Critical Yuanguang Software Co Ltd
Priority to CN202111651030.5A priority Critical patent/CN114372588B/en
Publication of CN114372588A publication Critical patent/CN114372588A/en
Application granted granted Critical
Publication of CN114372588B publication Critical patent/CN114372588B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • G06N20/20Ensemble learning
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/58Random or pseudo-random number generators
    • G06F7/588Random number generators, i.e. based on natural stochastic processes

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Artificial Intelligence (AREA)
  • Databases & Information Systems (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Medical Informatics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a method for selecting a consensus node and a related device, wherein the method is executed by a slave chain link point in a slave chain, the slave chain comprises a plurality of slave chain link points, the slave chain link points can interact with a main chain node in the main chain, the method comprises the steps of acquiring first type information from the chain link points, wherein the first type information comprises at least one of current training round information, historical random numbers in last round federal learning, first global parameters output by last round federal learning and the number of the consensus nodes required to be selected, calculating the random numbers of the current round based on the first type information, calculating the selection probability of the current round based on the random numbers, and determining that the current round is selected as the consensus node if the selection probability is smaller than or equal to a comparison threshold value. The method provided by the application can reduce the risk of selecting the consensus node and improve the safety of federal learning.

Description

Method for selecting consensus node and related device
Technical Field
The application relates to the technical field of federal learning, in particular to a method for selecting consensus nodes and a related device.
Background
In order to realize quick learning to obtain a machine learning model, a Google artificial intelligence laboratory proposes a federal learning architecture, specifically, the Google artificial intelligence laboratory is used for realizing that a plurality of scattered clients and a central server can cooperatively learn a machine learning model, and the Google artificial intelligence laboratory is used for improving the efficiency of training to obtain the machine learning model. However, in the existing federal learning architecture, the cooperation between the distributed clients is very dependent on the central server, that is, there is a problem that the dependency on the central server is too great, and once the central server fails or is attacked maliciously, it directly results in that an accurate machine learning model cannot be generated, or even a machine learning model cannot be generated. Therefore, the blockchain technology is applied to federal learning, but how to further reduce the risk of federal learning based on the blockchain technology and further improve the safety of federal learning is a technical problem which needs to be solved currently.
Disclosure of Invention
The application mainly solves the technical problem of providing a method and a related device for selecting a consensus node, which can reduce the risk of selecting the consensus node and improve the safety of federal learning.
In order to solve the technical problems, the application provides a method for selecting a consensus node, wherein the method is executed by a slave chain link point in a slave chain, the slave chain comprises a plurality of slave chain nodes, the slave chain link point can interact with a main chain node in a main chain, and the method comprises the following steps:
Acquiring first type information from chain link points, wherein the first type information comprises at least one of current training round information, historical random numbers in the last round of federal learning, first global parameters output by the last round of federal learning and the number of consensus nodes required to be selected in the round of federal learning;
calculating a random number of the current round based on the first type information;
calculating the selection probability of the current turn of the self based on the random number;
and if the selection probability is smaller than or equal to the comparison threshold value, determining that the self is selected as a consensus node in the current round.
Further, before the calculating the current round selection probability based on the random number, the method further includes:
acquiring preset safety parameters, and generating auxiliary global parameters based on the preset safety parameters;
And generating a verification public key and a verification private key based on the auxiliary global parameter.
Still further, the calculating the current round selection probability based on the random number further includes:
Generating a hash result using a randomly verifiable function based on the random number and the verification private key;
And normalizing the hash result to obtain a normalized result, and outputting the normalized result as the selection probability.
Still further, the random verifiable function is obtained by publishing the random number obtained by calculation according to each round by the system according to a preset rule.
Further, the calculating the random number of the current round based on the first kind of information includes:
If the current training round information is used for determining that the current round is the first round, the preset initial random number is determined to be the current round random number, or
If the current round is determined not to be the first round based on the current training round information, the first-class information is subjected to signature calculation by using a private key of a leading node of a public committee of the previous round to obtain a random number of the current round.
Further, if the selection probability is less than or equal to the comparison threshold, determining that the method itself is before the current round is selected as the consensus node, and further comprising:
The alignment threshold is calculated and obtained by the aid of a binomial distribution algorithm from the chain link points.
Still further, the calculating to obtain the comparison threshold by using a binomial distribution algorithm further includes:
Obtaining second-class information, wherein the second-class information comprises at least one of a first processing value of rewards obtained in the last-round federal learning, a sum of rewards obtained from the last-round federal learning of each link point in a chain, consensus nodes required to be selected in the current round and the number of effective rewards in the last-round federal learning;
based on the second class information, a binomial distribution result is obtained by utilizing the binomial distribution algorithm;
And determining the comparison threshold value in the current round based on the binomial distribution result.
Further, if the selection probability is less than or equal to the comparison threshold, determining that the node is selected as the consensus node after the current round, the method further includes:
Transmitting a leader node application request to at least part of the slave links in the slave chain to be selected as the leader node, and/or
And receiving a first local parameter to be verified, which is sent by the training node, and executing consensus verification on the first local parameter.
In order to solve the technical problem, the application adopts another technical scheme that the electronic equipment comprises a processor and a memory coupled with the processor, wherein,
The memory is used for storing a computer program;
the processor is configured to run the computer program to perform the method of any of the above.
To solve the above technical problem, a further technical solution adopted by the present application is to provide a computer readable storage medium, wherein the computer readable storage medium stores a computer program capable of being executed by a processor, and the computer program is used for implementing the method as set forth in any one of the above claims.
The method has the advantages that the method is different from the situation of the prior art, the first type of information is obtained from the slave chain link points in the chain, the first type of information comprises at least one of current training round information, historical random numbers in the last round of federal learning, first global parameters output by the last round of federal learning and the number of consensus nodes required to be selected in the round, after the first type of information is obtained from the chain nodes, the random numbers of the current round are further calculated based on the first type of information, then the selection probability of the current round is calculated based on the random numbers, and when the fact that the selection probability is smaller than or equal to a comparison threshold value is determined, the current round is determined to be selected as the consensus node. The method provided by the application determines the dynamic random number by combining the first type information dynamically changing along with the federal learning turn, and further determines the selection probability of the current turn based on the random number, so that the risk of being attacked in the process of selecting the consensus node can be reduced, the safety of federal learning is improved, and a good technical effect is achieved.
Drawings
FIG. 1 is a schematic diagram of an application scenario of a selection method of a consensus node according to the present application;
FIG. 2 is a flow chart illustrating a method for selecting a common node according to an embodiment of the present application;
FIG. 3 is a flow chart illustrating a selection method of a consensus node according to another embodiment of the present application;
FIG. 4 is a flowchart illustrating a selection method of a consensus node according to another embodiment of the present application;
FIG. 5 is a schematic diagram of an electronic device according to an embodiment of the application;
FIG. 6 is a schematic diagram of a computer-readable storage medium according to an embodiment of the application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. It is to be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In the description of the present application, the meaning of "plurality" means at least two, for example, two, three, etc., unless specifically defined otherwise. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
First, in order to facilitate understanding of the technical solution provided by the present application, a federal learning system to which the method provided by the present application is applied is first described. Referring to fig. 1, fig. 1 is a schematic diagram of an application scenario of a selection method of a consensus node according to the present application.
In the present embodiment, the method for selecting the consensus node provided by the present application is applied to a federal learning system, and the federal learning system 100 includes a slave chain a and a master chain B capable of interacting. Where the slave chain a is a block chain structure for training to obtain the target local parameters, the slave chain a includes several slave link points (A1 to Am illustrated in fig. 1). The slave link points include training nodes and consensus nodes, which are distinguished by the function performed by the slave link point, and in particular can be understood as dividing each slave link point in the current slave chain a into a training node and a consensus node, according to the function performed by each slave link point in the current round. Backbone B is a federated chain structure for performing aggregation of local parameters of interest resulting from chain a training to obtain global parameters, and includes several backbone nodes.
Further, the slave chain node may be any one of electronic devices that may perform a training function, such as a terminal device, a sensor, a wearable device, and the slave link points included in the same slave chain a may be different types of devices, which are not limited herein. For example, the device types of each of the several slave link points included in the same slave chain a may include a terminal device, an intercom device, a sensor, and a wearable device. Each slave link point and the user to which the slave link point corresponds have respective private and public keys, wherein the hash value of the slave link node's public key may be used as an ID to identify its identity and/or the wallet account address of the slave link point.
As described above, slave link points may be categorized into training nodes and consensus nodes according to the functions performed by the slave link points for each round. The training node is a slave chain node for executing training to obtain target local parameters, and the consensus node is a slave chain node for performing consensus verification on the local parameters obtained by training of the training node. In the federal learning process of different rounds, the training node and the consensus node are dynamically changed, for example, a certain slave link point is used as the consensus node to perform the consensus verification function in the first round of training, and the slave link point cannot be used as the consensus node to perform the consensus verification function in the next round or other rounds. A1 to An as illustrated in fig. 1 refer to training nodes in the slave chain a in the current round of federal learning, an+1 to Am refer to consensus nodes in the slave chain a in the current round, and an+1 to Am constitute the consensus committee 101.
Further, it should be noted that, when each slave link point in the slave chain a performs the process of federal learning of the current round, it is first necessary to clarify its own function in the current training round. Specifically, when federal learning of the current round is performed, any one slave link point in the slave chain can become a consensus node through the election, thereby qualifying for performing the consensus verification.
Each master node may interact with at least some slave link points in slave chain a, and the device type to which the master node corresponds includes server devices and computer devices. It will be appreciated that the backbone node may in other embodiments be other types of devices, not explicitly recited herein. As in fig. 1, B1 to Bk illustrated in fig. 1 refer to main chain nodes in the main chain B.
Further, the training node is used for obtaining the first local parameter through training, and is also used for determining the first local parameter which passes through the consensus verification of the consensus committee as a target local parameter, uploading the target local parameter to the main chain node, and carrying out the consensus verification on the first local parameter obtained through training of the training node from the consensus node in the chain. In other embodiments, the objective local parameters may be uploaded to the main chain node through the consensus node, specifically based on the actual setting.
Referring to fig. 2, fig. 2 is a flow chart illustrating an embodiment of a method for selecting a common node according to the present application. In the current embodiment, the method provided by the application can be executed by any slave chain link point in the slave chain, wherein a plurality of slave chain link points are included in the slave chain, and the slave chain link points can directly interact with main chain nodes in the main chain or indirectly interact with other nodes. Specifically, in the current embodiment, the method provided by the present application includes S210 to S240. If a certain slave link point in the slave chain desires to perform the consensus verification function in the current round of federation learning, the slave link point needs to perform steps S210 to S240 described below, thereby becoming a consensus node in the current round of federation learning.
And S210, acquiring first-type information from the link points.
When the slave link points compete for the consensus nodes, the slave link points first need to acquire first-class information. In the present embodiment, the slave link points may be the first type of information obtained from the chain of the slave chain.
The first type of information comprises at least one of current training round information, historical random numbers in the last round of federal learning, first global parameters output by the last round of federal learning and the number of consensus nodes required to be selected in the round.
Specifically, the current training round information refers to the number of times the same global machine learning model is trained using the federal learning system. If the training is the first time by using the federal learning system to acquire a certain global machine learning model, the current training round information at the moment is 1, and if the training is the ninth time by using the federal learning system to acquire a certain global machine learning model, the current training round information at the moment is 9.
The historical random number in the previous round of federal learning is the random number calculated in the previous round of federal learning by selecting members of the consensus committee. It should be noted that, when the common committee is selected in the federal learning process of the same round, each slave link point in the chain calculates to obtain the same random number based on the first type information, but the calculated random numbers may be unequal in different rounds of training the same global machine learning model based on federal learning. If the consensus committee is selected for the first round of federal learning, the initial random number directly preset is determined as the current round of random number.
The first global parameter outputted by the last round of federation learning is the global parameter finally obtained by the main chain aggregation in the last round of federation learning. If the common committee is selected for the first round of federal learning, the preset initial global parameters are directly output as first-class information for calculating the random number of the current round.
The number of consensus nodes to be selected for the round can be set according to the requirement. Specifically, the number of the consensus nodes required to be selected for setting the round can be adjusted by the main chain nodes in the main chain, and the main chain nodes can select different numbers of consensus nodes in the federal learning process of different rounds according to the requirements.
S220, calculating the random number of the current round based on the first type information.
After the first type of information is acquired, a random number of the current round is further calculated based on the acquired first type of information.
Further, in one embodiment, step S220 calculates the random number of the current round based on the first type of information, including determining the preset initial random number as the current round random number if the current round is determined to be the first round based on the current training round information.
In another embodiment, if it is determined that the current round is not the first round based on the current training round information, the first-class information is signed with a private key of a leading node of a public committee of the previous round to obtain a random number of the current round.
Specifically, a calculation formula for calculating the random number of the current round based on the first type of information is as follows:
Wherein, seed 0 represents an initial random number, which can be also understood as an initial random seed, that is, a preset random number for selecting a common node in the first round of training, and seed e represents a random number of the current round. epoch refers to current training round information, the round of training a global machine learning model based on current federal learning identified by epoch=1 is a first round, and the round of training a global machine learning model based on current federal learning is a second round or more than the first round.
A private key signature representing a Leader node (Leader) selected by the consensus node during a previous round of federal learning.
E represents current training round information, which is used to refer to the current round of federal learning for the same machine learning model.
Seed e-1 represents the random number calculated when the consensus node was selected during the previous training round.
Representing the first global parameter resulting from the last federal learning round.
Τ represents the number of consensus nodes required to be selected in the preset federation learning process of the round, and can be set in the federation learning process of different rounds performed on the same machine learning model, the number of the consensus nodes required to be selected can be unequal, namely, the number of the consensus nodes required in each federation learning process can be adjusted according to requirements.
S230, calculating the selection probability of the current round based on the random number.
After the random number is calculated, the selection probability of the current round is further calculated from the link points based on the random number. The selection probability refers to the probability of selecting the link point from the current round to be a consensus node.
Specifically, hash operation is performed based on a verification private key and a random number of the link point, so that a hash result is obtained, normalization processing is performed on the hash result to obtain a normalization processing result, and the normalization processing result is used for determining the self selection probability. Further, step S230 may refer to steps S303 to S304 in the embodiment corresponding to fig. 3 below.
And S240, if the selection probability is smaller than or equal to the comparison threshold value, determining that the selection probability is selected as a consensus node in the current round.
After the selection probability of the current round of the chain link point is calculated and obtained, whether the chain link point is selected as a consensus node in the current round is further judged based on the selection probability. The method comprises the steps of comparing the selection probability of the current round with a comparison threshold, determining that the current round is selected as a consensus node if the selection probability is smaller than or equal to the comparison threshold, otherwise determining that the current round is not selected as the consensus node if the selection probability is larger than the comparison threshold, namely, the slave link point is a training node in the federal learning process of the current round, and executing the function of training the first local parameter. When the slave link point is selected as the consensus node, the slave link point performs the function of the consensus node in the current round, and if the slave link point determines that the current round is not selected as the consensus node, the slave link point performs the function of the training node in the current round.
As described above, the slave chain in the federal learning system includes a plurality of slave link points, and each slave chain node that is expected to be selected as a slave link point of the consensus node and is successfully selected as a slave link point of the current round needs to perform the above steps S210 to S240.
In the embodiment corresponding to fig. 2 of the present application, a first type of information is acquired from a slave link point in a chain, wherein the first type of information comprises at least one of current training round information, a historical random number in the last round of federal learning, a first global parameter outputted by the last round of federal learning and the number of consensus nodes required to be selected in the present round, the random number of the current round is further calculated based on the first type of information after the first type of information is acquired from the chain node, the selection probability of the current round is calculated based on the random number, and the current round is determined to be selected as the consensus node when the selection probability is smaller than or equal to a comparison threshold value. The method provided by the application determines the dynamic random number by combining the first type information dynamically changing along with the federal learning turn, and further determines the selection probability of the current turn based on the random number, so that the risk of being attacked in the process of selecting the consensus node can be reduced, and the safety of federal learning is improved.
Referring to fig. 3, fig. 3 is a flow chart illustrating a selection method of a consensus node according to another embodiment of the present application. In the present embodiment, the method provided by the present application includes steps S301 to S307.
And S301, acquiring first-type information from the link points.
S302, calculating the random number of the current round based on the first type information.
In the present embodiment, steps S301 to S302 are the same as steps S210 to S220, respectively, and the description of the corresponding parts above may be referred to, and are not repeated herein, and in the present embodiment, before step S230 calculates the current round selection probability based on the random number, the method provided by the present application further includes steps S303 to S304.
S303, acquiring preset safety parameters and generating auxiliary global parameters based on the preset safety parameters.
Wherein the global parameter is a parameter common to individual slave link points within the slave chain. For each slave chain node desiring to compete to become a consensus node, a preset safety parameter is also acquired before the random number is calculated, and an auxiliary global parameter is further generated based on the preset safety parameter. In particular, the slave link points may be global parameters obtained from the acquisition of the slave chain.
Specifically, if the preset safety parameter obtained from the link point is 1 λ in one embodiment, the auxiliary global parameter common from the chain can be obtained by calling the preset probability algorithm from the link point based on the preset safety parameter generation, and the formula is ParamGen (1 λ) →pp. Where pp is an auxiliary global parameter and ParamGen is the probability algorithm invoked. It will be appreciated that in other embodiments, other types of probability algorithms may be invoked from the link points, and are not necessarily ParamGen herein, and may be specifically set to be in accordance with the actual setting.
And S304, generating a verification public key and a verification private key based on the auxiliary global parameters.
After the secondary global parameters are obtained by calculation, a verification public key and a verification private key are generated from the link point further based on the secondary global parameters. The slave link points intended to participate in the election as consensus nodes further generate a verification key and a verification private key using a key generation algorithm based on the respective generated auxiliary global parameters. The verification key and the verification private key are used for executing consensus verification on the first local parameter uploaded by the training node after the election is successful.
For example, in one embodiment, the formulas for generating the authentication key and the authentication private key based on the auxiliary global parameter are as follows, keyGen (pp) → (PK i,SKi). Wherein KeyGen refers to a key generation algorithm, an auxiliary global parameter pp is input, PK and SK are utilized to respectively refer to a generated verification public key and a generated verification private key, and a subscript i refers to an identification number of a slave link point. The verification private key is used for executing consensus verification on the first local parameter uploaded by the training node after the link point is selected to be a consensus node, and when a consensus verification result is generated, the common verification result is used for carrying out signature encryption on the common verification result, then the common verification result is externally transmitted to other nodes or devices, the verification public key is used for decrypting the signature encryption of the verified private key, and the verification public key is published in the chain, so that other link points can acquire data (such as the common verification result) after the signature encryption of the verified private key based on the verification public key.
In the present embodiment, the step S230 calculates the current round selection probability based on the random number, and further includes steps S305 to S306.
S305, based on the random number and the verification private key, generating a hash result by using a random verifiable function.
After obtaining the verification private key and the random number, a hash result is generated using a randomly verifiable function further based on the random number and the verification private key. The random verifiable function is a function obtained by publishing the random number obtained by calculation of each round according to a preset rule by the system.
Further, each hash function (which is intended to participate in consensus) in the random verifiable functions is called from the link point, and the verification private key and the random number are subjected to hash operation so as to obtain a hash result.
For example, the slave link point in the slave chain may call a vrf_hash (), and output a Hash result, which is expressed as hash=vrf_val (SK, S e), with the authentication private key and the random number obtained in the above steps as inputs.
Further, in another embodiment, the method provided by the application further comprises calculating a selection proof based on the verification private key and the random number while generating the hash result using the random verifiable function based on the random number and the verification private key. Specifically, the Prove function of VRF (i.e., vrf_proof) is called, and the verification private key and the random number obtained in the above steps are taken as input, and a selection proof pi is output, which is recorded as pi=vrf_proof (SK, se). The computed proof of choice may be used to invoke in performing the consensus verification process after being selected as a consensus node.
S306, normalizing the hash result to obtain a normalized result, and outputting the normalized result as a selection probability.
And normalizing the hash results obtained by calculation from the link points, and outputting the normalization results obtained by the normalization as the selection probability of the current slave link point in the current round.
And then comparing the selection probability with a comparison threshold value, and determining whether the selection probability is selected as a consensus node of the current round or not based on a comparison result. If the normalized result is smaller than or equal to the comparison threshold, the slave link point can privately know that the slave link point is selected as the consensus node, otherwise, the slave link point knows that the slave link point is not selected as the consensus node.
In particular using the formulaThe normalization result d (also known as the selection probability) is calculated on the hash result. Where d also represents the difficulty value=the maximum target value/the current target value (the solution formula of d can be understood as the square of the hash result length of the hash result to 2), d e 0,1, hashlen represents the length of the hash result (the number of bits of the hash result can be understood as well) of the output of the hash algorithm.
Further, the process of normalizing the hash result from the link point may be understood as a process of converting the hash result to a value in the middle of the interval [0,1 ].
The alignment threshold is identified by λ. Further, the alignment threshold may be calculated by constructing a binomial distribution function, and in particular, see the embodiment corresponding to fig. 4 below.
Further, in an embodiment, the alignment threshold is calculated based on the second type of information. Wherein the second type of information includes at least one of a first processed value of rewards obtained from the link points during a previous round of federal learning, a sum of rewards obtained from each of the link points in the chain, a number of consensus nodes to be selected for the current round, and a second processed value of rewards obtained from the link points during the previous round of federal learning. Specifically, based on the second class of information, a binomial distribution algorithm is used to obtain binomial distribution, and then a comparison threshold in the current round is determined based on the binomial distribution result.
S307, if the selection probability is smaller than or equal to the comparison threshold value, determining that the selection probability is selected as a consensus node in the current round.
In the present embodiment, step S307 is the same as step S240 described above, and reference may be made specifically to the explanation of the corresponding portions above, and the repetition is omitted here specifically.
In order to further improve the safety of selecting the consensus node and better select the consensus node with stronger service capability, the method provided by the application further comprises the step of calculating and obtaining the comparison threshold value from the link point by utilizing a binomial distribution algorithm if the selection probability is smaller than or equal to the comparison threshold value in the step S240.
Further, referring to fig. 4, fig. 4 is a flow chart illustrating a selection method of a consensus node according to another embodiment of the present application. In the present embodiment, the above steps calculate and obtain the alignment threshold value from the link points using the binomial distribution algorithm, and further include steps S401 to S403.
S401, acquiring second-class information.
When the link points are used for calculating the comparison threshold value by using a binomial distribution algorithm, the second kind of information is acquired first. The slave link points may be the acquisition of the second type of information from the chain and/or from the own memory area of the slave chain, in particular subject to the actual setting.
The second type of information comprises at least one of a first processing value of rewards obtained in the previous federal learning, a sum of rewards obtained from all chain link points in the previous federal learning, a consensus node required to be selected in the current federal learning and the number of effective rewards in the previous federal learning.
Specifically, the rewards obtained in the previous federal study refer to rewards obtained from the chain link points in the previous federal study, and the first processing value of the rewards obtained in the previous federal study refers to a value obtained by standard integer-transforming the rewards obtained from the chain link points in the previous federal study. If the reward obtained from the chain link point in the previous federal learning round is marked as m i, the standard integer formula is adoptedWherein, the Is the average of all rewards from link points in the previous federal study,Is the standard deviation of all rewards from link points in the previous federal study. For example, when m i =8.6, based on the average of all rewardsAnd standard deviationAnd the first processing value obtained by normalizing 8.6 by the standard integer formula is 10.
The larger the value of m i, the larger the number of times the slave link point is allowed to draw a drawing, and the larger the probability of being drawn as a consensus node.
The sum of rewards from each slave link point in the chain in the previous run of federal learning may be based on the rewards from each slave link point in the previous run of federal learning. Specifically, if the sum of rewards from each slave link point in the chain in the last round of federal learning is denoted as R, r= Σm i.
The number of active rewards in the previous run of federal learning refers to the rewards that were increased from the link points in the previous run of federal learning. It should be noted that if, during the previous federal learning, the slave link point has a reduced accuracy of the first global parameter due to the first local parameter provided, and a certain digital token is deducted or no prize is obtained, this may be understood as that the prize obtained by the slave link point is negative, and the effective prize of the slave link point is 0.
And S402, based on the second type of information, a binomial distribution result is obtained by using a binomial distribution algorithm.
After the second type of information is acquired, a binomial distribution result is further obtained by using a binomial distribution algorithm. The binomial distribution result is obtained based on the following formula:
Wherein the binomial distribution constructed represents the probability that a certain symbol is drawn from the link point i over multiple draws as a consensus node.
Wherein B (-) represents a binomial distribution algorithm (binominal distribution algorithm).
M represents each reward earned from a link point (from link point i) during the last round of federal learning. Here, m is a value obtained by integrating the prize criteria obtained from the chain node, and specifically calculated based on the standard integration formula.
R= Σr i represents the sum of rewards of all slave link points involved in one round of training.
K represents the number of consensus nodes expected to be selected in the current model training. For example, when a certain slave link point m i =10, k=4 indicates that the slave link point allows 10 rounds of drawing, where 4 rounds are written as "selected", that is, 4 rounds may be drawn as consensus nodes.
Τ represents the effective prize value, and all "effective" refer to the slave link points that actually contributed to the first global parameter in the previous round of model training.
Wherein, the For representing the probability that a draw is drawn as a consensus node at a time.
S403, determining an alignment threshold value in the current round based on the binomial distribution result.
After computing the binomial distribution result, the alignment threshold in the current round is further determined based on the binomial distribution result. Specifically, a binomial distribution result is used to determine a binomial distribution cumulative probability density curve, and a selection result is determined based on the cumulative probability density curve and the normalization result.
After completion of the construction of the binomial distribution, the cumulative probability density curve of the currently constructed binomial distribution is further determined:
Each slave chain node draws a drawing from 0 to m times, and the probability of each drawing is accumulated and recorded as the probability of the slave chain node being drawn. Finally, based on the cumulative probability density curve of the binomial distribution and the normalization result of the hash result normalization process d, it is determined whether or not the binomial distribution is competing for the consensus node.
Specifically, if the normalized result d satisfies d < f (j), j=0 indicates that the selected consensus node is not selected from the link points, and if j satisfies f (j). Ltoreq.d < f (j+1) in the curve, the value of j is recorded, and whether the current j is greater than zero is further determined. If the judgment result shows that f (j) is less than or equal to d < f (j+1) is established, j >0, the slave link point is successfully selected as a consensus node in the federal learning process of the current round. Further, when the slave link point successfully extracts to become a consensus node, the consensus node publishes the hash result of the slave link point, the selection evidence and the extraction times j for enabling the formula f (j) to be less than or equal to d < f (j+1) to be established.
In another embodiment, the determining the selection result based on the cumulative probability density curve and the normalization result is to determine whether the normalization result obtained by the normalization processing of the hash result belongs to the interval where the set threshold value is located, which may be specifically understood as a process of determining whether the following formula is satisfied:
the range of the interval corresponding to the set threshold lambda is as follows:
Judging whether the normalization result d is within the set threshold range or not; if the current link point is within the range, the current link point is selected as the common node of federal learning of the current round, and if the current link point is not within the range, the current link point is not selected as the common node.
Further, in the technical scheme provided by the application, if the selection probability is smaller than or equal to the comparison threshold value, the method further comprises the step of sending a Leader node application request to at least part of slave chain link points to select the Leader node (Leader node) after the current round is selected as the consensus node.
First, a plurality of consensus nodes are selected from a plurality of slave link points in a chain according to the method, and the selected plurality of consensus nodes form a consensus committee of the federal learning process of the current round. These consensus nodes may then each autonomously initiate a request to elect itself to be the leader node to all slave link points in the slave chain to request other slave link points to vote for themselves. Then wait a set time during which the leader node votes are selected by the individual slave link points. The consensus node with the highest ticket number is obtained in a certain time (counted by a timer) and becomes the leading node of the federal learning process of the current round. The leader node has a function of issuing an instruction to other slave link points in the slave chain, such as uploading a first local parameter to one slave link point and the first local parameter is determined to be a target local parameter by the common authentication of the common authentication node in the common authentication committee, then the leader node is used for issuing an instruction for performing account book synchronization to other slave link points in the slave chain at this time so that each slave link point in the slave chain saves the target local parameter to its own distributed account book.
Further, if in the process of selecting the leader node, the number of votes obtained by the consensus nodes is statistically determined that the number of votes obtained by two (or more) consensus nodes is equal, the method provided by the application further comprises the step of initiating a new voting process again for the plurality of consensus nodes with equal number of votes. The consensus node with the highest vote number obtained in the new voting process becomes the leading consensus node.
Still further, in another embodiment, if in the process of selecting the leader node, the number of tickets obtained by the consensus nodes is determined by counting the number of tickets obtained by two (or more) consensus nodes, then the final leader node may be determined by further combining the scores of the consensus nodes and/or the obtained rewards. Specifically, the consensus node with the highest score and/or the highest obtained reward is determined as the leading node in the federal learning of the current round.
Specifically, the technical scheme provided by the application is to complete the consensus verification of the first local parameter by optimizing the traditional RAFT consensus.
Further, after the slave link point is selected as the consensus node, the slave link point is further configured to receive a first local parameter to be verified sent by the training node, and perform consensus verification on the first local parameter.
The process of consensus verification is specifically as follows, as in the above example, the leader node in the consensus committee packages the first local parameter (w) transmitted by the training node, and the selection proof and the random number (selection proof: pi, random number: seede) generated in the process of the training node competing for the consensus node into a candidate block, and then broadcasts the candidate block to the consensus nodes in the chain, and after receiving the candidate block, the consensus node converts the selection proof (pi) in the candidate block into a hash value, that is, hashes the selection proof in the candidate block to obtain vrf_proof_to_hash (pi). Checking vrf_verify (PK, w, pi, seede) =true/False, using the public key of the leader node to check whether the chosen proof pi is a proof generated based on the original parameter w, i.e. to check whether vrf_hash (SK, w) is equal to vrf_proof_to_hash (pi), and whether the output is legal. If the candidate block is legal, the candidate block becomes a valid block through consensus verification, namely, the first local parameter is determined to be obtained based on legal data training stored by the candidate block. The SK is a verification private key generated by the slave link point in the process of competing for the consensus node, and the PK is a public key of the leader node.
Referring to fig. 5, fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the application. In the current embodiment, the electronic device 500 provided by the present application includes a processor 501 and a memory 502 coupled to the processor 501. The electronic device 500 may perform the methods of any of the embodiments of fig. 1 to 4 and corresponding embodiments, i.e., the electronic device 500 may be a server or a client.
The memory 502 includes a local storage (not shown) and is configured to store a computer program that, when executed, implements the methods of any of the embodiments of fig. 1-4 and corresponding thereto.
The processor 501 is coupled to the memory 502, the processor 501 being configured to execute a computer program for performing the method of any one of the embodiments of fig. 1-4 and corresponding thereto as described above.
Further, in some embodiments, the electronic device 500 may include any one of a mobile terminal, a handheld terminal, a wearable device, an in-vehicle terminal, a computer terminal, a server, and other types of electronic devices with computing power storage capability, etc.
Referring to fig. 6, fig. 6 is a schematic structural diagram of an embodiment of a computer readable storage medium according to the present application. The computer readable storage medium 600 stores a computer program 601 executable by a processor, the computer program 601 for implementing the method as described in any of the above fig. 1 to 4 and their corresponding embodiments. Specifically, the computer readable storage medium 600 may be one of a memory, a personal computer, a server, a network device, a usb disk, etc., which is not limited in this regard.
The foregoing description is only of embodiments of the present application, and is not intended to limit the scope of the application, and all equivalent structures or equivalent processes using the descriptions and the drawings of the present application or directly or indirectly applied to other related technical fields are included in the scope of the present application.

Claims (9)

1.一种共识节点的选取方法,其特征在于,所述方法是由从链中的从链节点执行,所述从链中包括若干所述从链节点,所述从链节点与主链中的主链节点能够进行交互,所述主链用于执行聚合所述从链训练所得的目标本地参数从而获得全局参数,所述方法包括:1. A method for selecting a consensus node, characterized in that the method is executed by a slave chain node in a slave chain, the slave chain includes a plurality of slave chain nodes, the slave chain nodes can interact with a master chain node in a master chain, the master chain is used to aggregate the target local parameters obtained by the slave chain training to obtain global parameters, and the method includes: 从链节点获取第一类信息,其中,所述第一类信息包括当前训练轮次信息、上一轮联邦学习中的历史随机数、上一轮联邦学习输出的第一全局参数和本轮所需选取的共识节点的数量中的至少一个;Obtaining first information from the chain node, wherein the first information includes at least one of current training round information, historical random numbers in the previous round of federated learning, a first global parameter output by the previous round of federated learning, and the number of consensus nodes required to be selected in this round; 基于所述第一类信息计算当前轮次的随机数;Calculate a random number for the current round based on the first type of information; 基于所述随机数计算自身当前轮次的选取概率;Calculate the selection probability of the current round based on the random number; 若所述选取概率小于或等于比对阈值,则确定自身在当前轮次被选取为共识节点;If the selection probability is less than or equal to the comparison threshold, it is determined that the node is selected as the consensus node in the current round; 其中,所述对比阈值是基于第二类信息计算获得的,所述第二类信息包括:上一轮联邦学习中获得的奖励的第一处理值、从链中各个所述从链节点在上一轮联邦学习中所得的奖励之和、本轮所需选取的共识节点和上一轮联邦学习中的有效奖励的数量中至少一个;The comparison threshold is calculated based on the second type of information, and the second type of information includes: a first processed value of a reward obtained in a previous round of federated learning, a sum of rewards obtained by each of the slave chain nodes in the slave chain in the previous round of federated learning, a consensus node to be selected in this round, and at least one of the number of valid rewards in the previous round of federated learning; 在所述基于所述随机数计算自身当前轮次选取概率之前,所述方法还包括:获取预设的安全参数,并基于所述预设的安全参数生成辅助全局参数;基于所述辅助全局参数生成验证公钥和验证私钥。Before calculating the probability of selecting the current round based on the random number, the method further includes: obtaining preset security parameters, and generating auxiliary global parameters based on the preset security parameters; and generating a verification public key and a verification private key based on the auxiliary global parameters. 2.根据权利要求1所述的方法,其特征在于,所述基于所述随机数计算自身当前轮次选取概率,进一步包括:2. The method according to claim 1, characterized in that the calculating the probability of selecting the current round based on the random number further comprises: 基于所述随机数和所述验证私钥,利用随机可验证函数生成哈希结果;Based on the random number and the verification private key, a hash result is generated using a random verifiable function; 对所述哈希结果进行归一化处理得到归一化结果,并将所述归一化结果输出为所述选取概率。The hash result is normalized to obtain a normalized result, and the normalized result is output as the selection probability. 3.根据权利要求2所述的方法,其特征在于,所述随机可验证函数为系统按照预设规则,根据每一轮次计算所得的所述随机数公布所得。3. The method according to claim 2 is characterized in that the random verifiable function is obtained by the system publishing the random number calculated in each round according to preset rules. 4.根据权利要求1所述的方法,其特征在于,所述基于所述第一类信息计算当前轮次的随机数,包括:4. The method according to claim 1, characterized in that the calculating of the random number of the current round based on the first type of information comprises: 若基于所述当前训练轮次信息确定当前轮次为首轮,则将预设的初始随机数确定为所述当前轮次随机数;或If it is determined based on the current training round information that the current round is the first round, a preset initial random number is determined as the current round random number; or 若基于所述当前训练轮次信息确定当前轮次不为首轮,则利用上一轮次公示委员会领导节点的私钥,对所述第一类信息进行签名计算获得所述当前轮次的随机数。If it is determined based on the current training round information that the current round is not the first round, the private key of the leading node of the previous round publicity committee is used to perform signature calculation on the first type of information to obtain the random number of the current round. 5.根据权利要求1所述的方法,其特征在于,所述若所述选取概率小于或等于比对阈值,则确定自身在当前轮次被选取为共识节点之前,所述方法还包括:5. The method according to claim 1, characterized in that if the selection probability is less than or equal to the comparison threshold, it is determined that before the node is selected as a consensus node in the current round, the method further comprises: 所述从链节点利用二项分布算法计算获得所述比对阈值。The slave chain node calculates the comparison threshold using a binomial distribution algorithm. 6.根据权利要求5所述的方法,其特征在于,所述利用二项分布算法计算获得所述比对阈值,进一步包括:6. The method according to claim 5, characterized in that the step of calculating the comparison threshold using a binomial distribution algorithm further comprises: 获取第二类信息;Obtain the second type of information; 基于所述第二类信息,利用所述二项分布算法获得二项分布结果;Based on the second type of information, using the binomial distribution algorithm to obtain a binomial distribution result; 基于所述二项分布结果确定当前轮次中的所述比对阈值。The comparison threshold in the current round is determined based on the binomial distribution result. 7.根据权利要求1所述的方法,其特征在于,所述若所述选取概率小于或等于比对阈值,则确定自身在当前轮次被选取为共识节点之后,所述方法还包括:7. The method according to claim 1, characterized in that if the selection probability is less than or equal to the comparison threshold, after determining that the node is selected as the consensus node in the current round, the method further comprises: 向所述从链中至少部分所述从链节点发送领导节点申请请求,以选取成为所述领导节点;和/或Sending a leader node application request to at least some of the slave chain nodes in the slave chain to select to become the leader node; and/or 接收训练节点发送的待验证的第一本地参数,并对所述第一本地参数执行共识验证。Receive a first local parameter to be verified sent by a training node, and perform consensus verification on the first local parameter. 8.一种电子设备,其特征在于,所述电子设备包括处理器以及与所述处理器耦接的存储器;其中,8. An electronic device, characterized in that the electronic device comprises a processor and a memory coupled to the processor; wherein, 所述存储器用于存储计算机程序;The memory is used to store computer programs; 所述处理器用于运行所述计算机程序以执行权利要求1至7任意一项所述的方法。The processor is configured to run the computer program to perform the method according to any one of claims 1 to 7. 9.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有能够被处理器运行的计算机程序,所述计算机程序用于实现权利要求1至7任一项所述的方法。9. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program that can be executed by a processor, and the computer program is used to implement the method according to any one of claims 1 to 7.
CN202111651030.5A 2021-12-30 2021-12-30 A method for selecting a consensus node and related device Active CN114372588B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111651030.5A CN114372588B (en) 2021-12-30 2021-12-30 A method for selecting a consensus node and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111651030.5A CN114372588B (en) 2021-12-30 2021-12-30 A method for selecting a consensus node and related device

Publications (2)

Publication Number Publication Date
CN114372588A CN114372588A (en) 2022-04-19
CN114372588B true CN114372588B (en) 2025-07-25

Family

ID=81142997

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111651030.5A Active CN114372588B (en) 2021-12-30 2021-12-30 A method for selecting a consensus node and related device

Country Status (1)

Country Link
CN (1) CN114372588B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116980281A (en) * 2022-11-30 2023-10-31 腾讯科技(深圳)有限公司 Node selection method, node selection device, first node, storage medium and program product

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112434280A (en) * 2020-12-17 2021-03-02 浙江工业大学 Block chain-based federal learning defense method
CN114372589A (en) * 2021-12-30 2022-04-19 远光软件股份有限公司 Federated learning method and related device

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11694110B2 (en) * 2019-06-12 2023-07-04 International Business Machines Corporation Aggregated machine learning verification for database
CN112801307B (en) * 2021-04-13 2021-07-06 深圳索信达数据技术有限公司 Block chain-based federal learning method and device and computer equipment
CN113467927B (en) * 2021-05-20 2024-12-27 杭州趣链科技有限公司 A blockchain-based federated learning method and device that can be trusted by participants
CN113408746B (en) * 2021-06-22 2023-03-14 深圳大学 Distributed federal learning method and device based on block chain and terminal equipment
CN113794675B (en) * 2021-07-14 2023-04-07 中国人民解放军战略支援部队信息工程大学 Distributed Internet of things intrusion detection method and system based on block chain and federal learning

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112434280A (en) * 2020-12-17 2021-03-02 浙江工业大学 Block chain-based federal learning defense method
CN114372589A (en) * 2021-12-30 2022-04-19 远光软件股份有限公司 Federated learning method and related device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种基于双链模型的分区共识协议;黄建华等;《计算机应用研究》;20210228;38(第02期);358-360页第2-4章 *

Also Published As

Publication number Publication date
CN114372588A (en) 2022-04-19

Similar Documents

Publication Publication Date Title
CN114372589B (en) A federated learning method and related device
CN113794675B (en) Distributed Internet of things intrusion detection method and system based on block chain and federal learning
US11687562B2 (en) Apparatus and method for adaptively managing sharded blockchain network based on deep Q network
US10965466B2 (en) Estimable proof-of-work for blockchain
CN109493062B (en) Block chain consensus method based on credit equity certification
WO2020133326A1 (en) Blockchain generation method and system, and computer storage medium and electronic device
CN107566124A (en) Common recognition method for building up, block catenary system and storage medium based on lottery mechanism
US11157899B1 (en) System and method for bootstrapping a separate proof of work chain
Azouvi et al. Betting on blockchain consensus with fantomette
CN115499129A (en) Multimode trust cross-chain consensus method, system, medium, equipment and terminal
CN114266293B (en) A federated learning method and a federated learning system
CN108769230A (en) Transaction data storage method, device, server and storage medium
US11354629B1 (en) Controlling initiation of a blockchain election using a burn quota
CN109359978A (en) Smart contract transaction method and system based on blockchain network
KR102248890B1 (en) System and method for lottery based on public blockchain and verification thereof
WO2020102456A1 (en) Gambling systems and methods based on blockchain technology
CN114205087B (en) Block chain random number generation method
CN110445603A (en) A kind of decentralization random digit generation method
US11290280B1 (en) Cryptocurrency mining using a single-leader election algorithm
CN114372588B (en) A method for selecting a consensus node and related device
CN116595094A (en) Federal learning incentive method, device, equipment and storage medium based on block chain
CN114519198A (en) Block chain consensus method and computer-readable storage medium
CN110990790B (en) Data processing method and equipment
Sultana et al. Blockchain-enabled federated learning approach for vehicular networks
CN114358324A (en) Federal learning method with reward and punishment mechanism and related device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载