A legendre-kan encryption reasoning method based on mode component homomorphism
By constructing the Legendre-KAN network and utilizing GPU parallel computing, combined with the modular component homomorphic algorithm, the problem of low computational efficiency of homomorphic encryption technology in deep learning inference is solved, achieving efficient and secure data privacy protection and meeting the high-precision computational needs of deep learning models.
Patent Information
- Application Number
- CN202510513100.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-23
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2045-04-23
AI Technical Summary
Existing homomorphic encryption technologies suffer from low computational efficiency and insufficient support for floating-point operations during deep learning inference, failing to meet all the computational needs of neural networks. Furthermore, traditional algorithms are inefficient and cannot meet the demands for high efficiency and real-time performance in real-world scenarios.
We adopt the Legendre-KAN cryptographic inference method based on modular component homomorphism. By constructing the Legendre-KAN network and utilizing GPU parallel computing strategy, we combine the modular component homomorphism algorithm for cryptographic inference. This method supports floating-point operations and high-precision calculations, avoiding the computational complexity and nonlinearity defects of traditional methods.
It improves computational efficiency, supports high-precision floating-point operations, reduces computational costs and storage overhead, and ensures the security and efficiency of data privacy in an encrypted environment.
Smart Images

Figure CN120449181B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of information security, and more particularly to a Legendre-KAN encryption reasoning method based on a modular component homomorphism. BACKGROUND
[0002] With the surge in data volume, the development of algorithms and the improvement of computing power, deep learning has been widely applied in medical diagnosis, facial recognition, credit risk assessment and other fields. Currently, many operators adopt the "Deep Learning as a Service" (DLaaS) mode, which regards deep learning as a cloud computing service, allowing users to use pre-configured models for prediction through the cloud platform. However, this mode usually requires the cloud service provider to have non-encrypted access to user data, resulting in the risk of data exposure and privacy leakage. Therefore, how to protect data privacy when using deep learning services has become a problem to be solved.
[0003] Existing privacy protection schemes, such as data desensitization and encrypted storage, can reduce the risk of data leakage to some extent, but cannot protect data privacy during computation. Therefore, homomorphic encryption technology has emerged. This technology allows direct computation on encrypted data without decryption, thereby ensuring data privacy and security during computation. Although homomorphic encryption can effectively protect user data privacy and ensure data security during storage, transmission and computation, its computational efficiency is still a bottleneck restricting its widespread application. The existing homomorphic encryption technology has high computational complexity and slow operation speed, especially in the deep learning model reasoning process, the computational cost is expensive. The existing homomorphic encryption method applied to convolutional neural networks has the following disadvantages: 1. Low computational efficiency: the existing homomorphic encryption technology has a large computational overhead in the application of deep learning tasks, especially in the convolutional neural network (CNN) inference process. Convolution and pooling operations require a large amount of computing resources, and these operations are very complex when implemented in a homomorphic encryption environment, resulting in low efficiency. 2. Insufficient support for floating-point number operations: some existing homomorphic encryption schemes cannot support floating-point number operations required in neural networks, limiting their direct application in an encrypted environment and failing to meet the full operation requirements of neural networks. 3. Limitations of homomorphic encryption algorithms: Currently, many deep learning methods based on homomorphic encryption rely on general-purpose homomorphic encryption algorithms developed by foreign countries (such as Paillier, BFV, CKKS, etc.). These algorithms are inefficient in neural network applications and cannot meet the demand for efficiency and real-time performance in practical scenarios.
[0004] Therefore, how to improve the computational efficiency of homomorphic encryption technology in deep learning inference is a problem that needs to be solved by those skilled in the art. SUMMARY
[0005] Therefore, the present application provides a Legendre-KAN encryption reasoning method based on a modulus component homomorphism, which is a privacy protection reasoning method based on a full homomorphic encryption and a KAN neural network and is suitable for a deep learning service scenario that needs to protect user data privacy in a cloud computing environment.
[0006] In order to achieve the above object, the present application adopts the following technical solutions:
[0007] A Legendre-KAN encryption reasoning method based on a modulus component homomorphism comprises the following steps:
[0008] Step 1: constructing a Legendre-KAN network based on a KAN structure of Legendre polynomials;
[0009] Step 2: collecting an image sample set to train the Legendre-KAN network and obtain a Legendre-KAN model;
[0010] Step 3: encrypting a to-be-predicted image to obtain ciphertext data;
[0011] Step 4: performing parallel reasoning on the ciphertext data by using the Legendre-KAN model in a GPU and adopting a modulus component homomorphism algorithm to obtain an encryption result;
[0012] Step 5: decrypting the encryption result to obtain an image prediction result.
[0013] Preferably, a Legendre-KAN network with a depth of 2 layers is constructed based on a Kolmogorov-Arnold theorem, the Legendre-KAN network comprises a plurality of neural network layers connected in sequence, an output of a last layer of neural network is taken as an image prediction result of the Legendre-KAN network, and a learnable activation function is realized by using Legendre polynomials; each layer of neural network in the Legendre-KAN network comprises a basic linear branch, a Legendre polynomial branch and a feature fusion layer;
[0014] The basic linear branch comprises a basic activation layer and a basic linear transformation layer, the basic activation layer performs nonlinear activation on an input by using a basic activation function to obtain an activated feature, and the basic linear transformation layer performs linear transformation on the activated feature by using a basic weight matrix to obtain a basic output;
[0015] The Legendre polynomial branch includes a normalization layer, a recursive layer, a reshaping layer, and a polynomial nonlinear transformation layer; the normalization layer performs normalization processing on the input, the recursive layer recursively generates the Legendre polynomial basis functions from 0 order to a preset order according to the normalized input, to form a three-dimensional basis function matrix, the reshaping layer reshapes the three-dimensional basis function matrix into a two-dimensional basis function matrix, and the polynomial nonlinear transformation layer performs nonlinear transformation on the two-dimensional basis function matrix by using a polynomial weight matrix, to generate a polynomial output;
[0016] The feature fusion layer includes a splicing layer, a batch normalization layer, and a basic activation layer; the splicing layer element-wise adds the basic output and the polynomial output to obtain a fusion output, the batch normalization layer performs normalization processing on the fusion output, and the basic activation layer linearly activates the normalized fusion output by using a basic activation function, to generate the output of the current layer and serve as the input of the next layer of neural network.
[0017] Preferably, the Legendre-KAN network is obtained by replacing the B-spline activation function in the Spline-KAN network with the Legendre polynomial basis function defined on the interval [-1, 1]; the polynomial nonlinear transformation layer performs nonlinear transformation on the input by linear combination of the Legendre polynomial basis function, to enhance the expression ability of the network, and is expressed as:
[0018]
[0019] wherein, L i (x) represents the i-th order of the Legendre polynomial basis function, c i represents a learnable parameter; in the gradient descent process of training the Legendre-KAN network, the problem of gradient explosion caused by excessively large parameter initialization is avoided, and a smaller learnable parameter c i is used, which can effectively prevent the positive and negative coefficients of the basis function from being too large and affect the stability of network training;
[0020] Preferably, the batch normalization layer is expressed as:
[0021]
[0022] wherein, x represents an input vector; μ represents the mean of the input vector, H represents the total number of elements of the input vector in a batch; σ 2 represents the variance of the input vector; ∈ is a set constant; γ and β represent learnable scaling parameters and offset parameters, respectively.
[0023] Preferably, the basic activation function used by the basic activation layer in the feature fusion layer is a linear activation form of x 2, x represents input, since homomorphic encryption does not directly support nonlinear operations in neural networks, SiLU(x) is approximated as an activation function using x 2 to enable approximate nonlinear calculation of neural networks in ciphertext state.
[0024] Preferably, the output of each layer of the neural network in the Legendre-KAN network is represented as:
[0025] output=base_activation(BN(base_output+poly_output))
[0026] Wherein, output represents the output of the current neural network layer; base_activation represents the base activation function; BN represents batch normalization; base_output represents the base output; poly_output represents the polynomial output.
[0027] Preferably, the Legendre-KAN network is trained on a server to obtain a Legendre-KAN model.
[0028] Preferably, in step 3, the client generates a user master key, and generates a user sub-key according to the user master key, the user sub-key including a secret key, a public key and a calculation key, and the to-be-predicted image is encrypted according to the public key; in step 4, the encrypted inference is performed by using the modular component homomorphic algorithm according to the calculation key in the user sub-key. The encryption of the to-be-predicted image obtains ciphertext data, which can ensure the privacy protection of the image in the transmission and processing process.
[0029] Preferably, the process of generating the user master key and the user sub-key by the client includes:
[0030] Step 311: The client randomly generates a user key Key(U)∈{0,1} 1 as a user master key;
[0031] Step 312: The secret key SK is generated by using a key derivation function according to the user master key, the secret key SK including a position base W, a projection base B, a magnification a and a proportion factor Δ of floating point precision;
[0032] Step 313: The secret key SK is used to encrypt the floating point 1.0 to obtain a ciphertext matrix pk M , which is taken as a public key PK; M
[0033] Step 3131: A first random number is selected to construct a matrix pk′ M ={r (i,j) |1≤i≤n,1≤j≤t,0≤r(i,j) <b i}, matrix pk′ M The elements in the i-th row do not exceed b i b i Let r represent the i-th component in the projection basis B, and let r represent the first random number.
[0034] Step 3132: Generate a second random number s>b n b n Let A represent the nth component in the projection basis B. Calculate A = 1.0 × a + s based on the magnification factor a.
[0035] Step 3133: Let A ≡ a i modb i , 1≤1≤n, calculate a i Use the n elements of the positional basis W as the matrix pk′ M The indices of the n row vectors in the matrix pk′ M elements in Replace with a i Obtain the ciphertext matrix PK M ;
[0036] Step 314: Combine the projection basis B, magnification a, and scaling factor Δ to form the computation key EK. The modulus component homomorphic algorithm uses the computation key EK for homomorphic operations.
[0037] Preferably, the client encrypts the image to be predicted using the public key, and then sends the encrypted data and the calculation key to the server. The server loads the trained Legendre-KAN model and the encrypted data into the GPU for parallel inference to obtain the encrypted result, and then feeds the encrypted result back to the client. The client decrypts the encrypted result using the secret key to obtain the image prediction result.
[0038] Preferably, when the client uses the public key to encrypt the image to be predicted, it first normalizes the image to be predicted, and then uses the public key to encrypt the pixel data of the image to be predicted pixel by pixel. The encryption method is to perform a multiplication operation between the public key and each pixel data to obtain the ciphertext data Ct.
[0039] Preferably, the process by which the server uses the Legendre-KAN model, ciphertext data, and computation key to perform inference and obtain the encryption result is as follows:
[0040] Step 41: The server expands the encrypted data Ct into a one-dimensional matrix ct = [ct1 ... ct2] n The one-dimensional matrix ct is encrypted using a modular component homomorphic algorithm based on the computation key EK, thereby obtaining the set of modular components for each ciphertext in the one-dimensional matrix ct. T denotes the transpose of a one-dimensional matrix, m denotes the mth ciphertext in a one-dimensional matrix ct, c p represents a modular component constituting the mth ciphertext, and M represents the number of modular components.
[0041] Step 42: inputting the modular component set of each ciphertext and the basic weight matrix and the polynomial weight matrix obtained after model training into the Legendre-KAN model on the GPU, performing matrix multiplication and addition operations in parallel through the CUDA core, and obtaining an encrypted result.
[0042] Preferably, the client decrypts the encrypted result according to the secret key to obtain an image prediction result.
[0043] Preferably, the Legendre-KAN network is trained and optimized using a loss function with a penalty term.
[0044] According to the above technical solution, compared with the prior art, the present application provides a Legendre-KAN encryption reasoning method based on modular component homomorphism, which constructs an efficient, secure and accurate homomorphic encryption reasoning system through multi-dimensional collaborative optimization, aiming to meet the needs of data privacy protection, and focuses on solving the inherent contradiction that the accuracy loss, calculation delay and privacy risk are difficult to balance in the traditional scheme. Specifically, the Legendre orthogonal polynomial is introduced to reconstruct the KAN network, the spline function in the KAN network is replaced by the Legendre polynomial, the approximation ability of linear combination and the low-order approximation completeness are utilized to avoid the segmented nonlinearity defect of the traditional B-spline function, and the influence of division and other non-homomorphic calculation operations is avoided, the modular component homomorphic encryption library is adapted and modified to ensure that the deep learning model reasoning can be efficiently performed in the encrypted environment; the encryption algorithm based on modular component homomorphism is adopted, the independent characteristics between each modular component are utilized, and the strategy of GPU parallel computation reasoning is combined to speed up the process of ciphertext reasoning, and the powerful computing power of the GPU accelerates the processing of ciphertext data; in the whole model reasoning process of the present application, the data is always in an encrypted state, which effectively avoids the problem of privacy leakage.
[0045] The present application combines homomorphic encryption and Legendre-KAN model to effectively solve the following technical problems:
[0046] 1. Improve the calculation efficiency: the modular component operation in the modular component homomorphic encryption algorithm is independent, which has a natural parallel advantage, based on this algorithm, the GPU parallel computing strategy can be used to utilize the powerful computing power of the GPU to significantly improve the ciphertext calculation efficiency, compared with the traditional convolutional neural network (CNN), the Legendre-KAN model has fewer parameters, thereby enabling the deep learning reasoning in the encrypted environment to be processed with lower calculation cost and storage overhead.
[0047] 2. Solve the precision problem: the modular component homomorphic encryption algorithm supports floating point operation and floating point coding, and can realize ciphertext calculation of 19 digits after the decimal point, and fully support the high precision calculation demand of model inference under ciphertext. BRIEF DESCRIPTION OF DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced below. 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 on the basis of the provided drawings.
[0049] Figure 1 The flowchart of the Legendre-KAN encryption inference method based on the modular component homomorphism provided by the present application is shown. DETAILED DESCRIPTION
[0050] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0051] The embodiment of the present application discloses a Legendre-KAN encryption inference method based on modular component homomorphism, as shown in Figure 1 The method comprises the following steps:
[0052] S1: Construct a Legendre-KAN network based on the KAN structure of Legendre polynomials;
[0053] S2: Collect image sample set to train the Legendre-KAN network and obtain a Legendre-KAN model;
[0054] S3: The client generates public and private keys, encrypts the image to be predicted, obtains ciphertext data, and transmits the calculation key and ciphertext data to the server; the public and private keys include user master key, secret key and calculation key;
[0055] S4: Deploy the trained Legendre-KAN model on the server, determine the model weight, and construct a ciphertext prediction network;
[0056] S5: Use the Legendre-KAN model to perform parallel inference on the ciphertext data in the GPU of the server using the modular component homomorphic algorithm, obtain the encryption result, and feed back the encryption result to the client;
[0057] S6: The client decrypts the encryption result to obtain an image prediction result.
[0058] Further, a Legendre-KAN network with a depth of 2 layers is constructed based on the Kolmogorov-Arnold theorem, to ensure the same structure in the training phase and the prediction phase, and to replace the original edge non-linear module (such as the traditional activation function ReLU, etc.) in the MLP with a learnable activation module based on the Legendre polynomial basis function. The Legendre-KAN network includes a plurality of neural network layers connected in sequence, and the output of the last neural network layer is taken as the image prediction result of the Legendre-KAN network. The Legendre-KAN network realizes a learnable activation function through the Legendre polynomial. Each layer of the Legendre-KAN network includes a basic linear branch, a Legendre polynomial branch, and a feature fusion layer.
[0059] The basic linear branch includes a basic activation layer and a basic linear transformation layer. The basic activation layer introduces preliminary nonlinearity to the input through a basic activation function, to obtain an activation feature. The basic linear transformation layer performs linear transformation on the activation feature through a basic weight matrix, to obtain a basic output.
[0060] The Legendre polynomial branch includes a normalization layer, a recursion layer, a reshaping layer, and a polynomial nonlinear transformation layer. The normalization layer performs normalization processing on the input, to map it to the interval [-1, 1]. Then, the recursion layer recursively generates Legendre polynomial basis functions from 0 order to a preset order according to the normalized input, to form a three-dimensional basis function matrix. The reshaping layer flattens and reshapes the three-dimensional basis function matrix into a two-dimensional basis function matrix. The polynomial nonlinear transformation layer performs nonlinear transformation on the Legendre basis functions in the two-dimensional basis function matrix through a polynomial weight matrix, to generate a polynomial output. The parameterized and learnable nonlinear mapping mechanism is constructed through the Legendre polynomial basis function, to form a nonlinear activation behavior that is adaptive to different tasks.
[0061] The feature fusion layer includes a splicing layer, a batch normalization layer (BatchNorm layer) and a basic activation layer. The splicing layer element-wise adds the basic output and the polynomial output to obtain a fusion output. The batch normalization layer normalizes the fusion output. The Batch Normalization is used to suppress gradient anomalies and improve training stability. The basic activation layer uses a basic activation function to linearly activate the normalized fusion output to generate the output of the current layer and serve as the input of the next layer of neural network. Since the fusion output exceeds the domain [-1, 1] of the Legendre polynomial basis function, the individual precision angle is caused. Therefore, the batch normalization layer is used to normalize the input in the Legendre polynomial branch. The batch normalization layer (Batch Normalization) of the feature fusion layer can enhance the overall training stability and accelerate the convergence.
[0062] Further, the Legendre-KAN network is obtained by using the Legendre polynomial basis function defined on the interval [-1, 1] to replace the B-spline activation function in the Spline-KAN network. The polynomial nonlinear transformation layer performs nonlinear transformation on the input through the linear combination of the Legendre polynomial basis function, enhances the network expression capability, and is expressed as:
[0063]
[0064] wherein L i (x) represents the i-th order of the Legendre polynomial basis function, c i represents a learnable parameter; in the gradient descent process of the Legendre-KAN network training, the gradient explosion problem caused by excessively large parameter initialization is avoided, and a smaller learnable parameter c i can effectively prevent the positive and negative coefficients of the basis function from being too large, and affect the stability of network training; through the linear combination of multiple Legendre polynomial basis functions, the nonlinear transformation can approximate any continuous function, thereby realizing the nonlinear mapping of the input features.
[0065] Further, the batch normalization layer learns the normalized learnable parameters in the training stage, and remains unchanged in the inference stage, which is particularly suitable for the homomorphic encryption scene, can effectively reduce the order of homomorphic encryption, and provides a new idea for realizing high-precision and high-efficiency homomorphic encryption; the batch normalization layer is expressed as:
[0066]
[0067] wherein x is an input vector; μ is the mean of the input vector, H represents the total number of elements of the input vector in a batch; σ 2is the variance of the input vector; ∈ is a small constant to prevent division by zero errors; γ and β are learnable scaling and shifting parameters to recover the expressivity of the model. Batch normalization layer has the following effects:
[0068] (1) Stabilize training: the base output base_output and the polynomial output poly_output can have different numerical ranges (especially the high-order terms of the polynomial branch can produce large fluctuations), and direct addition can cause the scale of the activation function input value to be unstable (such as too large or too small), gradient vanishing or explosion (large difference in gradient amplitude when backpropagation), and the batch normalization layer can constrain the numerical range after the fusion of the multi-branch to prevent gradient abnormalities;
[0069] (2) Accelerate convergence: the standardized feature distribution makes the optimization process more efficient;
[0070] (3) Avoid the problem of low individual accuracy.
[0071] Preferably, the base activation function used by the base activation layer in the feature fusion layer is a linear activation form of x 2 , x represents the input, since homomorphic encryption does not directly support nonlinear operations in neural networks, x 2 is used to approximate SiLU(x) as an activation function, so that the neural network in the ciphertext state can perform approximate nonlinear calculation;
[0072] The output of each layer of the neural network in the Legendre-KAN network is represented as:
[0073] output=base_activation(BN(base_output+poly_output))
[0074] Where, output represents the output of the current neural network layer; base_activation represents the base activation function; BN represents batch normalization; base_output represents the base output; poly_output represents the polynomial output.
[0075] Further, the Legendre-KAN network is trained on a server to obtain a Legendre-KAN model.
[0076] Further, the process of training the Legendre-KAN network is:
[0077] S21: receiving an input x;
[0078] S22: traversing the base linear branch, the Legendre polynomial branch and the feature fusion layer of each layer of the neural network;
[0079] S221: input x of the current layer is input to the base linear branch and the Legendre polynomial branch respectively;
[0080] S222: the base linear branch adopts the base activation function to activate the input x and performs linear transformation on the input x by using the base weight matrix base_weight, to obtain the base output base_output;
[0081] The Legendre polynomial branch normalizes the input x to the interval [-1, 1] to obtain x_normalized, to avoid numerical overflow or instability in high-order calculation, recursively generates the Legendre polynomial basis function legendre_basis from the 0th order to the polynomial_order (the order specified during training) according to the normalized input x_normalized, constructs a three-dimensional basis function matrix, reshapes the three-dimensional basis function matrix into a two-dimensional basis function matrix to match the dimensions of the polynomial weight matrix poly_weight, and then performs linear transformation on the Legendre polynomial basis function legendre_basis in the two-dimensional basis function matrix by using the polynomial weight matrix poly_weight, to obtain the polynomial output poly_output;
[0082] S223: the feature fusion layer elementwisely adds the base output base_output and the polynomial output poly_output to obtain the fused feature, adjusts the distribution of the fused feature by batch normalization, suppresses gradient anomaly, activates the normalized fused feature by using the base activation function, and obtains the output of the current layer;
[0083] S224: if the current layer is not the last layer, the output of the current layer is taken as the input of the next layer, and the process returns to S221; if the current layer is the last layer, the output is directly taken as the image prediction result and returned;
[0084] S23: output the image prediction result.
[0085] Further, the Legendre-KAN network is optimized by using a loss function with a penalty term, to reduce the influence of gradient explosion in the polynomial activation function. The loss function with a penalty term can be used for regularization or other constraint conditions, to help prevent model overfitting and improve the generalization ability of the model.
[0086] Furthermore, in S3, the client generates a user master key and a user subkey based on it. The user subkey includes a secret key, a public key, and a computation key. The image to be predicted is encrypted using the public key. In S4, a modular component homomorphic algorithm is used for encrypted inference based on the computation key from the user subkey. The secret key is used to generate the public key and is used in the decryption algorithm. The public key is used to encrypt plaintext and can be made public. Using the public key to encrypt the image to be predicted to obtain ciphertext data ensures privacy protection of the image during transmission and processing.
[0087] Furthermore, the process of the client generating the user master key and user subkey includes:
[0088] S311: The client randomly generates a user key Key(U)∈{0,1} 1 As the user's master key;
[0089] S312: Generate a secret key SK using a key derivation function based on the user's master key. The secret key SK consists of a positional basis W, a projection basis B, a magnification factor a, and a scaling factor Δ for floating-point precision.
[0090] The user's master key is used as a seed to derive and expand key material of sufficient length to generate the secret key; for example, the user generates a random string. The random string RS is encrypted using the user key Key(U) in SM4 (ECB mode) to obtain ciphertext C1. A number is formed by 10 bits, and n bits are selected to form a positional basis W = {w1, w2, ..., wn}. n},w i ∈[1,t],i=1,...,n, here This represents taking the smallest integer greater than or equal to ·, with the positional basis serving as the primary parameter of the secret key;
[0091] S313: The client uses the secret key SK to encrypt the floating-point number 1.0 to obtain the ciphertext matrix pk. M , pk the ciphertext matrix M As a public key PK;
[0092] S3131: Select the first random number to construct a matrix pk′ of size n×t. M ={r (i,j) |1≤i≤n,1≤j≤t,0≤r (i,j) <b i}, matrix pk′ M The elements in the i-th row do not exceed b i b i Let r represent the i-th component in the projection basis B, and let r represent the first random number.
[0093] S3132: Generate a second random number s>b n b n Let A represent the nth component in the projection basis B. Calculate A = 1.0 × a + s based on the magnification factor a.
[0094] S3133: Let A≡a i modb i , 1≤i≤n, calculate a i Use the n elements of the positional basis W as the matrix pk′ M The indices of the n row vectors in the matrix pk′ M elements in Replace with a i Obtain the ciphertext matrix PK M ;
[0095] S314: The projection basis B, magnification factor a, and scaling factor Δ form the computation key EK. The modulus component homomorphic algorithm uses the computation key EK for homomorphic operations. The scaling factor Δ participates in floating-point operations. By multiplying the model input in floating-point data form with the scaling factor Δ and rounding it to the nearest integer, the floating-point data is converted into integer form, realizing floating-point encoding. The converted integer is then used for addition or multiplication operations to achieve floating-point operations.
[0096] Furthermore, the client encrypts the image to be predicted using the public key, and then sends the encrypted data and the computation key to the server. The server loads the trained Legendre-KAN model and the encrypted data into the GPU for parallel inference to obtain the encrypted result, and then feeds the encrypted result back to the client. The client decrypts the encrypted result using the secret key to obtain the image prediction result.
[0097] Furthermore, the process by which the client encrypts the image to be predicted using the public key includes:
[0098] S321: The client reads the image to be predicted from the local device or a specified data source. The image to be predicted is a static single image or a frame from a dynamic video.
[0099] S322: Assuming the original size of the image to be predicted is 28×28, first normalize the image to be predicted, and then use the public key PK to encrypt the pixel data of the image to be predicted pixel by pixel. The encryption method is to multiply the public key PK with each pixel data once to obtain the ciphertext data Ct.
[0100]
[0101] ct represents the encrypted pixel data;
[0102] S323: Send the ciphertext data Ct and the calculation key EK to the server.
[0103] Further, the server uses the Legendre-KAN model and the ciphertext data to calculate the key to infer the encryption result, and the process is as follows:
[0104] Step 41: The server expands the ciphertext data Ct into a one-dimensional matrix ct = [ct1 … ct96] and encrypts the one-dimensional matrix ct using the modulus component homomorphic algorithm according to the calculation key EK to obtain a set of modulus components of each ciphertext in the one-dimensional matrix ct n T represents the transpose of the one-dimensional matrix, m represents the mth ciphertext in the one-dimensional matrix ct, cm represents the 96x4 modulus components constituting the mth ciphertext, and M represents 96x4, i.e., the number of modulus components. p
[0105] Step 42: The set of modulus components of each ciphertext and the basic weight matrix and the polynomial weight matrix obtained after model training are input into the Legendre-KAN model on the GPU, and matrix multiplication and addition operations are performed in parallel through CUDA cores to obtain the encryption result.
[0106] Suppose the ciphertext data is [1, 2, 3], and the ciphertext data is encrypted using the modulus component homomorphic encryption algorithm, 96 modulus bases are set, and 4 confusion positions are set. Then the ciphertext of ciphertext 1 after encryption is a one-dimensional matrix with a size of 96x4, and the ciphertexts of ciphertexts 2 and 3 are the same as that of ciphertext 1. For ciphertext 1; 96 modulus components are generated by performing modulus operation on 96 modulus bases, and each modulus component has 4 positions to be selected, and the other 3 positions are random numbers generated to confuse, thereby achieving the effect of encryption. The position where each component is stored is determined by the position base. The modulus components in corresponding positions are operated by homomorphic operation, and the operations of 96x4 modulus components are independent of each other, so that the GPU performs parallel operation and simultaneously calculates the operation process of all modulus components.
[0107] Further, the client decrypts the encryption result according to the secret key to obtain the image prediction result.
[0108] In one specific embodiment, a Legendre-KAN encryption inference method based on modulus component homomorphism includes the following steps:
[0109] S1, the server constructs a Legendre-KAN network with a depth of 2 layers;
[0110] S2, the server trains the Legendre-KAN network using an image sample set to obtain a Legendre-KAN model;
[0111] S3, the client generates a public and private key, including a user master key and a user sub-key, wherein the user master key is used to generate the user sub-key, and the user sub-key includes a secret key, a public key and a calculation key, the secret key is used to generate the public key and is used in the decryption algorithm, and the public key is used to encrypt the plaintext and can be public;
[0112] S4, the client encrypts the to-be-predicted image using the public key to obtain ciphertext data, ensuring privacy protection of the image in the transmission and processing process;
[0113] S5, the client sends the ciphertext data and the calculation key to the server;
[0114] S6, the server loads the pre-trained Legendre-KAN model and the ciphertext data into the GPU for parallel inference to obtain an encrypted result;
[0115] S7, the server transmits the ciphertext inference result back to the client, and the client decrypts the ciphertext inference result using the secret key to obtain an image prediction result.
[0116] Further, a Legendre-KAN network with a depth of 2 layers is constructed to ensure that the structure remains exactly the same in the training and prediction stages; in order to integrate the superior function approximation characteristics of Legendre polynomials into the KAN architecture, the Legendre polynomials defined on the interval [-1, 1] are used to replace the B-spline activation function used in the traditional Spline-KAN, and the Legendre polynomials as globally defined basis functions have the following advantages:
[0117] 1) Globality and smoothness: Unlike B-spline functions, Legendre polynomials are globally defined basis functions with smooth derivatives and good approximation ability. Through this globality, the computational complexity that may occur in encrypted computation of segmented functions is avoided, especially in homomorphic encryption, segmented nonlinear functions often lead to excessive computational overhead, and even cannot be directly encrypted;
[0118] 2) Efficient calculation adaptability: Legendre polynomials have strong adaptability in encrypted computation, especially suitable for homomorphic encryption scenarios. Traditional B-spline functions will cause computational bottlenecks due to the existence of non-homomorphic division operations, while the linear combination of Legendre polynomials can avoid such problems, thereby enabling effective calculation in an encrypted state;
[0119] 3) Low-order approximation completeness: Legendre polynomials have strong low-order approximation completeness and can effectively approximate complex functions at a lower order, which is particularly important for encrypted computation as it can reduce the computational cost of the encryption process.
[0120] Further, when the server calls the Legendre-KAN model for inference, the parallel computing capability of the GPU can be fully utilized to accelerate the matrix operations involved. The model is adapted and modified through the homomorphic algorithm of the modular component to support homomorphic operations. When performing operations between the ciphertext image and the plaintext weight, the semi-blind addition and semi-blind multiplication in the homomorphic encryption algorithm of the modular component are used to realize the mixed operation of ciphertext and plaintext. Since linear transformation is essentially matrix multiplication, these operations can be transferred to the GPU for execution, thereby significantly improving the computational efficiency. Specifically, the matrix multiplication operation of the input ciphertext data Ct and the weight matrix (self.base_weights and self.poly_weights) is performed on the GPU, which can utilize its highly parallelized computing architecture to accelerate these operations. Through the CUDA programming model, appropriate thread blocks and grids can be defined to decompose the matrix multiplication into smaller parallel or column multiplication tasks, which are then executed in parallel on multiple CUDA cores. This approach not only reduces the overhead of data transmission, but also maximizes the utilization of GPU computing resources.
[0121] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the device disclosed by the embodiments, since it corresponds to the method disclosed by the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part.
[0122] The above description of the disclosed embodiments enables a person skilled in the art to implement or use the present application. Various modifications to the embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A Legendre-KAN encrypted reasoning method based on modular component homomorphism, characterized in that, Includes the following steps: Step 1: Construct the Legendre-KAN network based on the Legendre polynomial KAN structure; Based on the Kolmogorov-Arnold theorem, a two-layer Legendre-KAN network is constructed. The Legendre-KAN network consists of several layers of neural networks connected in sequence, and the output of the last layer of the neural network is used as the image prediction result of the Legendre-KAN network. Each layer of the neural network includes a basic linear branch, a Legendre polynomial branch, and a feature fusion layer. The basic linear branch includes a basic activation layer and a basic linear transformation layer. The basic activation layer performs non-linear activation on the input through a basic activation function to obtain activation features. The basic linear transformation layer performs linear transformation on the activation features through a basic weight matrix to obtain the basic output. Legendre polynomial branches include a normalization layer, a recursive layer, a reshaping layer, and a polynomial nonlinear transformation layer; The normalization layer normalizes the input, the recursive layer recursively generates Legendre polynomial basis functions from order 0 to a preset order based on the normalized input, forming a three-dimensional basis function matrix, the reshaping layer flattens and reshapes the three-dimensional basis function matrix into a two-dimensional basis function matrix, and the polynomial nonlinear transformation layer uses the polynomial weight matrix to perform nonlinear transformation on the two-dimensional basis function matrix to generate a polynomial output. The feature fusion layer includes a splicing layer, a batch normalization layer, and a basic activation layer. The splicing layer adds the basic output and the multinomial output element by element to obtain the fused output. The batch normalization layer normalizes the fused output. The basic activation layer uses the basic activation function to linearly activate the normalized fused output to generate the output of the current layer, which is then used as the input of the next layer of the neural network. Step 2: Collect image sample sets to train the Legendre-KAN network and obtain the Legendre-KAN model; Step 3: Encrypt the image to be predicted to obtain ciphertext data; Step 4: In the GPU, the Legendre-KAN model is used to perform parallel inference on the ciphertext data using the modular component homomorphism algorithm to obtain the encryption result; the server uses the Legendre-KAN model, ciphertext data, and computed key to perform inference to obtain the encryption result. Step 41: The server unfolds the encrypted data Ct into a one-dimensional matrix. Based on the computation key EK, a modulo component homomorphic algorithm is used to encrypt the one-dimensional matrix ct, obtaining the set of modulo components for each ciphertext in the one-dimensional matrix ct. T represents the transpose of a one-dimensional matrix, m represents the m-th ciphertext in the one-dimensional matrix ct, and c p Let M represent the modulo component that makes up the m-th ciphertext, and M represent the number of modulo components. Step 42: Input the set of modulo components of each ciphertext and the basic weight matrix and multinomial weight matrix obtained after model training into the Legendre-KAN model on the GPU, and perform matrix multiplication and addition operations in parallel through the CUDA core to obtain the encryption result; Step 5: Decrypt the encrypted result to obtain the image prediction result.
2. The Legendre-KAN encrypted reasoning method based on modular component homomorphism according to claim 1, characterized in that, The batch normalization layer is represented as: ; in, Represents the input vector; This represents the mean of the input vector. H represents the total number of elements in the input vector in a batch; ϵ represents the variance of the input vector; ϵ is a constant. and These represent the learnable scaling and offset parameters, respectively.
3. The Legendre-KAN encrypted reasoning method based on modular component homomorphism according to claim 1, characterized in that, The basic activation function used in the feature fusion layer is of the linear activation form. , x represents the input; the output of each layer of the Legendre-KAN network is represented as: output=base_activation(BN(base_output+poly_output)) Where output represents the output of the current neural network layer; base_activation represents the base activation function; BN represents batch normalization; base_output represents the base output; and poly_output represents the polynomial output.
4. The Legendre-KAN encrypted reasoning method based on modular component homomorphism according to claim 1, characterized in that, The Legendre-KAN network is trained and optimized using a loss function with a penalty term.
5. The Legendre-KAN encrypted reasoning method based on modular component homomorphism according to claim 1, characterized in that, In step 3, the client generates a user master key and a user subkey based on the user master key. The user subkey includes a secret key, a public key, and a computation key. The image to be predicted is encrypted based on the public key. In step 4, the modular component homomorphic algorithm is used for encrypted inference based on the computation key in the user subkey.
6. The Legendre-KAN encrypted reasoning method based on modular component homomorphism according to claim 5, characterized in that, The process of generating user master keys and user subkeys includes: Step 311: Randomly generate a user key As the user's master key; Step 312: Generate a secret key SK using a key derivation function based on the user's master key. The secret key SK includes the positional basis W, the projection basis B, the magnification factor a, and the scaling factor for floating-point precision. ; Step 313: Encrypt the floating-point number 1.0 using the secret key SK to obtain the ciphertext matrix. ciphertext matrix As a public key PK; Step 3131: Select the first random number to construct a size of matrix ,matrix The elements in the i-th row do not exceed , Let r represent the i-th component in the projection basis B, and let r represent the first random number. Step 3132: Generate a second random number s>b n b n Let A represent the nth component in the projection basis B. Calculate A = 1.0 × a + s based on the magnification factor a. Step 3133: Let ,calculate Use the n elements of the positional basis W as the matrix. The indices of the n row vectors in the matrix will be used to... Replace the element in with Obtain the ciphertext matrix ; Step 314: Based on the projection datum B, magnification a, and scale factor Construct the computation key EK.
7. The Legendre-KAN encrypted reasoning method based on modular component homomorphism according to claim 5, characterized in that, The client encrypts the image to be predicted using the public key and sends the ciphertext data and the calculation key to the server. The server loads the trained Legendre-KAN model and the ciphertext data into the GPU for parallel inference, obtains the encryption result, and feeds the encryption result back to the client. The client decrypts the encrypted result using the secret key to obtain the image prediction result.
8. The Legendre-KAN encrypted reasoning method based on modular component homomorphism according to claim 5, characterized in that, When the client uses the public key to encrypt the image to be predicted, it first normalizes the image and then uses the public key to encrypt the pixel data of the image pixel by pixel. The encryption method is to multiply the public key with each pixel data to obtain the ciphertext data.
Citation Information
Patent Citations
Ciphertext convolutional neural network image classification method based on mode component homomorphism
CN116800906A