NIST随机性测试及参数范围

一 . 16种NIST随机性测试方法

软件下载地址点击打开链接

1. 频率检验(Frequency  Test)

        该检验主要是看0和1在整个序列中所占的比例。检验的目的是确定序列中的1和0数是否与真正的随机序列中的1和0数近似相同。检验评定1码占1/2,也就是说,在整个序列中0和1的数目是一样的。其余别的检验手段都是在该检验成立的基础上进行的,若通过该测试,则被测序列是随机的。 

测试数据:
(input)e=11001001000011111101101010100010001000010110100011                    00001000110100110001001100011001100010100010111000
(input) n = 100
(processing) S100 = -16
(processing) sobs = 1.6
(output) P-value = 0.109599

(conclusion) Since P-value ‡ 0.01, accept the sequence as random.

2. 块内频数检验(Frequency Test  within a Block)

        此检验主要是看M位的子块中“1”码的比例。该检验的目的是判定M位的子块内“1”码的频率是否像随机假设下所预期的那样,近似于M/2。当M=1时,该检测相当于检测1位,即频数(一位)检验。

测试数据:
(input)e=11001001000011111101101010100010001000010110100011                    00001000110100110001001100011001100010100010111000
(input) n = 100
(input) M = 10
(processing) N = 10
(processing) c2 = 7.2
(output) P-value = 0.706438

(conclusion) Since P-value ‡ 0.0, accept the sequence as random.

3. 游程检验(Runs Test)   

        此检验主要是看游程的总数,游程指的是一个没有间断的相同数序列,即游程或者是“1111„”或者是“0000„”。一个长度为k 的游程包含k 个相同的位。游程检测的目的是判定不同长度的“1”游程的数目以及“0”游程的数目是否跟理想的随机序列的期望值相一致。具体的讲,就是该检验手段判定在这样的“0”“1”子块之间的振荡是否太快或太慢。

测试数据:
(input)e=11001001000011111101101010100010001000010110100011                    00001000110100110001001100011001100010100010111000
(input) n = 100
(input) t = 0.02
(processing) p = 0.42
(processing) Vn(obs) =  52
(output) P-value = 0.500798

(conclusion) Since P-value ‡ 0.01, accept the sequence as random.

4. 块内最长游程检验(Test for the Longest Run of Ones in a Block)  

        该检验主要是看长度为M-bits的子块中的最长“1”游程。这项检验的目的是判定待检验序列的最长“1”游程的长度是否同随机序列的相同。注意:最长“1”游程长度上的一个不规则变化意味着相应的“0”游程长度上也有一个不规则变化,因此,仅仅对“1”游程进行检验室足够的。

测试数据:
For the case where K = 3 and M = 8:
(input)ε=11001100000101010110110001001100111000000000001001                00110101010001000100111101011010000000110101111100      
               1100111001101101100010110010
(input) n = 128
(processing)     Subblock      Max-Run     Subblock      Max-Run 
                        11001100            (2)         00010101           (1) 
                        01101100            (2)         01001100           (2) 
                        11100000            (3)         00000010           (1) 
                        01001101            (2)         01010001           (1) 
                        00010011            (2)         11010110           (2) 
                        10000000            (1)         11010111           (3) 
                        11001100            (2)         11100110           (3) 
                        11011000            (2)         10110010           (2)
(processing) n0 = 4;  n1 = 9;  n2 = 3;  n4 = 0;  c2 = 4.882457
(output) P-value = 0.180609

(conclusion) Since the P-value is ≥ 0.01, accept the sequence as random.

5. 二元矩阵秩检验(Binary Matrix Rank Test)

        该检验主要是看整个序列的分离子矩阵的秩。目的是核对源序列中固定长度子链间的线性依赖关系。  

测试数据:
(input) e = the first 100,000 binary digits in the expansion of e
(input) n = 100000, M = Q = 32 (NOTE:  672 BITS WERE DISCARDED.)
(processing) N = 97
(processing) FM = 23,  FM-1 = 60,  N – FM – FM-1= 14
(processing) c2 = 1.2619656
(output) P-value = 0.532069

(conclusion) Since P-value ‡ 0.01, accept the sequence as random. 

6.  离散傅里叶变换检验(Discrete Fourier Transform (Spectral) Test) 

        本检验主要是看对序列进行分步傅里叶变换后的峰值高度。目的是探测待检验信号的周期性,以此揭示其与相应的随机信号之间的偏差程度。做法是观察超过 95%阈值的峰值数目与低于 5%峰值的数目是否有显著不同。 

测试数据:
(input)e=11001001000011111101101010100010001000010110100011                    00001000110100110001001100011001100010100010111000
(input) n = 100
(processing) N1 = 46
(processing) N0 = 47.5
(processing) d = -0.973329
(output) P-value = 0.330390

(conclusion) Since P-value ‡ 0.01, accept the sequence as random.

7. 非重叠模块匹配检验(Non-overlapping Template Matching Test)

        此检测主要是看提前设置好的目标数据串发生地次数。目的是探测那些产生太多给出的非周期模式的发生器。对于非重叠模块匹配检验以及后面会谈到的重叠模块匹配检验方法,我们都是使用一个 m-bit 的窗口来搜素一个特定的 m-bit 模式。如果这个模式没有被找到,则窗口向后移动一位。如果模式被发现,则窗口移动到一发现的模式的后一位,重复前面的步骤继续搜素下一个模式。

测试数据:
For a template B = 000000001 whose size is m = 9:
(input) e = 220 bits produced by the G-SHA-1 generator1
(input) n = 220, B = 000000001
(processing) m = 255.984375 and s2= 247.499999
(processing) W1 = 259; W2 = 229; W3 = 271; W4 = 245; W5 = 272; W6 = 262; W7 = 259; and W8 = 246
(processing) c2(obs) = 5.999377
(output) P-value = 0.647302

(conclusion) Since the P-value ‡ 0.01, accept the sequence as random.

8.  重叠模块匹配检验(Overlapping Template Matching Test) 

        该检验主要是看提前设定的目标模块发生地数目。检验步骤同非重叠模块匹配检验方法大致一样,不同点在于,发现目标模块后,窗口仅向后移动1位,而后继续搜索。

测试数据:
(input) e = the binary expansion of e up to 1,000,000 bits
(input) n = 1000000, B = 111111111
(processing) n0 = 329; n1 = 164;  n2 = 150; n3 = 111; n4 = 78; and n5 = 136
(processing) c2(obs) = 8.965859
(output) P-value = 0.110434

(conclusion) Since the P-value ‡  0.01, accept the sequence as random.

9.  Maurer 的通用统计检验(Maurer's“Universal Statistical”Test)

        检验主要是看匹配模块间的bit数。目的是检验序列能否在没有信息损耗的条件下被大大的压缩。一个能被大大压缩的序列被认为是一个非随机序列。

测试数据:
(input) e = A binary string constructed using G-SHA-14
(input) n = 1048576, L = 7, Q = 1280
(note) Note: 4 bits are discarded.
(processing) c =0.591311, s = 0.002703, K = 148516, sum = 919924.038020
(processing) fn  = 6.194107, expectedValue = 6.196251, s = 3.125
(output) P-value = 0.427733

(conclusion) Since P-value ‡ 0.01, accept the sequence as random.

10. Lempel-Ziv压缩检验 (Lempel-Ziv Compression Test)

        本检测主要是看整个序列中不同模式积累的数目(单词数目)。检验目的是判定待测序列能够被压缩到什么程度。若序列不能被明显的压缩,则该序列就是非随机的。一个随机序列有特征数个不同模式。

测试数据:
(input) e = the first 1,000,000 digits in the binary expansion of e
(input) n = 1,000,000
(processing) Wobs = 69559
(output) P-value = 0.000584

(conclusion) Since P-value < 0.01, reject the sequence as being random. 

11. 线性复杂度检验(Linear Complexity Test)  

        本检验手段主要是看线性反馈移位寄存器的长度。检验的目的是判定序列的复杂程度是否达到可视为是随 机序列的程度。随机序列的特点是有较长的线性反馈移位寄存器。一个线性反馈移位寄存器太小的话意味着序列非随机。  

测试数据:
(input) e = “the first 1,000,000 binary digits in the expansion of e”
(input) n = 1000000 = 106, M = 1000
(processing) v0 = 11; v1 = 31; v2 = 116; v3 = 501; v4 = 258; v5 = 57; v6 = 26
(processing) c2(obs) = 2.700348
(output) P-value = 0.845406

(conclusion) Since the P-value ‡ 0.01, accept the sequence as random.

12. 序列检验(Serial Test)

        本检验主要是看整个序列中所有可能的重叠m-bit模式的频率,目的是判定2m个m-bit重叠模式的数目是否跟随机情况下预期的值相近似。随机序列具有均匀性也就是说对于每个m-bit模式其出现的概率应该是一样的。当m=1时等价于频数检验。

测试数据:
(input) e = 1,000,000 bits from the binary expansion of e
(input) m = 2;  n = 1000000 = 106
(processing) #0s = 499971; #1s = 500029
                    #00s = 250116; #01s = #10s = 249855; #11s = 250174
(processing) y22 = 0.343128; y21 = 0.003364; y20 = 0.000000
(processing) y22 = 0.339764;  2y22 = 0.336400
(output) P-value1 = 0.843764; P-value2 = 0.561915

(conclusion) Since both P-value1 and P-value2 were ‡ 0.01, accept the sequences as random for both tests.   

13. 近似熵检验(Approximate Entropy Test)  

        同序列检验一样,近似熵检验主要看的也是整个序列中所有可能的重叠 m-bit 模式的频率。目的是将两相邻长度(m和m+1)的重叠子块的频数与随机情况下预期的频数相比较。

测试数据:  
(input)e=11001001000011111101101010100010001000010110100011                    00001000110100110001001100011001100010100010111000
(input) m = 2; n = 100
(processing) ApEn(m) = 0.665393
(processing) c2(obs) = 5.550792
(output) P-value = 0.235301

(conclusion) Since P-value ‡ 0.01, accept the sequence as random. 

14. 累加和检验(Cumulative Sums (Cusum) Test)

        该检验主要是看随机游动的最大偏移。随机游动被定义为序列中调整后的-1,+1的累加和。检验的目的是判定序列的累加和相对于预期的累加和过大还是过小。这个累加和可被看做随机游动。对于随机序列,随机游动的偏离应该在0附近。而对于非随机序列,这个随机游动偏离将会比0大很多。

测试数据:
(input)e=11001001000011111101101010100010001000010110100011                      00001000110100110001001100011001100010100010111000
(input) n = 100
(input) mode = 0 (forward) ||  mode = 1 (reverse)
(processing) z = 1.6 (forward) || z = 1.9 (reverse)
(output) P-value = 0.219194 (forward) || P-value = 0.114866 (reverse)

(conclusion) Since P-value > 0.01, accept the sequence as random.

15. 随机游动检验(Random Excursions Test) 

        本检验主要是看一个累加和随机游动中具有 K 个节点的循环的个数。累加和随机游动由于将关于“0”,“1”的部分和序列转化成适当的“-1”、“+1”序列产生的。一个随机游动循环由单位步长的一个序列组成,这个序列的起点和终点均是 0。该检验的目的是确定在一个循环内的特殊状态对应的节点数是否与在随机序列中预计达到的节点数相背离。实际上,这个检验由八个检验(和结论)组成,一个检验和结论对应着一个特定的状态:-4,-3,-2,-1和+1,+2,+3,+4 。

测试数据:
(input) e = "the binary expansion of e up to 1,000,000 bits"
(input) n = 1000000 = 106
(processing) J = 1490
                  State=x               c2           P-value           Conclusion 
                      -4              3.835698     0.573306           Random 
                      -3              7.318707     0.197996           Random 
                      -2              7.861927     0.164011           Random 
                      -1              15.692617   0.007779         Non-random 
                     +1              2.485906     0.778616           Random 
                     +2              5.429381     0.365752           Random 
                     +3              2.404171     0.790853           Random                      
                     +4              2.393928     0.792378           Random

(conclusion) For seven of the states of x, the P-value is ≥ 0.01, and the conclusion would be that the sequence was random. However, for one state of x (x = -1), the P-value is < 0.01, so the conclusion would be that the sequence is non-random. When contradictions arise, further sequences should be examined to determine whether or not this behavior is typical of the generator.  

16. 随机游动状态频数检验(Random Excursions Variant Test) 

        该检验主要是看累计和随机游动中经历的特殊状态的总数。检验目的是判定随机游动中实际经历多个状态的值与预期值之间的偏离程度。该检验实际上是十八个检验(和结论),每个状态对应着一个检验和一个结论。这些状态分别是:-9,-8,-7,-6,-5,-4,-3,-2,-1和+1,+2,+3,+4,+5,+6,+7,+8。

测试数据:
(input) e = "the binary expansion of e up to 1,000,000 bits"
(input) n = 1000000 = 106
(processing) J = 1490


(conclusion) Since the P-value ‡ 0.01 for each of the eighteen states of x, accept the sequence as random.

二 . NIST随机性测试参数范围


















  • 5
    点赞
  • 11
    评论
  • 46
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值