Legendre-KAN encryption reasoning method based on module component homomorphism

By building Legendre-KAN network and using GPU parallel computing and modulo component homomorphic algorithms, the problem of low computational efficiency of homomorphic encryption technology in deep learning inference is solved, and efficient and secure data privacy protection and high-precision calculation are achieved.

CN120449181AActive Publication Date: 2025-08-08BEIJING ELECTRONICS SCI & TECH INST
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510513100.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-23
Publication Date
2025-08-08
Estimated Expiration
2045-04-23

AI Technical Summary

Technical Problem

The existing homomorphic encryption technology has low computational efficiency and insufficient support for floating-point number operations in the deep learning inference process, which cannot meet all the computing needs of neural networks. Moreover, traditional homomorphic encryption algorithms are low in efficiency in convolutional neural networks, which cannot meet the requirements for high efficiency and real-time in actual scenarios.

Method used

The Legendre-KAN encryption inference method based on modulo component homomorphism is adopted. By building a Legendre-KAN network, GPU parallel computing and modulo component homomorphism algorithm are used for crypto-inference to ensure the privacy protection of data during transmission and processing, and the B-spline function is replaced by Legendre polynomials, optimizing the network structure to improve computing efficiency and accuracy.

Benefits of technology

It significantly improves computing efficiency, supports floating-point operations and high-precision computing, reduces computing costs and storage overhead, realizes efficient deep learning inference in an encrypted environment, and avoids privacy leakage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120449181A_ABST
    Figure CN120449181A_ABST
Patent Text Reader

Abstract

The invention discloses a Legendre-KAN encryption inference method based on module component homomorphism, and relates to the technical field of information security, and the method comprises the steps: 1, constructing a Legendre-KAN network based on a KAN structure of a Legendre polynomial; step 2, acquiring an image sample set to train the Legendre-KAN network to obtain a Legendre-KAN model; 3, encrypting the to-be-predicted image to obtain ciphertext data; 4, performing parallel reasoning on the ciphertext data in the GPU by using a Legendre-KAN model and a modular component homomorphic algorithm to obtain an encryption result; and 5, decrypting the encryption result to obtain an image prediction result. According to the method, the data can be always in an encrypted state in the whole reasoning process, privacy leakage is effectively avoided, the model reasoning efficiency can be improved, and the data reasoning process is accelerated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information security technology, and more particularly to a Legendre-KAN encryption inference method based on modular component homomorphism. Background Art

[0002] With the surge in data volumes, the development of algorithms, and the increase in computing power, deep learning has been widely applied in fields such as medical diagnosis, facial recognition, and credit risk assessment. Currently, many operators are adopting the "Deep Learning as a Service" (DLaaS) model, offering deep learning as a cloud computing service, allowing users to make predictions using pre-configured models through the cloud platform. However, this model often requires cloud service providers to have unencrypted access to user data, leading to the risk of data exposure and privacy breaches. Therefore, protecting data privacy when using deep learning services has become a pressing issue.

[0003] Existing privacy protection schemes, such as data desensitization and encrypted storage, while reducing the risk of data leakage to a certain extent, fail to protect data privacy during the computational process. Homomorphic encryption has emerged as a solution to this problem. This technology allows computations to be performed directly on encrypted data without decryption, thereby ensuring data privacy and security during the computational process. While homomorphic encryption effectively protects user data privacy and ensures data security during storage, transmission, and computation, its computational efficiency remains a bottleneck hindering its widespread application. Existing homomorphic encryption techniques suffer from high computational complexity and slow operation speed, making them particularly computationally expensive during inference of deep learning models. Existing homomorphic encryption methods applied to convolutional neural networks suffer from the following drawbacks: 1. Low computational efficiency: The application of existing homomorphic encryption techniques to deep learning tasks, particularly convolutional neural network (CNN) inference, is computationally expensive. Convolution and pooling operations require significant computational resources, and these operations are highly complex to implement in a homomorphic encryption environment, resulting in low efficiency. 2. Insufficient support for floating-point operations: Some existing homomorphic encryption schemes fail to support the floating-point operations required by neural networks, limiting their direct application in encrypted environments and failing to meet the full computational requirements of neural networks. 3. Limitations of homomorphic encryption algorithms: Currently, many deep learning methods based on homomorphic encryption rely on general homomorphic encryption algorithms developed abroad (such as Paillier, BFV, CKKS, etc.). These algorithms are inefficient in neural network applications and cannot meet the requirements of high efficiency and real-time performance in actual scenarios.

[0004] Therefore, how to improve the computational efficiency of homomorphic encryption technology in deep learning reasoning is an urgent problem that technicians in this field need to solve. Summary of the Invention

[0005] In view of this, the present invention provides a Legendre-KAN encryption inference method based on modular component homomorphism, which is a privacy-preserving inference method based on fully homomorphic encryption and KAN neural network, and is suitable for deep learning service scenarios that need to protect user data privacy in cloud computing environments.

[0006] In order to achieve the above object, the present invention adopts the following technical solutions:

[0007] A Legendre-KAN encrypted inference method based on modular component homomorphism includes the following steps:

[0008] Step 1: Construct the Legendre-KAN network based on the KAN structure of Legendre polynomials;

[0009] Step 2: Collect image sample sets to train the Legendre-KAN network to obtain the Legendre-KAN model;

[0010] Step 3: Encrypt the image to be predicted to obtain ciphertext data;

[0011] Step 4: Use the Legendre-KAN model on the GPU to perform parallel reasoning on the ciphertext data using the modular component homomorphic algorithm to obtain the encryption result;

[0012] Step 5: Decrypt the encrypted result to obtain the image prediction result.

[0013] Preferably, a Legendre-KAN network with a depth of 2 layers is constructed based on the Kolmogorov-Arnold theorem. The Legendre-KAN network includes several layers of neural network layers connected in sequence. The output of the last layer of neural network serves as the image prediction result of the Legendre-KAN network, and a learnable activation function is implemented by Legendre polynomials. Each layer of the neural network in the Legendre-KAN network includes a basic linear branch, a Legendre polynomial branch, and a feature fusion layer.

[0014] The basic linear branch includes a basic activation layer and a basic linear transformation layer. The basic activation layer performs nonlinear activation on the input through the basic activation function to obtain activation features. The basic linear transformation layer performs linear transformation on the activation features through the basic weight matrix to obtain the 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 normalizes the input, the recursive layer recursively generates Legendre polynomial basis functions from order 0 to a preset order based on the normalized input to form a three-dimensional basis function matrix, the reshaping layer flattens the three-dimensional basis function matrix and reshapes it into a two-dimensional basis function matrix, and the polynomial nonlinear transformation layer uses a polynomial weight matrix to perform a nonlinear transformation on the two-dimensional basis function matrix to generate a polynomial output;

[0016] The feature fusion layer includes a splicing layer, a batch normalization layer, and a base activation layer. The splicing layer adds the base output and the polynomial output element by element to obtain the fused output. The batch normalization layer normalizes the fused output. The base activation layer uses the base activation function to linearly activate the normalized fused output to generate the output of the current layer and serve as the input of the next layer of neural network.

[0017] Preferably, the Legendre polynomial basis function defined on the interval [-1, 1] is used to replace the B-spline activation function in the Spline-KAN network to obtain the Legendre-KAN network; the polynomial nonlinear transformation layer performs a nonlinear transformation on the input through a linear combination of the Legendre polynomial basis functions to enhance the network expression capability, which is expressed as:

[0018]

[0019] Among them, L i (x) represents the i-th order of Legendre polynomial basis function, c i Represents a learnable parameter; in the gradient descent process of Legendre-KAN network training, a smaller learnable parameter c is used to avoid the gradient explosion problem caused by excessive parameter initialization. i , which can effectively prevent the positive and negative coefficients of the basis function from being too large, affecting the stability of network training;

[0020] Preferably, the batch normalization layer is expressed as:

[0021]

[0022] Where x represents the input vector; μ represents the mean of the input vector, H represents the total number of elements in the input vector in a batch; σ 2 represents the variance of the input vector; ∈ is a set constant; γ and β represent the learnable scaling parameter and offset parameter respectively.

[0023] Preferably, the basic activation function used by the basic activation layer in the feature fusion layer is a linear activation form x 2, x represents the input. Since homomorphic encryption does not directly support nonlinear operations in neural networks, x is used 2 To approximate SiLU(x) as the activation function, the neural network in the encrypted state can perform approximate nonlinear calculations.

[0024] Preferably, the output of each layer of the neural network in the Legendre-KAN network is expressed as:

[0025] output=base_activation(BN(base_output+poly_output))

[0026] Among them, output represents the output of the current neural network layer; base_activation represents the basic activation function; BN represents batch normalization; base_output represents the basic output; poly_output represents the polynomial output.

[0027] Preferably, the Legendre-KAN network is trained on the server to obtain a Legendre-KAN model.

[0028] Preferably, in step 3, the client generates a user master key and, based on the user master key, generates a user subkey. The user subkey includes a secret key, a public key, and a computation key. The predicted image is encrypted using the public key. In step 4, encryption inference is performed using a modular component homomorphic algorithm based on the computation key in the user subkey. Encrypting the predicted image to generate ciphertext data ensures privacy protection during image transmission and processing.

[0029] Preferably, the process of generating the user master key and the user subkey 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: Generate a secret key SK using a key derivation function based on the user master key. The secret key SK includes a position basis W, a projection basis B, a magnification factor a, and a scaling factor Δ of floating point precision.

[0032] Step 313: Use the secret key SK to encrypt the floating point number 1.0 to obtain the ciphertext matrix pk M , the ciphertext matrix pk M As the public key PK;

[0033] Step 3131: 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 row i of the i , b i represents the i-th component in the projection basis B, and r represents the first random number;

[0034] Step 3132: Generate a second random number s>b n , b n Represents the nth component in the projection basis B, calculated based on the magnification a as A = 1.0 × a + s;

[0035] Step 3133: Let A≡a i modb i , 1≤1≤n, calculate a i ; Use n elements in the position basis W as the matrix pk′ M The index of the n row vectors in the matrix pk′ M Elements in Replace with a i , get the ciphertext matrix pk M ;

[0036] Step 314: The projection basis B, the magnification a, and the scale factor Δ are combined to form a calculation key EK. The modular component homomorphic algorithm uses the calculation key EK to perform homomorphic operations.

[0037] Preferably, the client encrypts the image to be predicted using the public key, and then 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 to obtain the encryption result, and feeds the encryption result back to the client. The client decrypts the encryption result according to the secret key to obtain the image prediction result.

[0038] Preferably, when the client uses the public key to encrypt the predicted image, it first normalizes the predicted image, and then uses the public key to encrypt the pixel data of the predicted image pixel by pixel. The encryption method is to multiply the public key with each pixel data to obtain the ciphertext data Ct.

[0039] Preferably, the server uses the Legendre-KAN model and the ciphertext data and the calculation key to perform reasoning to obtain the encryption result as follows:

[0040] Step 41: The server expands the ciphertext data Ct into a one-dimensional matrix ct = [ct1 … ct n ], and encrypt the one-dimensional matrix ct using the modular component homomorphic algorithm according to the calculated key EK, and obtain the modular component set of each ciphertext in the one-dimensional matrix ct T represents the transpose of a one-dimensional matrix, m represents the mth ciphertext in the one-dimensional matrix ct, c p Represents the modular component that makes up the mth ciphertext, and M represents the number of modular components;

[0041] Step 42: Input the modular component set of each ciphertext and the basic weight matrix and polynomial 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.

[0042] Preferably, the client decrypts the encryption result according to the secret key to obtain the image prediction result.

[0043] Preferably, a loss function with a penalty term is used to train and optimize the Legendre-KAN network.

[0044] It can be seen from the above technical solution that compared with the existing technology, the present invention discloses a Legendre-KAN encryption inference method based on modular component homomorphism. Through multi-dimensional collaborative optimization, it constructs an efficient, secure and accurate homomorphic encryption inference system, aiming to meet the needs of data privacy protection. Its technical focus is on solving the inherent contradiction in traditional solutions that are difficult to balance between precision loss, computational delay and privacy risks. Specifically, Legendre orthogonal polynomials are introduced to reconstruct the KAN network, and the spline functions in the KAN network are replaced by Legendre polynomials. The approximation ability of linear combinations and the low-order approximation completeness of Legendre polynomials are utilized to circumvent the piecewise nonlinear defects of traditional B-spline functions, avoid the impact of other non-homomorphic computing operations such as division, and adapt the modular component homomorphic encryption library to ensure that the deep learning model can be efficiently inferred in an encrypted environment; an encryption algorithm based on modular component homomorphism is adopted, and the independent characteristics of each modular component are utilized, combined with the GPU parallel computing reasoning strategy, to accelerate the ciphertext reasoning process, and the powerful computing power of the GPU accelerates the processing of ciphertext data; the data is always in an encrypted state during the entire model reasoning process of the present invention, effectively avoiding the problem of privacy leakage.

[0045] This invention combines homomorphic encryption and the Legendre-KAN model to effectively solve the following technical problems:

[0046] 1. Improved computational efficiency: The modular component operations in the modular homomorphic encryption algorithm are independent and have a natural parallel advantage. Based on this algorithm, GPU parallel computing strategies can be used to significantly improve the efficiency of ciphertext calculations by leveraging the powerful computing power of GPUs. Compared with traditional convolutional neural networks (CNNs), the Legendre-KAN model has fewer parameters, enabling deep learning inference in encrypted environments to be processed with lower computational costs and storage overhead.

[0047] 2. Solving the precision problem: The modular component homomorphic encryption algorithm supports floating-point operations and floating-point encoding, enabling ciphertext calculations with 19 decimal places, fully supporting the high-precision computing requirements of model reasoning under ciphertext. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0049] Figure 1 Schematic diagram of the flowchart of the Legendre-KAN encrypted inference method based on modular component homomorphism provided by the present invention. DETAILED DESCRIPTION

[0050] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0051] The embodiment of the present invention discloses a Legendre-KAN encryption reasoning method based on modular component homomorphism, such as Figure 1 As shown, the following steps are included:

[0052] S1: Constructing Legendre-KAN network based on KAN structure of Legendre polynomials;

[0053] S2: Collect image sample sets to train the Legendre-KAN network to obtain the 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 the user master key, secret key, and calculation key.

[0055] S4: Deploy the trained Legendre-KAN model on the server, determine the model weights, and build the ciphertext prediction network.

[0056] S5: The server's GPU uses the Legendre-KAN model and the modular component homomorphic algorithm to perform parallel reasoning on the ciphertext data, obtain the encryption result, and feed the encryption result back to the client;

[0057] S6: The client decrypts the encrypted result to obtain the image prediction result.

[0058] Furthermore, based on the Kolmogorov-Arnold theorem, a two-layer Legendre-KAN network was constructed to ensure that the structure remained exactly the same during the training and prediction phases. The original edge nonlinear modules in the MLP (such as the traditional activation function ReLU) were replaced with learnable activation modules based on Legendre polynomial basis functions. The Legendre-KAN network consists of several layers of neural networks connected in sequence. The output of the last neural network layer serves as the image prediction result of the Legendre-KAN network, and the learnable activation function is implemented through Legendre polynomials. Each neural network layer in 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 the basic activation function to activate the activation feature. The basic linear transformation layer linearly transforms the activation feature through the basic weight matrix to obtain the basic output.

[0060] The Legendre polynomial branch includes a normalization layer, a recursive layer, a reshaping layer, and a polynomial nonlinear transformation layer. The normalization layer normalizes the input and maps it to the interval [-1, 1]. The recursive layer then recursively generates Legendre polynomial basis functions from order 0 to a preset order based on the normalized input to form a three-dimensional basis function matrix. The reshaping layer flattens the three-dimensional basis function matrix and reshapes it into a two-dimensional basis function matrix. The polynomial nonlinear transformation layer uses a polynomial weight matrix to perform a nonlinear transformation on the two-dimensional basis function matrix (the Legendre basis function in the matrix) to generate a polynomial output. A parameterized, learnable nonlinear mapping mechanism is constructed through the Legendre polynomial basis function, thereby forming a nonlinear activation behavior that is adaptive to different tasks.

[0061] The feature fusion layer consists of a concatenation layer, a batch normalization layer (BatchNorm layer), and a base activation layer. The concatenation layer adds the base output and the polynomial output element-by-element to obtain the fused output. The batch normalization layer normalizes the fused output, using Batch Normalization to suppress gradient anomalies and improve training stability. The base activation layer uses a base activation function to linearly activate the normalized fused output, generating the output of the current layer and serving as the input to the next neural network layer. Because the fused output exceeds the domain of the Legendre polynomial basis function [-1, 1], which can lead to individual precision errors, a batch normalization layer is used to normalize the input in the Legendre polynomial branch. The batch normalization layer in the feature fusion layer can enhance overall training stability and accelerate convergence.

[0062] Furthermore, the Legendre polynomial basis function defined on the interval [-1, 1] is used to replace the B-spline activation function in the Spline-KAN network to obtain the Legendre-KAN network; the polynomial nonlinear transformation layer performs nonlinear transformation on the input through the linear combination of the Legendre polynomial basis function to enhance the network expression ability, which is expressed as:

[0063]

[0064] Among them, L i (x) represents the i-th order of Legendre polynomial basis function, c i Represents a learnable parameter; in the gradient descent process of Legendre-KAN network training, a smaller learnable parameter c is used to avoid the gradient explosion problem caused by excessive parameter initialization. i , which can effectively prevent the positive and negative coefficients of the basis function from being too large, affecting 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 nonlinear mapping of the input features.

[0065] Furthermore, the batch normalization layer learns normalized learnable parameters during the training phase and remains unchanged during the inference phase. This is particularly suitable for homomorphic encryption scenarios and can effectively reduce the order of homomorphic encryption, providing a new approach to achieving high-precision and high-efficiency homomorphic encryption. The batch normalization layer is expressed as:

[0066]

[0067] Where x is the input vector; μ is the mean of the input vector, H represents the total number of elements in the input vector in a batch; σ 2is the variance of the input vector; ∈ is a small constant used to prevent division by zero errors; γ and β represent learnable scaling and offset parameters, respectively, used to restore the expressive power of the model. The batch normalization layer has the following functions:

[0068] (1) Stable training: The base output base_output and the polynomial output poly_output may have different numerical ranges (especially the high-order terms of the polynomial branches may fluctuate greatly). Direct addition may cause the scale of the activation function input value to be unstable (such as too large or too small), and the gradient may disappear or explode (the gradient amplitude varies greatly during backpropagation). The batch normalization layer can constrain the numerical range after multi-branch fusion to prevent gradient anomalies.

[0069] (2) Accelerated convergence: The standardized feature distribution makes the optimization process more efficient;

[0070] (3) Avoid the problem of low individual accuracy.

[0071] Preferably, the basic activation function used by the basic activation layer in the feature fusion layer is a linear activation form x 2 , x represents the input. Since homomorphic encryption does not directly support nonlinear operations in neural networks, x is used 2 To approximate SiLU(x) as the activation function, the neural network in the encrypted state can perform approximate nonlinear calculations;

[0072] The output of each layer of the neural network in the Legendre-KAN network is expressed as:

[0073] output=base_activation(BN(base_output+poly_output))

[0074] Among them, output represents the output of the current neural network layer; base_activation represents the basic activation function; BN represents batch normalization; base_output represents the basic output; poly_output represents the polynomial output.

[0075] Furthermore, the Legendre-KAN network is trained on the server to obtain the Legendre-KAN model.

[0076] Furthermore, the training process of the Legendre-KAN network is as follows:

[0077] S21: Receive input x;

[0078] S22: Traverse the basic linear branch, Legendre polynomial branch and feature fusion layer of each layer of the neural network;

[0079] S221: The input x of the current layer is input to the basic linear branch and the Legendre polynomial branch respectively;

[0080] S222: The basic linear branch activates the input x using the basic activation function and performs linear transformation using the basic weight matrix base_weight to obtain the basic 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 during high-order calculations. Based on the normalized input x_normalized, it recursively generates Legendre polynomial basis functions legendre_basis from order 0 to polynomial_order (the order that can be specified during training) to construct a three-dimensional basis function matrix. The three-dimensional basis function matrix is reshaped into a two-dimensional basis function matrix to match the dimension of the polynomial weight matrix poly_weight. The polynomial weight matrix poly_weight is then used to perform a linear transformation on the Legendre polynomial basis function legendre_basis in the two-dimensional basis function matrix to obtain the polynomial output poly_output;

[0082] S223: The feature fusion layer adds the base output base_output and the polynomial output poly_output element by element to obtain the fusion feature, performs batch normalization on the fusion feature to adjust the distribution of the fusion feature, suppresses gradient anomalies, and uses the basic activation function to activate the normalized fusion feature to obtain the output of the current layer;

[0083] S224: If the current layer is not the last layer, the output of the current layer will be used as the input of the next layer and returned to S221; if it is the last layer, it will be directly returned as the image prediction result;

[0084] S23: Output the image prediction result.

[0085] Furthermore, the Legendre-KAN network is optimized using a loss function with a penalty term to mitigate the impact of gradient explosion in the polynomial activation function. The use of a loss function with a penalty term can be used for regularization or other constraints to help prevent model overfitting and improve its generalization ability.

[0086] Furthermore, in S3, the client generates a user master key (UMK), which is then used to generate a user subkey based on the UMK. The user subkey consists of a secret key, a public key, and a computation key. The predicted image is encrypted using the public key. In S4, encryption inference is performed using a modular component homomorphic algorithm based on the computation key within the user subkey. The secret key is used to generate the public key, which is then 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 predicted image to generate ciphertext data ensures privacy protection during image transmission and processing.

[0087] Furthermore, the process of generating the user master key and user subkey by the client includes:

[0088] S311: The client randomly generates a user key Key(U)∈{0, 1} 1 As a user master key;

[0089] S312: Generate a secret key SK using a key derivation function based on the user master key. The secret key SK consists of a position basis W, a projection basis B, a magnification factor a, and a scaling factor Δ for floating-point precision.

[0090] The user master key is used as a seed to derive key material of sufficient length and generate a secret key; for example, a user generates a random string The random string RS is encrypted using the user key Key(U) through SM4 (ECB mode) to obtain the ciphertext C1. bits form a number, and n numbers are selected to form the position basis W = {w1, w2, ..., w n},w i ∈[1,t],i=1,...,n, where It means taking the smallest integer greater than or equal to ·, and the position basis as the main parameter of the secret key;

[0091] S313: The client encrypts the floating point number 1.0 using the secret key SK to obtain the ciphertext matrix pk M , the ciphertext matrix pk M As the 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 row i of the i , b i represents the i-th component in the projection basis B, and r represents the first random number;

[0093] S3132: Generate a second random number s>b n , b n Represents the nth component in the projection basis B, calculated based on the magnification a as A = 1.0 × a + s;

[0094] S3133: Let A≡a i modb i , 1≤i≤n, calculate a i ; Use the n elements in the position basis W as the matrix pk′ M The index of the n row vectors in the matrix pk′ M Elements in Replace with a i , get the ciphertext matrix pk M ;

[0095] S314: The projection basis B, the magnification factor a, and the scale factor Δ are combined to form a calculation key EK. The modular component homomorphic algorithm uses the calculation key EK for homomorphic operations. The scale factor Δ participates in floating-point operations. The floating-point data is converted to integer form by multiplying the model input in floating-point form by the scale factor Δ and rounding to the nearest integer, thus achieving floating-point encoding. The converted integer is then added or multiplied to achieve floating-point operations.

[0096] Furthermore, the client uses the public key to encrypt the image to be predicted, and then 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 encryption result according to the secret key to obtain the image prediction result.

[0097] Furthermore, the client uses the public key to encrypt the image to be predicted, which includes:

[0098] S321: The client reads the image to be predicted from the local device or the specified data source. The image to be predicted is a single static image or a frame of a dynamic video.

[0099] S322: Assuming that the original size of the image to be predicted is 28×28, the image to be predicted is first normalized, and then the pixel data of the image to be predicted is encrypted pixel by pixel using the public key PK. The encryption method is to perform a multiplication operation on the public key PK and each pixel data to obtain the ciphertext data Ct;

[0100]

[0101] ct represents the encrypted pixel data;

[0102] S323: Send the ciphertext data Ct and the calculated key EK to the server.

[0103] Furthermore, the server uses the Legendre-KAN model and the ciphertext data to calculate the key to perform reasoning and obtain the encryption result as follows:

[0104] Step 41: The server expands the ciphertext data Ct into a one-dimensional matrix ct = [ct1 … ct n ], and encrypt the one-dimensional matrix ct using the modular component homomorphic algorithm according to the calculated key EK, and obtain the modular component set of each ciphertext in the one-dimensional matrix ct T represents the transpose of a one-dimensional matrix, m represents the mth ciphertext in the one-dimensional matrix ct, c p Represents the 96×4 modular components that make up the mth ciphertext, and M represents 96×4, that is, the number of modular components;

[0105] Step 42: The modular component set of each ciphertext and the basic weight matrix and polynomial weight matrix obtained after model training are input into the Legendre-KAN model on the GPU. Matrix multiplication and addition operations are performed in parallel through the CUDA core to obtain the encryption result.

[0106] If the ciphertext data is [1,2,3], the ciphertext data is encrypted using the modular component homomorphic encryption algorithm, 96 modular bases and 4 confusion positions are set, then the encrypted ciphertext 1 is a one-dimensional matrix of size 96×4. The same is true for ciphertext 2 and plaintext ciphertext 3. For ciphertext 1, modular operations are performed on the 96 modular bases to generate 96 modular components. Each modular component has 4 optional positions, and the other 3 positions are generated random numbers for confusion, thereby achieving the encryption effect. The storage location of each component is determined by the position basis. The two ciphertexts perform homomorphic operations, and the modular components of the corresponding positions are operated. The operations of the 96×4 modular components are independent of each other, so the GPU runs in parallel and calculates the operation process of all modular components at the same time.

[0107] Furthermore, the client decrypts the encrypted result according to the secret key to obtain the image prediction result.

[0108] In a specific embodiment, a Legendre-KAN encrypted inference method based on modular component homomorphism includes the following steps:

[0109] S1. The server builds a Legendre-KAN network with a depth of 2 layers;

[0110] S2. The server trains the Legendre-KAN network using the image sample set to obtain a Legendre-KAN model.

[0111] S3. The client generates public and private keys, including a user master key and a user subkey. The user master key is used to generate the user subkey, which consists of a secret key, a public key, and a computation key. 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.

[0112] S4. The client uses the public key to encrypt the image to be predicted to obtain ciphertext data, ensuring the privacy protection of the image during transmission and processing;

[0113] S5. The client sends the encrypted data and the calculated key to the server.

[0114] S6. The server loads the pre-trained Legendre-KAN model and ciphertext data into the GPU for parallel inference to obtain the encryption result.

[0115] S7. The server transmits the encrypted inference result back to the client, and the client uses the secret key to decrypt it and obtain the image prediction result.

[0116] Furthermore, a two-layer Legendre-KAN network was constructed to ensure that the structure remained identical during the training and prediction phases. To incorporate the superior function approximation properties of Legendre polynomials into the KAN architecture, the B-spline activation function used in the traditional Spline-KAN was replaced with Legendre polynomials defined on the interval [-1, 1]. 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 capabilities. This globality avoids the computational complexity that may arise from piecewise functions in encryption calculations. In particular, when performing homomorphic encryption, piecewise nonlinear functions often lead to excessive computational overhead, or even prevent direct encryption calculations.

[0118] 2) Efficient Computational Adaptability: Legendre polynomials are highly adaptable to encryption computations, particularly in homomorphic encryption scenarios. Traditional B-spline functions suffer from computational bottlenecks due to the presence of non-homomorphic division operations. Linear combinations of Legendre polynomials avoid these issues, enabling efficient computation in encrypted environments.

[0119] 3) Completeness of low-order approximation: Legendre polynomials have strong low-order approximation completeness and can effectively approximate complex functions at lower orders. This is particularly important for encryption calculations because it can reduce the computational cost of the encryption process.

[0120] Furthermore, when the server invokes the Legendre-KAN model for inference, it can fully leverage the parallel computing capabilities of the GPU to accelerate the matrix operations involved. The model has been adapted to the modular component homomorphic encryption algorithm to support homomorphic operations. When performing operations between ciphertext images and plaintext weights, semi-blind addition and semi-blind multiplication from the modular component homomorphic encryption algorithm are used to implement mixed ciphertext-plaintext operations. Since linear transformations are essentially matrix multiplications, these operations can be offloaded to the GPU, significantly improving computational efficiency. Specifically, the matrix multiplication of the input ciphertext data Ct with the weight matrix (self.base_weights and self.poly_weights) is performed on the GPU, leveraging its highly parallel computing architecture to accelerate these operations. Using the CUDA programming model, appropriate thread blocks and grids can be defined to decompose the matrix multiplication into smaller subtasks, or column-by-column multiplications, which are then executed in parallel on multiple CUDA cores. This approach not only reduces data transfer overhead but also maximizes GPU computing resource utilization.

[0121] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.

[0122] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A Legendre-KAN encrypted inference method based on modular component homomorphism, characterized in that: The following steps are involved: Step 1: Construct the Legendre-KAN network based on the KAN structure of Legendre polynomials; Step 2: Collect image sample sets to train the Legendre-KAN network to obtain the Legendre-KAN model; Step 3: Encrypt the image to be predicted to obtain ciphertext data; Step 4: Use the Legendre-KAN model on the GPU to perform parallel reasoning on the ciphertext data using the modular component homomorphic algorithm to obtain the encryption result; Step 5: Decrypt the encrypted result to obtain the image prediction result.

2. The Legendre-KAN encrypted inference method based on modular component homomorphism according to claim 1 is characterized in that: Based on the Kolmogorov-Arnold theorem, a 2-layer Legendre-KAN network is constructed. The Legendre-KAN network consists of several sequentially connected neural network layers. The output of the last neural network layer serves as the image prediction result of the Legendre-KAN network. Each neural network layer 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 nonlinear activation on the input through the basic activation function to obtain activation features. The basic linear transformation layer performs linear transformation on the activation features through the basic weight matrix to obtain the basic output. The Legendre polynomial branch includes normalization layer, recursive layer, reshaping layer and 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 to form a three-dimensional basis function matrix. The reshaping layer flattens the three-dimensional basis function matrix and reshapes it into a two-dimensional basis function matrix. The polynomial nonlinear transformation layer uses a polynomial weight matrix to perform a 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 base activation layer. The splicing layer adds the base output and the polynomial output element by element to obtain the fused output. The batch normalization layer normalizes the fused output. The base activation layer uses the base activation function to linearly activate the normalized fused output to generate the output of the current layer and serve as the input of the next layer of neural network.

3. The Legendre-KAN encrypted inference method based on modular component homomorphism according to claim 2, characterized in that: The batch normalization layer is represented as: Where x represents the input vector; μ represents the mean of the input vector, σ 2 represents the variance of the input vector; ∈ is a set constant; γ and β represent the learnable scaling parameter and offset parameter respectively.

4. The Legendre-KAN encrypted inference method based on modular component homomorphism according to claim 2, characterized in that: The basic activation function used by the basic activation layer in the feature fusion layer is the linear activation form x 2 , x represents the input; the output of each layer of the neural network in the Legendre-KAN network is expressed as: output=base_activation(BN(base_output+poly_output)) Among them, output represents the output of the current neural network layer; base_activation represents the basic activation function; BN represents batch normalization; base_output represents the basic output; poly_output represents the polynomial output.

5. The Legendre-KAN encrypted inference 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.

6. The Legendre-KAN encrypted inference method based on modular component homomorphism according to claim 1, characterized in that: In step 3, the client generates a user master key and generates a user subkey based on the user master key. The user subkey includes a secret key, a public key, and a calculation key. The predicted image is encrypted according to the public key. In step 4, the modular component homomorphic algorithm is used to perform encryption inference based on the calculation key in the user subkey.

7. The Legendre-KAN encrypted inference method based on modular component homomorphism according to claim 6, characterized in that: The process of generating a customer master key and a customer subkey includes: Step 311: Randomly generate a user key Key(U)∈{0,1} l As a user master key; Step 312: Generate a secret key SK using a key derivation function based on the user master key. The secret key SK includes a position basis W, a projection basis B, a magnification factor a, and a scaling factor Δ of floating point precision. Step 313: Use the secret key SK to encrypt the floating point number 1.0 to obtain the ciphertext matrix pk M , the ciphertext matrix pk M As the public key PK; Step 3131: 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 row i of the i , b i represents the i-th component in the projection basis B, and r represents the first random number; Step 3132: Generate a second random number s>b n , b n Represents the nth component in the projection basis B, calculated based on the magnification a as A = 1.0 × a + s; Step 3133: Let A = a i modb i , 1≤i≤n, calculate a i ; Use n elements in the position basis W as the matrix pk M The index of the n row vectors in the matrix pk M Elements in Replace with a i , get the ciphertext matrix pk M ; Step 314: Construct a calculation key EK based on the projection basis B, the magnification a and the scale factor Δ.

8. The Legendre-KAN encrypted inference method based on modular component homomorphism according to claim 6, 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 encrypted result, and feeds the encrypted result back to the client. The client decrypts the encrypted result according to the secret key to obtain the image prediction result.

9. The Legendre-KAN encrypted inference method based on modular component homomorphism according to claim 6, characterized in that: When the client uses the public key to encrypt the predicted image, it first normalizes the predicted image, and then uses the public key to encrypt the pixel data of the predicted image pixel by pixel. The encryption method is to multiply the public key with each pixel data to obtain the ciphertext data.

10. The Legendre-KAN encrypted inference method based on modular component homomorphism according to claim 8, characterized in that: The server uses the Legendre-KAN model, ciphertext data, and calculation key to perform reasoning and obtain the encryption result as follows: Step 41: The server expands the ciphertext data Ct into a one-dimensional matrix ct = [ct1…ct n ], and encrypt the one-dimensional matrix ct using the modular component homomorphic algorithm according to the calculated key EK, and obtain the modular component set of each ciphertext in the one-dimensional matrix ct T represents the transpose of a one-dimensional matrix, m represents the mth ciphertext in the one-dimensional matrix ct, c p Represents the modular component that makes up the mth ciphertext, and M represents the number of modular components; Step 42: Input the modular component set of each ciphertext and the basic weight matrix and polynomial 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.

Citation Information

Patent Citations

  • Ciphertext convolutional neural network image classification method based on mode component homomorphism

    CN116800906A