## 4 The Proposed Stream Cipher (Strike)
### Detailed Design of Strike Stream Cipher
#### 4.2.3 Data Encryption
```
01:Input: 8-bit values \(\mathrm{I_{mean}}\), \(\mathrm{I_{std}}\) 16-bit value PC1, PC2, PC3, PC4, x0, y0, h0
02:Output: 16-bit value \(\mathrm{K_{stream}}\)
03: // select a peak current from each PC interval
04: \(\mathrm{I_{1}}\) = \(\mathrm{i}\mathrm{class\_I\_max(PC1,\,s\,\mathrm{mod\,\,iclasses})}\)
05: \(\mathrm{I_{2}}\) = \(\mathrm{class\_I\_min(PC2,\,s\,\mathrm{mod\,\,iclasses})}\)
06: \(\mathrm{I_{3}}\) = \(\mathrm{class\_I\_max(PC3,\,s\,\mathrm{mod\,\,iclasses})}\)
07: \(\mathrm{I_{4}}\) = \(\mathrm{class\_I\_min(PC4,\,s\,\mathrm{mod\,\,iclasses})}\)
08: // calculate the final peak current I
09: \(\mathrm{I=I_{1}}\oplus\mathrm{I_{1}}\oplus\mathrm{I_{1}}\)
10: // calculate the probability density function of all selected currents
11: \(\mathrm{u_{1}}\) = \(((\log(\mathrm{I_{1}})-\log(\mathrm{I_{mean}}))/(\mathrm{sqrt(2)\cdot I_{std}})\)
12: \(\mathrm{u_{2}}\) = \(((\log(\mathrm{I_{2}})-\log(\mathrm{I_{mean}}))/(\mathrm{sqrt(2)\cdot I_{std}})\)
13: \(\mathrm{u_{3}}\) = \(((\log(\mathrm{I_{3}})-\log(\mathrm{I_{mean}}))/(\mathrm{sqrt(2)\cdot I_{std}})\)
14: \(\mathrm{u_{4}}\) = \(((\log(\mathrm{I_{4}})-\log(\mathrm{I_{mean}}))/(\mathrm{sqrt(2)\cdot I_{std}})\)
15: \(\mathrm{init}\) = \(1\) - \((2/\mathrm{sqrt(PI)})\)
16: \(\mathrm{sum}\) = \(0\)
17: \(\mathrm{for}\) = \(1\) to \(\mathrm{i}\) = \(4\) do
18: \(\mathrm{for}\) = \(0\) to \(\mathrm{n}\) = \(10\) do
19: \(\mathrm{sum}\) = \(\mathrm{sum}+((-1)^{\mathrm{-}}\mathrm{n}\cdot(\mathrm{u_{i}})^{\mathrm{-}}( 2\mathrm{n}+1)/(\mathrm{nt}^{\mathrm{-}}\cdot(2\mathrm{n}+1))\)
20: \(\mathrm{end}\) \(\mathrm{for}\)
21: \(\mathrm{erfc[i]}\) = \(\mathrm{init}\) - \(\mathrm{sum}\)
22: \(\mathrm{end}\) \(\mathrm{for}\)
23: \(\mathrm{for}\) = \(1\) to \(\mathrm{n}\) = \(4\) do
24: \(\mathrm{P[i]}\) = \(1\) - \(\mathrm{erfc[i]}\)
25: \(\mathrm{end}\) \(\mathrm{for}\)
26: // concatenate P[i] to generate 4-bit TP value
27: \(\mathrm{TP}\) = \(\mathrm{P[1]}\) \(\mathrm{\mid}\) \(\mathrm{P[2]}\) \(\mathrm{\mid}\) \(\mathrm{P[3]}\) \(\mathrm{\mid}\) \(\mathrm{P[4]}\)
28: // calculate the distance of each jump
29: \(\mathrm{R}\) = \(10\) - \((\mathrm{TP}\cdot\Gamma(\cos(\mathrm{I_{mean}}+\mathrm{I_{std}}))\)
30: // re-calculate the new coordinates of stepped leader head
31: \(\mathrm{for}\) = \(1\) to \(\mathrm{i}\) = \(\mathrm{id}\)
32: \(\mathrm{ph_{i-1}}\) = \(\tau\) - \((2\) - \(\mathrm{P}\))
33: \(\mathrm{sigma}_{\mathrm{j-1}}\) = \((\mathrm{r}+1)\) - \((\mathrm{Pi}/2)\)
34: \(\mathrm{x_{j}}\) = \(\mathrm{x_{j-1}}\) + \(\mathrm{R}\) - \(\mathrm{sin(sigma_{\mathrm{j-1}})}\) - \(\mathrm{cos(\mathrm{ph_{i-1}})}\)
35: \(\mathrm{y_{j}}\) = \(\mathrm{y_{j-1}}\) + \(\mathrm{R}\) - \(\mathrm{sin(sigma_{\mathrm{j-1}})}\) - \(\mathrm{sin(\mathrm{Ph_{i-1}})}\)
36: \(\mathrm{h_{j}}\) = \(\mathrm{h_{j-1}}\) + \(\mathrm{R}\) - \(\mathrm{cos(sigma_{\mathrm{j-1}})}\)
37: \(\mathrm{end}\) \(\mathrm{for}\)
38: // calculate the keystream (\(\mathrm{K_{stream}}\)) of 16-bit length
39: \(\mathrm{K_{stream}}\) = \((\mathrm{x_{j}}\oplus\mathrm{y_{j}}\oplus\mathrm{y_{j}})\) << \(\mathrm{TP}\)
40: // \(\mathrm{shift}\) - \(\mathrm{security}\) - \(\mathrm{parameters}\)
41: \(r\) << \(\mathrm{KSC}\)
42: \(\mathrm{j}\) > \(\mathrm{KSC}\)
43: \(\mathrm{s}\) << \(\mathrm{KSC}\)
44: \(\mathrm{Skey}\) >> \(\mathrm{KSC}\)
45: \(\mathrm{I_{mean}}\) << \(\mathrm{IVSC}\)
46: \(\mathrm{I_{std}}\) >> \(\mathrm{IVSC}\)
47: \(\mathrm{classes}\) << \(\mathrm{IVSC}\)
48: \(\mathrm{IVSC}\) >> \(\mathrm{KSC}\)
49: \(\mathrm{KSC}\) << \(\mathrm{IVSC}\)
50: // re-calculate PC1-PC4
51: \(\mathrm{Calculate\_PCs}\) (\(\mathrm{SKey}\))
52: // re-initialize coordinates
53: \(\mathrm{a}\) = \(\mathrm{SKey[bit\_0\_bit\_7]}\)
54: \(\mathrm{b}\) = \(\mathrm{SKey[bit\_8\_bit\_15]}\)
55: \(\mathrm{c}\) = \(\mathrm{SKey[bit\_16\_bit\_23]}\)
56: \(\mathrm{Initialize\_Cord}\) (\(\mathrm{a}\), \(\mathrm{b}\), \(\mathrm{c}\), \(\mathrm{r}\))
57: // re-generate peak current classes
58: \(\mathrm{Generate\_Classes}\) (\(\mathrm{PC1}\), \(\mathrm{PC2}\), \(\mathrm{PC3}\), \(\mathrm{PC4}\), \(\mathrm{classes}\))
```  
**Algorithm 2** Keystream Generation (Lightning Strike Generator)