## 4 The Proposed Stream Cipher (Strike)
### Detailed Design of Strike Stream Cipher
#### 4.2.2 Keystream Generation  
Our stream cipher's keystream generator acts as a lightning strike generator. The lightning strike process is composed of five stages: selecting the peak current, computing the probability density function, calculating the jump distances, locating the stepped leader head and generating the keystream. The structure of the lightning strike generator for the keystream generation process is illustrated in Figure 5. \begin{table}
\begin{tabular}{l l l} \hline \hline
**Parameter** & **Length** & **Description** \\ \hline _SKey_ & 128-bit & Secret key \\ _IVec_ & 32-bit & Initial vector \\ \(a\) & 8-bit & _x_-coordinate on ground \\ \(b\) & 8-bit & _y_-coordinate on ground \\ \(c\) & 8-bit & _z_-coordinate in sky \\ \(r\) & 8-bit & Random number \\ \(j\) & 8-bit & Number of jumps composing the lightning strike \\ \(s\) & 8-bit & The order number of selected class in PC_i_ \\ PC1-PC4 & 16-bit/each & Peak current intervals \\ _KSC_ & 8-bit & _Skey_ shifting controller \\ _I\({}_{mem}\)_ & 8-bit & Mean value of current \(I\) \\ _I\({}_{std}\)_ & 8-bit & Standard deviation of current \(I\) \\ _IVSC_ & 8-bit & _IV_-shifting controller \\ _iclasses_ & 8-bit & Total number of classes in each PC_i_ \\ _K\({}_{stream}\)_ & 16-bit & Keystream binary bits \\ _C\({}_{ext}\)_ & 16-bit & Ciphertext binary bits \\ _P\({}_{heat}\)_ & 16-bit & Plaintext binary bits \\ _TP_ & 4-bit & Total peak value \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Logarithmic normal distribution of lightning current parameters. Figure 5: Lightning strike generator for keystream. ```
01:Input: 128-bit value SKey  32-bit value Ivec
02:Output: 8-bit values a, b, c, r, j, s  8-bit values KSC, \(I_{\text{mean}}\), I\({}_{\text{std}}\), IVSC, classes  16-bit values PC1, PC2, PC3, PC4  16-bit values x0, y0, h0
03:// extract Secret Key (SKay) parameters
04: a = SKey[bit_0 bit_7]
05: b = SKey[bit_8 bit_15]
06: c = SKey[bit_16 bit_23]
07: r = ( SKey[bit_24 bit_31] + SKey[bit_32-bit_39]) _mod_ 255
08: j = SKey[bit_40 bit_47]
09: s = SKey[bit_48-bit_55]
10:// initialize the min and max peak currents of each PC interval
11:functionCalculate_PCs (SKey)
12:PC1 = I_min = Min (SKey[bit_56-bit_63], SKey[bit_64-bit_71])
12: I_max = Max (SKey[bit_56-bit_63], SKey[bit_64-bit_71])
13: PC2 = I_min = Min (SKey[bit_72-bit_79], SKey[bit_80-bit_87])
14: PC3 = I_min = Min (SKey[bit_88-bit_95], SKey[bit_96-bit_103]),  1.max = Max (SKey[bit_88-bit_95], SKey[bit_96-bit_103])
15: PC4 = I_min = Min (SKey[bit_104-bit_111], SKey[bit_112-bit_119]),  1.max = Max (SKey[bit_104-bit_111], SKey[bit_112-bit_119])
16:endfunction
17:KSC = SKey[bit_120-bit_127]
18:// extract Initial Vector (Ivec) parameters
19: I\({}_{\text{mean}}\) = Ivec[bit_0-bit_7]
20: I\({}_{\text{std}}\) = Ivec[bit_8-bit_15]
21: IVSC = Ivec[bit_16-bit_23]
22: iclasses = Ivec[bit_24-bit_31]
23:// calculate the initial lighting strike coordinates over 3D space
24:functionInitialize_Coord (a, b, c, r)
25: x0 = r - a
26: y0 = r - b
27: h0 = r - c
28:endfunction
29://calcultic span of each class in each PC
30:functionGenerate_Classes (PC1, PC2, PC3, PC4, iclasses)
31:for PC = 1 to PC = 4 do
32: PC_span_I[PC] = (I_max - I_min)/iclasses
33:endfor
34:// generate peak current classes for each PC interval
35:for PC = 1 to PC = 4 do
36:for cls = 1 to cls = iclasses do
37: iclass_I_min = I_min[PC] + (classes - 1) - PC_span_I[PC]
38: iclass_I_max = iclass_I_min + PC_span_I[PC]
39:endfor
40:endfor
41:endfunction
```  
**Algorithm 1**Skey/IVec Setup  
The first step starts from the peak current selection by choosing four peaks (\(I_{1}\)-\(I_{4}\)) from their corresponding intervals (PC1-PC4), where [\(I_{1}\), \(I_{3}\)] are chosen as the maximum peaks and [\(I_{2}\), \(I_{4}\)] are chosen as the minimum peaks. Upon selecting the four peaks, the final general peak (\(I\)) is computed by XORing (\(\oplus\)) the four peaks as follows:  
\[I=I_{1}\oplus\ I_{2}\oplus\ I_{3}\oplus\ I_{4} \tag{17}\]Next, the probability density function is processed by applying Equations (1)-(3).