Quantum key distribution eavesdropping detection system and method based on improved BB84 protocol and AI doorkeeper
By adding a polarization basis to the BB84 protocol and combining a self-attention LSTM network with a PCA-optimized SVM, the security and efficiency issues of the BB84 protocol in practical applications are solved, achieving efficient eavesdropping detection and key generation.
Patent Information
- Application Number
- CN202511034156.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-25
- Publication Date
- 2025-10-28
AI Technical Summary
The existing BB84 protocol suffers from problems such as non-ideal light sources and detectors, limited polarization bases, environmental noise, and losses in practical applications, resulting in insufficient security and efficiency in eavesdropping detection. Furthermore, traditional SVM has low computational efficiency in complex quantum communication scenarios.
Based on the BB84 protocol, two new polarization bases are added. An LSTM network based on the self-attention mechanism and a PCA-optimized SVM are used for eavesdropping detection. The penalty parameter and kernel function width parameter are optimized by combining grid search, the model weights are dynamically adjusted, and the detection results are fused to improve accuracy and robustness.
It significantly improves the security and key generation efficiency of quantum key distribution, enhances the adaptability to environmental noise and losses, improves the accuracy and robustness of eavesdropping detection, and reduces computational costs and time.
Smart Images

Figure CN120856322A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quantum key distribution technology, and more specifically, to a quantum key distribution eavesdropping detection system and method based on an improved BB84 protocol and an AI gatekeeper. Background Technology
[0002] The BB84 protocol, a fundamental quantum key distribution (QKD) protocol, utilizes the polarization properties of quantum states to transmit key information. By randomly selecting the polarization basis, it makes it difficult for eavesdroppers to simultaneously obtain accurate key information without being detected. While the BB84 protocol offers high security, it suffers from the following problems in practical applications:
[0003] Non-idealities of light sources and detectors: Real single-photon sources may generate multiphoton pulses, providing opportunities for eavesdroppers, such as Photon Number Splitting (PNS) attacks. Furthermore, the low detection efficiency and high dark count probability of detectors can cause some qubits to go undetected, increasing the risk of misjudgment and information leakage.
[0004] Limited polarization bases: The traditional BB84 protocol uses only two polarization bases (such as a rectangular coordinate system and a diagonal coordinate system), which makes it relatively easy for an eavesdropper to guess the measurement base correctly. Especially when facing complex attack scenarios, security may be affected to some extent.
[0005] Environmental noise and loss: In long-distance quantum communication, quantum states are easily affected by environmental noise and fiber loss, which leads to an increase in the error rate of qubits and a decrease in key generation efficiency.
[0006] The AI gatekeeper of the quantum key distribution (QKD) eavesdropping detection system is an innovative intelligent monitoring system designed to ensure the security of quantum communication. It refers to an intelligent security protection module built using artificial intelligence technologies (such as machine learning and deep learning), specifically designed to detect abnormal behavior during quantum communication. Its core function is to monitor the real-time operating status of the QKD system, identify potential eavesdropping behavior or device anomalies, and proactively respond to ensure the security of key distribution. Support Vector Machine (SVM) is a commonly used machine learning classification algorithm that separates different categories of data by finding the optimal hyperplane. Combining it with Principal Component Analysis (PCA) for feature dimensionality reduction can effectively reduce data dimensionality, improve computational efficiency, and remove noise and redundant information, enhancing the model's generalization ability. Grid search is a commonly used parameter optimization method that finds the optimal parameter settings for model performance by exhaustively searching predefined parameter combinations. However, SVM, as an algorithm for identifying abnormal features in complex quantum communication processes, still has some limitations:
[0007] Limitations of SVM Feature Extraction and Selection: In complex quantum communication scenarios, grid search is used to optimize penalty parameters and kernel width parameters, but this process is computationally expensive. Although grid search can help find optimal model parameter combinations, it requires traversing a large number of parameter settings, leading to a significant increase in training time. Furthermore, relying solely on PCA for feature dimensionality reduction may lose some potentially useful information, especially in capturing nonlinear feature relationships. Particularly when dealing with high-dimensional, complex quantum data, it may fail to fully extract effective features, thus affecting classification performance. These limitations pose challenges to the application of traditional SVM in complex quantum communication environments, particularly when high real-time performance and accuracy are required.
[0008] Model complexity and computational efficiency: Although SVM performs well on small-sample, non-linear classification problems, its training and prediction processes may face computational inefficiencies for large-scale datasets. Summary of the Invention
[0009] Due to the aforementioned deficiencies in existing technologies, this invention aims to propose a quantum key distribution eavesdropping detection system and method based on an improved BB84 protocol and an AI gatekeeper, with the goal of improving the security and practicality of the BB84 protocol and enhancing the AI gatekeeper's ability and efficiency in detecting eavesdropping.
[0010] To achieve the above objectives, on the one hand, the present invention provides a quantum key distribution eavesdropping detection system based on an improved BB84 protocol and an AI gatekeeper. On the basis of the two polarization bases, the Cartesian coordinate system L and the diagonal coordinate system N of the BB84 protocol, two new polarization bases are added to form a set of four polarization bases.
[0011] We employ an LSTM network based on a self-attention mechanism and an SVM optimized by principal component analysis to simultaneously perform eavesdropping detection, and then fuse their detection results to obtain a probability distribution indicating the presence of an attack.
[0012] The aforementioned technical solution expands the range of polarization basis selection, increasing the difficulty for eavesdroppers to guess the measurement basis, thereby improving the security and key generation efficiency of the BB84 protocol in practical applications. Furthermore, it improves the BB84 protocol's adaptability to environmental noise and losses, ensuring high key quality and generation rate even in long-distance quantum communication. In the feature extraction stage, the modified characteristics of the BB84 protocol are fully considered, and multiple feature information is selected and fused to better and more accurately capture anomalous features in the quantum communication process. However, adding a polarization basis increases the size of the dataset and the complexity of encoding and measurement, thus affecting the computational efficiency of SVM in eavesdropping detection. This technical solution combines a self-attention-based LSTM network with a PCA-based SVM. The self-attention mechanism enhances the LSTM's ability to capture long-term dependencies and key features in sequence data, while leveraging the advantages of SVM in handling high-dimensional and complex data. This improves the accuracy and robustness of AI-powered eavesdropping detection without significantly increasing model training costs and time.
[0013] Furthermore, the two new polarization bases are 30° and 120°. Alice and Bob randomly select one of four polarization bases to prepare and measure the qubits, with each polarization base corresponding to a polarization direction of 0° / 90° (L), 45° / 135° (N), 30° / 150° (30° base), and 120° / 60° (120° base). The key bits can only be correctly obtained when Alice and Bob choose the same polarization base. The selection of 30° and 120° makes the polarization bases more uniformly distributed within the 0°-180° range. This uniform distribution allows for more efficient use of the quantum state encoding space, increasing the information-carrying capacity of the qubits. A uniformly distributed polarization base ensures similar efficiency and security for encoding in different directions, avoiding differences in encoding efficiency caused by uneven polarization base distribution. In system design, a uniformly distributed polarization base makes it easier to generate and measure polarization states, reducing the increase in system complexity caused by improper polarization base selection. This compatibility and design simplification contribute to improving system stability and reliability. The selection of polarization bases at 30° and 120° offers good compatibility with existing optical equipment and technologies. Existing polarization controllers and polarization analyzers can typically achieve high-precision polarization state control and measurement around these angles. This allows for the introduction of new polarization bases into existing systems without requiring large-scale hardware modifications, reducing system upgrade costs.
[0014] Furthermore, the SVM employs grid search to optimize the penalty parameters and kernel width parameters. Combining a self-attention-based LSTM network with a PCA- and grid search-based SVM can further improve attack detection accuracy and the detection rate against PNS attacks and retransmission attacks.
[0015] Furthermore, when fusing the results of eavesdropping detection from the LSTM network based on the self-attention mechanism and the optimized support vector machine, the weights of LSTM and SVM are first dynamically adjusted according to the current detected attack type (such as PNS attack, intercept and retransmission attack). Then, the comprehensive detection result is calculated based on the output results of LSTM and SVM and their corresponding weights. Finally, a threshold is set based on the comprehensive detection result. If the detection result is greater than the threshold, it is determined that there is eavesdropping behavior in the quantum key distribution process; otherwise, it is determined to be a secure state. The weights are allocated based on the performance metrics of each model on the validation set, including accuracy, recall, and F1 score.
[0016] Furthermore, the formula for calculating the weight is as follows:
[0017] and ;
[0018] in, For an LSTM network model, let's consider one of the performance metrics: accuracy, recall, and F1 score. For each of the following performance metrics of an SVM model: accuracy, recall, and F1 score, ... .
[0019] Furthermore, the quantum key distribution eavesdropping detection system uses a single-photon source as its light source and a single-photon detector as its detector. Thus, a more ideal single-photon source replaces the traditional weakly coherent light source. This single-photon source can generate high-purity, stable, and reliable single-photon states, with the polarization direction of the qubits randomly determined by the sender Alice, and the generation probability of each qubit being uniformly distributed. Simultaneously, a highly efficient and low-noise single-photon detector replaces the conventional detector, which possesses high detection efficiency (…). ) and low dark count probability ( This allows for more accurate detection of received qubits, reducing the risk of misjudgment and information leakage due to insufficient detector performance. By optimizing the performance of the light source and detector, and employing a more ideal single-photon source and a highly efficient, low-noise single-photon detector, the risk of misjudgment and information leakage can be reduced.
[0020] On the other hand, the present invention provides a quantum key distribution eavesdropping detection method based on an improved BB84 protocol and AI gatekeeper, comprising the following steps:
[0021] Step S1, Polarization basis expansion and key generation: Based on the two polarization bases of the BB84 protocol, the Cartesian coordinate system L and the diagonal coordinate system N, two new polarization bases are added to form a set of four polarization bases;
[0022] Step S2: Extract features and construct sequences from the BB84 protocol: Extract various feature information from the quantum key distribution process. The feature information includes two or more of the following: the sequence of qubit polarization results obtained by Bob's measurement, the sequence of measurement basis used by Bob, the sequence of qubit error rate (QBER) under different polarization basis, and the key generation rate sequence. Combine these features into a feature vector, which serves as the input sequence for the subsequent AI model.
[0023] Step S3, LSTM network based on self-attention mechanism and SVM processing optimized by PCA: The input sequence constructed in step S2 is input into the LSTM network based on self-attention mechanism for eavesdropping detection; the feature vector extracted in step S2 (i.e. each time step in the input sequence) is standardized, and the optimized SVM model is used to perform eavesdropping detection in the quantum key distribution process.
[0024] Step S4: Fuse the eavesdropping detection outputs of LSTM and SVM to obtain a comprehensive detection result and determine whether eavesdropping occurs during the quantum key distribution process.
[0025] Furthermore, the steps for eavesdropping detection using an LSTM network based on a self-attention mechanism include: firstly, calculating the query matrix, key matrix, and value matrix using a self-attention mechanism, and then calculating the attention score matrix (where... (This is the dimension of the key vector). Then, the attention score matrix is applied to the softmax function to obtain the attention weight matrix, and the weighted value vector is calculated. This vector is then concatenated with the original input sequence to form the enhanced input feature sequence. The enhanced input feature sequence is input into the LSTM layer, and sequentially passes through the forget gate, input gate, candidate memory unit state, memory unit state update, output gate, and the calculation of the current hidden state. Finally, the hidden state of the LSTM at the final time step is obtained, and it is input into the fully connected layer. The probability distribution of whether there is an attack or security is calculated by the softmax function.
[0026] In the improved self-attention mechanism LSTM technical solution, a feature weighting mechanism from the field of quantum communication is innovatively introduced: by dynamically adjusting the self-attention weights and combining quantum communication-specific indicators such as polarization basis matching probability and error rate gradient, attention to abnormal time steps is strengthened; polarization results, measurement basis, and error rate sequence are fused in cross-modal attention to capture attack-related nonlinear correlations; at the same time, attention weights are injected into the LSTM gating mechanism to make gating decisions take into account both local inputs and global features; in addition, a dynamically updatable attack mode-aware mask matrix is designed to guide the model to focus on high-risk areas for multiphoton pulse characteristics of PNS attacks or basis switching anomalies in intercepting retransmission attacks, thereby significantly improving the accuracy and robustness of eavesdropping detection in complex scenarios.
[0027] Furthermore, the steps for eavesdropping detection using PCA-optimized SVM include: standardizing the feature vectors extracted in step S2, calculating the covariance matrix of the standardized data, performing eigenvalue decomposition on the covariance matrix, selecting the eigenvectors corresponding to the first k principal components to form a matrix, projecting the original data onto the principal components to obtain dimensionality-reduced data; constructing an SVM model using a Gaussian kernel function, searching for the optimal parameter combination among predefined parameter combinations including different penalty parameters and kernel function width parameters through grid search, and using the optimized SVM model to detect eavesdropping in the quantum key distribution process.
[0028] Furthermore, when fusing the output results of the LSTM network based on the self-attention mechanism and the optimized support vector machine for eavesdropping detection, the weights of LSTM and SVM are dynamically adjusted according to the current detected attack type (such as PNS attack, intercept and retransmission attack). Then, based on the output results of LSTM and SVM and their corresponding weights, the comprehensive detection result is calculated. Finally, based on the comprehensive detection result, a threshold is set. If the detection result is greater than the threshold, it is determined that there is eavesdropping behavior in the quantum key distribution process; otherwise, it is determined to be a secure state.
[0029] The weights are allocated based on the performance metrics of each model on the validation set, including accuracy, recall, and F1 score.
[0030] The formula for calculating the weight is:
[0031] and ;
[0032] in, For an LSTM network model, let's consider one of the performance metrics: accuracy, recall, and F1 score. For each of the following performance metrics of an SVM model: accuracy, recall, and F1 score, ... ;
[0033] The comprehensive test results The calculation formula is:
[0034]
[0035]
[0036] ;
[0037] in, Here is the probability distribution of the existence of attacks obtained based on optimized SVM processing, where This indicates the probability that the attack was detected. Let represent the probability that the detection is safe, and satisfy . ; Here is the probability distribution of existence attacks obtained after processing by an LSTM network based on a self-attention mechanism, where... This indicates the probability that the attack was detected. Let represent the probability that the detection is safe, and satisfy . .
[0038] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0039] (1) Increasing the number of polarization bases increases the probability that the eavesdropper can guess the measurement base correctly, thus increasing the difficulty for them to obtain key information. Polarization base expansion improves the utilization rate of effective qubits, and experimental data show that the key generation rate increases by about 2.1 to 2.8 times.
[0040] (2) The LSTM enhanced by self-attention mechanism can effectively capture sequence features. The SVM is optimized by PCA dimensionality reduction. The fusion of the two outputs makes the attack detection accuracy as high as 97.8%, which is 7.6% and 5.3% higher than the traditional SVM (90.2%) or LSTM (92.5%) used alone. The SVM is more accurate in classification after PCA dimensionality reduction and grid search optimization. The fusion of the LSTM enhanced by self-attention mechanism and the SVM output optimized by PCA and grid search makes the attack detection accuracy as high as 98.7%, which is 14.3% and 16.8% higher than the SVM or LSTM used alone. In the simulated attack experiment, the detection rate of the fusion model reached 99.2% and 98.5% respectively in the face of PNS attack and intercept retransmission attack. It can quickly identify and warn of attack behavior and effectively protect the security of quantum communication. For communication scenarios with increased polarization basis, the encoding method of quantum state is more diversified. This is equivalent to providing more "channels" for the two communicating parties to transmit key information. Theoretically, the key generation rate can be multiplied under ideal conditions. The fusion model obtains more reliable detection conclusions by weightedly fusing the outputs of both methods. It can more accurately monitor the communication process, distinguish between attack behavior and normal communication, and reduce the number of qubits discarded due to misjudgment. This allows for full utilization of these additional polarization bases to improve key generation efficiency, optimizes communication process monitoring, reduces key discard due to misjudgment, and further improves key generation efficiency.
[0041] (3) The improved protocol is highly adaptable to environmental noise and loss, and the fusion model is robust. Experiments simulated different signal-to-noise ratio and loss rate scenarios. The fusion model still achieved a detection accuracy of 97.3% when the signal-to-noise ratio was 10dB and the loss rate was 20%, ensuring the security and stability of quantum communication.
[0042] (4) By optimizing the performance of the light source and detector, using an ideal single-photon source and a high-efficiency, low-noise detector, and combining polarization basis extension, the key generation process becomes more robust. Optimizing the light source and detector is expected to increase the company's initial investment by 15% to 20%, but the improved key generation efficiency reduces the unit key cost by 30% to 40%. Attached Figure Description
[0043] The invention, its features, and advantages will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings. The drawings are not drawn to scale; their purpose is to illustrate the spirit of the invention.
[0044] Figure 1 This is a diagram of an AI security guard detecting eavesdropping.
[0045] Figure 2 This is an embodiment of the present invention: an AI gatekeeper based on a self-attention mechanism using an LSTM network. Detailed Implementation
[0046] To further aid in understanding the technical solutions of the present invention, exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. It should be understood that all described exemplary embodiments are merely some embodiments and examples of the present invention, and not all of them. Rather, these exemplary embodiments are provided so that those skilled in the art can more thoroughly understand the present disclosure and more completely convey its technical content to them.
[0047] In the following detailed description, numerous specific details are set forth to provide a more thorough understanding of the invention. However, it will be apparent to those skilled in the art that well-known algorithms and models are not shown in detail to avoid obscuring the gist of the invention; and that the techniques not detailed in the following effect examples are readily available prior art.
[0048] Example
[0049] This embodiment provides a quantum key distribution eavesdropping detection system and method based on an improved BB84 protocol and an AI gatekeeper. As a preferred technical solution, the light source and detector are first optimized.
[0050] Single-photon source optimization: A more ideal single-photon source replaces the traditional weakly coherent light source. This single-photon source can generate high-purity, stable, and reliable single-photon states. The polarization direction of its qubits is randomly determined by the sender, Alice, and the generation probability of each qubit is uniformly distributed. Assume that the quantum state of one qubit generated by an ideal single-photon source is... Its polarization direction is randomly determined by the transmitter, Alice. In practical applications, when using a weakly coherent light source, the generated quantum state can be represented as a density matrix. ,in It is the probability of producing n photons. This is the Fock state with n photons. By introducing decoy state technology, Alice can send pulses of different intensities, including the signal state and the decoy state. Let the average number of photons in the signal state be... The average number of photons in the decoy state is Their density matrices are respectively and ,in , By comparing the detection statistics of the signal state and the decoy state at Bob, the single-photon component can be estimated as follows: ,in It is the count rate of the decoy state. This is the count rate in the vacuum state. Detector optimization: Assume the detector's detection efficiency is... The probability of a dark count is The probability that the detector actually detects a photon is . By improving the detector's detection efficiency and reducing the probability of dark counting, the risks of false positives and information leakage can be effectively reduced. The improved detector performance can be achieved by enhancing... and reduce This can be achieved, for example, by using upconversion single-photon detectors and other technologies.
[0051] It should be noted that, without optimizing the light source and detector, this invention can improve performance using subsequent polarization basis extension, LSTM based on self-attention mechanism, and optimized SVM combined eavesdropping detection techniques. Polarization basis extension can still enhance security. In other words, without optimizing the light source and detector, simply by extending the polarization basis—adding two new polarization bases (e.g., 30° and 120°) to form a set of four polarization bases—Alice and Bob can randomly select one of these four polarization bases to prepare and measure the qubit. This reduces the probability of an eavesdropper guessing the correct measurement base, thus improving security to some extent and increasing the difficulty for them to obtain key information. Even without optimizing the light source and detector, the eavesdropping detection using LSTM based on self-attention mechanism and optimized SVM can still improve detection accuracy.
[0052] Next, we will implement step S1, the selection and expansion of the polarization base.
[0053] Polarization base definition: The traditional BB84 protocol uses two polarization bases, such as a Cartesian coordinate system (L) and a diagonal coordinate system (N), with corresponding polarization directions of 0° / 90° and 45° / 135°, respectively. In the modified protocol, two new polarization bases are added, preferably 30° and 120°, with corresponding polarization directions of 30° / 150° and 120° / 60°. These four polarization bases can be represented as:
[0054]
[0055]
[0056]
[0057]
[0058]
[0059]
[0060]
[0061]
[0062] in and These represent the horizontal and vertical polarization states, respectively.
[0063] Key generation and basis matching probability: Alice and Bob randomly choose one of the four polarization bases to prepare and measure the qubits. The key bit can only be correctly obtained if their polarization base choices are the same. Key generation rate. It can be represented as:
[0064]
[0065] in Indicates polarization basis The probability of correctly obtaining the key bits. It can be L, N, 30, or 120. Assume the probability of correctly obtaining the key bits is given by the following formula: ,in In polarization base The error rate of the qubits.
[0066] Polarization base extension improves the utilization of effective qubits, and experimental data show that the key generation rate increases by about 2.1 to 2.8 times.
[0067] Step S2: Extract features from the BB84 protocol and construct the sequence.
[0068] The modified BB84 protocol introduces more polarization bases (30° and 120°) and optimizes the light source and detector. In the feature extraction stage, consider the following feature vectors:
[0069] Polarization measurement result sequence: Let the sequence of qubit polarization results obtained by Bob's measurement be as follows: ,in This represents the encoded value corresponding to the polarization measurement result of the t-th qubit (such as the encoded values corresponding to 0°, 45°, 30°, 120°, etc.).
[0070] Measurement basis sequence: The polarization basis sequence used by Bob for measurement is as follows: ,in This represents the encoding value corresponding to the measurement basis of the t-th qubit (such as the encoding value corresponding to L, N, 30, 120, etc.).
[0071] Quantum Bit Error Rate (QBER) Sequence: Calculating the QBER sequence under different polarization bases ,in This represents the QBER value within the t-th time window. The formula for calculating QBER is:
[0072]
[0073] Key generation rate sequence: Calculate the key generation rate sequence according to the formula for the key generation rate. ,in This represents the key generation rate within the t-th time window. These features are combined into a feature vector. This serves as input for subsequent AI models. A feature vector is a feature representation of a single sample (or time step) used to describe the static or dynamic properties during quantum communication.
[0074] Step S3, see Figure 1 The AI gatekeeper uses an LSTM network with a self-attention mechanism and an SVM optimized by PCA to perform classification processing for eavesdropping detection.
[0075] See Figure 2 LSTM networks based on self-attention mechanisms include:
[0076] (a) Input layer
[0077] After preprocessing, the input feature vector X forms the input sequence. Each of them It includes characteristic information such as the measurement value of the qubit, measurement basis, QBER, and key generation rate. The input sequence is a sequence of multiple feature vectors arranged in chronological order, which is a representation of time-series data.
[0078] (II) Self-attention mechanism layer
[0079] First, the query matrix is calculated using a self-attention mechanism. Key matrix Sum matrix ,in , , It is a learnable weight matrix used to map input features to query, key, and value spaces.
[0080] Based on known attack patterns in quantum communication (such as the multiphoton pulse characteristics of PNS attacks and the measurement basis anomaly switching pattern of intercepting retransmission attacks), an attention mask matrix is designed. This forces the model to focus on specific time steps relevant to the attack. Indicates the i The time step and the first j The correlation between time steps is strong (e.g., they all belong to high-frequency areas of the attack pattern); otherwise... The mask matrix is dynamically adjusted based on real-time detection results (for example, if a sudden increase in the error rate is detected at a certain time step, its correlation with neighboring time steps is enhanced), thus achieving adaptive capture of attack patterns.
[0081] Calculate the attention weight matrix:
[0082]
[0083] in This is the dimension of the key vector, used to scale the scores and prevent gradient vanishing. It is the transpose of the key matrix. Let be the characteristic weight matrix for quantum communication, where ⊙ denotes element-wise multiplication. Calculate the weighted value vector:
[0084] , context vector With the original input sequence These are concatenated to form the enhanced input feature sequence:
[0085]
[0086] (III) LSTM layer
[0087] The forgetting gate determines how much information is discarded from memory. The formula is:
[0088]
[0089] in, It is the activation value of the Forgotten Gate. It is a weight matrix. It is the bias term, and σ is the sigmoid activation function. These are the enhanced input features. It was the hidden state from a previous moment. For self-attention weights, This is the global feature vector.
[0090] The input gate determines how much new information is written to the memory cell. The calculation formula is:
[0091]
[0092] in, It is the activation value of the input gate. It is a weight matrix. It is the bias term, and σ is the sigmoid activation function. These are the enhanced input features. It was the hidden state from a previous moment. For self-attention weights, This is the global feature vector.
[0093] Calculate the state of candidate memory cells:
[0094]
[0095] in, It is entering the unit state. It is a weight matrix. It is the bias term, and tanh is the hyperbolic tangent activation function. These are the enhanced input features. It was the hidden state from a previous moment. For self-attention weights, This is the global feature vector.
[0096] By dynamically adjusting gating parameters through attention weights, the ability to remember and update key features is enhanced.
[0097] Update memory cell state:
[0098]
[0099] The output gate determines how much information from memory units is output. Introducing attention-weighted hidden states into the output gate makes the final output more focused on attack-related features; the calculation formula is as follows:
[0100]
[0101] in, It is the output of the output gate. These are the enhanced input features. It was the hidden state from a previous moment. It is a bias term. For attention weights.
[0102] Calculate the hidden state at the current moment:
[0103]
[0104] (iv) Output layer
[0105] The hidden state at the final moment of the LSTM The input is fed into a fully connected layer for attack detection and classification. The calculation formula for the output layer is:
[0106]
[0107] in It is the weight matrix of the output layer. It is a bias term. The softmax function is used to convert the output into a probability distribution, representing the probability of an attack or security.
[0108] PCA-based SVMs include:
[0109] (a) Principal Component Analysis (PCA)
[0110] The extracted feature vector X is standardized to have a mean of 0 and a variance of 1. The standardization formula for X is:
[0111]
[0112] Where μ is the mean of the feature and σ is the standard deviation of the feature.
[0113] Calculate the covariance matrix of the standardized data:
[0114]
[0115] Where n is the number of samples.
[0116] Perform eigenvalue decomposition on the covariance matrix:
[0117]
[0118] Where U is an orthogonal matrix composed of eigenvectors, and Λ is a diagonal matrix whose diagonal elements are eigenvalues.
[0119] Select the first k principal components, that is, select the eigenvectors corresponding to the k largest eigenvalues:
[0120]
[0121] Projecting the original data onto the principal components yields the dimensionality-reduced data:
[0122]
[0123] (ii) Support Vector Machine (SVM)
[0124] Using a Gaussian kernel function:
[0125]
[0126] Where σ is the width parameter of the kernel function, which controls the width of the Gaussian kernel.
[0127] The goal of SVM is to minimize the following objective function:
[0128]
[0129] Where w is the weight vector, b is the bias, and C is the penalty parameter, which controls the degree of penalty for misclassified points. It is a feature mapping function that maps input data to a high-dimensional feature space.
[0130] SVM can further incorporate grid search to find the optimal parameter combination among predefined combinations of parameters (such as different values of C and σ).
[0131]
[0132] ValidationLoss is the loss (such as classification error rate) calculated on the validation set.
[0133] The outputs of LSTM and SVM will be fused below:
[0134] (I) Obtaining Output Results
[0135] After processing by an LSTM network based on a self-attention mechanism, the probability distribution of the existence of an attack is obtained:
[0136]
[0137] in This indicates the probability that the attack was detected. Let represent the probability that the detection is safe, and satisfy:
[0138]
[0139] After processing with SVM, the probability distribution of the existence of attacks is obtained:
[0140]
[0141] in This indicates the probability that the attack was detected. Let represent the probability that the detection is safe, and satisfy:
[0142]
[0143] (ii) Weight Calculation
[0144] To fuse the outputs of LSTM and SVM, the weights of each model need to be determined first. These weights can be determined based on the model's performance on the validation set, for example, by calculating metrics such as accuracy, recall, and F1 score for each model on the validation set, and then assigning weights based on these metrics. Let's assume that on the validation set, the performance metrics of LSTM are... The performance metrics of SVM are Assuming the currently detected attack type is The weight calculation formula is:
[0145]
[0146]
[0147] in, It is the impact factor of attack type 𝑇 on model performance, and its value is predefined according to the adaptation relationship between attack type and model performance.
[0148] (III) Calculation of Comprehensive Test Results
[0149] The overall detection result is calculated based on the outputs of LSTM and SVM and their corresponding weights.
[0150]
[0151] The calculation formula is:
[0152]
[0153]
[0154] in,
[0155] (iv) Final decision
[0156] Based on the comprehensive test results y final Set a threshold (e.g., 0.5), if If the eavesdropping occurs, it is determined that there is eavesdropping during the quantum key distribution process; otherwise, it is determined to be a secure state.
[0157] Testing of eavesdropping detection rate and accuracy:
[0158] Detection accuracy refers to the proportion of correctly classified samples out of the total number of samples when the model predicts all samples. This metric mainly reflects the overall correctness of the model in distinguishing between attack and non-attack behaviors. The detection accuracy of the fusion model of SVM optimized by LSTM and PCA (the fusion model without grid search) is 97.8%, which is an improvement of 7.6% and 5.3% compared to using traditional SVM (90.2%) or LSTM alone (92.5%). The output of the fusion model of SVM optimized by LSTM and PCA and grid search shows an attack detection accuracy of 98.7%, indicating that 98.7% of the samples in the overall test samples were correctly classified (that is, attack samples and non-attack samples were correctly distinguished). Experiments simulating different signal-to-noise ratio and loss rate scenarios show that the fusion model still achieves a detection accuracy of 97.3% at a signal-to-noise ratio of 10dB and a loss rate of 20%, ensuring the security and stability of quantum communication.
[0159] The detection rate mentioned in the simulated attack experiments refers to the proportion of samples of a specific attack type (such as PNS attacks and intercepted re-attacks) that the model can correctly identify out of all actual samples of that attack type. For PNS attacks, the detection rate using traditional SVM (with grid search) alone is 85.1%. The detection rate using LSTM (with self-attention mechanism) alone is 89.3%. The detection rate of the fusion model without grid search is 98.4%. The detection rate of the fusion model based on LSTM and SVM optimized with PCA and grid search is 99.2%.
[0160] For intercepting re-attacks, the detection rate using only traditional SVM (with mesh search) was 82.7%.
[0161] The detection rate using LSTM alone (with self-attention mechanism) is 86.4%. The detection rate of the fusion model without grid search is 97.8%. The detection rate of the fusion model based on LSTM and PCA with grid search optimized SVM is 98.5%.
[0162] The gridless fusion model achieves a detection efficiency of 0.015 seconds per sample, a 25% improvement compared to the grid-search-required fusion model (0.020 seconds per sample), and significantly reduces training time from 8.7 hours to 3.1 hours. The lightweight design of LSTM reduces computational resource consumption.
[0163] In summary, this invention provides a quantum key distribution eavesdropping detection system and method based on an improved BB84 protocol and an AI gatekeeper. In addition to the two polarization bases of the BB84 protocol—the Cartesian coordinate system L and the diagonal coordinate system N—two new polarization bases are added, forming a set of four polarization bases. An LSTM network based on a self-attention mechanism and an SVM optimized by principal component analysis are used simultaneously for eavesdropping detection, and the detection results are fused to obtain a probability distribution indicating the presence of an attack. This invention improves the security and practicality of the BB84 protocol and enhances the ability and efficiency of the AI gatekeeper in detecting eavesdropping. Furthermore, optimizing the SVM through grid search further improves the accuracy and detection rate of eavesdropping detection.
[0164] Those skilled in the art will understand that all or part of the steps in the quantum key distribution eavesdropping detection method based on the improved BB84 protocol and AI gatekeeper in the above embodiments can be implemented by a program instructing related hardware, and the program can be stored in a computer-readable storage medium. The computer-readable storage medium may include, but is not limited to, optical discs, CD-ROMs (Read-Only Optical Disc Repository), magneto-optical discs, ROMs (Read-Only Memory), RAMs (Random Access Memory), EPROMs (Erasable Programmable Read-Only Memory), EEPROMs (Electrically Erasable Programmable Read-Only Memory), magnetic cards or optical cards, flash memory, or other types of media / machine-readable media suitable for storing machine-executable instructions. The computer-readable storage medium can be a product not connected to a computer device or a component used in a computer device.
[0165] The preferred embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and the devices and structures not described in detail should be understood as being implemented in a conventional manner in the art. Any person skilled in the art can make many possible variations and modifications to the technical solutions of the present invention using the methods and techniques disclosed above, or modify them into equivalent embodiments with equivalent changes, without departing from the scope of the present invention. This does not affect the essential content of the present invention. Therefore, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the present invention's technical solutions still fall within the protection scope of the present invention.
Claims
1. A quantum key distribution eavesdropping detection system based on an improved BB84 protocol and AI gatekeeper, characterized in that: Based on the two polarization bases of the Cartesian coordinate system L and the diagonal coordinate system N in the BB84 protocol, two new polarization bases are added to form a set of four polarization bases; We employ an LSTM network based on a self-attention mechanism and an SVM optimized by principal component analysis to simultaneously perform eavesdropping detection, and then fuse their detection results to obtain a probability distribution indicating the presence of an attack.
2. The quantum key distribution eavesdropping detection system based on the improved BB84 protocol and AI gatekeeper as described in claim 1, characterized in that, The two new polarization bases are the 30° base and the 120° base; Alice and Bob randomly select one of the four polarization bases to prepare and measure the qubits, with each polarization base corresponding to a polarization direction of 0° / 90° (L), 45° / 135° (N), 30° / 150° (30° base) and 120° / 60° (120° base); the key bits can only be obtained correctly when Alice and Bob select the same polarization base.
3. The quantum key distribution eavesdropping detection system based on the improved BB84 protocol and AI gatekeeper as described in claim 1 or 2, characterized in that, The SVM also employs grid search to optimize the penalty parameter and kernel function width parameter.
4. The quantum key distribution eavesdropping detection system based on the improved BB84 protocol and AI gatekeeper as described in claim 1, characterized in that, When integrating the results of eavesdropping detection from a self-attention-based LSTM network and an optimized support vector machine, the weights of LSTM and SVM are first dynamically adjusted according to the current detected attack type. Then, the comprehensive detection result is calculated based on the outputs of LSTM and SVM and their corresponding weights. Finally, a threshold is set based on the comprehensive detection result. If the detection result is greater than the threshold, it is determined that there is eavesdropping behavior in the quantum key distribution process; otherwise, it is determined to be a secure state. The weights are allocated based on the performance metrics of each model on the validation set, including accuracy, recall, and F1 score.
5. The quantum key distribution eavesdropping detection system based on the improved BB84 protocol and AI gatekeeper as described in claim 4, characterized in that, The formula for calculating the weight is: and ; in, For an LSTM network model, let's consider one of the performance metrics: accuracy, recall, and F1 score. For each of the following performance metrics of an SVM model: accuracy, recall, and F1 score, ... .
6. The quantum key distribution eavesdropping detection system based on the improved BB84 protocol and AI gatekeeper as described in claim 1, characterized in that, The quantum key distribution eavesdropping detection system uses a single-photon source as its light source and a single-photon detector as its detector.
7. A quantum key distribution eavesdropping detection method based on an improved BB84 protocol and AI gatekeeper, characterized in that, Includes the following steps: Step S1, Polarization basis expansion and key generation: Based on the two polarization bases of the BB84 protocol, the Cartesian coordinate system L and the diagonal coordinate system N, two new polarization bases are added to form a set of four polarization bases; Step S2: Extract features and construct sequences from the BB84 protocol: Extract various feature information from the quantum key distribution process. The feature information includes two or more of the following: the sequence of qubit polarization results obtained by Bob's measurement, the sequence of measurement basis used by Bob, the sequence of qubit error rates under different polarization basis, and the sequence of key generation rate. Combine these features into a feature vector, which serves as the input sequence for the subsequent AI model. Step S3: LSTM network based on self-attention mechanism and SVM processing optimized by principal component analysis: The input sequence constructed in step S2 is input into the LSTM network based on self-attention mechanism for eavesdropping detection; the feature vector extracted in step S2 is standardized, and the optimized SVM model is used to detect eavesdropping in the quantum key distribution process. Step S4: Fuse the eavesdropping detection outputs of LSTM and SVM to obtain a comprehensive detection result and determine whether eavesdropping occurs during the quantum key distribution process.
8. The quantum key distribution eavesdropping detection method based on the improved BB84 protocol and AI gatekeeper according to claim 7, characterized in that, The steps for eavesdropping detection using an LSTM network based on a self-attention mechanism include: first, calculating the query matrix, key matrix, and value matrix using a self-attention mechanism; then, calculating the attention score matrix; next, applying the softmax function to the attention score matrix to obtain the attention weight matrix; then calculating the weighted value vector; concatenating this vector with the original input sequence to form an enhanced input feature sequence; the enhanced input feature sequence is input into the LSTM layer, passing through the forget gate, input gate, candidate memory unit state, memory unit state update, output gate, and calculation of the current hidden state, finally obtaining the hidden state at the final time step of the LSTM, which is then input into the fully connected layer, where the probability distribution of attack or security is calculated using the softmax function.
9. The quantum key distribution eavesdropping detection method based on the improved BB84 protocol and AI gatekeeper according to claim 7, characterized in that, The steps for eavesdropping detection using SVM include: standardizing the feature vectors extracted in step S2, calculating the covariance matrix of the standardized data, performing eigenvalue decomposition on the covariance matrix, selecting the eigenvectors corresponding to the first k principal components to form a matrix, projecting the original data onto the principal components to obtain the dimensionality-reduced data; constructing an SVM model using a Gaussian kernel function, searching for the optimal parameter combination among predefined parameter combinations including different penalty parameters and kernel function width parameters through grid search, and using the optimized SVM model to detect eavesdropping in the quantum key distribution process.
10. The quantum key distribution eavesdropping detection method based on the improved BB84 protocol and AI gatekeeper according to claim 7 or 9, characterized in that, When integrating the outputs of the LSTM network based on the self-attention mechanism and the optimized support vector machine for eavesdropping detection, the weights of LSTM and SVM are first dynamically adjusted according to the current detected attack type. Then, the comprehensive detection result is calculated based on the outputs of LSTM and SVM and their corresponding weights. Finally, a threshold is set based on the comprehensive detection result. If the detection result is greater than the threshold, it is determined that there is eavesdropping behavior in the quantum key distribution process; otherwise, it is determined to be a secure state. The weights are allocated based on the performance metrics of each model on the validation set, including accuracy, recall, and F1 score.