Skip to main content
Log in

Jump and hop randomness tests for binary sequences

  • Published:
Cryptography and Communications Aims and scope Submit manuscript

Abstract

Linear complexity test included in the NIST test suite only checks whether or not the observed linear complexity is close to the expected linear complexity. To take full advantage of the information of the linear complexity profile, we propose two randomness tests including a jump test based on the jump complexity, i. e., the number of changes in the linear complexity profile of a sequence, and a hop test checking the sum of jump heights at intervals. By using an iterative algorithm we calculate some necessary statistical measures of a random sequence of length M, and combining with hypothesis test we determine whether a given binary sequence is random or not. Moreover, we provide the explicit formulae of the expectation and the variance of the statistical measure of the hop test. The computational complexity of the jump test and the hop test is the same as that of the linear complexity test. Additionally, we provide a type of sample which, having passed all tests in the NIST test suite, is rejected by the jump test and hop test. So the proposed tests deserve to be considered.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4

Similar content being viewed by others

References

  1. A statistical test suite for random and pseudorandom number generators for cryptographic applications, special publication 800-22. Tech. rep

  2. Carter, G.D.: Aspects of local linear complexity. Ph. D. thesis, University of London (1989)

  3. Mauduit, C., Sárközy, A.: On finite pseudorandom binary sequences i: Measure of pseudorandomness, the legendre symbol. Acta Arithmetica 82(4), 365–377 (1997)

    Article  MathSciNet  Google Scholar 

  4. Hamano, K., Sato, F., Yamamoto, H.: A new randomness test based on linear complexity profile. IEICE Transactions 92–A(1), 166–172 (2009)

  5. Cassaigne, J., Mauduit, C., Sarkozy, A.: On finite pseudorandom binary sequences vii: The measures of pseudorandomness. Acta Arithmetica 103(2), 97–118 (2002)

    Article  MathSciNet  Google Scholar 

  6. Massey, J.L.: Shift-register synthesis and BCH decoding. IEEE Trans. Information Theory 15(1), 122–127 (1969)

    Article  MathSciNet  Google Scholar 

  7. Mérai, L., Rivat, J., Sárközy, A.: The measures of pseudorandomness and the NIST tests. In: Number-Theoretic Methods in Cryptology - First International Conference, NuTMiC 2017, Warsaw, Poland, September 11-13, 2017, Revised Selected Papers, pp. 197–216 (2017)

  8. Niederreiter, H.: Sequences with almost perfect linear complexity profile. In: Advances in Cryptology - EUROCRYPT ’87, Workshop on the Theory and Application of of Cryptographic Techniques, Amsterdam, The Netherlands, April 13-15, 1987, Proceedings, pp. 37–51 (1987)

  9. Niederreiter, H.: The probabilistic theory of linear complexity. In: Advances in Cryptology - EUROCRYPT ’88, Workshop on the Theory and Application of of Cryptographic Techniques, Davos, Switzerland, May 25-27, 1988, Proceedings, pp. 191–209 (1988)

  10. Niederreiter, H.: Keysystem sequences with a good linear complexity profile for every strating point. In: Advances in Cryptology - EUROCRYPT ’89, Workshop on the Theory and Application of of Cryptographic Techniques, Houthalen, Belgium, April 10-13, 1989, Proceedings, pp. 523–532 (1989)

  11. Niederreiter, H.: The linear complexity profile and the jump complexity of keystream sequences. In: Advances in Cryptology - EUROCRYPT ’90, Workshop on the Theory and Application of of Cryptographic Techniques, Aarhus, Denmark, May 21-24, 1990, Proceedings, pp. 174–188 (1990)

  12. Rueppel, R.A.: Linear complexity and random sequences. In: Advances in Cryptology - EUROCRYPT ’85, Workshop on the Theory and Application of of Cryptographic Techniques, Linz, Austria, April 1985, Proceedings, pp. 167–188 (1985)

  13. Rueppel, R.A.: Analysis and Design of Stream Ciphers. Springer-Verlag, Berlin, Germany (1986)

    Book  Google Scholar 

  14. Wang, M.: Cryptographic aspects of sequence complexity measures, Ph.D. dissertation. ETH Zurich (1988)

  15. Wang, M.: Linear complexity profiles and continued fractions. In: Advances in Cryptology - EUROCRYPT ’89, Workshop on the Theory and Application of of Cryptographic Techniques, Houthalen, Belgium, April 10-13, 1989, Proceedings, pp. 571–585 (1989)

  16. Wang, M.: Linear complexity profiles and jump complexity. Information Processing Letters 61(3), 165–168 (1997)

    Article  MathSciNet  Google Scholar 

  17. Wang, M., Massey, J.L.: The characterization of all binary sequences with perfect linear complexity profiles. In: EUROCRYPT, pp. 35–36 (1986)

  18. Winterhof, A.: Linear complexity and related complexity measures. In: Selected Topics in Information and Coding Theory, pp. 3–40. World Scientific, Singapore (2010)

Download references

Acknowledgements

The authors would like to express their sincere thanks to the anonymous reviewers for providing valuable suggestions. They are partially supported by Tianjin Key Research and Development Project 19YFZCSF00900 and 20JCZDJC00610.

Author information

Authors and Affiliations

Authors

Additional information

Part of this work has been accepted and presented at SETA2020.

Appendix

Appendix

In order to calculate the expectation and variance of \(O_n\), we need to know its counting functions. Denote by \(N_n(\sigma )\) the number of n-bit binary sequences with the odd hop sum \(\sigma\), and \(NL_n(L,\sigma )\) by the number of n-bit binary sequences with the linear complexity L and the odd hop sum \(\sigma\).

From Proposition 1 or from the continued fraction method in [16], the number of n-bit binary sequences with a prescribed jump height sequence \(jh_1, jh_2, \dots , jh_m\), and the linear complexity L is

$$\begin{aligned} \left\{ \begin{array}{ll} 2^L, &{}2L\le n \\ 2^{n-L} , &{}2L>n\\ \end{array}\right. , \end{aligned}$$
(9)

where \(L=jh_1+jh_2+\cdots +jh_m\).

Let the last m-th jump be in position k of such an n-bit sequence, we have \(jh_m=2L-k\ge 2L-n\), and obtain

$$\begin{aligned} jh_m\ge \max \{1, 2L-n\}. \end{aligned}$$
(10)

By (9), for calculating \(NL_n(L,\sigma )\) we should count the number of sequences \(\{jh_1, jh_2, \ldots , jh_m\}\) with \(jh_1+jh_2+\cdots +jh_m=L\), \(jh_1+jh3+\cdots =\sigma\), and \(jh_m \ge \max \{1, 2L-n\}\). Next, we provide related lemmas.

Lemma 1

The number of positive integer sequences \(S=\{s_1,s_2,\dots ,s_m\}\) satisfying \(\sum _{i=1}^m s_i=h\) is

$$\begin{aligned} \left\{ \begin{array}{lll} \mathrm {C}_{h-1}^{m-1}, &{}0<m\le h\\ 0, &{}otherwise \end{array}\right. . \end{aligned}$$

Lemma 2

The number of positive integer sequences \(S=\{s_1,\dots ,s_{last}\}\) satisfying \(\sum _{i\ge 1} s_i=h\) and \(\sum _{j \ge 0} s_{2j+1}=\bar{h}\) is

$$\begin{aligned} \left\{ \begin{array}{lll} \mathrm {C}_{h-1}^{\bar{h}-1}, &{}0<\bar{h}\le h\\ 0, &{}otherwise \end{array}\right. . \end{aligned}$$

Proof

Let \(\mathcal {A}\) be the set of all positive integer sequences \(S_a=\{s_1,\dots ,s_{last}\}\) satisfying \(\sum _{i\ge 1} s_i=h\) and \(\sum _{j \ge 0} s_{2j+1}=\bar{h}\), and \(\mathcal {B}\) be the set of all positive integer sequences \(S_b=\{s_1,s_2,\dots ,s_{\bar{h}}\}\) satisfying \(\sum _{i=1}^{\bar{h}} s_i=h\).

Define \(f: \mathcal {A} \rightarrow \mathcal {B}\) as follows. For any sequence \(S_a=\{s_1,\dots ,s_{last}\}\) in \(\mathcal {A}\),

$$\begin{aligned}f(S_a)=\left\{ \begin{array}{lll} \{\underbrace{1,\dots ,1}_{s_1-1},1+s_2,\underbrace{1,\dots ,1}_{s_3-1},1+s_4,\dots \dots , \underbrace{1,\dots ,1}_{s_{last-1}-1},1+s_{last}\},&{}\quad \mathrm {if}\,\, last\,\,\mathrm {is\, even}\\ \{\underbrace{1,\dots ,1}_{s_1-1},1+s_2,\underbrace{1,\dots ,1}_{s_3-1},1+s_4,\dots \dots , 1+s_{last-1},\underbrace{1,\dots ,1}_{s_{last}}\},&{}\quad \mathrm {if}\,\, last\,\,\mathrm {is\, odd} \end{array}\right. \end{aligned}$$

Once \(s_{2i-1}-1=0\), the corresponding terms will disappear. Regarding \(f(S_a)\), its sum is still h and its length becomes \(s_1-1+1+s_3-1+1+\cdots =\bar{h}\), so f is a mapping from \(\mathcal {A}\) to \(\mathcal {B}\).

Define \(g: \mathcal {B} \rightarrow \mathcal {A}\): for any sequence \(S_b\in \mathcal {B}\), if its last term is larger than 1, we may write it in the following unique format

$$\begin{aligned} \{\underbrace{1,\dots ,1}_{s_1-1},1+s_2,\underbrace{1,\dots ,1}_{s_3-1},1+s_4,\dots \dots , \underbrace{1,\dots ,1}_{s_{2k-1}-1},1+s_{2k}\}, \end{aligned}$$

where \(s_1,s_2,\dots ,s_{2k}\) are all positive integers. Then, we have \(g(S_b)=\{s_1,s_2,\dots ,s_{2k}\}\). If its last term is 1, we write it as

$$\begin{aligned} \{\underbrace{1,\dots ,1}_{s_1-1},1+s_2,\underbrace{1,\dots ,1}_{s_3-1},1+s_4,\dots \dots , \underbrace{1,\dots ,1}_{s_{2k-1}}\}. \end{aligned}$$

Then, we have \(g(S_b)=\{s_1,s_2,\dots ,s_{2k-1}\}\). In both cases the length of \(S_b\) is \(s_1+s_3+\ldots +s_{2k-1}\), which equals \(\bar{h}\), the sum of those terms with odd subscripts of \(g(S_b)\).

Therefore, we have \(|\mathcal {A}|=|\mathcal {B}|\), and derive the conclusion from Lemma 1.

Lemma 3

The number of positive integer sequences \(S=\{ s_1, \ldots , s_{last}\}\) satisfying \(\sum _{i\ge 1} s_i =h\), \(\sum _{j \ge 0} s_{2j+1}=\bar{h}\) and \(s_{last}\ge t\) (\(t\in Z,0<t<h\)) is

$$\begin{aligned} \delta _{\bar{h}:(t,h]}\cdot \mathrm {C}_{h-t-1}^{\bar{h}-t-1}+\delta _{\bar{h}:(0,h-t]}\cdot \mathrm {C}_{h-t-1}^{\bar{h}-1}, \end{aligned}$$

where

$$\begin{aligned} \delta _{x:(a,b]}=\left\{ \begin{array}{ll} 1, &{} a<x\le b\\ 0 , &{} otherwise \end{array}\right. . \end{aligned}$$
(11)

Proof

Let \(\mathcal {R}\) be the set of all positive integer sequences \(S=\{ s_1, \ldots , s_{last}\}\) satisfying \(\sum _{i\ge 1} s_i =h\), \(\sum _{j \ge 0} s_{2j+1}=\bar{h}\) and \(s_{last}\ge t\). And let

\(\mathcal {C}: =\{S_c|S_c\in \mathcal {R}, \mathrm {the length of}\, S\, \mathrm {is odd}\}\), and \(\mathcal {D}: =\{S_d|S_d\in \mathcal {R}, \mathrm {the length of}\,\, S\,\ \mathrm {is even}\}\).

Then, \(\mathcal {C}\cap \mathcal {D}=\emptyset\) and \(\mathcal {C}\cup \mathcal {D}=\mathcal {R}\), so we have

$$\begin{aligned} |\mathcal {R}|=|\mathcal {C}|+|\mathcal {D}|. \end{aligned}$$
(12)

Let \(\mathcal {C}^{\prime }\) be the set of all positive integer sequences \(S=\{ s_1, \ldots , s_{last}\}\) satisfying \(\sum _{i\ge 1} s_i =h-t\), \(\sum _{j \ge 0} s_{2j+1}=\bar{h} - t\). Then, we define a mapping \(f_o: \mathcal {C}\rightarrow \mathcal {C}^{\prime }\): for any sequence \(S_c=\{ s_1, \ldots , s_{last}\}\in \mathcal {C}\),

$$\begin{aligned} f_o(S_c)=\left\{ \begin{array}{lll} \{s_1,s_2,\dots ,s_{last-1},s_{last}-t\}, \quad &{}\mathrm {if}\,\,s_{last}>t\\ \{s_1,s_2,\dots ,s_{last-1}\}.\quad &{}\mathrm {if}\,\, s_{last}=t \end{array}\right. . \end{aligned}$$

In both cases \(f_o(S)\) is still a positive integer sequence since \(t<h\). And \(S_c\in \mathcal {C}\), \(s_{last}\) has an odd subscript, so the sum of all terms of \(f_o(S_c)\) is \(h-t\), and the sum of terms with odd subscripts of \(f_o(S_c)\) is \(\bar{h}-t\). Thus, \(f_o(S_c)\in \mathcal {C}^{\prime }\).

Conversely, we define the mapping \(g_o: \mathcal {C}^{\prime } \rightarrow \mathcal {C}\): for any sequence \(S_{c^{\prime }}=\{ s_1, \ldots , s_{last}\}\) in \(\mathcal {C}^{\prime }\),

$$\begin{aligned} g_o(S_{c^{\prime }})=\left\{ \begin{array}{lll} \{s_1,s_2,\ldots ,s_{last}+t\}, &{}\quad \mathrm {if}\,\, last\,\,\mathrm {is\,odd}\\ \{s_1,s_2,\ldots ,s_{last},t\}. &{}\quad \mathrm {if}\,\,last\,\,\mathrm {is\,even} \end{array}\right. . \end{aligned}$$

In both cases the length of \(g_o(S_{c^{\prime }})\) is odd, the sum of all terms of \(g_o(S_{c^{\prime }})\) is t larger than that of \(S_{c^{\prime }}\), and the sum of terms with odd subscripts of \(g_o(S_{c^{\prime }})\) is also t larger than that of \(S_{c^{\prime }}\), thus \(g_o(S_{c^{\prime }})\in \mathcal {C}\).

Because \(f_o=g_o^{-1}\), they both are one-to-one mappings. Thus, we obtain \(|\mathcal {C}|=|\mathcal {C}^{\prime }|\). And by Lemma 2 we have

$$\begin{aligned} |\mathcal {C}|=|\mathcal {C}^{\prime }|=\left\{ \begin{array}{ll} \mathrm {C}_{h-t-1}^{\bar{h}-t-1},&{} 0<\bar{h}-t\le h-t\\ 0, &{}otherwise \end{array}\right. . \end{aligned}$$
(13)

Let \(\mathcal {D}^{\prime}\) be the set of all positive integer sequences \(S=\{ s_1, \ldots , s_{last}\}\) satisfying \(\sum _{i\ge 1} s_i =h-t\), \(\sum _{j \ge 0} s_{2j+1}=\bar{h}\). Similarly, we define a pair of inverse mappings \(f_e:\mathcal {D}\rightarrow \mathcal {D}^{\prime}\) and \(g_e:\mathcal {D}^{\prime}\rightarrow \mathcal {D}\). For any sequence \(S_d=\{ s_1, s_2, \ldots , s_{last}\}\in \mathcal {D}\),

$$\begin{aligned} f_e(S_d)=\left\{ \begin{array}{ll} \{s_1,s_2,\dots ,s_{last}-t\},&{}\quad \mathrm {if}\,\,s_{last}>t\\ \{s_1,s_2,\dots ,s_{last-1}\},&{}\quad \mathrm {if}\,\,s_{last}=t \end{array}\right. . \end{aligned}$$

And for any sequence \(S_{d'}=\{ s_1,s_2, \ldots , s_{last}\} \in \mathcal {D}'\),

$$\begin{aligned} g_e(S_{d'})=\left\{ \begin{array}{ll} \{s_1,s_2,\ldots ,s_{last},t\},&{}\quad \mathrm {if}\,\, last\,\,\mathrm {is\,\,odd}\\ \{s_1,s_2,\ldots ,s_{last}+t\},&{}\quad \mathrm {if}\,\, last\,\,\mathrm {is\,\,even} \end{array}\right. . \end{aligned}$$

We obtain \(|\mathcal {D}|=|\mathcal {D}'|\) analogously. And from Lemma 2 we derive

$$\begin{aligned} |\mathcal {D}|=|\mathcal {D}^{\prime }|=\left\{ \begin{array}{ll} \mathrm {C}_{h-t-1}^{\bar{h}-1},&{} 0<\bar{h}\le h-t\\ 0, &{}otherwise \end{array}\right. . \end{aligned}$$
(14)

Combining (12), (13) and (14), we have the conclusion.

For \(NL_n(L,\sigma )\), it is straightforward that \(L\in [0,n]\) and \(o\in [1,L]\). By Lemma 2 and (9), if \(0<L\le n/2\) and \(1\le \sigma \le L\), we have

$$\begin{aligned} NL_n(L,\sigma )=\mathrm {C}_{L-1}^{\sigma -1}2^{L}. \end{aligned}$$

If \(n/2<L<n\) and \(1\le \sigma \le L\), considering the restriction on the last jump height (10), and from (9) and Lemma 3 we obtain

$$\begin{aligned} NL_n(L,\sigma )=\left( \delta _{\sigma :(2L-n,L]}\cdot \mathrm {C}_{n-L-1}^{\sigma -2L+n-1} +\delta _{\sigma :(0,n-L]}\cdot \mathrm {C}_{n-L-1}^{\sigma -1}\right) 2^{n-L}. \end{aligned}$$

Special cases include \(NL_n(0,0)=1\) and \(NL_n(n,n)=1\). Therefore, we conclude in the following lemma.

Lemma 4

The number of n-bit binary sequences with the linear linear complexity L and the odd hop sum o is

$$\begin{aligned} NL_n(L,\sigma )=\left\{ \begin{array}{lll} 1, &{}L=\sigma =0\\ \mathrm {C}_{L-1}^{\sigma -1}2^{L}, &{}0<L\le n/2, 1\le \sigma \le L\\ (\delta _{\sigma :(2L-n,L]}\cdot \mathrm {C}_{n-L-1}^{\sigma -2L+n-1} +\delta _{\sigma :(0,n-L]}\cdot \mathrm {C}_{n-L-1}^{\sigma -1})2^{n-L}, &{}n/2<L<n, 1\le \sigma \le L\\ 1, &{}L=\sigma =n\\ 0, &{}otherwise \end{array}\right. . \end{aligned}$$
(15)

Because \(L \ge \sigma\), we get \(N_n(\sigma )=\sum _{L=0}^nNL_n(L,\sigma )=\sum _{L=\sigma }^nNL_n(L,\sigma ).\) Before deriving the explicit formulae of \(E(O_n)\) and \(V(O_n)\), we need the following identities.

$$\begin{aligned} \sum \limits _{i=0}^n \mathrm {C}_n^i= & {} 2^n.\end{aligned}$$
(16)
$$\begin{aligned} \sum \limits _{i=0}^n \mathrm {C}_i^1\mathrm {C}_n^i= & {} n2^{n-1}.\end{aligned}$$
(17)
$$\begin{aligned} \sum \limits _{i=0}^n \mathrm {C}_i^2\mathrm {C}_n^i= & {} n(n-1) 2^{n-3}.\end{aligned}$$
(18)
$$\begin{aligned} \sum \limits _{i=\alpha }^{\beta }q^i= & {} \frac{q^{\beta +1}-q^\alpha }{q-1}.\end{aligned}$$
(19)
$$\begin{aligned} \sum \limits _{i=\alpha }^{\beta }\mathrm {C}_i^1q^i= & {} \frac{(\beta (q-1)-1)q^{\beta +1}-(\frac{\alpha }{q} (q-1)-1)q^{\alpha +1}}{(q-1)^2}.\end{aligned}$$
(20)
$$\begin{aligned} \sum \limits _{i=\alpha }^{\beta }\mathrm {C}_i^2q^i= & {} \frac{(\frac{(q-1)^2}{q}\mathrm {C}_\beta ^2-\frac{q-1}{q}\beta +1)q^{\beta +2}-(\frac{(q-1)^2}{q^2}\mathrm {C}_\alpha ^2-\frac{q-1}{q}\alpha +1)q^{\alpha +2}}{(q-1)^3}, \end{aligned}$$
(21)

where the combinatorial numbers \(\mathrm {C}_i^1=i\) and \(\mathrm {C}_i^2=\frac{i(i-1)}{2}\). Also, we let \(\mathrm {C}_i^j:=0\) if \(j>i\). Proof of Theorem 1

Proof

It is straightforward that

$$\begin{aligned} E(O_n) = 2^{-n}\sum \limits _{L=0}^n \sum \limits _{\sigma =0}^L \sigma \cdot NL_n(L,\sigma ). \end{aligned}$$
(22)

Because of (15), we divide \(\sum _{L=0}^n \sum _{\sigma =0}^L \sigma \cdot NL_n(L,\sigma )\) into different parts:

$$\begin{aligned} \sum \limits _{L=0}^n \sum \limits _{\sigma =0}^L \sigma \cdot NL_n(L,\sigma )= & {} \sum \limits _{\sigma =0}^0 \sigma \cdot NL_n(0,\sigma )+\sum \limits _{L=1}^{\lfloor n/2\rfloor } \sum \limits _{\sigma =1}^L \sigma \cdot NL_n(L,\sigma )\nonumber \\&+ \sum \limits _{L=\lfloor n/2\rfloor +1}^{n-1} \sum \limits _{\sigma =1}^L \sigma \cdot NL_n(L,\sigma )+\sum \limits _{\sigma =1}^n \sigma \cdot NL_n(n,\sigma )\nonumber \\= & {} n+\sum \limits _{L=1}^{\lfloor n/2\rfloor } \sum \limits _{\sigma =1}^L \sigma \cdot NL_n(L,\sigma )+\sum \limits _{L=\lfloor n/2\rfloor +1}^{n-1} \sum \limits _{\sigma =1}^L \sigma \cdot NL_n(L,\sigma ). \end{aligned}$$
(23)

The last identity is due to \(NL_n(n,\sigma ) \ne 0\) only when \(\sigma =n\). Then, we compute the two sums in the right side of (23).

Initially, we set \(n>2\). Now let n be even. By (17), (18), (19) and (20) we obtain

$$\begin{aligned} \sum \limits _{L=1}^{\lfloor n/2\rfloor } \sum \limits _{\sigma =1}^L \sigma \cdot NL_n(L,\sigma )= & {} \sum \limits _{L=1}^{n/2} \sum \limits _{\sigma =1}^L \sigma \cdot \mathrm {C}_{L-1}^{\sigma -1}2^L\nonumber \\= & {} \sum \limits _{L=1}^{n/2}2^L \sum \limits _{i=0}^{L-1} (i+1)\cdot \mathrm {C}_{L-1}^{i} \nonumber \\= & {} \frac{(3n+4)2^{n-1}-2}{9}. \end{aligned}$$
(24)

And by (15) we have

$$\begin{aligned} \sum \limits _{L=\lfloor n/2\rfloor +1}^{n-1} \sum \limits _{\sigma =1}^L \sigma \cdot NL_n(L,\sigma )= & {} \sum \limits _{L=n/2+1}^{n-1} \sum \limits _{\sigma =1}^L \sigma \cdot (\delta _{\sigma :(2L-n,L]}\cdot \mathrm {C}_{n-L-1}^{\sigma -2L+n-1} +\delta _{\sigma :(0,n-L]}\cdot \mathrm {C}_{n-L-1}^{\sigma -1})2^{n-L}\nonumber \\= & {} \sum \limits _{L=n/2+1}^{n-1}2^{n-L}\left( \sum \limits _{\sigma =1}^L \delta _{\sigma :(2L-n,L]}\cdot \sigma \cdot \mathrm {C}_{n-L-1}^{\sigma -2L+n-1}+\sum \limits _{\sigma =1}^L \delta _{\sigma :(0,n-L]}\cdot \sigma \cdot \mathrm {C}_{n-L-1}^{\sigma -1}\right) . \end{aligned}$$
(25)

Because of (11) we have

$$\begin{aligned} \sum \limits _{\sigma =1}^L \delta _{\sigma :(2L-n,L]}\cdot \sigma \cdot \mathrm {C}_{n-L-1}^{\sigma -2L+n-1}=\sum \limits _{\sigma =2L-n+1}^L \sigma \cdot \mathrm {C}_{n-L-1}^{\sigma -2L+n-1} =\sum \limits _{i=0}^{n-L-1} (i+2L-n+1)\cdot \mathrm {C}_{n-L-1}^{i}, \end{aligned}$$
(26)

and

$$\begin{aligned} \sum \limits _{\sigma =1}^L \delta _{\sigma :(0,n-L]}\cdot \sigma \cdot \mathrm {C}_{n-L-1}^{\sigma -1}=\sum \limits _{\sigma =1}^{n-L} \sigma \cdot \mathrm {C}_{n-L-1}^{\sigma -1} =\sum \limits _{i=0}^{n-L-1} (i+1)\cdot \mathrm {C}_{n-L-1}^{i}. \end{aligned}$$
(27)

Combining (25), (26) and (27), we get

$$\begin{aligned} \sum \limits _{L=n/2+1}^{n-1} \sum \limits _{\sigma =1}^L \sigma \cdot NL_n(L,\sigma )= & {} \sum \limits _{L=n/2+1}^{n-1}2^{n-L}\sum \limits _{i=0}^{n-L-1}(2i+2L-n+2)\mathrm {C}_{n-L-1}^{i}\\= & {} \sum \limits _{L=n/2+1}^{n-1}2^{n-L}\left( 2(n-L-1)2^{n-L-2}+(2L-n+2)2^{n-L-1}\right) . \end{aligned}$$

By (16), (17), (19) and (20), we have

$$\begin{aligned} \sum \limits _{L=n/2+1}^{n-1} \sum \limits _{\sigma =1}^L \sigma \cdot NL_n(L,\sigma )=2^{-1}\sum \limits _{i=1}^{n/2-1}(n-i+1)4^{i}=\frac{(3n+14)2^{n-2}-6n-8}{9}. \end{aligned}$$
(28)

Therefore, combing (22), (23), (24) and (28), if n is even, we have

$$\begin{aligned} E(O_n)= & {} 2^{-n}\left( n+\frac{(3n+4)2^{n-1}-2}{9}+\frac{(3n+14)2^{n-2}-6n-8}{9}\right) \nonumber \\= & {} \frac{n}{4}+\frac{11}{18}+\frac{3n-10}{9\cdot 2^n}. \end{aligned}$$
(29)

If n is odd, since \(\lfloor n/2\rfloor =(n-1)/2\), similarly we have \(E(O_n) =\frac{n}{4}+\frac{23}{36}+\frac{3n-10}{9\cdot 2^n}\).

Now we compute \(V(O_n)\). Because \(V(O_n)=E(O_n^2)-E^2(O_n)\), we calculate \(E(O_n^2)\) first.

$$\begin{aligned} E(O_n^2)=\sum \limits _{\sigma =0}^n\sigma ^2\cdot Pr\{O_n=\sigma \}=2^{-n}\sum \limits _{L=0}^n\sum \limits _{\sigma =0}^L\sigma ^2\cdot NL_n(L,\sigma ). \end{aligned}$$
(30)

Because of (15) we have

$$\begin{aligned} \sum \limits _{L=0}^n \sum \limits _{\sigma =0}^L \sigma ^2\cdot NL_n(L,\sigma )= & {} \sum \limits _{\sigma =0}^0 \sigma ^2\cdot NL_n(0,\sigma )+\sum \limits _{L=1}^{\lfloor n/2\rfloor } \sum \limits _{\sigma =1}^L \sigma ^2\cdot NL_n(L,\sigma )\nonumber \\&+ \sum \limits _{L=\lfloor n/2\rfloor +1}^{n-1} \sum \limits _{\sigma =1}^L \sigma ^2\cdot NL_n(L,\sigma )+\sum \limits _{\sigma =1}^n \sigma ^2\cdot NL_n(n,\sigma )\nonumber \\= & {} n^2+\sum \limits _{L=1}^{\lfloor n/2\rfloor } \sum \limits _{\sigma =1}^L \sigma ^2\cdot NL_n(L,\sigma )+\sum \limits _{L=\lfloor n/2\rfloor +1}^{n-1} \sum \limits _{\sigma =1}^L \sigma ^2\cdot NL_n(L,\sigma ). \end{aligned}$$
(31)

Next we calculate the two sums in the right side of (31).

First, let n be even. Then we have

$$\begin{aligned} \sum _{L=1}^{\lfloor n/2\rfloor } \sum \limits _{\sigma =1}^L \sigma ^2\cdot NL_n(L,\sigma )= & {} \sum \limits _{L=1}^{n/2} \sum \limits _{\sigma =1}^L \sigma ^2\cdot \mathrm {C}_{L-1}^{\sigma -1}2^L\\= & {} \sum \limits _{L=1}^{n/2}2^L \sum \limits _{i=0}^{L-1} (2\mathrm {C}_i^2+3\mathrm {C}_i^1+1)\cdot \mathrm {C}_{L-1}^{i}\\= & {} \sum \limits _{L=1}^{n/2} 2^L(2\mathrm {C}_{L-1}^22^{L-3}+3\mathrm {C}_{L-1}^12^{L-2}+2^{L-1}), \end{aligned}$$

where the last identity is due to (16), (17) and (18). Combining (20) and (21), we have

$$\begin{aligned} \sum \limits _{L=1}^{\lfloor n/2\rfloor } \sum \limits _{\sigma =1}^L \sigma ^2\cdot NL_n(L,\sigma )=2^{-2}\sum _{L=1}^{n/2} (\mathrm {C}_{L}^2+2\mathrm {C}_{L}^1)4^L =\frac{(9n^2+42n-16)2^{n-3}+2}{27}. \end{aligned}$$
(32)

And from (15) we derive

$$\begin{aligned} \sum \limits _{L=\lfloor n/2\rfloor +1}^{n-1} \sum \limits _{\sigma =1}^L \sigma ^2\cdot NL_n(L,\sigma )= & {} \sum _{L=n/2+1}^{n-1} \sum _{\sigma =1}^L \sigma ^2\cdot \left( \delta _{\sigma :(2L-n,L]}\cdot \mathrm {C}_{n-L-1}^{\sigma -2L+n-1} +\delta _{\sigma :(0,n-L]}\cdot \mathrm {C}_{n-L-1}^{\sigma -1}\right) 2^{n-L}\nonumber \\= & {} \sum \limits _{L=n/2+1}^{n-1}2^{n-L}\left( \sum \limits _{\sigma =1}^L \delta _{\sigma :(2L-n,L]}\cdot \sigma ^2\cdot \mathrm {C}_{n-L-1}^{\sigma -2L+n-1}+\sum _{\sigma =1}^L \delta _{\sigma :(0,n-L]}\cdot \sigma ^2\cdot \mathrm {C}_{n-L-1}^{\sigma -1}\right) . \end{aligned}$$
(33)

We have

$$\begin{aligned} \sum \limits _{\sigma =1}^L \delta _{\sigma :(2L-n,L]}\cdot \sigma ^2\cdot \mathrm {C}_{n-L-1}^{\sigma -2L+n-1}=\sum \limits _{\sigma =2L-n+1}^L \sigma ^2\cdot \mathrm {C}_{n-L-1}^{\sigma -2L+n-1} =\sum \limits _{i=0}^{n-L-1} (i+2L-n+1)^2\cdot \mathrm {C}_{n-L-1}^{i}, \end{aligned}$$
(34)

and if \(n\le 2 L\) we have

$$\begin{aligned} \sum \limits _{\sigma =1}^L \delta _{\sigma :(0,n-L]}\cdot \sigma ^2\cdot \mathrm {C}_{n-L-1}^{\sigma -1}=\sum \limits _{\sigma =1}^{n-L} \sigma ^2\cdot \mathrm {C}_{n-L-1}^{\sigma -1} =\sum \limits _{i=0}^{n-L-1} (i+1)^2\cdot \mathrm {C}_{n-L-1}^{i}. \end{aligned}$$
(35)

Combining (33), (34) and (35), we get

$$\begin{aligned} \sum \limits _{L=n/2+1}^{n-1} \sum \limits _{\sigma =1}^L \sigma ^2\cdot NL_n(L,\sigma )= & {} \sum _{L=n/2+1}^{n-1}2^{n-L}\sum _{i=0}^{n-L-1}\left( 4\mathrm {C}_i^2+2(2L-n+3)\mathrm {C}_i^1+(2L-n+1)^2+1\right) \mathrm {C}_{n-L-1}^{i}\nonumber \\= & {} \sum \limits _{L=n/2+1}^{n-1}2^{n-L}\left( 4\mathrm {C}_{n-L-1}^22^{n-L-3}+2(2L-n+3)\mathrm {C}_{n-L-1}^12^{n-L-2}+((2L-n+1)^2+1)2^{n-L-1} \right) \nonumber \\= & {} 2^{-1}\sum \limits _{i=1}^{n/2-1}(5\mathrm {C}_i^2+(2-3n)\mathrm {C}_i^1+n^2+n)4^i =\frac{(9n^2+102n+448)2^{n-4}-18n^2-36n-28}{27}. \end{aligned}$$
(36)

Combing (30), (31), (32) and (36), we have

$$\begin{aligned} E(O_n^2)=\frac{n^2}{16}+\frac{31n}{72}+\frac{26}{27}+\frac{9n^2-36n-26}{27\cdot 2^n}, \end{aligned}$$

then if n is even, from (29) we derive

$$\begin{aligned} V(O_n)=E(O_n^2)-E^2(O_n) =\frac{n}{8}+\frac{191}{324}+\frac{27n^2-192n+64}{81\cdot 2^{n+1}}-\frac{(3n-10)^2}{81\cdot 4^n}. \end{aligned}$$

If n is odd, similarly we obtain \(V(O_n) =\frac{n}{8}+\frac{367}{648}+\frac{27n^2-195n+74}{162\cdot 2^n}-\frac{(3n-10)^2}{81\cdot 4^n}\).

Also, we can verify that the conclusion is still correct for \(n=1,2\).

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Li, H., Liu, Y., Su, M. et al. Jump and hop randomness tests for binary sequences. Cryptogr. Commun. 14, 483–502 (2022). https://doi.org/10.1007/s12095-021-00538-3

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s12095-021-00538-3

Keywords

Mathematics Subject Classification (2020)

Navigation