Disclosure of Invention
The application mainly aims to provide a federated learning modeling method, equipment and a readable storage medium, and aims to solve the technical problems of low federated learning modeling efficiency and poor accuracy in the prior art.
In order to achieve the above object, the present application provides a federal learning modeling method, where the federal learning modeling method is applied to a first device, and the federal learning modeling method includes:
receiving encryption model parameters sent by each second device and verification parameters corresponding to the encryption model parameters;
based on each verification parameter, respectively carrying out zero knowledge verification on each encryption model parameter so as to determine a false encryption model parameter in each encryption model parameter and obtain a zero knowledge verification result;
and coordinating each second device to carry out federated learning modeling based on the zero knowledge verification result and each encryption model parameter.
Optionally, the step of coordinating each second device to perform federal learning modeling based on the zero-knowledge verification result and each cryptographic model parameter includes:
based on the zero-knowledge verification result, eliminating the false encryption model parameters from the encryption model parameters to obtain the credible model parameters;
and aggregating the credible model parameters to obtain aggregated parameters, and feeding the aggregated parameters back to the second equipment respectively so that the second equipment can update the local training models thereof until the local training models reach the preset training ending condition.
Optionally, the zero-knowledge verification is performed on each encryption model parameter based on each verification parameter, so as to determine a false encryption model parameter in each encryption model parameter, and the step of obtaining a zero-knowledge verification result includes:
respectively calculating a first zero knowledge proof result and a second zero knowledge proof result corresponding to each verification parameter;
and respectively verifying whether each encryption model parameter is a false encryption model parameter or not based on each first zero knowledge proof result and each second zero knowledge proof result to obtain a zero knowledge verification result.
Optionally, the verification parameters include verification model parameters and verification random parameters,
the step of calculating a first zero knowledge proof result and a second zero knowledge proof result corresponding to each verification parameter respectively includes:
carrying out validity verification on each encryption model parameter based on a preset verification challenge parameter to obtain each first zero knowledge verification result;
and encrypting each verification model parameter based on a preset coordinator public key and each verification random parameter to obtain each second zero knowledge verification result.
Optionally, the preset verification challenge parameters include a first verification challenge parameter and a second verification challenge parameter;
the step of performing validity verification on each encryption model parameter based on a preset verification challenge parameter to obtain each first zero knowledge verification result comprises:
performing exponentiation operation on the first verification challenge parameter and each encryption model parameter respectively to obtain a first exponentiation operation result corresponding to each encryption model parameter;
performing exponentiation operation on the second verification challenge parameter and each encryption model parameter respectively to obtain a second exponentiation operation result corresponding to each encryption model parameter;
generating each of the first zero knowledge verification results based on each of the first exponentiation results and each of the second exponentiation results.
Optionally, the step of verifying whether each of the cryptographic model parameters is a dummy cryptographic model parameter based on each of the first zero knowledge proof results and each of the second zero knowledge proof results respectively includes:
comparing the first zero knowledge proof result and the second zero knowledge proof result corresponding to each encryption model parameter respectively;
if the first zero knowledge proof result and the second zero knowledge proof result corresponding to the encryption model parameter are not consistent, determining that the encryption model parameter is the false encryption model parameter;
and if the first zero knowledge proof result and the second zero knowledge proof result corresponding to the encryption model parameter are consistent, judging that the encryption model parameter is not the false encryption model parameter.
In order to achieve the above object, the present application further provides a federal learning modeling method, where the federal learning modeling method is applied to a second device, and the federal learning modeling method includes:
acquiring a model training parameter and a first verification random parameter, and encrypting the model training parameter based on the first verification random parameter and a preset public key to obtain an encrypted model parameter;
generating a verification model parameter and a second verification random parameter based on the first verification random parameter, the model training parameter and a preset verification challenge parameter;
sending the encryption model parameter, the verification model parameter and the second verification random parameter to first equipment so that the first equipment can carry out zero knowledge verification to obtain a zero knowledge verification result;
and receiving an aggregation parameter fed back by the first equipment based on the zero knowledge verification result and the encryption model parameter, and updating a local training model corresponding to the model training parameter based on the aggregation parameter until the local training model reaches a preset training end condition.
Optionally, the model training parameters comprise current model parameters and auxiliary model parameters,
the step of obtaining model training parameters comprises:
performing iterative training on a local training model corresponding to the model training parameters until the local training model reaches a preset iteration threshold value, and acquiring the current model parameters of the local training model;
and acquiring the prior model parameters of the local training model, and generating the auxiliary model parameters based on the prior model parameters.
The application also provides a federal study modeling device, federal study modeling device is virtual device, just federal study modeling device is applied to first equipment, federal study modeling device includes:
the receiving module is used for receiving the encryption model parameters sent by each second device and the verification parameters corresponding to the encryption model parameters;
the zero knowledge verification module is used for respectively performing zero knowledge verification on each encryption model parameter based on each verification parameter so as to determine a false encryption model parameter in each encryption model parameter and obtain a zero knowledge verification result;
and the coordination module is used for coordinating each second device to carry out federated learning modeling based on the zero knowledge verification result and each encryption model parameter.
Optionally, the coordination module comprises:
the eliminating submodule is used for eliminating the false encryption model parameters from the encryption model parameters based on the zero-knowledge verification result to obtain the credible model parameters;
and the aggregation sub-module is used for aggregating the credible model parameters to obtain aggregation parameters, and feeding the aggregation parameters back to the second equipment respectively so that the second equipment can update the local training models thereof until the local training models reach the preset training end conditions.
Optionally, the zero knowledge verification module comprises:
the calculation submodule is used for respectively calculating a first zero knowledge proof result and a second zero knowledge proof result corresponding to each verification parameter;
and the zero knowledge verification submodule is used for respectively verifying whether each encryption model parameter is a false encryption model parameter or not based on each first zero knowledge proof result and each second zero knowledge proof result so as to obtain a zero knowledge verification result.
Optionally, the computation submodule includes:
the validity verification unit is used for verifying the validity of each encryption model parameter based on a preset verification challenge parameter to obtain each first zero knowledge verification result;
and the encryption unit is used for encrypting each verification model parameter based on a preset coordinator public key and each verification random parameter to obtain each second zero knowledge verification result.
Optionally, the validity verifying unit includes:
the first power operation subunit is configured to perform power operation on the first verification challenge parameter and each encryption model parameter, respectively, to obtain a first power operation result corresponding to each encryption model parameter;
a second exponentiation subunit, configured to perform exponentiation operation on the second verification challenge parameter and each encryption model parameter, respectively, to obtain a second exponentiation operation result corresponding to each encryption model parameter;
a generating subunit, configured to generate each first zero knowledge verification result based on each first power operation result and each second power operation result.
Optionally, the zero knowledge verification sub-module includes:
a comparison unit, configured to compare the first zero knowledge proof result and the second zero knowledge proof result corresponding to each encryption model parameter respectively;
a first determining unit, configured to determine that the cryptographic model parameter is the dummy cryptographic model parameter if the first zero knowledge proof result and the second zero knowledge proof result corresponding to the cryptographic model parameter are not consistent;
a second determining unit, configured to determine that the cryptographic model parameter is not the dummy cryptographic model parameter if the first zero knowledge proof result and the second zero knowledge proof result corresponding to the cryptographic model parameter are consistent.
In order to achieve the above object, the present application further provides a federal learning modeling apparatus, the federal learning modeling apparatus is a virtual apparatus, and the federal learning modeling apparatus is applied to a second device, the federal learning modeling apparatus includes:
the encryption module is used for acquiring a model training parameter and a first verification random parameter, and encrypting the model training parameter based on the first verification random parameter and a preset public key to acquire an encrypted model parameter;
the generation module is used for generating verification model parameters and second verification random parameters based on the first verification random parameters, the model training parameters and preset verification challenge parameters;
the sending module is used for sending the encryption model parameter, the verification model parameter and the second verification random parameter to first equipment so as to enable the first equipment to carry out zero knowledge verification and obtain a zero knowledge verification result;
and the model updating module is used for receiving the aggregation parameters fed back by the first equipment based on the zero knowledge verification result and the encryption model parameters, and updating the local training model corresponding to the model training parameters based on the aggregation parameters until the local training model reaches a preset training ending condition.
Optionally, the encryption module includes:
the obtaining submodule is used for carrying out iterative training on a local training model corresponding to the model training parameters until the local training model reaches a preset iteration threshold value, and obtaining the current model parameters of the local training model;
and the generation submodule is used for acquiring the previous model parameters of the local training model and generating the auxiliary model parameters based on the previous model parameters.
The application also provides a federal learning modeling equipment, federal learning modeling equipment is entity equipment, federal learning modeling equipment includes: a memory, a processor, and a program of the federal learning modeling method stored in the memory and executable on the processor, the program of the federal learning modeling method being executable by the processor to perform the steps of the federal learning modeling method as described above.
The present application also provides a readable storage medium having stored thereon a program for implementing the federal learning modeling method, the program implementing the steps of the federal learning modeling method as described above when executed by a processor.
According to the method and the device, zero knowledge verification is respectively carried out on each encryption model parameter based on each verification parameter by receiving the encryption model parameter sent by each second device and the verification parameter corresponding to the encryption model parameter, so that a false encryption model parameter is determined in each encryption model parameter to obtain a zero knowledge verification result, and then each second device is coordinated to carry out federal learning modeling based on the zero knowledge verification result. That is, after receiving the encryption model parameters and the verification parameters corresponding to the encryption model parameters sent by each second device, the present application performs zero knowledge verification on each encryption model parameter based on each verification parameter, so as to determine a false encryption model parameter in each encryption model parameter and obtain a zero knowledge verification result, and further, based on the zero knowledge verification result, the false encryption model parameter can be removed from each encryption model parameter to coordinate each second device to perform federal learning modeling. That is, the application provides a method for determining false encryption model parameters in each local model based on zero-knowledge proof, and then when a malicious participant provides the false encryption model parameters in the training process, the false encryption model parameters can be accurately identified and eliminated, so that the situation that the Federal learning modeling is carried out based on the encryption model parameters mixed with the false encryption model parameters is avoided, the overall model quality of the Federal model obtained through the Federal learning modeling is improved, the efficiency and the accuracy of the Federal learning modeling are improved, and the technical problems of low Federal learning modeling efficiency and poor accuracy are solved.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In a first embodiment of the federal learning modeling method of the present application, the federal learning modeling method is applied to a first device, and referring to fig. 1, the federal learning modeling method includes:
step S10, receiving the encryption model parameters sent by each second device and the verification parameters corresponding to the encryption model parameters;
in this embodiment, it should be noted that, before performing federal learning modeling, the first device performs negotiation interaction with each of the second devices to determine standard verification challenge parameters, where the number of the standard verification challenge parameters may be determined during the negotiation interaction. The first device is a coordinator performing federated learning modeling and is used for coordinating the second devices to perform federated learning modeling, the second devices are participants performing federated learning modeling, the encryption model parameters are model training parameters encrypted based on a homomorphic encryption algorithm, for example, assuming that a public key of the participants held by the second devices is P, and a first verification random parameter used for homomorphic encryption is r1Encrypting model parameter h after encrypting model training parameter m based on homomorphic encryption algorithmm=Enc(P,m,r1) Where Enc is a homomorphic encrypted symbol, and further, the model training parameter is a model parameter of a local training model of the second device, for example, assuming that the local training model is a linear model and an expression is Y ═ β0+β1x1+β2x2+…+βnxnThen the model parameter is the vector (β)0+β1+β2+…+βn)。
Additionally, it should be noted that the verification parameter is a parameter for zero-knowledge proof, wherein the verification parameter includes a second verification random parameter and a verification model parameter, wherein the verification model parameter is generated by the second device based on a model training parameter and a verification challenge parameter, for example, assuming that the verification challenge parameter includes a parameter x1And x2If the model training parameter is m, the verification model parameter is n ═ m × x1+m*x2Further, the second verification random parameter is generated by the second device based on the first verification random parameter and the verification challenge parameter, e.g., assuming that the first verification random parameter is r1The verification challenge parameter comprises a parameter x1And parameter x2Then the second verification random parameter r2=r1x1*r1x2。
Additionally, it should be noted that a malicious party in each of the parties may modify the cryptographic parameters of the homomorphic encryption of the model training parameters to achieve the purpose of generating the false cryptographic model parameters, and when the coordinator performs federated modeling, the cryptographic model parameters sent by each of the second devices are usually directly aggregated to obtain the aggregated parameters, and if the false cryptographic model parameters exist in each of the cryptographic model parameters, the efficiency and accuracy of federated model training will be affected, for example, if the cryptographic model parameters sent by the second device a are 5a, if the second device B is a malicious party, the sent false cryptographic model parameters are 100B, and if the aggregation process is a weighted average, the first aggregated parameters obtained after aggregation process are (5a +100B)/2, if the second device B is not a malicious party, if the sent encryption model parameter is 5b, the second aggregation parameter obtained after aggregation processing is (5a +5b)/2, and therefore, if a malicious party exists in each second device, the difference between the second aggregation parameter obtained by the first device performing aggregation processing on the encryption model parameter sent by each second device and the first set parameter obtained when no malicious party exists is extremely large, and further, if a malicious party exists in each second device, the efficiency and the accuracy of federal model training are greatly influenced.
Additionally, it should be noted that, in this embodiment, the first device and the second device both perform encryption based on a homomorphic encryption algorithm, where in an implementable scheme, the homomorphic encryption algorithm should satisfy the following properties:
c ═ Enc (PK, m, r), and for C
1=Enc(PK,m
1,r
1) And C) and
2=Enc(PK,m
2,r
2) And satisfies the following conditions:
wherein, C, C
1And C
2All are parameters to be encrypted after encryption, PK is an encrypted secret key, m and m
1And m
2As the parameters to be encrypted, the parameters are encrypted,r、r
1and r
2The random number required for encryption.
Step S20, based on each verification parameter, respectively performing zero-knowledge verification on each encryption model parameter to determine a false encryption model parameter in each encryption model parameter and obtain a zero-knowledge verification result;
in this embodiment, based on each verification parameter, performing zero-knowledge verification on each encryption model parameter, respectively, to determine a dummy encryption model parameter in each encryption model parameter, and obtain a zero-knowledge verification result, specifically, based on each verification parameter, calculating a first zero-knowledge proof result and a second zero-knowledge proof result corresponding to each encryption model parameter, respectively verifying whether each encryption model parameter is a dummy encryption model parameter, and determining a dummy encryption model parameter in each encryption model parameter, and obtaining a zero-knowledge verification result, based on a first zero-knowledge proof result and a second zero-knowledge proof result corresponding to each encryption model parameter, where the zero-knowledge verification result is a verification result of whether each encryption model parameter is a dummy encryption model parameter, and the dummy encryption model parameter is a model training parameter in which a malicious party maliciously encrypts the model training parameter, and the malicious encryption is achieved, for example, by changing the encryption parameters when homomorphic encryption is performed.
Wherein, the zero knowledge verification is respectively carried out on each encryption model parameter based on each verification parameter so as to determine a false encryption model parameter in each encryption model parameter, and the step of obtaining the zero knowledge verification result comprises the following steps:
step S21, respectively calculating a first zero knowledge proof result and a second zero knowledge proof result corresponding to each of the verification parameters;
in this embodiment, it should be noted that the verification parameters include a verification model parameter and a second verification random parameter.
Respectively calculating a first zero knowledge proof result and a second zero knowledge proof result corresponding to each verification parameter, specifically, for each verification parameter, executing the following steps:
performing homomorphic addition operation on the encryption model parameter based on a preset verification challenge parameter to obtain a first zero knowledge proof result, and performing homomorphic encryption operation on the verification model parameter based on a preset coordinator public key and a second verification random parameter to obtain a second zero knowledge proof result, for example, assuming that the preset verification challenge parameter is x
1And x
2The cryptographic model parameter is h
m=Enc(P
1,m,r
1) Wherein P is
1Is a participant public key, r
1For the first verification random parameter, m is the model training parameter, and n is the verification model parameter m x
1+m*x
2And is and
and the first zero knowledge verification result is
The second zero knowledge verification result is
Wherein, P
2Is a coordinator public key, and if each of the second devices is maliciously modified, the participant public key and the coordinator public key should be identical.
Step S22, based on each of the first zero knowledge proof results and each of the second zero knowledge proof results, respectively verifying whether each of the encryption model parameters is a dummy encryption model parameter, to obtain a zero knowledge verification result.
In this embodiment, based on each of the first zero knowledge proof results and each of the second zero knowledge proof results, whether each of the encryption model parameters is a dummy encryption model parameter is verified, and a zero knowledge verification result is obtained, specifically, the following steps are performed for each of the first zero knowledge proof result and the second zero knowledge proof result corresponding to each of the verification parameters:
comparing the first zero knowledge proof result with the second zero knowledge proof result, determining whether the first zero knowledge proof result is consistent with the second zero knowledge proof result, if so, determining that the second device does not make malicious modification when performing homomorphic encryption on the model training parameters, that is, the encryption model parameters are not false encryption model parameters, and if not, determining that the second device makes malicious modification when performing homomorphic encryption on the model training parameters, that is, the encryption model parameters are false encryption model parameters.
Wherein the step of verifying whether each of the cryptographic model parameters is a dummy cryptographic model parameter based on each of the first zero knowledge proof results and each of the second zero knowledge proof results, respectively, comprises:
step S221, comparing the first zero knowledge proof result and the second zero knowledge proof result corresponding to each encryption model parameter respectively;
in this embodiment, the first zero knowledge proof result and the second zero knowledge proof result corresponding to each of the encryption model parameters are respectively compared, and specifically, the first zero knowledge proof result and the second zero knowledge proof result corresponding to each of the encryption model parameters are respectively compared to respectively calculate a difference between the first zero knowledge proof result and the second zero knowledge proof result corresponding to each of the encryption model parameters.
Step S222, if the first zero knowledge proof result and the second zero knowledge proof result corresponding to the cryptographic model parameter are not consistent, determining that the cryptographic model parameter is the false cryptographic model parameter;
in this embodiment, if the first zero knowledge proof result and the second zero knowledge proof result corresponding to the cryptographic model parameter are not consistent, it is determined that the cryptographic model parameter is the false cryptographic model parameter, specifically, if the difference is not 0, it is determined that the second device corresponding to the cryptographic model parameter performs malicious encryption on the model training parameter, and then it is determined that the cryptographic model parameter is the false cryptographic model parameter, and then a false identifier is given to the cryptographic model parameter, so as to identify the cryptographic model parameter as the false cryptographic model parameter.
Step S223, if the first zero knowledge proof result and the second zero knowledge proof result corresponding to the encryption model parameter are consistent, determining that the encryption model parameter is not the false encryption model parameter.
In this embodiment, if the first zero-knowledge proof result and the second zero-knowledge proof result corresponding to the cryptographic model parameter are consistent, it is determined that the cryptographic model parameter is not the false cryptographic model parameter, specifically, if the difference is 0, it is determined that the second device corresponding to the cryptographic model parameter does not perform malicious encryption on the model training parameter, and then it is determined that the cryptographic model parameter is not the false cryptographic model parameter, and a trusted identifier is given to the cryptographic model parameter, so as to identify the cryptographic model parameter as the trusted model parameter.
And step S30, coordinating each second device to perform federated learning modeling based on the zero knowledge verification result and each encryption model parameter.
In this embodiment, it should be noted that the zero-knowledge verification result includes a calibration identifier corresponding to each encryption model parameter, where the calibration identifier is an identifier for identifying whether the encryption model parameter is a false encryption model parameter.
And coordinating each second device to perform federated learning modeling based on the zero-knowledge verification result and each encryption model parameter, specifically, based on each calibration identifier, eliminating false encryption model parameters from each encryption model parameter to obtain each credible model parameter, further performing aggregation processing on each credible model parameter to obtain an aggregation parameter, and further coordinating each second device to perform federated learning modeling based on each aggregation model parameter.
The step of coordinating each second device to perform federated learning modeling based on the zero-knowledge verification result and each encryption model parameter includes:
step S31, based on the zero-knowledge verification result, eliminating the false encryption model parameters from the encryption model parameters to obtain the credible model parameters;
in this embodiment, it should be noted that after finding the false cryptographic model parameter, the coordinator may penalize a malicious party corresponding to the false cryptographic model parameter according to a preset incentive mechanism or cancel a subsequent qualification of the malicious party to participate in federal learning modeling.
Step S32, performing aggregation processing on each of the trusted model parameters to obtain aggregated parameters, and feeding back the aggregated parameters to each of the second devices, so that each of the second devices updates its own local training model until the local training model reaches a preset training end condition.
In this embodiment, each trusted model parameter is aggregated to obtain an aggregation parameter, and the aggregation parameter is fed back to each second device, so that each second device updates its local training model until the local training model reaches a preset training end condition, specifically, each trusted model parameter is aggregated to obtain an aggregation parameter based on a preset aggregation processing rule, where the preset aggregation processing rule includes weighted averaging, summation, and the like, and further, each aggregation parameter is sent to each second device, so that each second device decrypts the aggregation parameter based on a participant private key corresponding to the participant public key to obtain a decrypted aggregation parameter, and updates a local training model held by its own party based on the decrypted aggregation parameter, obtaining an updated local training model, judging whether the updated local training model reaches a preset training end condition, if the updated local training model reaches the preset training end condition, judging to complete the task of federal learning modeling, if the updated local training model does not reach the preset training end condition, performing iterative training on the local training model again, and if the updated local training model reaches the preset iteration threshold value, re-obtaining model training parameters of the local training model, re-encrypting and sending the model training parameters to the coordinator to re-perform federal training until the local training model reaches the preset training end condition, wherein the training end condition comprises reaching a preset maximum iteration, and a loss function corresponding to the local training model converges and the like.
Further, the local training model includes a wind control model, wherein the wind control model is a machine learning model for evaluating the loan risk of the user, and when a malicious party exists in each of the parties, the false encryption model parameters sent by the malicious party and the encryption model parameters sent by a normal party in each of the parties are aggregated to obtain an error aggregation parameter which is greatly different from an accurate aggregation parameter, and each of the second devices updates the wind control model based on the error aggregation parameter to reduce the accuracy of the wind control model in evaluating the loan risk of the user, and further based on the federal learning modeling method in the present application, the false encryption model parameters can be screened and eliminated from the encryption model parameters sent by each of the parties to obtain credible encryption model parameters, so that in the whole federal learning modeling process, the wind control model is updated always based on the aggregation parameters obtained by aggregating the parameters of the credible encryption models, so that the assessment of the user loan risk by the wind control model is more accurate, namely, the loan risk assessment accuracy of the wind control model is improved.
In this embodiment, zero knowledge verification is performed on each encryption model parameter respectively based on each verification parameter by receiving the encryption model parameter sent by each second device and the verification parameter corresponding to the encryption model parameter, so as to determine a false encryption model parameter in each encryption model parameter, obtain a zero knowledge verification result, and then coordinate each second device to perform federal learning modeling based on the zero knowledge verification result. That is, in this embodiment, after receiving the encryption model parameters and the verification parameters corresponding to the encryption model parameters sent by each second device, based on each verification parameter, zero knowledge verification is performed on each encryption model parameter, so as to determine a false encryption model parameter in each encryption model parameter, and obtain a zero knowledge verification result, further, based on the zero knowledge verification result, the false encryption model parameter may be removed from each encryption model parameter, so as to coordinate each second device to perform federal learning modeling. That is, the embodiment provides a method for determining false encryption model parameters in each local model based on zero-knowledge proof, and then when a malicious participant provides the false encryption model parameters in the training process, the false encryption model parameters can be accurately identified and eliminated, so that the occurrence of the situation that the federal learning modeling is performed based on each encryption model parameter mixed with the false encryption model parameters is avoided, the overall model quality of the federal model obtained through the federal learning modeling is improved, the efficiency and accuracy of the federal learning modeling are improved, and the technical problems of low efficiency and poor accuracy of the federal learning modeling are solved.
Further, referring to fig. 2, based on the first embodiment in the present application, in another embodiment of the present application, the verification parameters include a verification model parameter and a verification random parameter,
the step of calculating a first zero knowledge proof result and a second zero knowledge proof result corresponding to each verification parameter respectively includes:
step S211, based on preset verification challenge parameters, performing validity verification on each encryption model parameter to obtain each first zero knowledge verification result;
in this embodiment, it should be noted that the preset verification challenge parameter includes a first verification challenge parameter and a second verification challenge parameter, and the encryption model parameter includes a first encryption model parameter and a second encryption model parameter, where the first encryption model parameter is an encryption parameter after the second device performs homomorphic encryption on the current model parameter, the second encryption model parameter is an encryption parameter after the second device performs homomorphic encryption on the previous model parameter, where the current model parameter is a model parameter extracted when the local training model reaches a preset training iteration threshold value during the federation of the current round, and the previous model parameter is a model parameter extracted when the local training model reaches a preset training iteration threshold valueThe model parameter is a model parameter based on the previous round of federation before the present round of federation, for example, historical model parameters corresponding to the previous three rounds of federation are taken, and the historical model parameters are weighted and averaged to obtain the previous model parameter, for example, assuming that the current model parameter is m and the previous model parameter is m0Then the first cryptographic model parameter h0=Enc(P,m0,r1) Where P is the participant public key, r1For the first authentication random parameter, the second cryptographic model parameter hm=Enc(P,m,r2) Wherein r is2Is the second authentication random parameter.
Based on preset verification challenge parameters, performing validity verification on each encryption model parameter to obtain each first zero knowledge verification result, and specifically, executing the following steps for each encryption model parameter:
respectively performing exponentiation operation on the first encryption model parameter and the second encryption model parameter and summing based on the first verification challenge parameter and the second verification challenge parameter to obtain a first zero-knowledge verification result, for example, assuming a first encryption model parameter h
0=Enc(P,m
0,r
1) Second cryptographic model parameter h
m=Enc(P,m,r
2) The first verification challenge parameter is x
1The second verification challenge parameter is x
2Then said first zero knowledge proof result
Based on the property of homomorphic encryption algorithm, the method can obtain
Where P is the participant public key, x
1For the first verification challenge parameter, x
2For the second verification challenge parameter, r
1For the first authentication random parameter, r
2For the second verification random parameter, the current model parameter is m, and the previous model parameter is m
0。
The preset verification challenge parameters comprise a first verification challenge parameter and a second verification challenge parameter;
the step of performing validity verification on each encryption model parameter based on a preset verification challenge parameter to obtain each first zero knowledge verification result comprises:
step A10, performing exponentiation operation on the first verification challenge parameter and each encryption model parameter respectively to obtain a first exponentiation operation result corresponding to each encryption model parameter;
in this embodiment, the first verification challenge parameter and each encryption model parameter are respectively subjected to exponentiation operation to obtain a first exponentiation operation result corresponding to each encryption model parameter, and specifically, for each encryption model parameter, the following steps are performed: performing a power operation on the first cryptographic model parameter based on the first verification challenge parameter to obtain a first power operation result, for example, assuming that the first verification challenge parameter is x and the first cryptographic model parameter is h, the first power operation result is hx。
Step A20, performing exponentiation operation on the second verification challenge parameter and each encryption model parameter respectively to obtain a second exponentiation operation result corresponding to each encryption model parameter;
in this embodiment, the second verification challenge parameter and each encryption model parameter are respectively subjected to exponentiation operation to obtain a second exponentiation operation result corresponding to each encryption model parameter, and specifically, for each encryption model parameter, the following steps are performed: and performing power operation on the second encryption model parameter based on the second verification challenge parameter to obtain a second power operation result.
Step a30, generating each of the first zero knowledge verification results based on each of the first exponentiation results and each of the second exponentiation results.
In this embodiment, each of the first zero knowledge verification results is generated based on each of the first exponentiation results and each of the second exponentiation results, specifically, a product of the first exponentiation result and the second exponentiation result is found, and the product is taken as the first zero knowledge verification result.
Step S212, based on a preset coordinator public key and each verification random parameter, performing encryption processing on each verification model parameter to obtain each second zero knowledge verification result.
In this embodiment, it should be noted that each of the participants is a valid participant, and then the public key of the participant is consistent with the public key of the preset coordinator, the verification random parameter includes a third verification random parameter, and the third verification random parameter is obtained by calculation based on the first verification random parameter, the second verification random parameter, the first verification challenge parameter and the second verification challenge parameter, for example, assuming that the first verification random parameter is r1, the second verification random parameter is r2, the first verification challenge parameter is x1, and the second verification challenge parameter is x2, the third verification challenge parameter is
Additionally, the verification model parameters are calculated based on a first verification challenge parameter, a second verification challenge parameter, a current model parameter and a previous model parameter, for example, assuming that the first verification challenge parameter is x1, the second verification challenge parameter is x2, the current model parameter is m, and the previous model parameter is m0If the verification model parameter is n ═ m, then the verification model parameter is m0x1+mx2。
Based on a preset coordinator public key and each verification random parameter, performing encryption processing on each verification model parameter to obtain each second zero knowledge verification result, and specifically, executing the following steps for each verification model parameter:
homomorphic encryption is performed on the verification model parameter based on a preset coordinator public key and the third verification challenge parameter to obtain the second zero knowledge verification result, for example, assuming the third verification challenge parameter
Wherein the first verification random parameter is r1, the second verification random parameter is r2, the first verification random parameter is r 3578A verification challenge parameter of x1, a second verification challenge parameter of x2, and a verification model parameter of n-m
0x
1+mx
2If the public key of the coordinator is P, then
Further, if the participating party does not maliciously encrypt the encryption model parameters, for example, maliciously tamper with the encryption algorithm, maliciously tamper with the encrypted parameters, etc., the first zero knowledge proof result is the same as the second zero knowledge proof result, that is, the encryption model parameters provided by the participating party is the trusted model parameters, and if the participating party maliciously encrypts the encryption model parameters, the first zero knowledge proof result is different from the second zero knowledge proof result, that is, the encryption model parameters provided by the participating party is the false encryption model parameters.
In this embodiment, validity verification is performed on each encryption model parameter based on a preset verification challenge parameter to obtain each first zero knowledge verification result, and then encryption processing is performed on each verification model parameter based on a preset coordinator public key and each verification random parameter to obtain each second zero knowledge verification result. That is, the embodiment provides a method for calculating the first zero knowledge proof result and the second zero knowledge proof result, and then after the first zero knowledge proof result and the second zero knowledge proof result are obtained through calculation, the first zero knowledge proof result and the second zero knowledge proof result are only compared to determine whether the encryption model parameters are the false encryption model parameters, so that a foundation is laid for determining the false encryption model parameters in each encryption model parameter, and a foundation is laid for solving the technical problems of low federal learning modeling efficiency and poor accuracy.
Further, referring to fig. 3, based on the first embodiment and the second embodiment in the present application, in another embodiment of the present application, the federal learning modeling method is applied to a second device, and the federal learning modeling method includes:
step B10, obtaining a model training parameter and a first verification random parameter, and encrypting the model training parameter based on the first verification random parameter and a preset public key to obtain an encrypted model parameter;
in this embodiment, the federal learning modeling includes at least one federal, and in each federal, the second device performs iterative training on a local training model until a preset iteration threshold is reached, then sends model parameters of the local training model to the first device, receives aggregation parameters fed back by the first device based on the model parameters, updates the local training model based on the aggregation parameters, and uses the local training model as an initial model of the next federal until the local training model reaches a preset training end condition, where the preset training end condition includes reaching of a maximum iteration number, convergence of a loss function, and the like.
Obtaining a model training parameter and a first verification random parameter, encrypting the model training parameter based on the first verification random parameter and a preset public key to obtain an encrypted model parameter, specifically, when the local training model reaches a preset iteration threshold, extracting the model parameter of the local training model as the model training parameter, obtaining the first verification random parameter, and homomorphically encrypting the model training parameter based on the first verification random parameter and the preset public key to obtain an encrypted model parameter, for example, assuming that the model training parameter is m, and the first verification random parameter is r1If the preset public key is P, the encryption model parameter is hm=Enc(P,m,r1) And Enc is a homomorphic encryption symbol.
Wherein the model training parameters comprise current model parameters and auxiliary model parameters,
the step of obtaining model training parameters comprises:
step B11, performing iterative training on the local training model corresponding to the model training parameters until the local training model reaches a preset iteration threshold value, and acquiring the current model parameters of the local training model;
in this embodiment, it should be noted that the current model parameter is a current iteration model parameter of the local training model when the current iteration model reaches a preset iteration threshold in the current federation.
And step B12, acquiring the prior model parameters of the local training model, and generating the auxiliary model parameters based on the prior model parameters.
In this embodiment, a previous model parameter of the local training model is obtained, and the auxiliary model parameter is generated based on the previous model parameter, specifically, each previous iteration model parameter of a previous round of federation corresponding to the current round of federation is obtained, and each previous iteration model parameter is weighted and averaged to obtain the auxiliary model parameter, for example, if each previous iteration model parameter is a, b, c, the weight corresponding to a is 20%, the weight corresponding to b is 30%, and the weight corresponding to c is 50%, the auxiliary model parameter m is the auxiliary model parameter m0=a*20%+b*30%+c*50%。
Step B20, generating verification model parameters and second verification random parameters based on the first verification random parameters, the model training parameters and preset verification challenge parameters;
in this embodiment, it should be noted that, in a possible implementation, the preset verification challenge parameter may be calculated by the coordinator according to each previous encryption model parameter and a preset hash function sent by each participant in the previous round federation, for example, if there are 10 participants, the corresponding 10 previous encryption model parameters are freely combined, and then n results of the free combination are input to the preset hash function to obtain the verification challenge parameter x1、x2。xnAnd a specific predetermined verification challenge parameter x1、x2。xnThe generation mode and the number of the method are not limited.
Generating a verification model parameter and a second verification random parameter based on the first verification random parameter, the model training parameter and a preset verification challenge parameter, specifically, for the first verification random parameter and the second verification random parameterThe preset verification challenge parameter performs a power operation to obtain a second verification random parameter, and generates a verification model parameter based on the model training parameter and the preset verification challenge parameter, e.g., assuming that the first verification random parameter is r1The model training parameter is m, and the preset verification challenge parameter is x1And x2The verification model parameter n ═ m × x1+m*x2The second verification random parameter
Step B30, sending the encryption model parameter, the verification model parameter and the second verification random parameter to a first device for the first device to perform zero knowledge verification to obtain a zero knowledge verification result;
in this embodiment, the encryption model parameter, the verification model parameter, and the second verification random parameter are sent to a first device for the first device to perform zero-knowledge verification to obtain a zero-knowledge verification result, and specifically, the encryption model parameter, the verification model parameter, and the second verification random parameter are sent to a first device associated with a second device for the first device to calculate a first zero-knowledge proof result and a second zero-knowledge proof result based on the encryption model parameter, the verification model parameter, and the second verification random parameter, and determine whether the encryption model parameter is a false encryption model parameter based on the first zero-knowledge proof result and the second zero-knowledge proof result to obtain a determination result, and record the determination result in the zero-knowledge verification result, and the zero knowledge verification result comprises a determination result corresponding to each second device.
And step B40, receiving the aggregation parameters fed back by the first equipment based on the zero knowledge verification result and the encryption model parameters, and updating the local training model corresponding to the model training parameters based on the aggregation parameters until the local training model reaches the preset training end condition.
In this embodiment, the aggregation parameters fed back by the first device based on the zero knowledge verification result and the encryption model parameters are received, and the local training model corresponding to the model training parameters is updated based on the aggregation parameters until the local training model reaches a preset training end condition, specifically, after the first device obtains a zero knowledge proof result, false encryption model parameters are removed from the encryption model parameters sent by each second device based on the zero knowledge proof result to obtain each trusted model parameter, and aggregation processing is performed on each trusted model parameter, where the aggregation processing includes summing, weighting and averaging, to obtain an aggregation parameter, and the aggregation parameters are respectively fed back to each second device, and further, after the second device ends the aggregation parameters, based on a preset private key corresponding to the preset public key, decrypting the aggregation parameters to obtain decrypted aggregation parameters, updating the local training model based on the decrypted aggregation parameters, and using the updated local training model as an initial model of the next round of federation until the local training model reaches a preset training end condition, wherein the training end condition comprises reaching of maximum iteration times, convergence of a loss function and the like.
The present embodiment obtains the model training parameter and the first verification random parameter, and based on the first verification random parameter and the preset public key, encrypting the model training parameters to obtain encrypted model parameters, generating verification model parameters and second verification random parameters based on the first verification random parameters, the model training parameters and preset verification challenge parameters, further sending the encryption model parameter, the verification model parameter and the second verification random parameter to a first device for the first device to perform zero knowledge verification to obtain a zero knowledge verification result, further receiving an aggregation parameter fed back by the first device based on the zero knowledge verification result and the encryption model parameter, and based on the aggregation parameter, and updating the local training model corresponding to the model training parameters until the local training model reaches a preset training ending condition. That is, this embodiment provides a federate learning modeling method based on zero knowledge certification, that is, when a model training parameter is encrypted as an encryption model parameter, a verification model parameter and a second verification random parameter are generated at the same time, and then the encryption model parameter, the verification model parameter and the second verification random parameter are sent to a first device, so that the first device performs zero knowledge verification to obtain a zero knowledge verification result, and then the first device determines and eliminates a false encryption model parameter in each second device, and then an aggregation parameter received by the second device is obtained by aggregating the first device based on a trusted encryption model parameter, and then a local training model is updated based on the aggregation parameter to complete federate learning modeling, thereby avoiding updating the local training model based on an aggregation parameter aggregated by each encryption model parameter mixed with the false encryption model parameter, the situation that the local training model is difficult to reach the preset training end condition and the local training model is determined to be low occurs, so that the efficiency and the accuracy of the federal learning modeling are improved, and the technical problems that the federal learning modeling is low in efficiency and poor in accuracy are solved.
Referring to fig. 4, fig. 4 is a schematic device structure diagram of a hardware operating environment according to an embodiment of the present application.
As shown in fig. 4, the federal learning modeling apparatus may include: aprocessor 1001, such as a CPU, amemory 1005, and acommunication bus 1002. Thecommunication bus 1002 is used for realizing connection communication between theprocessor 1001 and thememory 1005. Thememory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). Thememory 1005 may alternatively be a memory device separate from theprocessor 1001 described above.
Optionally, the federal learning modeling apparatus may further include a rectangular user interface, a network interface, a camera, RF (Radio Frequency) circuits, a sensor, an audio circuit, a WiFi module, and the like. The rectangular user interface may comprise a Display screen (Display), an input sub-module such as a Keyboard (Keyboard), and the optional rectangular user interface may also comprise a standard wired interface, a wireless interface. The network interface may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface).
Those skilled in the art will appreciate that the federated learning modeling apparatus architecture shown in FIG. 4 does not constitute a limitation of the federated learning modeling apparatus, and may include more or fewer components than shown, or some components in combination, or a different arrangement of components.
As shown in fig. 4, amemory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, and a federal learning modeling method program. The operating system is a program that manages and controls the hardware and software resources of the Federal learning modeling device, and supports the operation of the Federal learning modeling method program as well as other software and/or programs. The network communication module is used for realizing communication among components in thememory 1005 and communication with other hardware and software in the system of the federal learning modeling method.
In the federal learning modeling apparatus shown in fig. 4, theprocessor 1001 is configured to execute the program of the federal learning modeling method stored in thememory 1005, and implement the steps of any one of the above-mentioned federal learning modeling methods.
The specific implementation of the federal learning modeling device of the application is basically the same as that of each embodiment of the federal learning modeling method, and is not described herein again.
The embodiment of the present application further provides a federal learning modeling device, which is applied to the first device, and the federal learning modeling device includes:
the receiving module is used for receiving the encryption model parameters sent by each second device and the verification parameters corresponding to the encryption model parameters;
the zero knowledge verification module is used for respectively performing zero knowledge verification on each encryption model parameter based on each verification parameter so as to determine a false encryption model parameter in each encryption model parameter and obtain a zero knowledge verification result;
and the coordination module is used for coordinating each second device to carry out federated learning modeling based on the zero knowledge verification result and each encryption model parameter.
Optionally, the coordination module comprises:
the eliminating submodule is used for eliminating the false encryption model parameters from the encryption model parameters based on the zero-knowledge verification result to obtain the credible model parameters;
and the aggregation sub-module is used for aggregating the credible model parameters to obtain aggregation parameters, and feeding the aggregation parameters back to the second equipment respectively so that the second equipment can update the local training models thereof until the local training models reach the preset training end conditions.
Optionally, the zero knowledge verification module comprises:
the calculation submodule is used for respectively calculating a first zero knowledge proof result and a second zero knowledge proof result corresponding to each verification parameter;
and the zero knowledge verification submodule is used for respectively verifying whether each encryption model parameter is a false encryption model parameter or not based on each first zero knowledge proof result and each second zero knowledge proof result so as to obtain a zero knowledge verification result.
Optionally, the computation submodule includes:
the validity verification unit is used for verifying the validity of each encryption model parameter based on a preset verification challenge parameter to obtain each first zero knowledge verification result;
and the encryption unit is used for encrypting each verification model parameter based on a preset coordinator public key and each verification random parameter to obtain each second zero knowledge verification result.
Optionally, the validity verifying unit includes:
the first power operation subunit is configured to perform power operation on the first verification challenge parameter and each encryption model parameter, respectively, to obtain a first power operation result corresponding to each encryption model parameter;
a second exponentiation subunit, configured to perform exponentiation operation on the second verification challenge parameter and each encryption model parameter, respectively, to obtain a second exponentiation operation result corresponding to each encryption model parameter;
a generating subunit, configured to generate each first zero knowledge verification result based on each first power operation result and each second power operation result.
Optionally, the zero knowledge verification sub-module includes:
a comparison unit, configured to compare the first zero knowledge proof result and the second zero knowledge proof result corresponding to each encryption model parameter respectively;
a first determining unit, configured to determine that the cryptographic model parameter is the dummy cryptographic model parameter if the first zero knowledge proof result and the second zero knowledge proof result corresponding to the cryptographic model parameter are not consistent;
a second determining unit, configured to determine that the cryptographic model parameter is not the dummy cryptographic model parameter if the first zero knowledge proof result and the second zero knowledge proof result corresponding to the cryptographic model parameter are consistent.
The specific implementation of the federal learning modeling apparatus of the application is basically the same as that of each embodiment of the federal learning modeling method, and is not described herein again.
In order to achieve the above object, this embodiment further provides a federal learning modeling apparatus, where the federal learning modeling apparatus is applied to a second device, and the federal learning modeling apparatus includes:
the encryption module is used for acquiring a model training parameter and a first verification random parameter, and encrypting the model training parameter based on the first verification random parameter and a preset public key to acquire an encrypted model parameter;
the generation module is used for generating verification model parameters and second verification random parameters based on the first verification random parameters, the model training parameters and preset verification challenge parameters;
the sending module is used for sending the encryption model parameter, the verification model parameter and the second verification random parameter to first equipment so as to enable the first equipment to carry out zero knowledge verification and obtain a zero knowledge verification result;
and the model updating module is used for receiving the aggregation parameters fed back by the first equipment based on the zero knowledge verification result and the encryption model parameters, and updating the local training model corresponding to the model training parameters based on the aggregation parameters until the local training model reaches a preset training ending condition.
Optionally, the encryption module includes:
the obtaining submodule is used for carrying out iterative training on a local training model corresponding to the model training parameters until the local training model reaches a preset iteration threshold value, and obtaining the current model parameters of the local training model;
and the generation submodule is used for acquiring the previous model parameters of the local training model and generating the auxiliary model parameters based on the previous model parameters.
The specific implementation of the federal learning modeling apparatus of the application is basically the same as that of each embodiment of the federal learning modeling method, and is not described herein again.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings, or which are directly or indirectly applied to other related technical fields, are included in the scope of the present application.