# Bit Independence Criterion Extended to Stream Ciphers
## 4 Experiments and Discussion of the Results
### Scenario 2 (BIC in Stream Cipher)  
For this scenario, it is convenient to apply the test to a stream cipher that violates the BIC. RC4 was chosen because there are reports of the existence of dependencies between the inputs and outputs in this cipher [22; 23; 24; 25]. Experiments were performed setting the parameters \(n=m\in\{32,64,128,160,256\}\) and 1000 sets \(D\) of \(l=16\),384 entries each were built. In each set, \(Z_{T}\) was calculated and compared with the critical value \(Z_{1-\alpha_{2}}\), varying \(\alpha_{2}\). Figure 3 shows the distribution of the 1000 values of \(Z_{T}\) obtained. Table 9 show the values \(\widehat{E}(Z_{T})\) and \(\widehat{o^{2}}(Z_{T})\) observed in each sample, for each value of \(n,m\), and \(l\). \begin{table}
\begin{tabular}{c c c c} \hline \hline \(\alpha_{2}\) & \(E(\#\left[Z_{T}>Z_{1-\alpha_{2}}|H_{0}\right])\) & \(\dfrac{\#\left[Z_{T}>Z_{1-\alpha_{2}}|H_{0}\right]}{n=m=32}\) & \(n=m=64\) \\ \hline
0.05 & 50 & 31 & 43 \\ \hline
0.01 & 10 & 8 & 9 \\ \hline
0.001 & 1 & 1 & 1 \\ \hline
0.0001 & 0 & 0 & 0 \\ \hline \hline \end{tabular}
\end{table} 
Table 7: Expected \(E(\#\left[Z_{T}>Z_{1-\alpha_{2}}|H_{0}\right])\) and observed \(\#\left[Z_{T}>Z_{1-\alpha_{2}}|H_{0}\right]\) number of rejections in samples of 1000 values of \(Z_{t}\) for \(n=m\), in \(H^{i}\) random matrices. In Figure 4 we can see how by increasing the values of \(m=n\) the Normal distribution \(N(\mu,1)\) of the statistician \(Z_{t}\) is maintained, however, the value of \(\mu\) increases (see Figure 3 and Table 9). It is observed that in all cases the \(p\)-values are greater than the usual values assumed for \(\alpha\), such as 0.01 or 0.05 and the samples maintain normality. In Table 11 it is noted how in RC4 the effectiveness of the criterion increases as the values of \(n\) and \(m\) increase. That is, increasing the values \(m=n\) increases the number of correct decisions to reject \(H_{0}\). As mentioned, it is known that by increasing the value of \(n\) in RC4 the probability of finding very similar outputs, or even the same, increases for inputs that differ by a few bits [22; 24; 25; 26]. This experiment confirms the effectiveness of the BIC test by detecting dependence between the inputs-outputs of RC4 and allows us to conclude that in RC4, the effectiveness is an increasing function of the value of the parameters \(n=m\). All cases in which the observed number of rejections exceeds the expected value are indicated in italics. An important feature in statistical tests is the determination of type I and type II errors [2]. Under \(H_{0}\), we have that \(v^{i}_{\cdot j}\) and \(v^{i}_{\cdot k}\) are independent, then the type I error consists in rejecting independence when they are and therefore deciding that the cipher has a weakness when it does not have it. Meanwhile, not rejecting \(H_{0}\) when there is a dependency means that it would be decided that the cipher passes the BIC, when in fact it does not pass it, and a type II error would be committed. Table 12 shows the proportion of Type I and II errors, committed by the BIC test, for some parameter sets. It can be seen that for \(\alpha_{2}=0.0001\) type I and II errors are not made. The outputs of RC4 [23] are known to pass numerous statistical tests [49], however they do not satisfy the BIC statistical test proposed in this work. This shows that the BIC statistical test complements the classic randomness tests, therefore it constitutes a tool to consider to evaluate stream ciphers. \begin{table}
\begin{tabular}{c c c c c c} \hline \multirow{2}{*}{\(\alpha_{2}\)} & \multicolumn{4}{c}{**Estimation Type I Error**} & \multicolumn{2}{c}{**Estimation Type II Error**} \\ \cline{2-6}  & \(n=32,m=32\) & \(n=64,m=64\) & \(n=32,m=32\) & \(n=64,m=64\) \\ \hline
0.05 & 0.031 & 0.043 & 0.077 & 0.155 \\ \hline
0.01 & 0.008 & 0.009 & 0.022 & 0.044 \\ \hline
0.001 & 0.001 & 0.001 & 0.002 & 0.011 \\ \hline
0.0001 & 0 & 0 & 0 & 0 \\ \hline \end{tabular}
\end{table} 
Table 12: Proportion of type I and II errors made by the BIC test.