Two-party horizontal federated secure aggregation method and system based on k-means clustering

Through the two-party horizontal federated secure aggregation method based on K-means clustering, the nodes of two parties are used for data transmission and encryption processing, which solves the problem of data privacy leakage in horizontal federated learning and realizes efficient and secure data aggregation.

CN119106441BActive Publication Date: 2025-10-17LINGSHU TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411261600.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-10
Publication Date
2025-10-17
Estimated Expiration
2044-09-10

AI Technical Summary

Technical Problem

In horizontal federated learning scenarios, the traditional k-means clustering algorithm cannot be directly applied because direct data exchange will leak each party's data privacy. Although the existing method uses third-party nodes to protect data privacy to a certain extent, there is still room for improvement in efficiency and security.

Method used

A bilateral horizontal federated security aggregation method based on K-means clustering is adopted to transmit data through two-party nodes, avoiding the use of third-party nodes. Encryption and blinding technology are used to protect data privacy during data transmission, and only the central point and data volume are encrypted for transmission, reducing the amount of data transmission.

Benefits of technology

It improves data security and transmission efficiency, ensures that data is not leaked to the other party or third party, reduces the amount of data transmission, and improves data processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119106441B_ABST
    Figure CN119106441B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a two-party horizontal federated security aggregation method and system based on K-means clustering, wherein the method comprises: S1, each participant randomly generates a preset number of initial center points according to local samples; S2, each participant clusters according to the distance between the local sample and the current center point to obtain a local clustering result; S3, each participant updates the current center point according to the local clustering result to obtain an updated center point; S4, each participant calculates the distance sum of the center point and the updated center point; S5, whether the current iteration converges or reaches the maximum iteration number is judged according to the distance sum, if the current iteration converges or reaches the maximum iteration number, each participant calculates the aggregation model by using the local updated center point; otherwise, steps S2-S5 are repeated until the model converges or reaches the maximum iteration number, and the aggregation model is obtained. The transmission efficiency is improved on the basis of ensuring the security of data transmission.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of privacy computing, and particularly relates to a two-party transverse federated secure aggregation method based on K-means clustering. BACKGROUND

[0002] In the transverse federated learning scenario, that is, the two parties P0 and P1 have the same feature space but different sample space data sets, the traditional k-means clustering algorithm cannot be directly applied because direct exchange of data will leak the respective data privacy.

[0003] The existing transverse federated clustering learning method has a third-party node, which can protect data privacy to a certain extent, but there is still room for improvement in efficiency and security.

[0004] There is currently no effective solution to the problem of low efficiency and security risks caused by the use of third-party nodes in the prior art. SUMMARY

[0005] To solve the above problems, the present application provides a two-party transverse federated secure aggregation method and system based on K-means clustering, which only uses two nodes for data transmission, avoiding the problem of poor security caused by the use of third-party nodes, and transmitting the center point in the transmission process, with small data transmission volume, to solve the problem of low transmission efficiency.

[0006] To achieve the above purpose, the present application provides a two-party transverse federated secure aggregation method based on K-means clustering, comprising: S1, each participant randomly generates a predetermined number of initial center points according to the local sample; wherein the participants include a first participant and a second participant; S2, each participant clusters according to the distance between the local sample and the current center point to obtain a local clustering result; wherein the current center point in the initial state is the initial center point; S3, each participant updates the current center point according to the local clustering result to obtain an updated center point; S4, each participant calculates the distance sum according to the local current center point and the updated center point; S5, according to the distance sum, it is judged whether the current iteration converges or reaches the maximum iteration number, if the convergence or the maximum iteration number is reached, each participant calculates the aggregation model using the local updated center point; otherwise, steps S2-S5 are repeated until the aggregation model is obtained.

[0007] Further optionally, the each participant adopts a local update center point to calculate an aggregated model, comprising: S501, the first participant generates a public key and a private key, and encrypts a local first local model and a first sample quantity respectively by using the public key to obtain a first encrypted local model and a first encrypted sample quantity, and sends the public key, the first encrypted local model and the first encrypted sample quantity to the second participant; wherein the first local model is obtained according to the update center point of the first participant; S502, the second participant encrypts a local second local model and a second sample quantity respectively by using the public key to obtain a second encrypted local model and a second encrypted sample quantity, securely aggregates the first encrypted local model and the second encrypted local model to obtain an encrypted aggregated model, and securely aggregates the first encrypted sample quantity and the second encrypted sample quantity to obtain an encrypted aggregated sample quantity; wherein the second local model is obtained according to the update center point of the second participant; S503, the second participant blind processes the encrypted aggregated model and the encrypted aggregated sample quantity respectively by using a random number to obtain a blind encrypted aggregated model and a blind encrypted aggregated sample quantity, and sends the blind encrypted aggregated model and the blind encrypted aggregated sample quantity to the first participant; S504, the first participant decrypts the blind encrypted aggregated model and the blind encrypted aggregated sample quantity respectively by using the private key to obtain a blind aggregated model and a blind aggregated sample quantity, and sends the blind aggregated model and the blind aggregated sample quantity to the second participant; S505, the second participant de-blind processes the blind aggregated model and the blind aggregated sample quantity respectively according to the random number to obtain an aggregated model, and sends the aggregated model to the first participant.

[0008] Further optionally, the each participant clusters according to a distance of a local sample and a current center point to obtain a local clustering result, comprising: S201, calculating a Euclidean distance of each local sample relative to all current center points; S202, putting each local sample into a category corresponding to a current center point with the smallest Euclidean distance to obtain a clustering result.

[0009] Further optionally, the each participant updates the current center point according to the local clustering result to obtain an updated center point, comprising: S301, forming a clustering data set by local samples in each category in the clustering result; S302, calculating an arithmetic mean value of each feature in each clustering data set, and taking the arithmetic mean value of all features as an updated center point of the category.

[0010] Further optionally, the distance sum is calculated by each participant according to the local current center point and the update center point, comprising: S401, the second participant calculates the first center point distance between the local current center point and the update center point; S402, the first participant calculates the second center point distance between the local current center point and the update center point, and sends the second center point distance to the second participant; S403, the second participant calculates the distance sum of the first center point distance and the second center point distance.

[0011] In another aspect, the application further provides a two-party horizontal federated security aggregation system based on K-means clustering, comprising: an initial center point generation module, configured to generate a preset number of initial center points by each participant according to local samples; wherein the participants include a first participant and a second participant; a clustering module, configured to cluster by each participant according to the distance between the local sample and the current center point to obtain a local clustering result; wherein the current center point in the initial state is the initial center point; a center point update module, configured to update the current center point according to the local clustering result by each participant to obtain an update center point; a distance sum calculation module, configured to calculate the distance sum by each participant according to the local current center point and the update center point; an iteration module, configured to judge whether the current iteration converges or reaches the maximum iteration number according to the distance sum, if the current iteration converges or reaches the maximum iteration number, each participant uses the local update center point to calculate the aggregation model; otherwise, repeat the steps of the clustering module, the center point update module, the distance sum calculation module and the iteration module until the aggregation model is obtained.

[0012] Further optionally, the model aggregation module comprises: an encryption submodule, configured to generate a public key and a private key by the first participant, and encrypt the first local model and the first sample size locally by using the public key respectively to obtain an encrypted first local model and an encrypted first sample size, and send the public key, the encrypted first local model and the encrypted first sample size to the second participant; wherein the first local model is obtained according to an updated center point of the first participant; an aggregation submodule, configured to encrypt the second local model and the second sample size locally by the second participant using the public key to obtain an encrypted second local model and an encrypted second sample size, securely aggregate the encrypted first local model and the encrypted second local model to obtain an encrypted aggregated model, and securely aggregate the encrypted first sample size and the encrypted second sample size to obtain an encrypted aggregated sample size; wherein the second local model is obtained according to an updated center point of the second participant; a blinding submodule, configured to perform blinding processing on the encrypted aggregated model and the encrypted aggregated sample size by the second participant using a random number to obtain a blinded encrypted aggregated model and a blinded encrypted aggregated sample size, and send the blinded encrypted aggregated model and the blinded encrypted aggregated sample size to the first participant; a decryption submodule, configured to perform decryption on the blinded encrypted aggregated model and the blinded encrypted aggregated sample size by the first participant using the private key to obtain a blinded aggregated model and a blinded aggregated sample size, and send the blinded aggregated model and the blinded aggregated sample size to the second participant; a deblinding submodule, configured to perform deblinding processing on the blinded aggregated model and the blinded aggregated sample size by the second participant according to the random number to obtain an aggregated model, and send the aggregated model to the first participant.

[0013] Further optionally, the clustering module comprises: a distance calculation submodule, configured to calculate the Euclidean distance of each local sample relative to all current center points; a clustering submodule, configured to classify each local sample into a category corresponding to the current center point with the minimum Euclidean distance to obtain a clustering result.

[0014] Further optionally, the center point updating module comprises: a clustering data set generation submodule, configured to group the local samples in each category in the clustering result into a clustering data set; a center point updating submodule, configured to calculate the arithmetic mean of each feature in each clustering data set, and take the arithmetic mean of all features as the updated center point of the category.

[0015] Further optionally, the distance and calculation module comprises: a first calculation submodule, configured to calculate, by the second participant, a first center point distance between the current center point and the updated center point locally; a second calculation submodule, configured to calculate, by the first participant, a second center point distance between the current center point and the updated center point locally, and send the second center point distance to the second participant; a summation submodule, configured to calculate, by the second participant, a distance sum of the first center point distance and the second center point distance.

[0016] The technical scheme has the following beneficial effects: data transmission and analysis between two participants are performed to ensure that data is not leaked and improve data security; in the data security aggregation process, encryption and blinding techniques are used to ensure that the original data is not leaked to the other party during data transmission, and no third party is relied on, and intermediate data is not leaked to the third party, further improving security; only the center point and data volume are encrypted and transmitted in the security aggregation process, reducing data transmission volume, thereby improving data processing efficiency. BRIEF DESCRIPTION OF DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0018] Figure 1 is a flowchart of the two-party horizontal federated security aggregation method based on K-means clustering provided by the embodiments of the present application;

[0019] Figure 2 is a flowchart of the model security aggregation method provided by the embodiments of the present application;

[0020] Figure 3 is a flowchart of the clustering method provided by the embodiments of the present application;

[0021] Figure 4 is a flowchart of the center point updating method provided by the embodiments of the present application;

[0022] Figure 5 is a flowchart of the distance and calculation method provided by the embodiments of the present application;

[0023] Figure 6 is a structural schematic diagram of the two-party horizontal federated security aggregation system based on K-means clustering provided by the embodiments of the present application;

[0024] Figure 7 is a structural schematic diagram of the iteration module provided by the embodiments of the present application;

[0025] Figure 8 is a structural schematic diagram of the clustering module provided by the embodiments of the present application;

[0026] Figure 9 is a structural schematic diagram of the center point updating module provided by the embodiments of the present application;

[0027] Figure 10is a structural schematic diagram of a distance and calculation module provided by an embodiment of the present application.

[0028] Reference signs: 100-initial center point generation module; 200-clustering module; 2001-distance calculation submodule; 2002-clustering submodule; 300-center point update module; 3001-clustered data set generation submodule; 3002-center point update submodule; 400-distance and calculation module; 4001-first calculation submodule; 4002-second calculation submodule; 4003-summation submodule; 500-iteration module; 5001-encryption submodule; 5002-aggregation submodule; 5003-blinding submodule; 5004-decryption submodule; 5005-deblinding submodule. DETAILED DESCRIPTION

[0029] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0030] To solve the problems of low security and efficiency in horizontal federated learning in the prior art, an embodiment of the present application provides a two-party horizontal federated secure aggregation method based on K-means clustering, Figure 1 is a flowchart of the two-party horizontal federated secure aggregation method based on K-means clustering provided by an embodiment of the present application, as Figure 1 shown, the method comprises the following steps.

[0031] S1, each participant randomly generates a preset number of initial center points according to local samples; wherein the participants include a first participant and a second participant;

[0032] Horizontal federated learning is commonly used in loan limit prediction, investment risk analysis, medical data analysis, market analysis and other scenarios. Both parties participating in horizontal federated learning do not want to share original data with each other, but need to perform data analysis through an aggregated model after aggregation.

[0033] Taking the market analysis scenario as an example, two participants are the first retailer P0 and the second retailer P1, and the two participants hope to cooperate to conduct market segmentation analysis to better position their marketing strategies. The first retailer P0 has extensive customer purchase data, while the second retailer P1 has detailed customer feedback and survey data. Due to privacy policies and business confidentiality considerations, they do not want to directly share the original data. Therefore, model aggregation is performed to utilize the aggregated model to identify different customer groups, and to design customized marketing strategies such as personalized recommendations, specific discounts, etc., thereby improving customer satisfaction and sales performance.

[0034] Taking the medical data analysis scenario as an example, two participants are the first hospital P0 and the second hospital P1, and the two participants hope to jointly analyze patient health data to study the pathogenesis and treatment effect of a specific disease. Hospital P0 has a large number of patients' electronic health records, while hospital P1 has detailed treatment response data. Due to legal requirements for patient privacy protection, they cannot directly share patients' sensitive data. Therefore, model aggregation is performed to utilize the aggregated model to identify specific health characteristics and treatment responses of different patient groups, thereby providing more accurate guidance for clinical treatment, optimizing treatment plans, and improving treatment effects. At the same time, this cooperation method also helps to speed up the research and development process of new drugs and treatment methods.

[0035] To realize the model aggregation of both parties, first, the data of each participant needs to be standardized to make the feature dimensions of both parties the same. For example, in the medical data analysis scenario, one of the participants P0 performs data standardization to obtain a data set X, which includes m samples, each with f features, i.e., m patients, each with f features (age, gender, disease type, treatment duration, etc.). Another participant P1 performs data standardization to obtain a data set Y, which includes n samples, each with f features.

[0036] The first participant P1 after standardization has a standardized data set Y with n rows and f columns, and the second participant P0 after standardization has a standardized data set X with m rows and f columns. Assuming there are k categories, k >= 2, and the preset number is the number of categories k, then the first participant and the second participant randomly generate k initial center points.

[0037] The P0 sample ID list is ids_0, and the P0 center point: the i-th center point Ci = [Xr0, Xr1, Xr2, … Xr(f-1)], where i = 0, 1, 2, …, k-1; r = random.sample(ids_0, k);

[0038] The P1 sample ID list is ids_1, and the P1 center point: the jth center point Cj=[Yr0, Yr1, Yr2, …Yr(f-1)], where j=0, 1, 2, …, k-1; r=random.sample(ids_1, k).

[0039] S2, each participant clusters according to the distance between the local sample and the current center point to obtain a local clustering result; wherein, in the initial state, the current center point is the initial center point;

[0040] At the beginning of iteration, the initial center point is taken as the current center point for the first clustering. The first participant P1 calculates the Euclidean distance between each sample in the standardized data set and the k current center points, and clusters each sample according to the Euclidean distance, i.e., each sample is classified into the category of the nearest current center point, to obtain the local clustering result of the first participant P1.

[0041] The second participant P0 obtains the local clustering result of the second participant in the same way.

[0042] S3, each participant updates the current center point according to the local clustering result to obtain an updated center point;

[0043] The first participant P1 updates the current center point according to the characteristics of the samples in the local clustering result to obtain the updated center point of each category.

[0044] The second participant P0 obtains the updated center point of the first participant in the same way.

[0045] S4, each participant calculates the distance sum according to the local current center point and the updated center point;

[0046] Then, the two participants respectively calculate the center point distance according to the local current center point and the updated center point, and calculate the distance sum according to the center point distance of the two parties as a judgment mark for whether the subsequent iteration converges or not.

[0047] S5, according to the distance sum, it is judged whether the current iteration converges or reaches the maximum iteration number, if it converges or reaches the maximum iteration number, the local updated center point is used by each participant to calculate the aggregation model; otherwise, steps S2-S5 are repeated until the aggregation model is obtained.

[0048] If the distance sum is greater than the preset convergence distance, it is considered that the iteration does not converge, otherwise it is considered that the iteration converges. In addition, the iteration number can also be used for judgment, if the current iteration number reaches the maximum iteration number, it is considered that the iteration converges, otherwise, it is considered that it does not converge.

[0049] If the iteration converges, two participants use their respective updated center points to aggregate according to a secure model of a Paillier encryption protocol to obtain an aggregated model, so as to ensure that data privacy is not disclosed.

[0050] If the iteration does not converge, the steps S2-S5 are repeated, and the iteration number is increased by 1 each time, until the iteration converges or the maximum iteration number is reached, and the updated center point obtained in the last iteration is used for secure aggregation to obtain the aggregated model.

[0051] It should be noted that in each iteration, the updated center point is used as the current center point for subsequent calculation.

[0052] As an optional implementation, Figure 2 is a flowchart of the model secure aggregation method provided by the embodiment of the application, as Figure 2 shown, each participant uses a local updated center point to calculate an aggregated model, including:

[0053] S501, the first participant generates a public key and a private key, and encrypts a first local model and a first sample size locally using the public key to obtain a first encrypted local model and a first encrypted sample size, and sends the public key, the first encrypted local model and the first encrypted sample size to the second participant; wherein the first local model is obtained according to the updated center point of the first participant;

[0054] The first participant P1 uses the paillier encryption protocol to generate a key pair, i.e. a public key and a private key, and encrypts a first local model and a first sample size locally using the public key to obtain a first encrypted local model and a first encrypted sample size, and sends the public key, the first encrypted local model and the first encrypted sample size to the second participant P0.

[0055] S502, the second participant encrypts a second local model and a second sample size locally using the public key to obtain a second encrypted local model and a second encrypted sample size, securely aggregates the first encrypted local model and the second encrypted local model to obtain an encrypted aggregated model, and securely aggregates the first encrypted sample size and the second encrypted sample size to obtain an encrypted aggregated sample size; wherein the second local model is obtained according to the updated center point of the second participant;

[0056] After receiving the public key, the first encrypted local model and the first encrypted sample size, the second participant P0 encrypts a second local model and a second sample size using the public key to obtain a second encrypted local model and a second encrypted sample size.

[0057] The two encrypted local models are securely aggregated to obtain an encrypted aggregated model, and the two encrypted sample sizes are aggregated to obtain an encrypted aggregated sample size.

[0058] S503: The second participant uses random numbers to blind the encryption aggregation model and the encryption aggregation sample size, respectively, to obtain a blinded encryption aggregation model and a blinded encryption aggregation sample size, and sends the blinded encryption aggregation model and the blinded encryption aggregation sample size to the first participant;

[0059] The second participant P0 pre-generates two random numbers r0 and r1, and uses the two random numbers to blind the encryption aggregation model and the encryption aggregation sample size, respectively, to obtain the blinded encryption aggregation model and the blinded encryption aggregation sample size. The blinded encryption aggregation model and the blinded encryption aggregation sample size are sent to the first participant P1.

[0060] S504: The first participant uses the private key to decrypt the blinded encrypted aggregation model and the blinded encrypted aggregation sample size, respectively, to obtain the blinded aggregation model and the blinded aggregation sample size, and sends the blinded aggregation model and the blinded aggregation sample size to the second participant;

[0061] After receiving the blinded encrypted aggregation model and the blinded encrypted aggregation sample size, the first participant P1 decrypts them using the private key to obtain the blinded aggregation model and the blinded aggregation sample size. Then, the blinded aggregation model and the blinded aggregation sample size are sent to the second participant P0.

[0062] S505. The second participant deblinds the blinded aggregation model and the blinded aggregation sample size according to the random number to obtain the aggregation model, and sends the aggregation model to the first participant.

[0063] The second participant P0 performs deblinding on the aggregation model according to two random numbers to obtain the aggregation model.

[0064] As an optional implementation, the aggregation model = blinded aggregation model / blind aggregation sample size*r1 / r0, and the aggregation model is sent to the first participant P1.

[0065] As an optional implementation, Figure 3 is a flow chart of the clustering method provided by an embodiment of the present invention, such as Figure 3 As shown in the figure, each participant clusters based on the distance between the local sample and the current center point, and obtains the local clustering results, including:

[0066] S201, calculating the Euclidean distance of each local sample relative to all current center points;

[0067] Taking a local sample Xt of the second participant P0 as an example, the sample Xt is a vector with f dimensions, t = [0, 1, 2, …, m-1], and the Euclidean distance dti between the sample Xt and a certain center point Ci is calculated as follows: dti = sqrt((Xt0-Xr0)^2+(Xt1-Xr1)^2+…+(Xt(f-1)-Xr(f-1))^2).

[0068] The Euclidean distances between each local sample of the second participant P0 and all current center points are calculated in the above manner, and a distance data set D mk :

[0069]

[0070] The Euclidean distances between each local sample of the first participant P1 and the current center points are calculated in the same manner, and a distance data set D nk :

[0071]

[0072] S202, each local sample is classified into a category corresponding to the current center point with the smallest Euclidean distance, to obtain a clustering result.

[0073] Taking the second participant P0 as an example, the column index value corresponding to the minimum value of each row in the distance data set D mk of the second participant P0 is taken as the category to which the sample belongs, to obtain a clustering result cluster0 of the second participant P0 including k categories. In the same manner, a clustering result cluster1 of the first participant P1 including k categories is obtained.

[0074] As an optional implementation, Figure 4 is a flowchart of a center point updating method provided by an embodiment of the present application, as shown in Figure 4 Each participant updates the current center point according to the local clustering result, to obtain an updated center point, including:

[0075] S301, local samples of each category in the clustering result are grouped into a clustering data set;

[0076] S302, the arithmetic mean of each feature in each clustering data set is calculated, and the arithmetic means of all features are taken as the updated center point of the category.

[0077] Local samples of the same category in the clustering result are grouped into a clustering data set, and the arithmetic mean of each column feature in each clustering data set is calculated. The k-row f-column array composed of all arithmetic means is taken as the set of updated center points, and each row represents an updated center point of a category.

[0078] As an optional implementation,Figure 5 is a flowchart of the distance and calculation method provided by the embodiment of the present application, as shown in Figure 5 According to the local current center point and the updated center point, each participant calculates the distance and, including:

[0079] S401, the second participant calculates the first center point distance between the local current center point and the updated center point;

[0080] The second participant P0 calculates the Euclidean distance between the local current center point and the updated center point as the first center point distance d0.

[0081] S402, the first participant calculates the second center point distance between the local current center point and the updated center point, and sends the second center point distance to the second participant;

[0082] The first participant P1 calculates the Euclidean distance between the local current center point and the updated center point as the second center point distance d1, and sends the second center point distance d1 to the second participant P0.

[0083] S403, the second participant calculates the distance sum of the first center point distance and the second center point distance.

[0084] The second participant calculates the distance sum of the first center point distance d0 and the second center point distance d1, that is, d0+d1. If the distance sum is greater than the preset convergence distance, it does not converge and needs to continue iteration, otherwise it converges and stops iteration.

[0085] The embodiment of the present application also provides a two-party horizontal federated security aggregation system based on K-means clustering, Figure 6 is a structural schematic diagram of the two-party horizontal federated security aggregation system based on K-means clustering provided by the embodiment of the present application, as shown in Figure 6 The system comprises:

[0086] The initial center point generation module 100 is used for each participant to randomly generate a preset number of initial center points according to local samples; wherein the participants include a first participant and a second participant;

[0087] The horizontal federation is commonly used in loan limit prediction, investment risk analysis, medical data analysis, market analysis and other scenes. Both parties participating in the horizontal federated learning do not want to share the original data with each other, but need to analyze the data through the aggregated aggregation model.

[0088] For example, in a market analysis scenario, two parties, retailer P0 and retailer P1, wish to collaborate on market segmentation analysis to better target their marketing strategies. Retailer P0 possesses extensive customer purchase data, while retailer P1 possesses detailed customer feedback and survey data. Due to privacy and commercial confidentiality concerns, they prefer not to share their raw data directly. Therefore, they perform model aggregation to identify different customer segments using the resulting aggregated model. They can then design customized marketing strategies for these segments, such as personalized recommendations and targeted discounts, to improve customer satisfaction and sales performance.

[0089] For example, consider a medical data analysis scenario. Hospital P0 and hospital P1 aim to jointly analyze patient health data to study the pathogenesis and treatment outcomes of specific diseases. Hospital P0 possesses a large collection of electronic health records for patients, while hospital P1 possesses detailed treatment response data. Due to legal requirements for patient privacy, these two parties cannot directly share sensitive patient data. Instead, they aggregate models to identify specific health characteristics and treatment responses across patient populations. This allows for more precise clinical guidance, optimized treatment plans, and improved outcomes. This collaborative approach also helps accelerate the development of new drugs and treatments.

[0090] To achieve model aggregation between two parties, the data of each participant must first be standardized to ensure that both parties have the same feature dimensions. For example, in a medical data analysis scenario, after data standardization by one participant, P0, the resulting dataset X includes m samples, each with f features, i.e., m patients, each with f features (age, gender, disease type, treatment duration, etc.). After data standardization by the other participant, P1, the resulting dataset Y includes n samples, each with f features.

[0091] After standardization, the first participant P1 has a standardized dataset Y with n rows and f columns. The second participant P0 has a standardized dataset X with m rows and f columns. Assuming there are k categories, k >= 2, and the preset number is the number of categories k, the first and second participants each randomly generate k initial center points.

[0092] The P0 sample ID list is ids_0, the P0 center point: the i-th center point Ci = [Xr0, Xr1, Xr2, ... Xr(f-1)], where i = 0, 1, 2, ..., k-1; r = random.sample(ids_0, k);

[0093] The P1 sample ID list is ids_1, and the P1 center point: the jth center point Cj=[Yr0, Yr1, Yr2, …Yr(f-1)], where j=0, 1, 2, …, k-1; r=random.sample(ids_1, k).

[0094] The clustering module 200 is configured to cluster each participant according to the distance between the local sample and the current center point to obtain a local clustering result; and in an initial state, the current center point is an initial center point.

[0095] In the initial state, the initial center point is used as the current center point to perform the first clustering.

[0096] The first participant P1 calculates the Euclidean distance between each sample in the standardized data set and the k current center points, and clusters each sample according to the Euclidean distance, i.e., each sample is classified into the category of the nearest current center point, to obtain the local clustering result of the first participant P1.

[0097] The second participant P0 obtains the local clustering result of the second participant in the same way.

[0098] The center point updating module 300 is configured to update the current center point according to the local clustering result to obtain an updated center point.

[0099] The first participant P1 updates the current center point according to the features of the samples in the local clustering result to obtain an updated center point of each category.

[0100] The second participant P0 obtains the updated center point of the first participant in the same way.

[0101] The distance sum calculation module 400 is configured to calculate the distance sum between the local current center point and the updated center point.

[0102] Then, the two participants calculate the center point distance between the local current center point and the updated center point, and calculate the distance sum according to the center point distance of the two parties as a judgment mark for whether the subsequent iteration converges or not.

[0103] The iteration module 500 is configured to judge whether the current iteration converges or reaches the maximum iteration number according to the distance sum, and if so, each participant calculates the aggregated model using the local updated center point; otherwise, the steps of the clustering module, the center point updating module, the distance sum calculation module, and the iteration module are repeated until the aggregated model is obtained.

[0104] If the distance and is greater than the preset convergence distance, it is considered that the iteration does not converge, otherwise it is considered that the iteration converges. In addition, the iteration number can also be used for judgment, if the current iteration number reaches the maximum iteration number, it is considered that the iteration converges, otherwise, it is considered not to converge.

[0105] If the iteration converges, the two participants use the respective updated center points to perform horizontal federated secure model aggregation according to the Paillier encryption protocol to obtain an aggregated model, so as to ensure that the data privacy is not leaked.

[0106] If the iteration does not converge, the steps of the clustering module, the center point updating module, the distance and calculation module and the iteration module are repeated, and the iteration number is increased by 1 each time until the iteration converges or the maximum iteration number is reached, and the updated center point obtained in the last iteration is used for secure aggregation to obtain an aggregated model.

[0107] It should be noted that in each iteration, the updated center point needs to be used as the current center point for subsequent calculation.

[0108] As an optional implementation, Figure 7 is a structural schematic diagram of the iteration module provided by the embodiment of the application, as Figure 7 shown, the iteration module comprises:

[0109] The encryption submodule 5001 is configured to generate a public key and a private key by the first participant, and encrypt the first local model and the first sample quantity locally by the public key to obtain a first encrypted local model and a first encrypted sample quantity, and send the public key, the first encrypted local model and the first encrypted sample quantity to the second participant; wherein the first local model is obtained according to the updated center point of the first participant.

[0110] The first participant P1 generates a key pair, i.e. a public key and a private key, using the paillier encryption protocol, and encrypts the first local model and the first sample quantity locally by the public key to obtain a first encrypted local model and a first encrypted sample quantity, and sends the public key, the first encrypted local model and the first encrypted sample quantity to the second participant P0.

[0111] The aggregation submodule 5002 is configured to encrypt the second local model and the second sample quantity locally by the public key to obtain a second encrypted local model and a second encrypted sample quantity, and perform secure aggregation on the first encrypted local model and the second encrypted local model to obtain an encrypted aggregated model, and perform secure aggregation on the first encrypted sample quantity and the second encrypted sample quantity to obtain an encrypted aggregated sample quantity; wherein the second local model is obtained according to the updated center point of the second participant.

[0112] The second participant P0 receives the public key, the first encrypted local model and the first encrypted sample quantity, and encrypts the second local model and the second sample quantity using the public key to obtain the second encrypted local model and the second encrypted sample quantity.

[0113] The two encrypted local models are securely aggregated to obtain an encrypted aggregated model, and the two encrypted sample quantities are aggregated to obtain an encrypted aggregated sample quantity.

[0114] The blinding sub-module 5003 is configured to perform blinding processing on the encrypted aggregated model and the encrypted aggregated sample quantity using random numbers to obtain a blinded encrypted aggregated model and a blinded encrypted aggregated sample quantity, and send the blinded encrypted aggregated model and the blinded encrypted aggregated sample quantity to the first participant.

[0115] The second participant P0 generates two random numbers r0 and r1 in advance, and performs blinding processing on the encrypted aggregated model and the encrypted aggregated sample quantity using the two random numbers to obtain a blinded encrypted aggregated model and a blinded encrypted aggregated sample quantity. The blinded encrypted aggregated model and the blinded encrypted aggregated sample quantity are sent to the first participant P1.

[0116] The decryption sub-module 5004 is configured to perform decryption on the blinded encrypted aggregated model and the blinded encrypted aggregated sample quantity using a private key to obtain a blinded aggregated model and a blinded aggregated sample quantity, and send the blinded aggregated model and the blinded aggregated sample quantity to the second participant.

[0117] The first participant P1 receives the blinded encrypted aggregated model and the blinded encrypted aggregated sample quantity, and performs decryption on the blinded encrypted aggregated model and the blinded encrypted aggregated sample quantity using the private key to obtain a blinded aggregated model and a blinded aggregated sample quantity. The blinded aggregated model and the blinded aggregated sample quantity are then sent to the second participant P0.

[0118] The deblinding sub-module 5005 is configured to perform deblinding processing on the blinded aggregated model and the blinded aggregated sample quantity using the random numbers to obtain an aggregated model, and send the aggregated model to the first participant.

[0119] The second participant P0 performs deblinding processing on the aggregated model using the two random numbers to obtain an aggregated model.

[0120] As an optional implementation, the aggregated model = blinded aggregated model / blinded aggregated sample quantity*r1 / r0, and the aggregated model is sent to the first participant P1.

[0121] As an optional implementation, Figure 8 is a structural schematic diagram of the clustering module provided by an embodiment of the application, as shown in Figure 8 The clustering module 200 includes:

[0122] The distance calculation submodule 2001 is used to calculate the Euclidean distance of each local sample relative to all current center points;

[0123] Taking a local sample Xt of the second participant P0 as an example, Xt is a vector with f dimensions, t = [0, 1, 2, …, m-1], calculate the Euclidean distance dti = sqrt((Xt0-Xr0)^2+(Xt1-Xr1)^2+…+(Xt(f-1)-Xr(f-1))^2) between the sample Xt and a central point Ci.

[0124] Calculate the Euclidean distance between each local sample in the second participant P0 and all current center points in the above way, and generate the distance dataset D mk :

[0125]

[0126] In the same way, calculate the Euclidean distance between each local sample in the first participant P1 and the current center point, and generate the distance dataset D nk :

[0127]

[0128] The clustering submodule 2002 is used to classify each local sample into the category corresponding to the current center point with the smallest Euclidean distance to obtain a clustering result.

[0129] Taking the second participant P0 as an example, the distance dataset D of the second participant P0 is mk In , the column index value corresponding to the minimum value of each row is used as the category to which the sample belongs, so as to obtain the clustering result cluster0 of the second participant P0 including k categories. The same method is used to obtain the clustering result cluster1 of the first participant P1 including k categories.

[0130] As an optional implementation, Figure 9 This is a schematic diagram of the structure of the central point update module provided by an embodiment of the present invention. Figure 9 As shown, the central point update module 300 includes:

[0131] The clustering data set generation submodule 3001 is used to form a clustering data set from the local samples of each category in the clustering results;

[0132] The center point updating submodule 3002 is used to calculate the arithmetic mean of each feature in each cluster data set, and use the arithmetic mean of all features as the updated center point of the corresponding category.

[0133] The local samples with the same class in the clustering result are combined to form a clustering data set, and the arithmetic mean of each column feature in each clustering data set is calculated. The array of all arithmetic means combined into k rows and f columns is used as the set of updated center points, and each row represents an updated center point of a class.

[0134] As an optional implementation, Figure 10 is a structural schematic diagram of the distance and calculation module provided by the embodiment of the application, as shown in Figure 10 The distance and calculation module 400 includes:

[0135] The first calculation submodule 4001 is configured to calculate, by the second participant, a first center point distance between the current center point and the updated center point locally.

[0136] The second participant P0 calculates the Euclidean distance between the current center point and the updated center point locally as the first center point distance d0.

[0137] The second calculation submodule 5002 is configured to calculate, by the first participant, a second center point distance between the current center point and the updated center point locally, and send the second center point distance to the second participant.

[0138] The first participant P1 calculates the Euclidean distance between the current center point and the updated center point locally as the second center point distance d1, and sends the second center point distance d1 to the second participant P0.

[0139] The summation submodule 5003 is configured to calculate, by the second participant, a distance sum of the first center point distance and the second center point distance.

[0140] The second participant calculates the distance sum of the first center point distance d0 and the second center point distance d1, that is, d0+d1. If the distance sum is greater than a preset convergence distance, the convergence is not achieved, and iteration needs to be continued. Otherwise, the convergence is achieved, and the iteration is stopped.

[0141] The above technical solution has the following beneficial effects: by transmitting and analyzing the data between the two participants, it is ensured that the data will not be leaked, and the security of the data is improved; in the process of secure aggregation of data, the encryption and blinding techniques are used to ensure that the original data will not be leaked to the other party in the process of data transmission, and the security is further improved without relying on any third party and without leaking the intermediate data to the third party; only the center point and the data volume are encrypted and transmitted in the process of secure aggregation, the data transmission volume is reduced, and the data processing efficiency is improved.

[0142] The above detailed description of the application is only a specific embodiment of the application, and is not intended to limit the protection scope of the application. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the application shall be included in the protection scope of the application.

Claims

1. A two-party horizontal federation security aggregation method based on K-means clustering, characterized by: include: S1. Each participant randomly generates a preset number of initial center points based on a local sample; wherein each participant includes a first participant and a second participant; S2. Each participant clusters based on the distance between the local sample and the current center point to obtain a local clustering result. In the initial state, the current center point is the initial center point. S3. Each participant updates the current center point according to the local clustering result to obtain an updated center point; S4. Each participant calculates the distance sum based on the local current center point and the updated center point; S5. Determine whether the current iteration has converged or reached the maximum number of iterations based on the distance. If so, each participant calculates the aggregate model using the local update center point. Otherwise, repeat steps S2-S5 until the aggregate model is obtained. Each participant uses a local update center point to calculate an aggregation model, including: S501: A first participant generates a public key and a private key, and uses the public key to encrypt a local first local model and a first sample volume, respectively, to obtain a first encrypted local model and a first encrypted sample volume, and sends the public key, the first encrypted local model, and the first encrypted sample volume to a second participant; wherein the first local model is obtained based on an update center point of the first participant; S502: The second participant uses the public key to encrypt the local second local model and the second sample volume, respectively, to obtain a second encrypted local model and a second encrypted sample volume, securely aggregates the first encrypted local model with the second encrypted local model to obtain an encrypted aggregate model, and securely aggregates the first encrypted sample volume with the second encrypted sample volume to obtain an encrypted aggregate sample volume; wherein the second local model is obtained based on the update center point of the second participant; S503: The second party uses random numbers to blind the encrypted aggregation model and the encrypted aggregation sample size to obtain a blinded encrypted aggregation model and a blinded encrypted aggregation sample size, and sends the blinded encrypted aggregation model and the blinded encrypted aggregation sample size to the first party. S504: The first participant uses the private key to decrypt the blinded encrypted aggregation model and the blinded encrypted aggregation sample size, respectively, to obtain the blinded aggregation model and the blinded aggregation sample size, and sends the blinded aggregation model and the blinded aggregation sample size to the second participant; S505: The second participant performs deblinding processing on the blinded aggregation model and the blinded aggregation sample size according to the random number to obtain an aggregation model, and sends the aggregation model to the first participant.

2. The K-means clustering-based two-party horizontal federation security aggregation method according to claim 1 is characterized in that: Each participant clusters the local samples based on the distance between the local samples and the current center point to obtain a local clustering result, including: S201, calculating the Euclidean distance of each local sample relative to all current center points; S202: Classify each local sample into the category corresponding to the current center point with the smallest Euclidean distance to obtain a clustering result.

3. The two-party horizontal federation security aggregation method based on K-means clustering according to claim 1 is characterized in that: Each participant updates the current center point according to the local clustering result to obtain an updated center point, including: S301, forming a clustering data set from local samples of each category in the clustering result; S302: Calculate the arithmetic mean of each feature in each cluster data set, and use the arithmetic mean of all features as the update center point of the category to which it belongs.

4. The K-means clustering-based two-party horizontal federation security aggregation method according to claim 1 is characterized in that: Each participant calculates the distance sum based on the local current center point and the updated center point, including: S401: The second participant calculates the first center point distance between the local current center point and the updated center point; S402: The first participant calculates a second center point distance between the local current center point and the updated center point, and sends the second center point distance to the second participant; S403: The second participant calculates the sum of the distance between the first center point and the distance between the second center point.

5. A two-party horizontal federation security aggregation system based on K-means clustering, characterized by: include: An initial center point generation module is used for each participant to randomly generate a preset number of initial center points based on local samples; wherein each participant includes a first participant and a second participant; The clustering module is used for each participant to cluster according to the distance between the local sample and the current center point to obtain the local clustering result; wherein, in the initial state, the current center point is the initial center point; A center point updating module, configured for each participant to update the current center point according to the local clustering result to obtain an updated center point; The distance sum calculation module is used by each participant to calculate the distance sum based on the local current center point and the updated center point; An iteration module is used to determine whether the current iteration has converged or reached the maximum number of iterations based on the distance sum. If so, each participant uses the local updated center point to calculate the aggregation model; otherwise, the steps of the clustering module, the center point update module, the distance sum calculation module, and the iteration module are repeated until the aggregation model is obtained; The iteration module includes: an encryption submodule, configured for the first participant to generate a public key and a private key, and to use the public key to encrypt a local first local model and a first sample volume, respectively, to obtain a first encrypted local model and a first encrypted sample volume, and to send the public key, the first encrypted local model, and the first encrypted sample volume to the second participant; wherein the first local model is obtained based on the update center point of the first participant; An aggregation submodule, configured for the second participant to use the public key to encrypt a local second local model and a local second sample volume, respectively, to obtain a second encrypted local model and a second encrypted sample volume, securely aggregate the first encrypted local model with the second encrypted local model to obtain an encrypted aggregate model, and securely aggregate the first encrypted sample volume with the second encrypted sample volume to obtain an encrypted aggregate sample volume; wherein the second local model is obtained based on the update center point of the second participant; a blinding submodule, configured for the second participant to perform blinding processing on the encrypted aggregation model and the encrypted aggregation sample size using random numbers, obtain a blinded encrypted aggregation model and a blinded encrypted aggregation sample size, and send the blinded encrypted aggregation model and the blinded encrypted aggregation sample size to the first participant; a decryption submodule, configured for the first participant to use the private key to decrypt the blinded encrypted aggregation model and the blinded encrypted aggregation sample size, respectively, to obtain the blinded aggregation model and the blinded aggregation sample size, and to send the blinded aggregation model and the blinded aggregation sample size to the second participant; The deblinding submodule is used for the second participant to perform deblinding processing on the blinded aggregation model and the blinded aggregation sample size according to random numbers, obtain the aggregation model, and send the aggregation model to the first participant.

6. The K-means clustering-based two-party horizontal federation security aggregation system according to claim 5, characterized in that: The clustering module includes: The distance calculation submodule is used to calculate the Euclidean distance of each local sample relative to all current center points; The clustering submodule is used to classify each local sample into the category corresponding to the current center point with the smallest Euclidean distance to obtain the clustering result.

7. The K-means clustering-based two-party horizontal federation security aggregation system according to claim 5, characterized in that: The central point updating module includes: The clustering dataset generation submodule is used to form a clustering dataset from the local samples of each category in the clustering results; The center point update submodule is used to calculate the arithmetic mean of each feature in each clustering data set and use the arithmetic mean of all features as the updated center point of the category to which it belongs.

8. The K-means clustering-based two-party horizontal federation security aggregation system according to claim 5, characterized in that: The distance and calculation module includes: A first calculation submodule, configured for the second participant to calculate a first center point distance between a local current center point and an updated center point; A second calculation submodule is used for the first participant to calculate the second center point distance between the local current center point and the updated center point, and send the second center point distance to the second participant; The summation submodule is used by the second participant to calculate the sum of the distance between the first center point and the distance between the second center point.

Citation Information

Patent Citations

  • Safe hybrid federal learning framework and method for removing a third party

    CN113689003A

  • Multi-party transverse federation security aggregation method and system and computer storage medium

    CN117852082A