Homomorphic encryption privacy protection method for decision tree in cloud environment
By designing an optimized homomorphic encryption privacy protection method in the cloud environment and using low-order polynomial functions to approximate the step function of the decision tree, efficient training and reasoning of the decision tree under ciphertext is achieved, solving the problem of data sharing in the cloud environment. The problem of privacy leakage risk and high computational overhead improves the efficiency and security of data processing.
Patent Information
- Application Number
- CN202410849643.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-09-03
AI Technical Summary
In the field of artificial intelligence, there is a risk of privacy leakage during data sharing, especially in cloud environments. Traditional encryption methods are insufficient in providing security, and fully homomorphic encryption technology has high computational overhead, making it difficult to combine data usability and privacy. A balance between protection.
A homomorphic encryption privacy protection method for decision trees in a cloud environment is proposed. By optimizing the algorithm design, the computational overhead of operating on ciphertext data is reduced. A low-order polynomial function is used to approximate the step function of the decision tree, and during training and In the prediction phase, a lightweight interactive protocol is designed to achieve efficient training and reasoning of decision trees under ciphertext.
It improves the efficiency and security of data processing, ensures data privacy protection, reduces computational complexity and communication complexity, is suitable for enterprise architecture in cloud environments, and provides strong data privacy protection.
Smart Images

Figure CN118590213A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of data security, and in particular relates to a homomorphic encryption privacy protection method for a decision tree in a cloud environment. Background Art
[0002] In the wave of artificial intelligence, data collected by products and services has become a key driving force for technological development. Especially in the era of smart Internet, endpoint devices collect and analyze user behavior data and information about user interaction with products to achieve product intelligence and provide customized user experience. In order to achieve these functions, personal data stored in terminal devices needs to be accessed and processed by multiple servers. Although this processing method can greatly improve user experience and satisfaction, it also inevitably increases the risk of data privacy leakage.
[0003] Whether it is passwords, photos, texts or videos, any form of data leakage is absolutely intolerable. Therefore, the public is aware that strict measures must be taken to protect the security of personal privacy data and the protection of data managed by third-party service providers needs to be strengthened.
[0004] With the continuous advancement of technology, a variety of methods have been developed to protect the security of private data in order to minimize the potential risk of data leakage. The most basic strategy is to encrypt static data to ensure that the data is safe even if the database is illegally stolen. However, with the rapid development of cloud services, more and more applications can directly access plaintext data (that is, unencrypted data), which may make traditional encryption methods less reliable in providing security. Ideally, we expect all applications to run normally without accessing plaintext data. Homomorphic encryption technology, especially fully homomorphic encryption technology, provides technical possibilities for achieving this ideal state. It allows calculations to be performed directly on encrypted data without decrypting the data, which greatly enhances the balance between data usability and privacy protection.
[0005] Fully homomorphic encryption technology allows us to perform operations on encrypted data (i.e. ciphertext) without decryption. This operation is called "homomorphic computing". It ensures that the calculation result is consistent with the result of the same operation on unencrypted data (i.e. plaintext). Specifically, fully homomorphic encryption (FHE) supports addition and multiplication operations on ciphertext data, making polynomial calculations of arbitrary complexity possible. However, a major drawback of FHE is that it costs a lot to perform multiplication operations, including computing time and required storage space. Therefore, in practical applications, there are certain restrictions on the order of polynomials and the number of multiplications involved in homomorphic encryption calculations to ensure the feasibility and efficiency of the operation.
[0006] A decision tree is a tree structure that includes a root node, multiple internal nodes, and leaf nodes. The root node is at the top of the tree and contains all samples. The internal nodes represent a test of a certain attribute of the data, and according to the test results, the data is diverted to the next level of nodes, which can be further internal nodes or final leaf nodes. Each leaf node corresponds to a classification result, that is, they represent the final decision of the decision tree to classify the sample based on the given attribute.
[0007] 1. A complete public key encryption scheme (PKE) has the following three algorithms:
[0008] 1) Gen (key generation): with security parameter 1 λ As input, output (pk, sk), that is, public key pk and secret key sk. It is expressed as: Gen(1 λ )→(pk,sk).
[0009] 2) Enc (encryption): in plain text and public key pk as input, and output ciphertext c. Expressed as: Enc pk (m)→c.
[0010] 3) Dec (decryption): takes ciphertext c and key sk as input and outputs plaintext Expressed as: Dec sk (c)→m′.
[0011] Correctness: For a certain solution, if in Gen(1 λ ), for each key pair (pk, sk) and each plaintext Both: Pr[Dec sk (Enc pk If [(m)] = m = 1, then the solution is called correct.
[0012] 2. CPA Security:
[0013] For a public key encryption scheme ε = (Gen, Enc, Dec), if any adversary A has the following negligible function neg in the PPT, such that: Then ε is said to be CPA-secure.
[0014] 3. Fully homomorphic encryption scheme: A complete fully homomorphic encryption scheme ε = (Gen, Enc, Dec, Eval):
[0015] 1)(Gen,Enc,Dec): is PKE.
[0016] 2) Eval (homomorphic computation): using public key pk, circuit The ciphertext (c1, c2,..., c2) is used as input, and the ciphertext is output It is expressed as:
[0017] 4. Privacy protection protocol for two parties:
[0018] The protocol involves two parties, namely the client and the server, denoted by Client and Server respectively. The client has the input x, the server has no input (denoted as input ⊥), and both have the security parameter λ. The client and the server perform interactive operations in the interactive protocol (π = <Client, Server>). Executing the protocol on the client input x, the server input ⊥, and the security parameter λ is denoted as <Client(x), Server>. For an interactive protocol <Client, Server>, if Client and Server are within PPT and satisfy the following conditions:
[0019] Completeness: There exists a negligible function neg such that for all x ∈ A, such that:
[0020] Privacy: For every distinguisher within PPT selects plaintexts x0, x1 ∈ A of equal length, and there exists a negligible function neg such that for all such that:
[0021] Then this interactive protocol is said to be privacy-protected. Summary of the Invention
[0022] The purpose of the present invention is to solve the problem of privacy leakage risk faced in the process of data sharing, especially in the application in the field of artificial intelligence. The present invention proposes a new privacy protection decision tree scheme, which realizes the training and inference of decision trees under ciphertext. It includes the decision tree algorithm and privacy protection protocol in the training stage, and the decision tree algorithm and privacy protection protocol in the prediction stage.
[0023] Aiming at the problem that the fully homomorphic encryption technology provides a secure path but has high computational overhead, the present invention reduces the computational overhead of operations on ciphertext data through optimized algorithm design while maintaining the effectiveness of privacy protection.
[0024] The technical solution of the present invention is as follows: A homomorphic encryption privacy protection method for decision trees in a cloud environment, the method includes:
[0025] Decision tree algorithm and privacy protection protocol in the training stage
[0026] S1: Input stage: 1) Client C TPCall the key generation algorithm Gen(1 λ ), generate a public key pair (pk, sk);
[0027] 2) Client C TP Use the public key pk to identify each sample and its corresponding tags Encrypt and generate ciphertext data c x and
[0028] 3) Client C TP The ciphertext data Send to S TP ;
[0029] S2: Calculation phase: 1) Initialize the weight corresponding to node v All weights are initially And initialize the depth to 0;
[0030] 2) Define the training function DecisionTree_Train(). For each node v with depth depth=1,2,...max_depth, the server S TP and client C TP Through joint computing, based on encrypted data and C TP =pk (i.e. the server is based on The client is based on C TP =pk, the two collaborate to complete the training process), call the function DecisionTree_Train() to calculate and obtain the segmentation features of node v and threshold And the corresponding left and right child node weights and
[0031] 3) When node v is a leaf node, its label value v.leaf_value needs to be calculated;
[0032] S3: Output phase: 1) Server S TP Send the trained encrypted decision tree to client C TP ;
[0033] 2) Client C TP Use the private key sk to decrypt the encrypted decision tree, and finally get the plaintext decision tree T = (V, E);
[0034] Decision tree algorithm and privacy protection protocol in the prediction stage
[0035] P1: Input phase: 1) Client CPP Using the key generation function Gen(1 λ ) Generate a pair of public and private keys (pk, sk);
[0036] 2) Client C PP Encrypt the plaintext data x into ciphertext data c, and then send the ciphertext data c and the public key pk to the server S PP ;
[0037] P2: Calculation phase: Server S PP After receiving the ciphertext data c, starting from the root node of the decision tree, recursive calculation is performed according to the sub-algorithm Sub_DecisionTress_Predict(); for each node v, if v is not a leaf node, the results of the left child node and the right child node are calculated respectively, and the weighted sum is taken; if v is a leaf node, the label value v.leaf_value of the node is directly returned, and finally after the root node is calculated, the L-dimensional ciphertext data result is returned;
[0038] P3: Output phase: 1) Server S PP Send the calculated ciphertext result to client C PP ;
[0039] 4) Client C PP Use the private key sk to decrypt the ciphertext result result to get the plaintext result m resulf ;
[0040] 5) Client C PP By calculation Get the predicted label label.
[0041] Preferably, a low-order polynomial function is constructed in the training stage and prediction stage of the decision tree to approximate the step function of the decision tree; the low-order polynomial function is as follows:
[0042]
[0043] Where, for x∈[-5,5], w(x)>0, and Where Φ is a low-degree polynomial function used to approximate the step function, w(x) is the weight function, I0(x) is the step function, usually used to represent a step from 0 to 1, P n is a set of polynomial functions whose degree does not exceed the real number n, and p(x) is a function in P n The polynomial selected from the set is used to approximate the step function I0(x); In the set P of polynomial functions of degree not exceeding n n Find the polynomial p that minimizes the objective function.
[0044] Preferably, the decision algorithm of the calculation phase of step S22) in the training phase is as follows:
[0045] Input: Input dataset and weight W, the current depth is initialized to 0, node v; n samples and its corresponding tags Each sample The value range is [-1,1] k ,Label It is 1-hot encoding;
[0046] Output: A decision tree T = (V, E) with a depth of max_depth, where each node v∈V contains the following information: feature information v.feature, threshold v.θ, label information v.leaf_value; if v is a leaf node, v.left and v.right represent its left and right child nodes respectively;
[0047] Step 1: Check if the maximum depth has been reached
[0048] a. If the current depth depth reaches the maximum depth max_depth, execute step 2;
[0049] b. If the maximum depth is not reached, proceed to step 3;
[0050] Step 2: Set the label value of the leaf node
[0051] Calculate the label value v.leaf_value of the leaf node v as the label value that minimizes the cumulative weighted loss, that is, Among them, y x is the label corresponding to sample x, w x is the weight of sample x; It means finding the label with the largest cumulative value among all possible labels l;
[0052] Step 3: Select the best segmentation features and threshold
[0053] a. For each feature i and each threshold θ combination, calculate the weighted sum of the right child node and the left child node:
[0054]
[0055] Among them, Φ is based on the formula The obtained low-order polynomial is used to calculate the segmentation result of the sample;
[0056] b. Select the optimal feature v.featvre and threshold v.θ by calculating the Gini index or other evaluation indicators: ((v.feature, v.θ)←Gini({right[i,θ],left[i,θ]} i∈[k],θ∈S );
[0057] c. Update the weights and segmented sample sets based on the optimal features and thresholds:
[0058]
[0059] Among them, i * and θ * is the optimal feature index and threshold selected;
[0060] d. Recursive call Construct the right subtree;
[0061] e. Recursive call Construct the left subtree;
[0062] According to the training data set And initialize weights W to build a decision tree T with a depth of max_depth, which is used for subsequent classification or regression tasks in the prediction stage.
[0063] Preferably, the decision tree algorithm of the P2 calculation stage in the prediction stage is as follows:
[0064] Main algorithm DecisonTree_Predict():
[0065] Assume that T is a decision tree, where each node v includes: feature v.feature and threshold v.θ; v.leaf_value is the 1-hot encoded value of the label associated with v; v.left and v.right represent the left and right child nodes of v respectively; v is initialized to the root node of T;
[0066] Input: prediction feature vector x∈[-1,1] k , where k is the number of features;
[0067] Output: predicted value, y∈{0,1};
[0068] Step 1: Check if the node is a leaf node
[0069] a. If node v is a leaf node, execute step 2;
[0070] b. If node v is not a leaf node, go to step 3;
[0071] Step 2: Return the label value of the leaf node
[0072] Return the attribute v.leaf_value of node v as output y, where y is an L-dimensional ciphertext data. Take v and y as input and call the sub-algorithm Sub_DecisonTree_Predic();
[0073] Step 3: Calculate the predicted values of non-leaf nodes
[0074] a. Calculate Φ(x[v.feature]-v.θ), where Φ is the indicator function or activation function;
[0075] b. Recursively call DecisonTree_Predict(v.right,x) and multiply the result by Φ(x[v.feature]-v.θ).
[0076] c. Calculate Φ(v.θ-x[v.feature]), where Φ is the indicator function or activation function;
[0077] d. Recursively call DecisonTree_Predict(v.left, x) and multiply the result by Φ(v.θ-x[v.feature]).
[0078] e. Add the results of parts b and d to get the output y, which is an L-dimensional ciphertext data. Take v and y as input and call the sub-algorithm Sub_DecisonTree_Predic(); the main algorithm finally outputs an L-dimensional vector, which is used as the input of the sub-algorithm.
[0079] Sub-algorithm Sub_DecisonTree_Predict():
[0080] Input: a node v of decision tree T, L-dimensional ciphertext data c
[0081] Output: result
[0082] Step 1: Check if the node is a leaf node
[0083] a. If node v is a leaf node, go to step 2.
[0084] b. If node v is not a leaf node, go to step 3.
[0085] Step 2: Return the label value of the leaf node
[0086] Return the attribute v.leaf_value of node v as output result;
[0087] Step 3: Calculate the predicted values of non-leaf nodes
[0088] a. Calculate Φ(c[v.feature]-v.θ), where Φ is the indicator function or activation function.
[0089] b. Calculate Sub_DecisonTree_Predict(v.right, x) and multiply the result by Φ(c[v.feature]-v.θ);
[0090] c. Calculate Φ(v.θ-c[v.feature]), where Φ is the indicator function or activation function;
[0091] d. Calculate Sub_DecisonTree_Predict(v.left, x) and multiply the result by Φ(v.θ-c[v.feature]);
[0092] e. Add the results of parts b and d to get the output result.
[0093] The main algorithm directly uses data x, while the sub-algorithm uses encrypted ciphertext data. The main algorithm is suitable for common prediction tasks, while the sub-algorithm is used in privacy protection scenarios to ensure that predictions are achieved when both data and models are encrypted.
[0094] Preferably, the calculation process of the Gini index is as follows: the server first homomorphically aggregates the ciphertext data in the training data set into |S|·k·L, where |S| is the number of thresholds, k is the number of features, and L is the number of labels, and sends the aggregation result to the client; then, the client re-encrypts the threshold and features, and sends the ciphertext back to the server for the next round of collaborative calculation.
[0095] Compared with the prior art, the present invention has the following beneficial effects: Based on the CKKS fully homomorphic encryption algorithm, the present invention adopts a low-order approximate step function and a lightweight interactive protocol, and innovatively proposes a privacy-preserving decision tree scheme, which realizes efficient training and reasoning of decision trees under ciphertext, thereby improving the efficiency and security of data processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0096] Figure 1 is a flow chart of the method of the present invention;
[0097] Figure 2 It is the training stage of the safety decision tree of the present invention;
[0098] Figure 3 It is the prediction stage of the safety decision tree of the present invention;
[0099] Figure 4 This is a comparison chart of AUC and F1-Score. DETAILED DESCRIPTION
[0100] In order to enable those skilled in the art to better understand the technical solution of the present invention, the technical solution of the present invention is further described below with reference to specific examples.
[0101] The present invention can be applied to enterprise environments, especially in cloud environments. Focusing on the secure interaction between the client (microservice end) and the server, the present invention constructs a decision tree solution that is compatible with the enterprise architecture and has privacy protection capabilities. In this solution, the enterprise makes full use of the "data lake" in the cloud as a centralized storage center for multi-source data, while using the KMS (key management service) of the cloud service to manage and distribute the keys required for encryption. KMS is designed to be lightweight and secure. It ensures that the microservice end cannot directly access plaintext data, but can only perform calculations on encrypted data and generate encryption results, which are then decrypted through KMS. This innovative design not only meets the enterprise's technical needs for scalability, flexibility and security, but also provides strong protection for data privacy in a cloud environment, building a solid line of defense for the enterprise's data security.
[0102] The present invention proposes a design and application of a privacy-preserving decision tree algorithm based on fully homomorphic encryption (FHE) technology, a prediction algorithm and a privacy-preserving protocol based on a tree model, and a training algorithm and a privacy-preserving protocol. In these algorithms and privacy-preserving protocols, the data involved in the calculation are encrypted by the FHE algorithm.
[0103] Example 1
[0104] This embodiment will describe in detail the specific implementation steps of the algorithm, as well as how to train and reason about the decision tree on ciphertext data. Figure 1 As shown, a homomorphic encryption privacy protection method for decision trees in a cloud environment includes the following steps:
[0105] Step 1: Construct a low-degree polynomial to approximate the step function in the decision tree during the training and prediction phases of the decision tree
[0106] The core of this algorithm is to use low-order polynomials to approximate the step function "x<θ" in the decision tree to reduce the complexity of homomorphic computation. In order to construct a low-order polynomial to approximate the step function, we first consider the simplest scenario: a step function with a threshold of 0. Let's assume:
[0107]
[0108] The mean square integration method is used here, that is, the soft-setp function is converted into the solution of the following optimization problem: Where P nis a set of polynomial functions whose degree does not exceed the real number n. After standardizing the data, we constrain the data range to the interval [-1,1]. Therefore, it is sufficient to set the approximate interval to [-5,5]. Too small an interval will lead to excessive errors, while too large an interval will increase the complexity of the calculation. However, in most cases, the approximate error of the step function is unevenly distributed over the entire interval. Especially near the threshold, the approximate error is often the smallest. Therefore, in order to reduce the approximate error caused by this situation, the present invention introduces a weight function, thereby converting the optimization problem into the following problem: Where, for x∈[-5,5], w(x)>0, and
[0109] Selection of optimization method: For the above optimization problem, a common method is to use l ∞ The norm is used to approximate the polynomial, i.e., the Remez algorithm. However, in this embodiment, the mean square error (MSE) is selected to solve the optimization problem. Because the Remez algorithm may have numerical instability, which may cause "large fluctuations" in the polynomial, the use of the mean square error can effectively avoid this situation.
[0110] Step 2: Propose a decision tree algorithm and privacy protection protocol based on the training phase, see Figure 2 shown.
[0111] 1) Decision tree algorithm based on the training phase:
[0112] In the decision tree training algorithm, we use the formula The method can be used to obtain a low-degree polynomial to approximate the step function. The specific algorithm is:
[0113] Algorithm 1: Decision tree algorithm based on training phase
[0114] Here we use Represents the data set involved in the calculation, using represents a set of weights initialized to 1; k and L represent the number of features and labels respectively; S represents the set of all thresholds; Φ represents the value according to the formula The obtained low-degree polynomial; the parameter max_depth represents the depth of the decision tree, and depth is initialized to 0.
[0115] Input: n samples and its corresponding tags Each sample The value range is [-1, 1] k ,Label It is 1-hot encoding.
[0116] Output: A decision tree T = (V, E) with a depth of max_depth, where each node v∈V contains the following information: v.feature (feature information), v.θ (threshold), v.leaf_value (label information); if v is a leaf node, v.left and v.right represent its left and right child nodes respectively.
[0117] Step 1: Check if the maximum depth has been reached
[0118] a. If the current depth depth reaches the maximum depth max_depth, execute step 2.
[0119] b. If the maximum depth has not been reached, proceed to step 3.
[0120] Step 2: Set the label value of the leaf node
[0121] Calculate the label value v.leaf_value of the leaf node v as the label value that minimizes the cumulative weighted loss, that is, Among them, y x is the label corresponding to sample x, w x is the weight of sample x.
[0122] Step 3: Select the best segmentation features and threshold
[0123] a. For each feature i and each threshold θ combination, calculate the weighted sum of the right child node and the left child node:
[0125] Among them, Φ is based on the formula The obtained low-degree polynomial is used to calculate the segmentation results of the samples.
[0126] b. Select the optimal feature v.feature and threshold v.θ by calculating the Gini index or other evaluation indicators: ((v.feature, v.θ)←Gini({right[i,θ],left[i,θ]} i∈[k],θ∈S )
[0127] c. Update the weights and segmented sample sets based on the optimal features and thresholds:
[0128]
[0129] Among them, i * and θ * is the optimal feature index and threshold selected.
[0130] d. Recursive call Construct the right subtree.
[0131] e. Recursive call Construct the left subtree.
[0132] The core principle of the function DecisionTree_Train() is to build a decision tree model recursively and use a weighted method to optimize node splitting in the process. Specifically, the function first checks whether the maximum depth has been reached. If so, the current node is set as a leaf node and its label is determined according to the weight. Otherwise, the function traverses all features and thresholds and selects the best split point by calculating the weighted sum of the left and right subtrees. The basis for splitting each feature and threshold is to calculate the weighted sum of the left and right subtrees through a low-order polynomial Φ, and then select the optimal split point through the Gini index. After selecting the best split point, the function updates the sample weights and recursively calls itself to continue splitting the left and right child nodes. Finally, a decision tree with a depth of max_depth is generated, in which each node contains feature information, thresholds, and label values of leaf nodes. The weighted method ensures that the model can learn and classify more accurately when the data is unbalanced.
[0133]
[0134]
[0135] Through the above steps, the algorithm can And initialize weights W to build a decision tree T with a depth of max_depth, which is used for subsequent classification or regression tasks in the prediction stage.
[0136] 2) Decision tree privacy protection protocol during training:
[0137] Client input: n samples and its corresponding tags Each sample The value range is [-1, 1] k ,Label It is 1-hot encoding.
[0138] Client output: a decision tree T = (V, E) with a depth of max_depth, where each node v∈V contains the following information: v.featvre (feature information), v.θ (threshold), v.leaf_value (label information); if v is a leaf node, v.left and v.right represent its left and right child nodes respectively.
[0139] Protocol TP <C TP , S TP >The specific process is as follows: Represents the encrypted ciphertext data)
[0140] 1. Input stage:
[0141] C TP Use Gen(1 λ )Generate a public key pair: (pk, sk).
[0142] B C TP Encrypt each sample using pk and its tags Get the corresponding ciphertext data c x and and will Send to S TP .
[0143] 2. Calculation phase:
[0144] For each node v, here we use Represents the weight corresponding to v and initializes it to And initialize depth to 0; for nodes v with depth = 1, 2, ... max_depth, through the server and client C TP =pk joint calculation to obtain as well as (When v is a leaf node, v.leaf_value will also be calculated)
[0145] 3. Output stage:
[0146] S TP Send the trained encrypted decision tree (ciphertext decision tree CryT) to C TP , C TP Use sk to decrypt it and get the plaintext decision tree T = (V, E).
[0147] In the calculation phase of the decision tree privacy protection protocol during the training phase, the server (S TP ) performs homomorphic operations based on Algorithm 1. At the same time, the client (C TP) assists in processing some tasks, thereby reducing the overall computational complexity and achieving lightweight computing. Specifically, we implement homomorphic operations on ciphertext data (where the calculation of the Gini index is completed with the cooperation of the client). In order to calculate the Gini index, the server first homomorphically aggregates the ciphertext data in the training set into |S|·k·L (where |S| is the number of thresholds, k is the number of features, and L is the number of labels), and sends the aggregation result to the client. The client then re-encrypts these thresholds and features and sends the ciphertext back to the server for the next round of collaborative computing. This approach ensures that the computational burden of the client does not increase significantly due to the increase in the data set, and the server cannot access any sensitive plaintext information, thereby maintaining data security.
[0148] Step 3: Propose a decision tree algorithm and privacy protection protocol based on the prediction stage, see Figure 3 shown.
[0149] 1) Decision tree algorithm based on the prediction stage
[0150] We replace the step function I with the soft-step function Φ(x[v.feature]-v.θ) v,θ (x[v.feature]); then, traverse all paths in the decision tree and calculate the weighted combination of all leaf node values, where the value of each leaf node is a 1-hot (one-hot) encoding of the leaf node label; finally, an L-dimensional vector is calculated, in which each component corresponds to the probability value of a label, and the label with the highest probability value is output.
[0151] Algorithm 2 (main algorithm): Decision tree algorithm in the prediction stage
[0152] Assume that T is a decision tree, where each node v includes: v.feature (feature) and v.θ (threshold); v.leaf_value is the 1-hot encoded value of the label associated with v; v.left and v.right represent the left and right child nodes of v respectively; v is initialized to the root node of T.
[0153] Input: x∈[-1,1]k, where k is the number of features.
[0154] Output: predicted value, y∈{0,1}.
[0155] Step 1: Check if the node is a leaf node
[0156] a. If node v is a leaf node, go to step 2.
[0157] b. If node v is not a leaf node, go to step 3.
[0158] Step 2: Return the label value of the leaf node
[0159] Returns the attribute v.leaf_value of node v as output y, where y is an L-dimensional ciphertext data.
[0160] Step 3: Calculate the predicted values of non-leaf nodes
[0161] a. Calculate Φ(x[v.feature]-v.θ), where Φ is the indicator function or activation function.
[0162] b. Recursively call DecisonTree_Predict(v.right,x) and multiply the result by Φ(x[v.feature]-v.θ).
[0163] c. Calculate Φ(v.θ-x[v.feature]), where Φ is the indicator function or activation function.
[0164] d. Recursively call DecisonTree_Predict(v.left, x) and multiply the result by Φ(v.θ-x[v.feature]).
[0165] e. Add the above two results together to get the output y, which is an L-dimensional ciphertext data.
[0166] The core principle of the function DecisonTree_Predict() is to traverse the decision tree recursively to predict the input sample. At each non-leaf node, the function uses the indicator function Φ to calculate the feature value of the input sample and the threshold of the node, generate the weighted sum of the left and right subtrees, and thus determine the recursive direction of the next step. When recursing to a leaf node, the function returns the label value of the leaf node. In this way, DecisonTree_Predict() can effectively traverse the decision tree path according to the input sample, and finally output an L-dimensional vector, in which each component corresponds to the probability value of a label, and outputs the label with the highest probability value.
[0167]
[0168] Algorithm 3 (sub-algorithm): Sub-algorithm based on decision tree in prediction stage
[0169] Input: a node v of decision tree T, L-dimensional ciphertext data c
[0170] Output: result
[0171] Step 1: Check if the node is a leaf node
[0172] a. If node v is a leaf node, go to step 2.
[0173] b. If node v is not a leaf node, go to step 3.
[0174] Step 2: Return the label value of the leaf node
[0175] Returns the attribute v.leaf_value of node v as output result.
[0176] Step 3: Calculate the predicted values of non-leaf nodes
[0177] a. Calculate Φ(c[v.feature]-v.θ), where Φ is the indicator function or activation function.
[0178] b. Calculate Sub_DecisonTree_Predict(v.right, x) and multiply the result by Φ(c[v.feature]-v.θ).
[0179] c. Calculate Φ(v.θ-c[v.feature]), where Φ is the indicator function or activation function.
[0180] d. Calculate Sub_DecisonTree_Predict(v.left, x) and multiply the result by Φ(v.θ-c[v.feature]).
[0181] e. Add the above two parts of results to get the output result.
[0182] The core principle of the function Sub_DecisionTree_Predict() is to achieve the prediction of the decision tree model under the premise of protecting privacy. The function receives a node v of the decision tree T and L-dimensional ciphertext data c as input. If the node v is not a leaf node, the function uses the indicator function Φ to calculate the feature value in the ciphertext data c and the threshold v.θ of the node respectively, and generates the weighted sum of the left and right subtrees. Then, recursively call itself to process the left and right child nodes v.lef and v.right of the node respectively. When recursing to the leaf node, the function returns the label value v.leaf_value of the leaf node. In this way, Sub_DecisonTree_Predict() can traverse the decision tree layer by layer under the condition of encrypted data, and finally output the prediction result of the decision tree for the input ciphertext data.
[0183]
[0184] 2) Decision tree privacy protection protocol in the prediction stage
[0185] Client input: data x∈[-1, 1]k .
[0186] Client output: label l∈L.
[0187] Protocol PP <C PP , the specific process of SPP> is as follows:
[0188] 1. Input stage:
[0189] C PP Use Gen(1 λ )Generate a public key pair (pk, sk).
[0190] B C PP Encrypt the plaintext data x to get the ciphertext data c, and send c and pk to S PP .
[0191] 2. Calculation phase:
[0192] S PP After receiving c, recursive calculation is performed starting from the root node according to the sub-algorithm based on the decision tree in the prediction stage. After the root node completes the calculation, the L-dimensional ciphertext data result is returned.
[0193] 3. Output stage:
[0194] S PP Send the result to C PP , C PP Use sk to decrypt and get m result , and get the label
[0195] In protocol 1, a decision tree T is encrypted as follows: for each node v in T, first convert v.feature into 1-hot encoding, then use pk to encrypt v.feature, v.θ and v.leaf-value to obtain feature, θ and leaf_value, without encrypting v.left and v.right, because they are not related to the core of the model. In particular, in step 2 of protocol 1, we use the 1-hot encoding of the encrypted v.feature instead of directly using v.feature for calculation; finally, we return the ciphertext data of v.leaf_value instead of the plaintext data.
[0196] In addition, in some other applications, if the tree model used for prediction needs to be encrypted and protected, it is only necessary to fine-tune the parameters of the protocol in the prediction phase to convert it into a computing protocol that meets the requirements of encrypted data and encryption models.
[0197] For the privacy protection protocol of decision trees in the prediction phase, the protocol only considers two parties: the client holding the data and the server holding the (decision tree) model. In this protocol, the communication complexity is proportional to the size of the input data and is not affected by the size and depth of the decision tree. The protocol can be applied to various tree-based prediction models, such as the random forest algorithm, and ensures the security of both parties under the premise that both the data and the model are encrypted.
[0198] Step 4: Prove the security of the algorithms in the training and prediction phases
[0199] 1) Prediction stage: PP = <Client PP , Server PP > is a privacy-preserving protocol used in decision tree algorithms in the prediction phase, provided that the encryption scheme ε used is CPA-secure.
[0200] Proof: Let ε = (Gen, Enc, Dec, Eval) to represent the protocol PP = <Client PP , Server PP >, and assumes that ε is CPA-secure.
[0201] First, analyze the complexity of PP and prove that it is PPT. PP Given an input x∈[-1, 1] k , the following operations are performed: execute Gen once, execute Enc k times (corresponding to each feature in x), execute Dec L times (corresponding to the output result P res The weight of each label in ), and calculate the maximum value of these L values. Since the complexity of Gen, Enc, and Dec is poly(λ), we can conclude that Client PP It is PPT, and its complexity is proportional to the encryption input and decryption output. PP A fixed number of basic homomorphic operations (i.e., addition and multiplication) are performed on each internal node, and O(L) operations are performed on each leaf node. The complexity of each basic homomorphic operation is poly(λ). Therefore, we can conclude that Server PP It is PPT, and its complexity is O(m·L)·poly(λ).
[0202] Next, we prove that PP = <ClientPP , Server PP > is complete. It can be noted that PP homomorphically evaluates the same function as computed in Algorithm 2, so the completeness immediately follows from the correctness of the encryption scheme ε.
[0203] Finally, prove that PP = <Client PP , Server PP >Satisfy the privacy conditions in the privacy protection protocol. Assume that PP does not satisfy privacy protection, that is, there is a distinguisher in PPT It selects two plaintexts x0, x1∈A of equal length and a polynomial p(·). So that:
[0204]
[0205] In the following we prove that for a given An attacker A can be constructed to break the CPA-security of the encryption scheme ε. Attacker A participates in a chosen plaintext attack The process is as follows:
[0206] 1) After receiving pk, execute to get x0, x1, and send them to
[0207] 2) After receiving c x ←Enc pk (x b ) after the behavior is consistent with the Server PP When executing PP, the client receives PP (c x , pk) after the behavior is exactly the same.
[0208] 3) In the distinguisher Run on And output Results
[0209] Since x0 and x1 can be selected efficiently, and Server PP and D are both PPT, so attacker A is PPT. We use To indicate that In the process, the challenger selects bit b * When simulating the Server executed by A PP Because A's behavior is similar to that of Server in PP PP is completely consistent, so for each b * ∈{0,1}, all have:
[0210]
[0211] According to (1) and (2), we can get:
[0212]
[0213] So we can get:
[0214]
[0215] This contradicts the assumption, so privacy protection is satisfied. The proof is complete.
[0216] 2) Training phase: TP = <Client TP , Server TP > is the privacy-preserving protocol of Algorithm 1, provided that the encryption scheme ε used is CPA-secure.
[0217] Proof: Let ε = (Gen, Enc, Dec, Eval) represent the protocol TP = <Client TP , Server TP ), assuming that ε is CPA-secure.
[0218] First, we analyze the complexity of TP, which can be proved to be PPT. We use k, L, m, |S| to represent the number of features, the number of labels, the number of decision tree nodes, and the number of thresholds considered, and λ is a security parameter. First, we analyze Server TP In the protocol, Server TP Perform nL homomorphic multiplications and n homomorphic additions on each leaf and each internal node and each threshold and feature, plus an additional k homomorphic multiplications and additions to process the data from the client. TP , and each homomorphic operation is polynomial time with respect to the security parameter λ. Therefore, Server TP It is a PPT, and the overall complexity is O(n·m·|S|·k·L)·poly(λ). Then analyze Client TP .client TP In the calculation phase, O(|S|·kL) Dec(·) operations and O(k) Enc(·) operations are performed, and the Gini of the plaintext data is calculated. The time to calculate each Dec(·) and Enc(·) is at the polynomial level with respect to the security parameter λ, and the time to calculate the Gini of the plaintext data is O(|S|·k·L). Therefore, Client TP The complexity of the training phase is O(m·|S|·k·L)·poly(λ). In addition, ClientTP The overall computation process (including key generation, input encryption, and output decryption) is polynomial time with respect to its input and security parameters, so the Client TP It is from PPT. Finally, we analyzed the complexity of communication. O(|S|·k·L) ciphertexts are transmitted at each node, so the communication complexity is O(m·|S|·k·L)·poly(λ).
[0219] Next, we prove that TP=(Client TP , Server TP > is complete. It can be noted that <Client TP , Server TP > Homomorphically computes the same function as in Algorithm 1. Therefore, completeness follows directly from the correctness of the encryption scheme ε.
[0220] Finally, we prove that TP satisfies the privacy condition in the privacy protection protocol. Assume that the privacy of TP does not hold, that is, there exists a distinguisher of PPT It selects equal-length ciphertext pairs (x0, y0), (x1, y1)∈A, and a polynomial p(·) for infinite So that:
[0221] In the following we prove that for a given It is possible to construct an attacker A that breaks the CPA-security of the encryption scheme ε. Attacker A participates in the following way
[0222] 1) After receiving pk, execute to get (x0, y0), (x1, y1), and send them to Chal.
[0223] 2) After receiving CTXT←Enc pk (x b ,y b ) after that, except for each TP Sent to Client TP Information (where i∈[k], θ∈S), A’s other behaviors must be consistent with Server TP When executing TP and TP Received The behavior is exactly the same as that of pk. For this information, attacker A responds as follows: A uniformly randomly samples i←[k] and θ←S, and calculates Enc pk (i, θ), and send this ciphertext to Server TP .
[0224] 3) In Run on And output result.
[0225] Attacker A is PPT, because (x0, y0), (x1, y1) can be sampled efficiently, and Server TP and All are PPT. Assume that TP′ is a protocol that is identical to TP, except for the client TP Each query of is answered by encrypting a randomly sampled (i, θ)←[k]×S. We use To indicate that When Server A simulates TP According to the definition of TP', for each b∈{0,1}, we have:
[0226]
[0227] In addition, the CPA-security of ε ensures that the server’s view in TP and TP are computationally indistinguishable. Equation (6) can be further expressed as:
[0228]
[0229] Combining equations (6) and (7), we can obtain:
[0230]
[0231] So we can get:
[0232]
[0233] This contradicts the assumption, so TP satisfies privacy protection. The proof is complete.
[0234] Experimental Evaluation
[0235] This implementation selects four classic UCI datasets: Cancer, Digits, Iris, and Wine to evaluate the performance of the proposed privacy-preserving decision tree algorithm and protocol. The required low-order polynomials, these data sets need to be normalized. The experimental evaluation focuses on two core performance indicators: accuracy and computational efficiency. In terms of accuracy, F1-score and AUC are used as evaluation criteria. In terms of computational efficiency, the operation time of the algorithm and protocol is specifically quantified. Through such evaluation, the performance of the proposed method in practical applications is fully reflected.
[0236] In order to comprehensively evaluate the effectiveness and efficiency of our proposed method, we selected two representative existing privacy-preserving decision tree schemes, PrivaTree and SecDT, for detailed comparison: the dataset uses 5-fold cross validation (the dataset is evenly divided into 5 equal parts, also called folds. In each iteration, one fold is selected as the validation set, and the remaining 4 folds are used as the training set. Repeat 5 times, and select a different fold as the validation set each time). In order to more comprehensively and objectively compare the accuracy of the algorithm in this article with the other two models, decision trees with depths of 1, 2, 3, 4, and 5 are selected for comparison, and repeated 10 times. The results are shown in the figure. Figure 4 As shown:
[0237] As can be seen from the above figure, the algorithm proposed in this paper is better than PrivaTree and SecDT schemes in terms of accuracy (F1-Score and AUC) and has better robustness. Specifically, the average AUC on the four data sets is 0.92 for our algorithm, 0.845 for PrivaTree scheme, and 0.842 for SecDT scheme; in terms of average F1-Score, our algorithm is 0.77, 0.741 for PrivaTree scheme, and 0.755 for SecDT scheme. In general, the algorithm proposed in this invention is better than PrivaTree and SecDT schemes in terms of accuracy and robustness.
[0238] In summary, the present invention proposes a privacy-preserving decision tree algorithm based on CKKS fully homomorphic encryption technology, which effectively replaces complex nonlinear operations by adopting low-order approximate step functions and lightweight interactive protocols, and realizes the training and reasoning of decision trees in a ciphertext state. In the training stage, the present invention designs a lightweight interactive protocol, which realizes the collaboration between different computing nodes through encrypted gradient exchange and parameter update, significantly reduces the calculation time, and avoids the exposure of the original data. In the prediction stage, a protocol that does not require interaction is adopted to ensure that the server side cannot access the plaintext data, providing a high degree of security for the client while maintaining high computing efficiency. The server side cannot access the plaintext data, providing a high degree of security for the client while maintaining high computing efficiency.
[0239] The above embodiments are merely examples for the purpose of clear explanation, and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the present invention.
Claims
1. A homomorphic encryption privacy protection method for decision trees in a cloud environment, characterized in that: The method comprises: Decision tree algorithm and privacy protection protocol in the training phase S1: Input phase: 1) Client C TP Call the key generation algorithm Gen(1 λ ), generate a public key pair (pk, sk); 2) Client C TP Use the public key pk to identify each sample and its corresponding tags Encrypt and generate ciphertext data c x and 3) Client C TP The ciphertext data Send to S TP ; S2: Calculation phase: 1) Initialize the weight corresponding to node v All weights are initially And initialize the depth to 0; 2) Define the training function DecisionTree_Train(). For each node v with depth depth=1,2,…max_depth, the server S TP and client C TP Through joint computing, based on encrypted data and C TP =pk, call the function DecisionTree_Train() to calculate and obtain the segmentation features of node v and threshold And the corresponding left and right child node weights and 3) When node v is a leaf node, its label value v.leaf_value needs to be calculated; S3: Output phase: 1) Server S TP Send the trained encrypted decision tree to client C TP ; 2) Client C TP Use the private key sk to decrypt the encrypted decision tree, and finally get the plaintext decision tree T = (V, E); Decision tree algorithm and privacy protection protocol in the prediction stage P1: Input phase: 1) Client C PP Using the key generation function Gen(1 λ ) Generate a pair of public and private keys (pk, sk); 2) Client C PP Encrypt the plaintext data x into ciphertext data c, and then send the ciphertext data c and the public key pk to the server S PP ; P2: Calculation phase: Server S PP After receiving the ciphertext data c, starting from the root node of the decision tree, recursive calculation is performed according to the sub-algorithm Sub_DecisionTress_Predict(); for each node v, if v is not a leaf node, the results of the left child node and the right child node are calculated respectively, and the weighted sum is taken; if v is a leaf node, the label value v.leaf_value of the node is directly returned, and finally after the root node is calculated, the L-dimensional ciphertext data result is returned; P3: Output phase: 1) Server S PP Send the calculated ciphertext result to client C PP ; 2) Client C PP Use the private key sk to decrypt the ciphertext result result to get the plaintext result m result ; 3) Client C PP By calculation Get the predicted label label.
2. According to claim 1, the homomorphic encryption privacy protection method for decision trees in a cloud environment is characterized in that: In the training and prediction stages of the decision tree, a low-order polynomial function is constructed to approximate the step function of the decision tree; the low-order polynomial function is as follows: Where, for x∈[-5,5], w(x)>0, and Where Φ is a low-degree polynomial function used to approximate the step function, w(x) is the weight function, I0(x) is the step function, usually used to represent a step from 0 to 1, P n is a set of polynomial functions whose degree does not exceed the real number n, and p(x) is a function in P n The polynomial selected from the set is used to approximate the step function I0(x); In the set P of polynomial functions of degree not exceeding n n Find the polynomial p that minimizes the objective function.
3. The homomorphic encryption privacy protection method for decision trees in a cloud environment according to claim 2 is characterized in that: The decision algorithm of step S2 2) calculation phase in the training phase is as follows: Input: Input dataset and weight W, the current depth is initialized to 0, node v; n samples and its corresponding tags Each sample The value range is [-1,1] k ,Label It is 1-hot encoding; Output: A decision tree T = (V, E) with a depth of max_depth, where each node v∈V contains the following information: feature information v.feature, threshold v.θ, label information v.leaf_value; if v is a leaf node, v.left and v.right represent its left and right child nodes respectively; Step 1: Check if the maximum depth has been reached a. If the current depth depth reaches the maximum depth max_depth, execute step 2; b. If the maximum depth is not reached, proceed to step 3; Step 2: Set the label value of the leaf node Calculate the label value v.leaf_value of the leaf node v as the label value that minimizes the cumulative weighted loss, that is, Among them, y x is the label corresponding to sample x, w x is the weight of sample x; Step 3: Select the best segmentation features and threshold a. For each feature i and each threshold θ combination, calculate the weighted sum of the right child node and the left child node: Among them, Φ is based on the formula The obtained low-order polynomial is used to calculate the segmentation result of the sample; b. Select the optimal feature v.feature and threshold v.θ by calculating the Gini index or other evaluation indicators: ((v.deature,v.θ)←Gini({right[i,θ],left[i,θ]} i∈[k],θ∈S ); c. Update the weights and segmented sample sets based on the optimal features and thresholds: Among them, i * and θ * is the optimal feature index and threshold selected; d. Recursive call Construct the right subtree; e. Recursive call Construct the left subtree; According to the training data set And initialize weights W to build a decision tree T with a depth of max_depth, which is used for subsequent classification or regression tasks in the prediction stage.
4. The homomorphic encryption privacy protection method for decision trees in a cloud environment according to claim 2 is characterized in that: The decision tree algorithm of the P2 calculation phase in the prediction phase is as follows: Main algorithm DecisonTree_Predict(): Assume that T is a decision tree, where each node v includes: feature v.feature and threshold v.θ; v.leaf_value is the 1-hot encoded value of the label associated with v; v.left and v.right represent the left and right child nodes of v respectively; v is initialized to the root node of T; Input: prediction feature vector x∈[-1,1] k , where k is the number of features; Output: predicted value, y∈{0,1}; Step 1: Check if the node is a leaf node a. If node v is a leaf node, execute step 2; b. If node v is not a leaf node, go to step 3; Step 2: Return the label value of the leaf node Return the attribute v.leaf_value of node v as output y, where y is an L-dimensional ciphertext data. Take v and y as input and call the sub-algorithm Sub_DecisonTree_Predict(); Step 3: Calculate the predicted values of non-leaf nodes a. Calculate Φ(x[v.feature]-v.θ), where Φ is the indicator function or activation function; b. Recursively call DecisonTree_Predict(v.right,x) and multiply the result by Φ(x[v.feature]-v.θ); c. Calculate Φ(v.θ-x[v.feature]), where Φ is the indicator function or activation function; d. Recursively call DecisonTree_Predict(v.left,x) and multiply the result by Φ(v.θ-x[v.feature]); e. Add the results of parts b and d to get the output y, which is an L-dimensional ciphertext data. Take v and y as input and call the sub-algorithm Sub_DecisonTree_Predic(); Sub-algorithm Sub_DecisonTree_Predict(): Input: a node v of decision tree T, L-dimensional ciphertext data c Output: result Step 1: Check if the node is a leaf node a. If node v is a leaf node, execute step 2; b. If node v is not a leaf node, go to step 3; Step 2: Return the label value of the leaf node Return the attribute v.leaf_value of node v as output result; Step 3: Calculate the predicted values of non-leaf nodes a. Calculate Φ(c[v.feature]-v.θ), where Φ is the indicator function or activation function; b. Calculate Sub_DecisonTree_Predict(v.right,x) and multiply the result by Φ(c[v.feature]-v.θ); c. Calculate Φ(v.θ-c[v.feature]), where Φ is the indicator function or activation function; d. Calculate Sub_DecisonTree_Predict(v.left,x) and multiply the result by Φ(v.θ-c[vf(eature]); e. Add the results of parts b and d to get the output result.
5. The homomorphic encryption privacy protection method for decision trees in a cloud environment according to claim 3 is characterized in that: The calculation process of the Gini index is as follows: the server first homomorphically aggregates the ciphertext data in the training dataset into |S|·k·L, where |S| is the number of thresholds, k is the number of features, and L is the number of labels, and sends the aggregation result to the client; then, the client re-encrypts the threshold and features and sends the ciphertext back to the server for the next round of collaborative calculation.
Citation Information
Cited By
CKKS three-way decision dynamic hierarchical encryption neural network training method and system
CN120834906A
