A ciphertext anomaly detection method and system based on weight mapping and surface modeling
Patent Information
- Application Number
- CN202611417845.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-14
- Publication Date
- 2026-10-16
AI Technical Summary
但是,该方法主要依赖于明文域预先生成的静态历史聚类中心进行比对,缺乏对数据流动态变化的实时捕捉能力;更重要的是,该方案在求取最小异常值(即执行多簇比较与排序环节)时,必须依赖监测中心对中间态同态运算结果进行解密才能完成后续逻辑,并非真正的密文域闭环计算,存在中间态隐私泄露风险,且同样未能解决密文样本的连续增量式更新问题
[0047] 1. The computational performance is significantly improved. Compared with existing logic comparison schemes, this invention helps to reduce the computational depth of encrypted domain anomaly detection, reduces system latency, and can meet the real-time detection requirements of high-speed industrial streaming data.
Smart Images

Figure CN122933280A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of encrypted traffic detection, and in particular to a method and system for detecting encrypted anomalies based on weight mapping and surface modeling. Background Technology
[0002] With the development of the Industrial Internet, edge computing, and real-time network monitoring, network traffic data is generated at high speed in a continuous streaming manner, placing extremely high demands on real-time anomaly detection. To ensure data privacy in outsourced computing, fully homomorphic encryption technology is widely used.
[0003] However, existing technologies have shortcomings when applied to high-frequency streaming data and homomorphic encryption environments. First, system throughput is limited by logical comparison operations; existing schemes rely on ciphertext size comparison or sorting during neighborhood search, which requires approximation using extremely high-order polynomials in homomorphic encryption, resulting in huge processing latency and rapid noise accumulation, making it difficult to meet streaming response requirements. Second, discretized neighborhood selection leads to unstable discrimination results; existing technologies often use hard thresholds to define neighborhoods, and in dynamic streaming scenarios, even small noises can easily cause sudden changes in neighborhood members, resulting in drastic fluctuations in discrimination scores and a lack of robustness. Finally, multi-level nonlinear operations exacerbate the stacking of computational depth; traditional detection models, such as density ratio evaluation, involve complex ciphertext division or nested nonlinear operations, which amplify the accuracy loss, making it difficult for the system to achieve low-latency closed-loop detection while ensuring accuracy. Therefore, a ciphertext anomaly detection method that does not rely on ciphertext comparison or sorting, supports sliding window incremental updates, and can complete anomaly scoring with low computational depth is needed.
[0004] The publication number CN115085898A, titled "An Anomaly Detection Method for UAV Data Based on Homomorphic Encryption," proposes encrypting UAV data using the CKKS fully homomorphic encryption algorithm and constructing an isolated forest model in the cloud using the ciphertext data to achieve anomaly detection. To partition the nodes of the isolated tree in the ciphertext domain, this method uses a composite polynomial iterative approximation of the sign function, thus enabling numerical comparison of the ciphertext data. However, this method heavily relies on logical comparison operations in the ciphertext domain. Even with polynomial approximation, the deep ciphertext multiplication iterations still result in extremely high homomorphic computation depth and modular level consumption. Furthermore, this scheme lacks a sliding window and incremental maintenance mechanism for streaming data, making it unsuitable for real-time detection of frequently changing network traffic.
[0005] The publication number CN117688502A, entitled "A Secure Outsourcing Computation Method and System for Local Anomaly Detection," proposes a secure outsourcing scheme based on the CBLOF (Cluster-Based Local Anomaly Detection) algorithm. This method encrypts operational data and preset historical cluster centers, performs multiplicative homomorphic operations at a third-party computing center, and then the monitoring center decrypts the data and calculates the Euclidean distance between the test point and each cluster center, using the minimum distance as the anomaly score. However, this method primarily relies on comparison with pre-generated static historical cluster centers in the plaintext domain, lacking the ability to capture real-time changes in the data stream. More importantly, when calculating the minimum anomaly value (i.e., performing multi-cluster comparison and sorting), the scheme requires the monitoring center to decrypt the intermediate homomorphic operation results to complete subsequent logic, which is not a true closed-loop computation in the encrypted domain, posing a risk of intermediate privacy leakage. Furthermore, it fails to address the problem of continuous incremental updates of encrypted samples. Summary of the Invention
[0006] To solve the above-mentioned technical problems, one technical solution adopted by the present invention is: to provide a method for detecting encrypted anomalies based on weight mapping and surface modeling, the method comprising:
[0007] The S10 client collects raw traffic, extracts multi-dimensional feature vectors, constructs samples to be detected, performs normalization processing on the samples using preset distribution parameters, calls the public key to encapsulate them into ciphertext tensors, and transmits them to the server in real time according to the time sequence.
[0008] The S20 server determines expired ciphertext tensors based on the timing identifier attached to the ciphertext tensor, removes the expired ciphertext tensors, stores newly arrived ciphertext tensors at the end of the window, and updates the window storage structure and the total ciphertext state baseline inside the window.
[0009] The S30 server calculates the ciphertext squared distance between the newly arrived ciphertext tensor and each ciphertext tensor in the window, and inputs the ciphertext squared distance into a preset polynomial kernel function to assign continuous soft neighborhood mapping weights to each ciphertext tensor in the window.
[0010] The S40 server performs weighted aggregation on each ciphertext tensor within the window based on the continuous soft neighborhood mapping weight, extracts the weighted first-order statistics and weighted second-order statistics, and constructs a local statistical parameter matrix based on this, and calculates the local energy value of the newly arrived ciphertext tensor based on the quadratic energy function.
[0011] The S50 server aggregates the local energy value with the local statistical parameter matrix, calls the pre-trained discriminant parameter matrix to perform a homomorphic inner product operation on the aggregation result, and generates an encrypted anomaly detection score.
[0012] The S60 server sends back the anomaly detection score in the encrypted form. The client calls the private key to decrypt and recover the plaintext score. The plaintext score is then compared with a preset threshold to determine the abnormal traffic situation.
[0013] The process of the client collecting raw traffic and extracting multi-dimensional feature vectors to construct a sample to be detected includes: the client capturing real-time traffic data packets through a network acquisition interface, aggregating the data packets to obtain a network flow based on the network flow quintuple, extracting the time dimension and spatial dimension features of the network flow, concatenating them according to a preset system feature dimension template to generate an original feature vector, and constructing the original feature vector as a sample to be detected in the current time series.
[0014] Furthermore, the sample is normalized using preset distribution parameters, wherein the preset distribution parameters include the feature mean vector and feature standard deviation vector corresponding to each feature dimension of the sample to be detected. The normalized sample is calculated by substituting each feature component of the sample to be detected into the standardization formula.
[0015] The process of encapsulating the public key into a ciphertext tensor and transmitting it to the server in real time according to the time sequence includes: setting a preset scaling factor; the client calling a pre-configured fully homomorphic encryption algorithm public key; performing encoding and homomorphic encryption operations on the real number feature components in the normalized sample to generate the corresponding ciphertext tensor; attaching a time sequence identifier to the ciphertext tensor; constructing a ciphertext tensor carrying the time sequence; and pushing the ciphertext tensor into the output queue and transmitting it to the server in real time.
[0016] Furthermore, the algebraic operations performed on each of the ciphertext tensors by the fully homomorphic encryption algorithm are implemented through a preset set of homomorphic operator sequences, the homomorphic operator sequences and their execution rules including:
[0017] Homomorphic addition: performs linear accumulation between ciphertext tensors and homomorphic summation between ciphertext tensors and plaintext bias terms; among them, homomorphic subtraction is achieved by performing a negation operation on the term to be subtracted and then performing homomorphic addition, so as to complete the vector difference calculation in the ciphertext domain;
[0018] Homomorphic multiplication: Performs product operations between ciphertext tensors and plaintext parameters, or between ciphertext tensors; where homomorphic multiplication and addition are implemented by performing homomorphic multiplication and homomorphic addition in sequence; for ciphertext tensors with inconsistent modulus levels before the operation, the levels are aligned by performing a modulus switching operation to ensure the legality of algebraic operations;
[0019] Rescaling: After homomorphic multiplication, the scaling factor of the resulting ciphertext is adjusted, and the alignment of the scale factor of the resulting ciphertext and the management of ciphertext noise are achieved by consuming the ciphertext modulus chain level.
[0020] Homomorphic rotation: The alignment of feature dimensions and expansion of feature space are achieved by cyclic displacement of ciphertext slots. By performing a rotation operation with a preset step size inside the ciphertext tensor, parallel extraction of cross terms in the weighted second-order statistics is supported.
[0021] Furthermore, the server maintains a contiguous storage structure with a preset capacity in memory to cache the ciphertext tensor transmitted in step S10 in a time sequence, while initializing a total ciphertext state baseline that matches the dimensions of the ciphertext tensor.
[0022] The process involves removing the expired ciphertext tensor and storing the newly arrived ciphertext tensor at the end of the window. When the newly arrived ciphertext tensor is received and the contiguous storage structure reaches capacity saturation, the server parses the time sequence identifier in the ciphertext tensor, extracts the earliest arriving ciphertext tensor in the time dimension, records it as the expired ciphertext tensor, calls the homomorphic multiplication, performs a homomorphic scalar multiplication operation between the expired ciphertext tensor and the plaintext constant, and generates the inverted ciphertext.
[0023] The server calls the homomorphic addition to update the total state of the window storage structure and the window internal state. The server performs homomorphic addition on the current total ciphertext state baseline, the newly arrived ciphertext tensor, and the inverted ciphertext to obtain the updated total ciphertext state baseline. Then, the server removes the expired ciphertext tensor from the contiguous storage structure and appends the newly arrived ciphertext tensor.
[0024] Furthermore, the total ciphertext state benchmark is initially a zero vector ciphertext encapsulation, which is used to accumulate the algebraic sum of each ciphertext tensor in the storage window in real time during the incremental update process, and serves as the pre-variable for the global algebraic operation to calculate the mean offset when constructing the continuous weight field later.
[0025] The incremental update process uses the homomorphic addition to accumulate the newly arrived ciphertext tensor into the total ciphertext state benchmark, and uses the homomorphic addition to superimpose the inverted ciphertext of the expired ciphertext tensor into the total ciphertext state benchmark.
[0026] Further, the server calculates the ciphertext squared distance between the newly arrived ciphertext tensor and each ciphertext tensor within the window. The server extracts each ciphertext tensor cached in the contiguous storage structure, calculates the difference ciphertext with the newly arrived ciphertext tensor using the homomorphic addition, performs the homomorphic multiplication and rescaling to calculate the squared difference of the feature dimensions of each ciphertext tensor, and calls the homomorphic rotation and homomorphic addition to perform the cyclic displacement and accumulation of the ciphertext slots to obtain the ciphertext squared distance in scalar form.
[0027] The method involves assigning continuous soft neighborhood mapping weights to each ciphertext tensor within the window. The server inputs the ciphertext squared distance as an independent variable into the polynomial kernel function, performs homomorphic multiplication and addition iteration operations on the independent variable using preset polynomial coefficients, calculates the continuous soft neighborhood mapping weights corresponding to each ciphertext tensor, and constructs a continuous weight field from the continuous soft neighborhood mapping weights corresponding to each ciphertext tensor.
[0028] Furthermore, the polynomial kernel function is a polynomial approximation function of a monotonically decreasing continuous function over a preset distance interval; the preset polynomial coefficients are obtained by fitting the polynomial kernel function in the plaintext domain and are preset as plaintext parameters on the server.
[0029] Furthermore, the server performs weighted aggregation on each ciphertext tensor within the window based on the continuous soft neighborhood mapping weights to extract a weighted first-order statistic. The server then uses the continuous soft neighborhood mapping weights and the corresponding ciphertext tensors within the window to perform the homomorphic multiplication and rescaling to generate a scale-aligned weighted ciphertext tensor. Finally, the server performs linear accumulation on all the weighted ciphertext tensors within the window using homomorphic addition to extract the weighted first-order statistic.
[0030] To extract the weighted second-order statistics, the server performs feature space expansion on each weighted ciphertext tensor, uses homomorphic rotation to shift the weighted ciphertext tensor, and performs homomorphic multiplication and rescaling with the weighted ciphertext tensor before the shift. Then, homomorphic addition is called to accumulate and aggregate all the expanded weighted ciphertext tensors within the window to extract the weighted second-order statistics containing feature square terms and feature pairwise intersection terms.
[0031] The construction of the local statistical parameter matrix involves the server performing tensor splicing and aggregation on the weighted first-order statistics and the weighted second-order statistics after performing ciphertext modulus level alignment, to construct the local statistical parameter matrix. Each slot element of the local statistical parameter matrix covers the mean, variance and covariance distribution information in the current soft neighborhood, which is used as a surface parameter fitting to form a quadratic energy function describing the local spatial distribution characteristics.
[0032] The local energy value of the newly arrived ciphertext tensor is calculated based on the quadratic energy function. The server takes the feature components of the newly arrived ciphertext tensor as independent variables and inputs them into the quadratic energy function characterized by the local statistical parameter matrix. The offset potential energy of the newly arrived ciphertext tensor relative to the local distribution center is calculated through homomorphic multiplication and rescaling to generate the corresponding local statistical energy value ciphertext.
[0033] Furthermore, the feature space expansion is performed on each of the weighted ciphertext tensors. The server utilizes the batch processing parallelism of the ciphertext domain to simultaneously extract pairwise cross-product terms between feature dimensions within the ciphertext slots by rearranging the spatial positions of feature elements and performing nonlinear product operations. The obtained cross-product terms are then linearly aggregated with the squared terms of the original features, thereby mapping the original feature space to a second-order enhanced feature space containing mean, variance, and covariance information.
[0034] The weighted ciphertext tensor is shifted. The server calls homomorphic rotation to perform a cyclic shift operation on the weighted ciphertext tensor containing multi-dimensional features according to a preset feature crossover rule, generating multiple shifted ciphertext vectors with different dimensional offsets. This is used to align the feature dimensions that were originally in different ciphertext slots to the same mapping position, providing aligned ciphertext input for subsequent cross-product operations.
[0035] Furthermore, the discriminant parameter matrix is obtained by training a parameter matrix in the plaintext domain using a normal traffic baseline. The dimension of the discriminant parameter matrix is consistent with the total feature dimension after superimposing the local statistical matrix with the local statistical energy value ciphertext.
[0036] The process of generating an encrypted anomaly detection score involves concatenating and aggregating the local statistical parameter matrix and the local statistical energy value ciphertext, performing a homomorphic matrix inner product operation with the discriminant parameter matrix, performing a homomorphic rotation summation operation on the inner product result, aggregating the weighted contribution of each component of the matrix and the energy value into a scalar result, and introducing a scoring bias term by calling homomorphic addition, ultimately generating a scalar form of the anomaly detection score ciphertext.
[0037] Furthermore, the decryption and recovery of the plaintext score involves transmitting the calculated anomaly detection score ciphertext back to the client via a network communication interface. The client then calls the pre-configured fully homomorphic encryption algorithm private key to perform decryption and decoding operations, thereby recovering the detection score in plaintext form.
[0038] To determine abnormal traffic conditions, the client retrieves the system's preset security baseline threshold and performs a numerical comparison logic between the plaintext detection score and the security baseline threshold within the plaintext calculation domain to determine the security status of the network traffic in the current time series. If the comparison result indicates that the plaintext detection score exceeds the security baseline threshold, the client generates a security alarm command based on the original network flow 5-tuple information or issues a traffic blocking policy to the network edge device.
[0039] This invention also provides a ciphertext anomaly detection system based on continuous weight mapping and quadratic surface modeling, comprising:
[0040] Data encapsulation and preprocessing module: used by the client to collect raw network flow features in real time and perform normalization processing, introduce a preset scaling factor and encapsulate the feature vector into a ciphertext tensor through a fully homomorphic encryption public key, and transmit it to the server in real time according to the time sequence;
[0041] Window state incremental management module: used for server-side maintenance of a ciphertext storage structure with a preset capacity. It removes expired ciphertext tensors and loads new ciphertext tensors through homomorphic negation and homomorphic addition, and completes the algebraic incremental update of the total window state without decryption intervention.
[0042] The continuous weight field construction module is used by the server to calculate the ciphertext squared distance between the new ciphertext tensor and each ciphertext tensor in the window, and input it into the preset polynomial kernel function. The Qin Jiushao algorithm is used to recursively generate soft neighborhood mapping weights that describe the spatial correlation strength of the ciphertext tensors in the ciphertext domain.
[0043] The statistical energy surface modeling module is used by the server to aggregate and extract the first-order, second-order, and cross-order terms of features based on soft neighborhood weights, construct the local statistical matrix of the ciphertext, fit a second-order statistical energy surface, and calculate the local statistical energy value of the ciphertext that reflects the degree of offset of the new ciphertext tensor relative to the local distribution center.
[0044] The linear scoring mapping module is used by the server to concatenate and aggregate the local statistical matrix and local statistical energy values of the encrypted data, call the pre-trained discriminant parameter matrix to perform a single homomorphic matrix inner product operation, and generate an encrypted anomaly detection score through linear discriminant function mapping.
[0045] Decryption judgment and closed-loop response module: It is used by the client to send back the received encryption detection score and call the private key to perform decryption and decoding. It compares the recovered plaintext score with the preset security threshold and executes security alarm commands or issues traffic blocking policies based on the comparison results.
[0046] The beneficial effects of this invention are:
[0047] 1. The computational performance is significantly improved. Compared with existing logic comparison schemes, this invention helps to reduce the computational depth of encrypted domain anomaly detection, reduces system latency, and can meet the real-time detection requirements of high-speed industrial streaming data.
[0048] 2. The discrimination results are more stable. Continuous weight mapping avoids drastic changes in scores caused by hard boundary screening, which helps to improve the stability of abnormal scores in streaming scenarios.
[0049] 3. Superior privacy protection: The entire detection process is completely blind on the server side, eliminating the need for self-bootstrapping to complete long-term streaming monitoring, ensuring the confidentiality of data throughout its entire lifecycle, and facilitating anomaly detection without exposing original characteristics. Attached Figure Description
[0050] Figure 1 This is a flowchart of a ciphertext anomaly detection method based on weight mapping and surface modeling provided by the present invention.
[0051] Figure 2 This is a conceptual diagram of a ciphertext anomaly detection method based on weight mapping and surface modeling provided by the present invention.
[0052] Figure 3 This is a module structure diagram of a ciphertext anomaly detection system based on weight mapping and surface modeling provided by the present invention. Detailed Implementation
[0053] The preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby providing a clearer and more explicit definition of the scope of protection of the present invention.
[0054] Many specific details are set forth in the following description in order to provide a full understanding of the invention, but the invention may also be practiced in other ways different from those described herein; obviously, the embodiments in the specification are only some embodiments of the invention, and not all embodiments.
[0055] Example 1
[0056] Figure 1 This is a flowchart of a ciphertext anomaly detection method based on weight mapping and surface modeling provided by the present invention. The method includes:
[0057] The S10 client collects raw traffic, extracts multi-dimensional feature vectors, constructs samples to be detected, performs normalization processing on the samples using preset distribution parameters, calls the public key to encapsulate them into ciphertext tensors, and transmits them to the server in real time according to the time sequence.
[0058] The S20 server determines expired ciphertext tensors based on the timing identifier attached to the ciphertext tensor, removes the expired ciphertext tensors, stores newly arrived ciphertext tensors at the end of the window, and updates the window storage structure and the total ciphertext state baseline inside the window.
[0059] The S30 server calculates the ciphertext squared distance between the newly arrived ciphertext tensor and each ciphertext tensor in the window, and inputs the ciphertext squared distance into a preset polynomial kernel function to assign continuous soft neighborhood mapping weights to each ciphertext tensor in the window.
[0060] The S40 server performs weighted aggregation on each ciphertext tensor within the window based on the continuous soft neighborhood mapping weight, extracts the weighted first-order statistics and weighted second-order statistics, and constructs a local statistical parameter matrix based on this, and calculates the local energy value of the newly arrived ciphertext tensor based on the quadratic energy function.
[0061] The S50 server aggregates the local energy value with the local statistical parameter matrix, calls the pre-trained discriminant parameter matrix to perform a homomorphic inner product operation on the aggregation result, and generates an encrypted anomaly detection score.
[0062] The S60 server sends back the anomaly detection score in the encrypted form. The client calls the private key to decrypt and recover the plaintext score. The plaintext score is then compared with a preset threshold to determine the abnormal traffic situation.
[0063] The client collects raw traffic and extracts multi-dimensional feature vectors to construct samples to be detected, including: the client capturing real-time traffic data packets through a network acquisition interface. , This represents a captured single physical network packet, and the network flow is obtained by aggregating the packet based on the network flow 5-tuple. , This represents a set of data packets logically linked together by a 5-tuple. The temporal and spatial features of the network flow are extracted and concatenated according to a preset system feature dimension template to generate the original feature vector. :
[0064] ;
[0065] in, This represents the original feature vector generated after concatenation according to the template. This indicates the total number of feature dimensions preset by the system. Represents the original feature vector The first in There are 1 feature components, among which , express 3D real-valued feature space;
[0066] The original feature vector Construct as the current time series The sample to be tested , Indicates the current system runtime sequence; This indicates the sample carrier at the corresponding time series.
[0067] The sample is normalized using preset distribution parameters, wherein the preset distribution parameters include feature mean vectors corresponding to each feature dimension of the sample to be detected. With the feature standard deviation vector , This is the mean vector of global historical features. The standard deviation vector represents the global historical features. The mean vector and standard deviation vector are obtained statistically from historical normal traffic samples. The normalized sample is calculated by substituting each feature component of the sample to be detected into the standardization formula. The calculation formula is:
[0068] ;
[0069] This indicates the number after standardization. Each normalized feature component For the first The standard deviation of historical data for dimensional features This represents a preset positive number to prevent division by zero, thus preventing division by zero anomalies when the standard deviation is zero.
[0070] The public key is encapsulated into a ciphertext tensor and transmitted to the server in real time according to the time sequence, including: setting a preset scaling factor. , To enlarge the feature map of the real number field while preserving decimal precision, the client invokes a pre-configured fully homomorphic encryption algorithm public key. , This represents the pre-allocated fully homomorphic public key of the system. Denotes the polynomial indeterminate elements that constitute the cryptographic ring structure. and The public-key polynomial components generated based on the ring error learning problem are used to perform encoding and homomorphic encryption operations on the real-valued feature components in the normalized samples. First, polynomial encoding is performed:
[0071] ;
[0072] in, This represents the plaintext polynomial obtained after encoding. This represents a coding function that maps a real number vector to a polynomial. This represents the nearest integer rounding operator;
[0073] The corresponding ciphertext tensor is then generated:
[0074] ;
[0075] ;
[0076] ;
[0077] in, This represents the final generated fully homomorphic ciphertext tensor. It is the first polynomial of the ciphertext tensor (containing plaintext information terms). This is the second polynomial (blinding term) of the ciphertext tensor. This is the mask polynomial randomly sampled during the encryption process. and A noise polynomial sampled from a Gaussian error distribution, used to ensure safety. The initial top-level modulus set before ciphertext computation. Represents all pairs of polynomial coefficients Perform modulo operation;
[0078] Add a timing identifier to the ciphertext tensor , To record the time scalar of the physical arrival time of the samples, a ciphertext tensor carrying the time sequence is constructed. This represents the combined data structure ultimately used for network transmission, which pushes the ciphertext tensor into the output queue and transmits it to the server in real time.
[0079] Furthermore, the algebraic operations performed on each of the ciphertext tensors by the fully homomorphic encryption algorithm are implemented through a preset set of homomorphic operator sequences, the homomorphic operator sequences and their execution rules including:
[0080] Let the set of fully homomorphic operator sequences of the system be... ,
[0081] in, This represents the set of encrypted field operations that the server is authorized to execute. Represents homomorphic multiplication in ciphertext fields. Indicates rescaling of the ciphertext field. Represents the homomorphic addition of the ciphertext field. This indicates a homomorphic rotation of the ciphertext slot;
[0082] Homomorphic addition: performs linear accumulation between ciphertext tensors and homomorphic summation between ciphertext tensors and plaintext bias terms; among them, homomorphic subtraction is achieved by performing a negation operation on the term to be subtracted and then performing homomorphic addition, so as to complete the vector difference calculation in the ciphertext domain;
[0083] Homomorphic multiplication: Performs product operations between ciphertext tensors and plaintext parameters, or between ciphertext tensors; where homomorphic multiplication and addition are implemented by performing homomorphic multiplication and homomorphic addition in sequence; for ciphertext tensors with inconsistent modulus levels before the operation, the levels are aligned by performing a modulus switching operation to ensure the legality of algebraic operations;
[0084] Rescaling: After homomorphic multiplication, the scaling factor of the resulting ciphertext is adjusted, and the alignment of the scale factor of the resulting ciphertext and the management of ciphertext noise are achieved by consuming the ciphertext modulus chain level.
[0085] Homomorphic rotation: The alignment of feature dimensions and expansion of feature space are achieved by cyclic displacement of ciphertext slots. By performing a rotation operation with a preset step size inside the ciphertext tensor, parallel extraction of cross terms in the weighted second-order statistics is supported.
[0086] Furthermore, the server maintains a contiguous storage structure of preset capacity in memory to cache the ciphertext tensor transmitted in step S10 in a time-sequential manner, and simultaneously initializes a baseline for the total amount of ciphertext states that matches the dimensions of the ciphertext tensor: the server constructs a maximum capacity of [missing information] in the trusted memory area. First-in-first-out contiguous storage structure , This indicates the maximum number of ciphertext samples that the sliding window can hold. This indicates a time-series-maintained ciphertext buffer queue, which sequentially pushes the ciphertext tensors arriving in real-time from step S10 into the queue. In the middle, the cache state is recorded as At the same time, the system initializes the total amount of encrypted state baseline at startup (or when the window is first filled). :
[0087] ;
[0088] in, Indicates in time series Below, the global state baseline is the sum of the features of all ciphertext tensors within the current window. The timing is represented as Historical cipher tensor of time, This indicates a series of calls to the defined homomorphic addition. Perform the summation of the ciphertext fields;
[0089] The process involves removing expired ciphertext tensors and storing newly arriving ciphertext tensors at the end of the window. When a newly arriving ciphertext tensor is received and the contiguous storage structure reaches capacity saturation, the server parses the time sequence identifier in the ciphertext tensor, extracts the earliest arriving ciphertext tensor in the time dimension, designates it as the expired ciphertext tensor, calls the scalar homomorphic multiplication of the fully homomorphic encryption algorithm, performs a homomorphic scalar multiplication operation between the expired ciphertext tensor and the plaintext constant, generates the negated ciphertext, and when the current time sequence is received... New Arrival Cipher Tensor And detected At that time, the server parses the timing identifier of the first and second parts of the contiguous storage structure. Locate and extract the earliest arriving expired ciphertext tensor in the time dimension. , This refers to the last data that the sliding window is about to slide out, with a preset plaintext constant of 0. The server encodes it as a plaintext polynomial. And call the homomorphic multiplication to generate the negated ciphertext. The calculation formula is:
[0090] ;
[0091] in, This represents the latest ciphertext tensor that is ready to join the ranks. This represents an expired ciphertext tensor that has reached the end of its lifecycle and is ready to be removed from the queue. To achieve the negation of real-number coefficients in logical subtraction, for go through Plaintext scalar parameters mapped after the operation This represents the inverted ciphertext result after homomorphic scalar multiplication, where the signs of all the numerical values in the internal feature slots are flipped.
[0092] The update window storage structure and the total state within the window are determined by the server calling the homomorphic addition operation. This operation performs homomorphic addition on the current ciphertext state total baseline, the newly arrived ciphertext tensor, and the negated ciphertext to obtain the updated ciphertext state total baseline. Then, the expired ciphertext tensor is removed from the contiguous storage structure, and the newly arrived ciphertext tensor is appended. This completes the decryption-free algebraic evolution of the ciphertext state total baseline with constant-time computational complexity. The server then calls the homomorphic addition operation. Homomorphic iteration of the total number of states is performed using incremental logic:
[0093] ;
[0094] in, This indicates the latest time series after incremental evolution. The updated ciphertext state total baseline is calculated using algebraically equivalent formulas: subtracting the old value and adding the new value. Then, queue shifting is performed on the physical storage, calculated using the following formula:
[0095] ;
[0096] in, Indicates completion of element stripping With addition The latest contiguous storage structure state after the above ciphertext state evolution, regardless of the sliding window capacity The value of depends on only two homomorphic additions during its update process, regardless of the value. Homomorphic multiplication with a first-order scalar That is, the time complexity is This achieves decryption-free algebraic evolution with constant-level computational complexity in engineering.
[0097] Furthermore, the total ciphertext state benchmark, initially a zero-vector ciphertext encapsulation, is used to accumulate the algebraic sum of each ciphertext tensor within the storage window in real time during incremental updates, and serves as a pre-variable for the global algebraic operation to calculate the mean offset when constructing a continuous weight field. During system startup or window reset phases, the server initializes the total ciphertext state benchmark. First, construct a feature dimension Matching zero vector Then, encoding and homomorphic encryption operations are performed, calculated using the following formula:
[0098] ;
[0099] in, express The baseline for the total amount of ciphertext state initialized at each moment. This represents the original plaintext vector where all feature components are zero. and These are the defined homomorphic encryption and encoding functions, respectively. For the pre-scale factor, and These represent the polynomial components of the initial zero vector ciphertext. During system operation, this reference dynamically stores the current window. The algebraic summation of all ciphertext samples is defined mathematically and physically as follows:
[0100] ;
[0101] in, Representing timing The real-time algebra sum of all ciphertext samples within the lower window is used as the offset for subsequent calculation of the neighborhood mean. Pre-input variables;
[0102] The incremental update process utilizes homomorphic addition to accumulate newly arriving ciphertext tensors into the total ciphertext state baseline, and also utilizes homomorphic addition to superimpose the inverted ciphertext of expired ciphertext tensors into the total ciphertext state baseline. This achieves constant-level sliding update of window statistical properties without decryption. When the window slides, new samples are available. Arrival and existing samples Upon expiration, the server will process the data via the following algebraic path. To proceed with the evolution, firstly, homomorphic accumulation of the new samples is performed, calculated using the following formula:
[0103] ;
[0104] in, This represents the sum of intermediate ciphertexts containing the feature information of the new sample. This indicates the defined homomorphic addition, followed by the inversion of the ciphertext from expired samples. Homomorphic superposition completes the sliding update:
[0105] ;
[0106] in, This represents the baseline of the latest encrypted state after removing contributions from expired samples. To meet The inverted ciphertext, through the two homomorphic addition operations described above, eliminates the need for the server to process the remaining text within the window. The computational cost of repeatedly traversing or decrypting a ciphertext tensor is... Constantly satisfies:
[0107] ;
[0108] in, This represents the time cost of performing a single homomorphic addition. This represents the time cost of performing a single scalar homomorphic multiplication (inversion operation). Since this cost is independent of window size... The value increases with the increase of , thus achieving statistical properties in the ciphertext field. Constant-level glide update.
[0109] Furthermore, the server-side uses a contiguous storage structure Extracting the time-series index is Historical cipher tensor And using homomorphic addition Calculate its relationship with the newly arrived ciphertext tensor The dimensional difference between the two values is inverted to generate the difference ciphertext. :
[0110] ;
[0111] in, Indicates the first [number]th ... A encrypted tensor of historical samples to be compared This represents the ciphertext tensor of the newly arrived sample to be tested. This represents a ciphertext vector containing the differences in features across various dimensions between two samples. This represents homomorphic addition, performing homomorphic multiplication and rescaling to calculate the squared difference of each ciphertext tensor feature dimension, and calling homomorphic rotation and homomorphic addition to perform cyclic displacement and accumulation of ciphertext slots to obtain the scalar form of the ciphertext squared distance. The server then uses this information to... Homomorphic self-multiplication is performed to extract the squared deviation values of each feature dimension, resulting in the squared difference ciphertext. :
[0112] ;
[0113] in, This indicates that the slot stores a ciphertext tensor containing the characteristic squared difference. and These are defined as homomorphic multiplication and rescaling, respectively. Then, the server uses divide-and-conquer summation logic, through... Subhomomorphic rotation and addition operations will The values of all slots are summed to extract the scalar form of the ciphertext squared distance. :
[0114] ;
[0115] in, Indicates the first The squared Euclidean distance between the window sample and the new sample is the ciphertext value (at this time, all slots in the ciphertext tensor are filled with this scalar). The total number of defined feature dimensions. This represents a homomorphic rotation operation with a step size of 2 powers, used to achieve efficient folding and summation of values within a slot;
[0116] The process involves assigning continuous soft-neighborhood mapping weights to each ciphertext tensor within the window. The server inputs the squared ciphertext distance as an independent variable into the polynomial kernel function and recursively performs homomorphic multiplication and homomorphic addition within the ciphertext domain using the Horner algorithm. The calculated results are then processed accordingly. The server introduces pre-built A polynomial kernel function of order 1, wherein the sequence of polynomial coefficients is . Server-side initialization of intermediate iteration variables The recursive rules are as follows:
[0117] ;
[0118] in, This represents the fitting order of the polynomial kernel function. Represents the corresponding polynomial The plain text coefficient component of the second term, Indicates the first The intermediate ciphertext result generated by the recursive step is used to iteratively multiply and add the independent variable to the plaintext coefficients of the polynomial kernel function to calculate the continuous soft neighborhood mapping weights corresponding to each ciphertext tensor. A continuous weight field describing the spatial correlation strength of the current ciphertext tensor is constructed from the continuous soft neighborhood mapping weights corresponding to each ciphertext tensor. When the recursion reaches... At that time, the soft neighborhood mapping weights corresponding to each ciphertext tensor are calculated. :
[0119] ;
[0120] in, Indicates the first The server calculates the neighborhood contribution weights of each window sample relative to the newly arrived sample, and performs this calculation in parallel on all samples within the window. This process ultimately constructs a continuous weight field describing the correlation strength of the current ciphertext tensor space. .
[0121] Furthermore, the polynomial kernel function, in the plaintext domain, is selected as a continuous function with monotonically decreasing characteristics as the benchmark model for the neighborhood contribution distribution, used to characterize the negative correlation mapping relationship between the distance between samples and the neighborhood weights. The server first selects the benchmark kernel function in the plaintext environment. represents the ideal continuous function used to simulate the decay characteristics of the physical neighborhood, for example, a variant using a Gaussian radial basis structure, calculated as follows:
[0122] ;
[0123] in, This represents the corresponding value of the ciphertext squared distance scalar in the plaintext domain calculated in the embodiment. This represents a preset neighborhood smoothing factor. This function, through its negative exponential property, ensures that the neighborhood contribution monotonically decreases as the sample interval increases. Based on the characteristic distribution range of historical samples, the target distance range is defined as the fitting domain of the polynomial. Based on the statistical characteristics of historical traffic data, the maximum possible value of the distance is determined. Thus, the fitting interval is defined:
[0124] ;
[0125] in, This represents the effective domain in which the polynomial approximation algorithm is effective. This is a preset upper limit for the distance threshold based on the feature dimensions;
[0126] Using Chebyshev polynomials as basis functions, the benchmark model is subjected to [further testing] within the range of the target distance. To minimize the consistency error in the ciphertext field, orthogonal polynomials of order 1 are used for approximation. This is achieved by utilizing Chebyshev polynomials of the first kind. As an orthogonal basis, first, the variables are... from Mapped to Chebyshev standard interval :
[0127] ;
[0128] in, Represents the normalized independent variable after mapping. Defined as , for the Chebyshev polynomial of the th The term base, and then, within the said interval, the reference model. conduct Expand the order and construct the fitting polynomial :
[0129] ;
[0130] in, This indicates the fitting order described in the claims, corresponding to the order described in the claims. Logic of order, Indicates the first The expansion coefficients of the Chebyshev basis functions;
[0131] The corresponding polynomial coefficient vector is calculated, and the polynomial coefficient vector is preset as plaintext parameters. The polynomial coefficient vector is then calculated through numerical integration or discrete cosine transform (DCT). :
[0132] ;
[0133] in, This represents the vector of coefficients of the final transformed standard power term, corresponding to... coefficient, For the first Second item The corresponding plaintext parameters are pre-stored in the server's memory for use in the Qin Jiushao algorithm in this embodiment. This algorithm constructs and generates an M-order polynomial kernel function that satisfies the chained rules of fully homomorphic addition and multiplication. The coefficient vector is then used to... As input to the operator chain, a kernel function execution body that can be executed in the ciphertext domain is constructed. Since the function is entirely composed of homomorphic multiplication Homomorphic addition Composition, the execution depth and order of its operator chain They exhibit a logarithmic relationship:
[0134] ;
[0135] in, This indicates the number of modular chain layers consumed when executing the kernel function in the ciphertext field. This ensures that complex nonlinear weight mapping can be completed through chained calls without decryption.
[0136] refer to Figure 2The server performs weighted aggregation on each ciphertext tensor within the window based on the continuous soft neighborhood mapping weights, extracting a weighted first-order statistic. The server then uses the continuous soft neighborhood mapping weights and the corresponding ciphertext tensors within the window to perform homomorphic multiplication and rescaling, generating a scale-aligned weighted ciphertext tensor. The server then extracts the generated continuous weight field. Each weight component in For window-cached ciphertext tensors Calculate the weighted ciphertext features :
[0137] ;
[0138] in, Indicates the first The weighted ciphertext tensor of each sample after soft neighborhood weight mapping For the calculated corresponding to the first The soft neighborhood mapping weights of each sample and Homomorphic multiplication and rescaling are defined respectively, and all weighted ciphertext tensors within the window are linearly accumulated using homomorphic addition to extract the weighted first-order statistic describing the local distribution center. The server generates a first-order statistical feature vector by homomorphically summing all weighted samples within the window. :
[0139] ;
[0140] in, This represents the extracted weighted first-order statistic, whose mathematical meaning corresponds to the weighted mean center within the soft neighborhood. The defined sliding window capacity;
[0141] The extraction of weighted second-order statistics involves the server performing feature space expansion on each weighted ciphertext tensor, shifting the weighted ciphertext tensor using homomorphic rotation, and performing homomorphic multiplication and rescaling with the weighted ciphertext tensor before the shift. The server achieves space expansion through cross-product of feature dimensions for each weighted ciphertext tensor. Using a preset rotation step size Generate the displacement vector and extract the intermediate terms of the second-order features. :
[0142] ;
[0143] in, Indicates the first The second-order feature ciphertext obtained by spatial expansion of a weighted ciphertext tensor Homomorphic rotations are defined to achieve dimension alignment. Given the preset feature intersection depth parameter, this operation is performed through... Extracting the feature squared terms, through The pairwise interaction terms of the features are extracted, and then homomorphic addition is used to accumulate and aggregate all the expanded weighted ciphertext tensors within the window to extract the weighted second-order statistic containing the squared features and the pairwise interaction terms of the features. The server aggregates the expanded features of all samples to generate a second-order statistical feature vector. :
[0144] ;
[0145] in, This represents the extracted weighted second-order statistic, which covers the variance and covariance distribution information within the soft neighborhood;
[0146] To construct the local statistical parameter matrix, the server performs tensor concatenation and aggregation on the weighted first-order and weighted second-order statistics after aligning them at the ciphertext modulus level. Since the first-order and second-order operations consume different modulus levels, the server first uses a modulus switching operator to... and Align to uniform module level Then, a statistical matrix was constructed. :
[0147] ;
[0148] in, To construct the local statistical parameter matrix, each slot element encompasses local mean, variance, and covariance information through a specific encoding method. Each slot element of the local statistical parameter matrix covers the distribution information of mean, variance, and covariance within the current soft neighborhood, serving as a quadratic energy function for surface parameter fitting to describe the local spatial distribution characteristics. Corresponding to the quadratic energy function The set of coefficients defines the probability density energy distribution mapping of the local feature space in the ciphertext domain;
[0149] The local energy value of the newly arrived ciphertext tensor is calculated based on the quadratic energy function. The server uses the characteristic components of the newly arrived ciphertext tensor as independent variables and inputs them into the quadratic energy function characterized by the local statistical parameter matrix. The server utilizes the currently newly arrived ciphertext tensor... and By combining operators, an energy metric function is constructed:
[0150] ;
[0151] in, This represents the ciphertext of the calculated local statistical energy value. This represents the evaluation logic based on a quadratic energy function, which includes a nonlinear mapping for the features of the new sample. It calculates the offset potential energy of the newly arrived ciphertext tensor relative to the local distribution center through homomorphic multiplication and rescaling, generating the corresponding local statistical energy ciphertext. Specifically, the calculation path involves extracting the second-order term of the new sample through homomorphic multiplication and then... Accumulated execution points quantify the degree to which they deviate from the local distribution center.
[0152] ;
[0153] Among them, the offset potential energy is measured through homomorphic multiplication and addition operations, generating... The smaller the ciphertext size, the more the new sample conforms to the local distribution pattern; conversely, the larger the ciphertext size, the higher the abnormal potential energy.
[0154] Furthermore, the feature space expansion is performed on each of the weighted ciphertext tensors. The server utilizes the batch processing parallelism of the ciphertext domain, performing spatial rearrangement and nonlinear multiplication operations on the feature elements. This synchronously extracts pairwise cross-product terms between feature dimensions within the ciphertext slots, and linearly aggregates the obtained cross-product terms with the squared terms of the original features. This maps the original feature space to a second-order enhanced feature space containing mean, variance, and covariance information. This applies to each weighted ciphertext tensor generated in the embodiment. The server constructs a second-order augmented feature tensor. This process uses homomorphic addition to linearly aggregate the independently computed feature square terms with the cross-product terms of each dimension:
[0155] ;
[0156] in, This represents the latest ciphertext tensor mapped to the second-order enhanced feature space after feature space expansion (containing the underlying information of variance and covariance). This represents the original feature squared terms of the ciphertext extracted synchronously within the ciphertext slot. This represents the ciphertext of pairwise cross-product terms between feature dimensions extracted synchronously within the ciphertext slot. This represents the preset feature cross-depth parameter (which determines the dimensional span when extracting the covariance term). The defined homomorphic addition is used to implement the linear aggregation of the above terms. The weighted ciphertext tensor is shifted. The server, according to preset feature crossover rules, calls homomorphic rotation to perform a cyclic shift operation on the weighted ciphertext tensor encapsulating multi-dimensional features, generating multiple shifted ciphertext vectors with different dimensional offsets. This aligns the feature dimensions originally in different ciphertext slots to the same mapping position, providing aligned ciphertext input for subsequent cross-product operations, and facilitating the calculation of the above... and The server determines the step size based on the preset step size. Call homomorphic rotation Perform a cyclic shift operation on the weighted ciphertext tensor:
[0157] ;
[0158] in, This indicates the generated dimension offset. The displacement ciphertext vector, the underlying algebraic meaning of this operation is to index the original ciphertext slot as... The feature components are forced to align to the index. Location, Given the defined total number of feature dimensions, after slot alignment, the server performs homomorphic multiplication and rescaling in parallel to provide ciphertext input for the cross-product operation. For the cross-product term:
[0159] ;
[0160] Meanwhile, when the offset is implicitly 0 (i.e., no displacement occurs), the server extracts the squared term through a self-multiplication operation:
[0161] ;
[0162] in, and These are defined homomorphic multiplication and rescaling, respectively. Since these operations directly operate on the entire ciphertext tensor, they utilize the SIMD (Single Instruction Multiple Data) characteristic of fully homomorphic encryption. The time overhead is used to perform nonlinear product operations in all dimensions in parallel within the slot.
[0163] Furthermore, the discriminant parameter matrix is obtained by pre-training a parameter matrix in the plaintext domain using a normal traffic baseline. The dimension of the discriminant parameter matrix is consistent with the total feature dimension after superimposing the local statistical matrix with the ciphertext of the local statistical energy value. The server extracts the pre-deployed plaintext parameter matrix. This matrix is a set of discrimination weights trained using machine learning algorithms based on baseline traffic data without anomalies during the offline phase. Let's assume the encrypted local statistical matrix generated in the preceding steps... The flattening feature dimension is The local statistical energy value ciphertext The dimension occupied is (Usually a scalar dimension 1), then it is required that The total dimension of the vector space before polynomial encoding Strictly meet:
[0164] ;
[0165] in, This represents the plaintext parameter matrix used to perform the final linear discrimination, which has been obtained according to the settings before computation in the ciphertext field. The scaling factor is encoded as a polynomial. This represents the total feature dimension span after alignment, ensuring a one-to-one correspondence of slot numbers during homomorphic inner product operations;
[0166] The process of generating an encrypted anomaly detection score involves concatenating and aggregating the local statistical parameter matrix with the ciphertext of the local statistical energy value, and then performing a homomorphic matrix inner product operation with the discriminant parameter matrix. The server then reassembles the data within the ciphertext slots. and Tensor splicing is performed along a preset dimension to generate fused ciphertext. :
[0167] ;
[0168] Subsequently, the fused ciphertext With the discriminant parameter matrix Perform slot-by-slot homomorphic multiplication and rescaling to compute the inner product intermediate ciphertext. :
[0169] ;
[0170] in, This indicates a splicing and aggregation operation within the ciphertext slot space. This indicates a concatenated ciphertext that integrates local statistical distribution characteristics and offset potential energy characteristics. This represents the intermediate-state ciphertext tensor that has not undergone slot accumulation after performing the homomorphic inner product operation. and For the defined homomorphic multiplication and rescaling, a homomorphic rotation and summation operation is performed on the inner product operation result, aggregating the weighted contributions of each matrix component and energy value into a scalar result. To integrate the discriminative information from all dimensions, the server... Invoke the divide-and-conquer, rotation, and summation logic in binary tree form:
[0171] ;
[0172] in, This represents the scalar result ciphertext obtained after multiple homomorphic rotations and homomorphic additions, where all valid slots of the ciphertext tensor are filled with the sum of this scalar. Homomorphic rotation is defined to achieve efficient folding and accumulation between slots, and a scoring bias term is introduced by calling homomorphic addition. Finally, a scalar form of anomaly detection score ciphertext is generated. Finally, the server introduces a plaintext bias term from the linear discriminant scoring function. The definition of this bias term and the homomorphic addition rule have been stated in detail, along with the scalar result. Perform ciphertext homomorphic addition:
[0173] ;
[0174] in, This represents the plaintext bias term obtained during offline training, used to translate the decision boundary. This represents the final output, an encrypted form of the anomaly score (Ciphertext). This score remains encrypted throughout the entire computation lifecycle and can only be used for threshold comparison and attack alerts after it is sent back to the client and decrypted.
[0175] Further, the decryption process recovers the plaintext score by sending the calculated anomaly detection score ciphertext back to the client via a network communication interface. The client then uses a pre-configured fully homomorphic encryption algorithm private key to sequentially decrypt and decode the anomaly detection score, recovering the plaintext detection score. The server then sends the final encrypted anomaly detection score calculated in the previous step back to the client. The public key is sent back to the client, which then uses it. Paired fully homomorphic encryption algorithm private key , To represent the private key polynomial under the ring structure, first perform a low-level polynomial decryption operation on the ciphertext:
[0176] ;
[0177] ;
[0178] in, This represents the plaintext polynomial containing score information extracted after decryption. This is the underlying cryptographic decryption function. and For ciphertext tensors polynomial components in This represents the underlying module at the end of the ciphertext after multiple rescaling operations. Subsequently, the client... Perform the inverse decoding operation of the encoding operation and remove the scaling factor. The impact of the test results is used to recover the plaintext test score. :
[0179] ;
[0180] in, This represents the plaintext scalar score restored to the real number field. The decoding function is used to remap the polynomial back to the real number space. The preset scaling factor set in Example 1 is used to restore decimal precision during the decoding stage;
[0181] To determine abnormal traffic conditions, the client retrieves a preset security baseline threshold from the system. Within the plaintext calculation domain, it compares the plaintext detection score with the security baseline threshold to determine the security status of the network traffic at the current time. If the comparison result indicates that the plaintext detection score exceeds the security baseline threshold, the client generates a security alarm command based on the original network flow 5-tuple information, or issues a traffic blocking policy to the network edge device. The client then retrieves a locally pre-configured security baseline threshold. , This represents the plaintext security boundary value set based on the extreme values of the historical distribution of normal network flows, and the calculated real-valued score. Substituting this threshold into the step discrimination function, the timing is determined. The safe state under :
[0182] ;
[0183] in, This variable represents the determination result of the current network flow. That is, when the score exceeds the threshold, the client immediately backtracks and retrieves the saved original network flow quintuple information:
[0184] ;
[0185] Based on this precise positioning information Generate security response instructions :
[0186] ;
[0187] in, For the defined network flow quintuple that caused the anomaly, This represents the system's security policy response mapping function. This indicates the generated execution instructions, covering those based on Access control lists (ACLs) generated from IP addresses and ports can be used to block policies or to send alarm logs to the SIEM platform.
[0188] Example 2
[0189] The following describes a ciphertext anomaly detection system based on weight mapping and surface modeling provided by an embodiment of the present invention. The ciphertext anomaly detection system based on weight mapping and surface modeling described below can be referred to in correspondence with the ciphertext anomaly detection method based on weight mapping and surface modeling described above.
[0190] refer to Figure 3 A ciphertext anomaly detection system based on weight mapping and surface modeling includes:
[0191] Data encapsulation and preprocessing module: Deployed at the edge computing node at the network egress point, this module employs an instruction set-optimized embedded processor and integrates a homomorphic computing library. This module is responsible for capturing raw traffic packets in real time via the underlying driver, parsing the five-tuple location information, and mapping it to a high-dimensional feature vector. In the in-memory computing area, the module performs normalization mapping on the raw features, unifying their dimensions to a preset value range. Subsequently, the module introduces a high-precision scaling factor and uses a fully homomorphic encryption public key to perform masking and noise injection on the polynomial coefficients, generating a ciphertext tensor with a two-component structure, which is then sent to the server via an asynchronous network interface with a high-precision timestamp.
[0192] The window state incremental management module runs in a memory-resident process within the server-side high-performance computing cluster and is responsible for managing the encrypted observation data pool. This module maintains a fixed-capacity ciphertext storage structure through a circular buffer to achieve temporal replacement of samples. When a new sample's arrival causes the buffer to saturate, the module does not directly perform physical deletion. Instead, it calls homomorphic scalar multiplication to perform sign flipping on expired ciphertext that has reached its lifespan, generating logically inverted ciphertext. Homomorphic addition is then used to simultaneously apply the inverted ciphertext and the newly arrived ciphertext to the current global state baseline, achieving constant-level evolution of statistical total indicators without decryption.
[0193] The continuous weighted field construction module utilizes high-bandwidth memory and multi-core parallel processing capabilities to model the topological correlation of the ciphertext distribution within a window. This module extracts the ciphertext of newly arriving samples and performs homomorphic addition operations on each cached historical sample within the window, achieved through inversion. It then uses rotation to perform slot folding and summation, extracting the scalar-form squared Euclidean distance within the ciphertext domain. Subsequently, the module uses a pre-defined polynomial kernel function and a Qin Jiushao operator chain to perform a nonlinear mapping on the distance scalar. This process recursively executes ciphertext multiplication and addition iterations, assigning each sample a soft-neighborhood weight reflecting the strength of spatial correlation, thus constructing a continuous weighted field describing the local distribution density of features.
[0194] The Statistical Energy Surface Modeling module is responsible for extracting deep statistical components from weighted features and characterizing energy distribution features. This module uses pre-generated soft neighborhood weights to perform linear scaling on the encrypted features, extracting the first-order statistical center. Simultaneously, the module uses homomorphic rotation to perform cyclic displacement of the feature dimensions, synchronously completing cross-product operations of each dimension within the encrypted slots, thereby extracting the second-order statistical components containing covariance information. Through tensor concatenation and modulus alignment operations, the module fits the first-order and second-order components into a local statistical matrix of the encrypted text, and constructs a quadratic statistical energy surface based on this matrix, quantifying the anomalous potential energy of newly arriving samples deviating from the local distribution center.
[0195] The linear scoring mapping module performs compressed mapping and decision preparation from the high-dimensional distribution matrix to a single anomaly score. Within the ciphertext space, this module reconstructs features from the local statistical matrix and the calculated potential scalar, generating a unified fused ciphertext to be discriminated. The module retrieves the discriminant parameter matrix generated during offline training and performs homomorphic weighted aggregation of weights through a single matrix inner product operation. Leveraging the batch processing characteristics of fully homomorphic encryption, the module quickly merges the anomaly contributions of all statistical components without revealing specific feature weights, adds a plaintext discriminant bias, and generates the final encrypted anomaly detection score, which is then sent back to the client.
[0196] The decryption judgment and closed-loop response module, deployed in the trusted client security hub, is responsible for distributing security policies after anomaly detection. Upon receiving the encryption score from the cloud, this module, within a hardware-isolated decryption unit, uses the private key to recover the plaintext polynomial and restores the original real-valued score using decoding operators. The module compares this score with dynamic thresholds in the system's security policy library. Once an anomaly is confirmed, it immediately retrieves the original characteristics of the stream cached before encryption, automatically generates corresponding access control instructions (ACLs) or traffic rate limiting policies, and distributes them to edge-isolated devices for execution, achieving a closed-loop defense from threat awareness to real-time blocking.
[0197] In this embodiment, privacy awareness and ciphertext encapsulation are first performed at the client edge. The raw traffic features collected in real time are normalized and a preset scaling factor is introduced. The multidimensional feature vector is then mapped into a ciphertext tensor with algebraic mask properties using a fully homomorphic encryption public key. To ensure the confidentiality of feature data throughout its entire lifecycle of transmission and subsequent processing, the server maintains the sliding window using a window state incremental management mechanism after receiving the ciphertext stream. By using homomorphic negation of expired samples for sign offsetting and combining this with homomorphic addition to load new samples, the total number of states in a window can be statistically analyzed without decryption intervention. In the core detection logic stage, the server uses the Qin Jiushao algorithm to recursively execute polynomial kernel function mapping in the ciphertext domain, dynamically assigning soft neighborhood mapping weights to each sample within the window, and calling homomorphic rotation and multiplication to perform feature space expansion, extracting the first-order mean component and the second-order statistical component containing covariance information, thereby fitting and generating a quadratic statistical energy surface describing the characteristics of the local feature distribution, which is used to quantify the offset potential energy of newly arrived samples relative to the local background distribution. Finally, the server performs homomorphic matrix inner product operation on the local statistical matrix and the energy offset value to generate an encrypted anomaly detection score and sends it back to the client. The client decrypts the plaintext score using the private key and compares it with a preset security threshold. If an unauthorized alarm is triggered, an automated traffic blocking or security alarm strategy is executed based on the original five-tuple information retained before encryption, achieving a closed loop of network security protection in a privacy computing environment.
[0198] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those 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 invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for detecting encrypted anomalies based on weight mapping and surface modeling, characterized in that, include: The S10 client collects raw traffic, extracts multi-dimensional feature vectors, constructs samples to be detected, performs normalization processing on the samples using preset distribution parameters, calls the public key to encapsulate them into ciphertext tensors, and transmits them to the server in real time according to the time sequence. The S20 server determines expired ciphertext tensors based on the timing identifier attached to the ciphertext tensor, removes the expired ciphertext tensors, stores newly arrived ciphertext tensors at the end of the window, and updates the window storage structure and the total ciphertext state baseline inside the window. The S30 server calculates the ciphertext squared distance between the newly arrived ciphertext tensor and each ciphertext tensor in the window, and inputs the ciphertext squared distance into a preset polynomial kernel function to assign continuous soft neighborhood mapping weights to each ciphertext tensor in the window. The S40 server performs weighted aggregation on each ciphertext tensor within the window based on the continuous soft neighborhood mapping weight, extracts the weighted first-order statistics and weighted second-order statistics, and constructs a local statistical parameter matrix based on this, and calculates the local energy value of the newly arrived ciphertext tensor based on the quadratic energy function. The S50 server aggregates the local energy value with the local statistical parameter matrix, calls the pre-trained discriminant parameter matrix to perform a homomorphic inner product operation on the aggregation result, and generates an encrypted anomaly detection score. The S60 server sends back the anomaly detection score in the encrypted form. The client calls the private key to decrypt and recover the plaintext score. The plaintext score is then compared with a preset threshold to determine the abnormal traffic situation.
2. The encrypted anomaly detection method based on weight mapping and surface modeling as described in claim 1, characterized in that: The process of the client collecting raw traffic and extracting multi-dimensional feature vectors to construct a sample to be detected includes: the client capturing real-time traffic data packets through a network acquisition interface, aggregating the data packets to obtain a network flow based on the network flow quintuple, extracting the time dimension and spatial dimension features of the network flow, concatenating them according to a preset system feature dimension template to generate an original feature vector, and constructing the original feature vector as a sample to be detected in the current time series.
3. The encrypted anomaly detection method based on weight mapping and surface modeling as described in claim 1, characterized in that: The sample is normalized using preset distribution parameters, wherein the preset distribution parameters include the feature mean vector and feature standard deviation vector corresponding to each feature dimension of the sample to be detected. The normalized sample is calculated by substituting each feature component of the sample to be detected into the standardization formula. The process of encapsulating the public key into a ciphertext tensor and transmitting it to the server in real time according to the time sequence includes: setting a preset scaling factor; the client calling a pre-configured fully homomorphic encryption algorithm public key; performing encoding and homomorphic encryption operations on the real number feature components in the normalized sample to generate the corresponding ciphertext tensor; attaching a time sequence identifier to the ciphertext tensor; constructing a ciphertext tensor carrying the time sequence; and pushing the ciphertext tensor into the output queue and transmitting it to the server in real time.
4. The encrypted anomaly detection method based on weight mapping and surface modeling as described in claim 3, characterized in that: The fully homomorphic encryption algorithm performs algebraic operations on each of the ciphertext tensors through a preset set of homomorphic operator sequences, the homomorphic operator sequences and their execution rules including: Homomorphic addition: performs linear accumulation between ciphertext tensors and homomorphic summation between ciphertext tensors and plaintext bias terms; among them, homomorphic subtraction is achieved by performing a negation operation on the term to be subtracted and then performing homomorphic addition, so as to complete the vector difference calculation in the ciphertext domain; Homomorphic multiplication: Performs product operations between ciphertext tensors and plaintext parameters, or between ciphertext tensors; where homomorphic multiplication and addition are implemented by performing homomorphic multiplication and homomorphic addition in sequence; for ciphertext tensors with inconsistent modulus levels before the operation, the levels are aligned by performing a modulus switching operation to ensure the legality of algebraic operations; Rescaling: After homomorphic multiplication, the scaling factor of the resulting ciphertext is adjusted, and the alignment of the scale factor of the resulting ciphertext and the management of ciphertext noise are achieved by consuming the ciphertext modulus chain level. Homomorphic rotation: The alignment of feature dimensions and expansion of feature space are achieved by cyclic displacement of ciphertext slots. By performing a rotation operation with a preset step size inside the ciphertext tensor, parallel extraction of cross terms in the weighted second-order statistics is supported.
5. The encrypted anomaly detection method based on weight mapping and surface modeling as described in claim 1, characterized in that: The server maintains a contiguous storage structure with a preset capacity in memory to cache the ciphertext tensor transmitted in step S10 in a time sequence, and initializes a total ciphertext state baseline that matches the dimensions of the ciphertext tensor. The process involves removing the expired ciphertext tensor and storing the newly arrived ciphertext tensor at the end of the window. When the newly arrived ciphertext tensor is received and the contiguous storage structure reaches capacity saturation, the server parses the time sequence identifier in the ciphertext tensor, extracts the earliest arriving ciphertext tensor in the time dimension, records it as the expired ciphertext tensor, calls the homomorphic multiplication, performs a homomorphic scalar multiplication operation between the expired ciphertext tensor and the plaintext constant, and generates the inverted ciphertext. The server calls the homomorphic addition to update the total state of the window storage structure and the window internal state. The server performs homomorphic addition on the current total ciphertext state baseline, the newly arrived ciphertext tensor, and the inverted ciphertext to obtain the updated total ciphertext state baseline. Then, the server removes the expired ciphertext tensor from the contiguous storage structure and appends the newly arrived ciphertext tensor.
6. The encrypted anomaly detection method based on weight mapping and surface modeling as described in claim 5, characterized in that: The total ciphertext state baseline is initially a zero vector ciphertext encapsulation, used to accumulate the algebraic sum of each ciphertext tensor in the storage window in real time during the incremental update process, and used as a pre-variable for the global algebraic operation to calculate the mean offset when constructing a continuous weight field later. The incremental update process uses the homomorphic addition to accumulate the newly arrived ciphertext tensor into the total ciphertext state benchmark, and uses the homomorphic addition to superimpose the inverted ciphertext of the expired ciphertext tensor into the total ciphertext state benchmark.
7. The encrypted anomaly detection method based on weight mapping and surface modeling as described in claim 1, characterized in that: The server calculates the ciphertext squared distance between the newly arrived ciphertext tensor and each ciphertext tensor within the window. The server extracts each ciphertext tensor cached in the contiguous storage structure, calculates the difference ciphertext with the newly arrived ciphertext tensor using the homomorphic addition, performs the homomorphic multiplication and rescaling to calculate the squared difference of the feature dimensions of each ciphertext tensor, and calls the homomorphic rotation and homomorphic addition to perform the cyclic displacement and accumulation of the ciphertext slots to obtain the ciphertext squared distance in scalar form. The method involves assigning continuous soft neighborhood mapping weights to each ciphertext tensor within the window. The server inputs the ciphertext squared distance as an independent variable into the polynomial kernel function, performs homomorphic multiplication and addition iteration operations on the independent variable using preset polynomial coefficients, calculates the continuous soft neighborhood mapping weights corresponding to each ciphertext tensor, and constructs a continuous weight field from the continuous soft neighborhood mapping weights corresponding to each ciphertext tensor.
8. The encrypted anomaly detection method based on weight mapping and surface modeling as described in claim 7, characterized in that: The polynomial kernel function is a polynomial approximation function of a monotonically decreasing continuous function over a preset distance interval; the preset polynomial coefficients are obtained by fitting the polynomial kernel function in the plaintext domain and are preset as plaintext parameters on the server.
9. The encrypted anomaly detection method based on weight mapping and surface modeling as described in claim 1, characterized in that: The server performs weighted aggregation on each ciphertext tensor within the window based on the continuous soft neighborhood mapping weights, and extracts the weighted first-order statistics. The server uses the continuous soft neighborhood mapping weights and the corresponding ciphertext tensors within the window to perform the homomorphic multiplication and rescaling to generate scale-aligned weighted ciphertext tensors, and linearly accumulates all the weighted ciphertext tensors within the window through homomorphic addition to extract the weighted first-order statistics. To extract the weighted second-order statistics, the server performs feature space expansion on each weighted ciphertext tensor, uses homomorphic rotation to shift the weighted ciphertext tensor, and performs homomorphic multiplication and rescaling with the weighted ciphertext tensor before the shift. Then, homomorphic addition is called to accumulate and aggregate all the expanded weighted ciphertext tensors within the window to extract the weighted second-order statistics containing feature square terms and feature pairwise intersection terms. The construction of the local statistical parameter matrix involves the server performing tensor splicing and aggregation on the weighted first-order statistics and the weighted second-order statistics after performing ciphertext modulus level alignment, to construct the local statistical parameter matrix. Each slot element of the local statistical parameter matrix covers the mean, variance and covariance distribution information in the current soft neighborhood, which is used as a surface parameter fitting to form a quadratic energy function describing the local spatial distribution characteristics. The local energy value of the newly arrived ciphertext tensor is calculated based on the quadratic energy function. The server takes the feature components of the newly arrived ciphertext tensor as independent variables and inputs them into the quadratic energy function characterized by the local statistical parameter matrix. The offset potential energy of the newly arrived ciphertext tensor relative to the local distribution center is calculated through homomorphic multiplication and rescaling to generate the corresponding local statistical energy value ciphertext.
10. The encrypted anomaly detection method based on weight mapping and surface modeling as described in claim 9, characterized in that: The feature space expansion is performed on each of the weighted ciphertext tensors. The server utilizes the batch processing parallelism of the ciphertext domain to perform spatial position rearrangement and nonlinear product operation on the feature elements. It synchronously extracts the pairwise cross product terms between feature dimensions within the ciphertext slots and linearly aggregates the obtained cross product terms with the square terms of the original features, thereby mapping the original feature space to a second-order enhanced feature space containing mean, variance and covariance information. The weighted ciphertext tensor is shifted. The server calls homomorphic rotation to perform a cyclic shift operation on the weighted ciphertext tensor containing multi-dimensional features according to a preset feature crossover rule, generating multiple shifted ciphertext vectors with different dimensional offsets. This is used to align the feature dimensions that were originally in different ciphertext slots to the same mapping position, providing aligned ciphertext input for subsequent cross-product operations.
11. The encrypted anomaly detection method based on weight mapping and surface modeling as described in claim 1, characterized in that: The discriminant parameter matrix is obtained by training a parameter matrix in the plaintext domain using a normal traffic baseline. The dimension of the discriminant parameter matrix is consistent with the total feature dimension after superimposing the local statistical matrix with the local statistical energy value ciphertext. The process of generating an encrypted anomaly detection score involves concatenating and aggregating the local statistical parameter matrix and the local statistical energy value ciphertext, performing a homomorphic matrix inner product operation with the discriminant parameter matrix, performing a homomorphic rotation summation operation on the inner product result, aggregating the weighted contribution of each component of the matrix and the energy value into a scalar result, and introducing a scoring bias term by calling homomorphic addition, ultimately generating a scalar form of the anomaly detection score ciphertext.
12. The encrypted anomaly detection method based on weight mapping and surface modeling as described in claim 1, characterized in that: The process of decrypting and restoring the plaintext score involves sending the calculated anomaly detection score ciphertext back to the client via a network communication interface. The client then calls a pre-configured fully homomorphic encryption algorithm private key to perform decryption and decoding operations, thereby restoring the plaintext detection score. To determine abnormal traffic conditions, the client retrieves the system's preset security baseline threshold and performs a numerical comparison logic between the plaintext detection score and the security baseline threshold within the plaintext calculation domain to determine the security status of the network traffic in the current time series. If the comparison result indicates that the plaintext detection score exceeds the security baseline threshold, the client generates a security alarm command based on the original network flow 5-tuple information or issues a traffic blocking policy to the network edge device.
13. A ciphertext anomaly detection system based on continuous weight mapping and quadratic surface modeling, characterized in that, Implementing the ciphertext anomaly detection method based on weight mapping and surface modeling as described in any one of claims 1-12, comprising: Data encapsulation and preprocessing module: used by the client to collect raw network flow features in real time and perform normalization processing, introduce a preset scaling factor and encapsulate the feature vector into a ciphertext tensor through a fully homomorphic encryption public key, and transmit it to the server in real time according to the time sequence; Window state incremental management module: used for server-side maintenance of a ciphertext storage structure with a preset capacity. It removes expired ciphertext tensors and loads new ciphertext tensors through homomorphic negation and homomorphic addition, and completes the algebraic incremental update of the total window state without decryption intervention. The continuous weight field construction module is used by the server to calculate the ciphertext squared distance between the new ciphertext tensor and each ciphertext tensor in the window, and input it into the preset polynomial kernel function. The Qin Jiushao algorithm is used to recursively generate soft neighborhood mapping weights that describe the spatial correlation strength of the ciphertext tensors in the ciphertext domain. The statistical energy surface modeling module is used by the server to aggregate and extract the first-order, second-order, and cross-order terms of features based on soft neighborhood weights, construct the local statistical matrix of the ciphertext, fit a second-order statistical energy surface, and calculate the local statistical energy value of the ciphertext that reflects the degree of offset of the new ciphertext tensor relative to the local distribution center. The linear scoring mapping module is used by the server to concatenate and aggregate the local statistical matrix and local statistical energy values of the encrypted data, call the pre-trained discriminant parameter matrix to perform a single homomorphic matrix inner product operation, and generate an encrypted anomaly detection score through linear discriminant function mapping. Decryption judgment and closed-loop response module: It is used by the client to send back the received encryption detection score and call the private key to perform decryption and decoding. It compares the recovered plaintext score with the preset security threshold and executes security alarm commands or issues traffic blocking policies based on the comparison results.
Citation Information
Patent Citations
Unmanned aerial vehicle data anomaly detection method based on homomorphic encryption
CN115085898A
Secure outsourcing calculation method and system for local abnormal factor detection
CN117688502A