# Secure Cryptographic Key Encapsulation and Recovery Scheme in Noisy Network Conditions
## 5 Key Encapsulation and Recovery Method Using CRP
### Example  
Consider the ephemeral key represented by a 6-bit sequence 011010. In Figure 2, bit positions are labeled with white squares denoting \"0\"s and black squares denoting \"1\"s. The full set of responses, each of length \(P\) bits where \(P\) is elective, correspond in black to the \"1\" positions in the ephemeral key, forming the subsets of responses. After noise injection, these subsets are transmitted to the receiver. Utilizing the CRP mechanism, the receiver generates a full set of responses and uses the search algorithm. This algorithm assesses the hamming distance between each subset and response in the search window against a threshold to determine matches, categorizing them into OneMatch, NoMatch, and Collisions. For instance, the initial search window may detect positions 0 and 1 as matches, thus recording them in the Collisions list. The second window may reveal a single match at position 2 classified into OneMatch, and the last search, finding no matches, adds positions 3, 4, and 5 to NoMatch. The recovery algorithm first utilizes OneMatch to generate a preliminary key. It then combines Collisions and NoMatch to exhaustively produce all possible key combinations, designated as keys (1) through (7). Figure 2: Simplified illustration of key encapsulation on the sender side and error detection process on the receiver side. The orange responses represent the collision, green represents one match, and white represents the no match responses. The numbers in front of the OneMatch, Collisions, and NoMatch variable represents the positions of the responses that showed the characteristics of these variables. In the process of key recovery, although key (6) is the actual correct key, the receiver determines the correct key through a process of elimination. This involves decrypting the ciphertext with each potential key, in sequence, until a readable plaintext is obtained. This method ensures that even without prior knowledge of the correct key, the receiver can systematically identify it by testing each one against the ciphertext. Enhanced List Processing  
The key recovery protocol is refined by incorporating additional comparison steps after collecting the OneMatch, Collision, and NoMatch lists. By cross-referencing the OneMatch list with both the Collision and NoMatch lists, any common positions should be removed from the latter two. If this elimination results in a sublist with a single element, then this position should be reallocated to the OneMatch list, as it represents the sole possible match for its corresponding search window. This strategy not only streamlines the search space but also enhances the efficiency of the key recovery process. A step-by-step approach of this method is shown in Algorithm 4. ```
1:Input: OneMatch[], Collisions[], NoMatch[]
2:Procedure: RefineKeyRecovery(OneMatch, Collisions, NoMatch)
3:for each position pos in OneMatch[]do
4:if pos is in Collisions[]then
5: Remove pos from Collisions[]
6:endif
7:if pos is in NoMatch[]then
8: Remove pos from NoMatch[]
9:endif
10:endfor
11:for each list \(L\) in {Collisions[], NoMatch[]}do
12:if Length of \(L\) is 1 then
13: Move element from \(L\) to OneMatch[]
14:endif
15:endfor
16:Output: Updated OneMatch[], Collisions[], NoMatch[]
```  
**Algorithm 4** Enhanced List Processing  
This collection of scatter plots presented in Figure 3 presents a comparative analysis of error rates before and after the implementation of the enhancement technique (segmented by varying response lengths of 8 to 512). Each subplot correlates the pre-enhancement error rates on the x-axis with the post-enhancement error rates on the y-axis; thus, the presence of a trend line in each plot bearing a positive slope of less than 45 degrees suggests an overall reduction in errors. The data points predominantly reside below the line y = x, implying that for most instances, the enhancement method has successfully lowered the error rates.