## 3 The Proposed Key Generation Protocol
### Multi-Bit Adaptive Quantization (MAQ)  
The classic quantization algorithm converts the channel measurement value into a binary number by setting different threshold standards. The single threshold quantization method quantizes the part of the measurement value above the threshold as \"1\" and the part below the threshold as \"0\". This method is fast in generating the initial key and has strong robustness to noise. However, due to the low quantization accuracy, the information entropy is lost, and it is easy to generate a long string of \"0\"s or \"1\"s, which affects the randomness of the key. In the multi-threshold equal probability quantization method, the channel estimation value is distributed into different quantization intervals so that the probability of each interval is equal, and the ratio of \"0\" and \"1\" in the generated sequence is roughly the same. This method has advantages in reducing the loss of information entropy and can generate a more balanced random sequence, but the guard bands set between different quantization intervals cause the loss of some key materials. Considering that a single quantization method does not easily adapt to the complex maritime communication environment, especially when the quantization results of the two communicating parties are quite different, it increases the overhead of the subsequent information coordination stage. Therefore, this paper designs an adaptive quantization scheme based on Gray code to reduce the sequence inconsistency rate. This scheme uses Gray code encoding to reduce the impact of quantization error on key generation and adaptively adjusts the number of quantization bits to balance quantization accuracy and noise robustness, thereby effectively balancing the randomness and consistency of the key. Through this adaptive quantization scheme, the inconsistency rate of the sequence can be significantly reduced, the overhead of information coordination can be reduced, and the efficiency and security of key generation can be improved. The steps for MAQ are as follows:  
* Determine the number of bits \(m\) required for the quantization of each CIR sequence value based on the length of the initial sequence and the SNR of the probing signal.
* Select the maximum and minimum amplitudes of the sampled values of the initial sequence, and divide this range into \(Q=2^{m+2}=4\times 2^{m}\) intervals with equal probability, with boundaries \(q_{0},q_{1},\cdots,q_{Q}\).
* Calculate the cumulative distribution function \(g(x_{A}(t),x_{B}(t))\) of \(h_{AB}\) and \(h_{BA}\), and designate the interval \((q_{k-1},q_{k}]\) as the \(k\)-th quantization interval, \(q_{i}=g^{-1}\Big{(}\frac{k}{Q}\Big{)},\ \text{k}=1,\cdots,Q\).
* For the divided intervals, assign each a corresponding binary Gray code. Gray code ensures that when [PERSON] and [PERSON] encounter differences in quantization, each sample value results in at most one inconsistent bit, thereby reducing the cost of subsequent information reconciliation. The flag bit \(e(k)\) is defined as follows: \[e(k)=\begin{cases}1,&k\text{ mod }4\geq 2\\ 0,&\text{others}\end{cases}\quad(k=1,2,\cdots,q)\] (13)
* The sender determines the corresponding quantization interval \(k_{A}(i)\) and obtains the value of \(e(k_{A}(i))\) from \(k_{A}(i)\). When \(e(k_{A}(i))=1\), \(x_{A}(i)\) is encoded as \(c_{1}(k_{A}(i))\); when \(e(k_{A}(i))=2\), \(x_{A}(i)\) is encoded as \(c_{2}(k_{A}(i))\). The receiver follows the same procedure. The specific quantization schemes for \(m=1\) and \(m=2\) are shown in Table 1 and Table 2, respectively.