Home › Forums › TrueRNG Hardware random number generator › Extremely biased distribution from v2 device
- This topic has 6 replies, 4 voices, and was last updated 10 years, 5 months ago by
piersona.
-
AuthorPosts
-
August 22, 2014 at 2:17 am #814
zsaw
MemberI just received my v2 TrueRNG a couple days ago, and I’m running some basic tests, but the output is enormously uneven. I’m on Windows 8, installed the unsigned driver fine, no trouble communicating with it.
I ran rngcapture a number of times, with similar results as this;
Byte occurrences from rngcapture.exe 10000000 (10MB)
Min: 3319
Max: 157347
Standard Deviation: 33101[0] : 7133
[1] : 8893
[2] : 39536
[3] : 4715
[4] : 20854
[5] : 27888
[6] : 46901
[7] : 29522
[8] : 18442
[9] : 16722
[10] : 36850
[11] : 16239
[12] : 4617
[13] : 6761
[14] : 37934
[15] : 3608
[16] : 52799
[17] : 84518
[18] : 10074
[19] : 25794
[20] : 16892
[21] : 51053
[22] : 65760
[23] : 26489
[24] : 39592
[25] : 70190
[26] : 26468
[27] : 29782
[28] : 39172
[29] : 144984
[30] : 8756
[31] : 38772
[32] : 10609
[33] : 6890
[34] : 150652
[35] : 15350
[36] : 11656
[37] : 13505
[38] : 136427
[39] : 23197
[40] : 33788
[41] : 37923
[42] : 38796
[43] : 12403
[44] : 4233
[45] : 3319
[46] : 143222
[47] : 7011
[48] : 8495
[49] : 6054
[50] : 32223
[51] : 3355
[52] : 6999
[53] : 7792
[54] : 103141
[55] : 14772
[56] : 30766
[57] : 20747
[58] : 41894
[59] : 13883
[60] : 8990
[61] : 4504
[62] : 41066
[63] : 4241
[64] : 13464
[65] : 17302
[66] : 96751
[67] : 10992
[68] : 22278
[69] : 22627
[70] : 92196
[71] : 50798
[72] : 22006
[73] : 32354
[74] : 38024
[75] : 9053
[76] : 13991
[77] : 12382
[78] : 29609
[79] : 18232
[80] : 39947
[81] : 49713
[82] : 57000
[83] : 21934
[84] : 23460
[85] : 43437
[86] : 110958
[87] : 46503
[88] : 85515
[89] : 89591
[90] : 72316
[91] : 38456
[92] : 39242
[93] : 38972
[94] : 25269
[95] : 38727
[96] : 16032
[97] : 47499
[98] : 103360
[99] : 17539
[100] : 49220
[101] : 44934
[102] : 143463
[103] : 75689
[104] : 65395
[105] : 86261
[106] : 90172
[107] : 30797
[108] : 20571
[109] : 39440
[110] : 66555
[111] : 17456
[112] : 17950
[113] : 37006
[114] : 81919
[115] : 10625
[116] : 24231
[117] : 16561
[118] : 84496
[119] : 45025
[120] : 42595
[121] : 65395
[122] : 87679
[123] : 21308
[124] : 31922
[125] : 38158
[126] : 38581
[127] : 19895
[128] : 18100
[129] : 30735
[130] : 29166
[131] : 28828
[132] : 32654
[133] : 53014
[134] : 31022
[135] : 31100
[136] : 45312
[137] : 73078
[138] : 48630
[139] : 48326
[140] : 14495
[141] : 22833
[142] : 29089
[143] : 26953
[144] : 54671
[145] : 144801
[146] : 54826
[147] : 27312
[148] : 38894
[149] : 101038
[150] : 59199
[151] : 31058
[152] : 84536
[153] : 139087
[154] : 113086
[155] : 88491
[156] : 106061
[157] : 142699
[158] : 69963
[159] : 45617
[160] : 22675
[161] : 22177
[162] : 65811
[163] : 34794
[164] : 72386
[165] : 109307
[166] : 94102
[167] : 52949
[168] : 15732
[169] : 42617
[170] : 41028
[171] : 21560
[172] : 8232
[173] : 13992
[174] : 51242
[175] : 27493
[176] : 11408
[177] : 16593
[178] : 15113
[179] : 35257
[180] : 17676
[181] : 68972
[182] : 36846
[183] : 31330
[184] : 25607
[185] : 50591
[186] : 24696
[187] : 21990
[188] : 7345
[189] : 11535
[190] : 17664
[191] : 18940
[192] : 15082
[193] : 13636
[194] : 23428
[195] : 10181
[196] : 37713
[197] : 34775
[198] : 29014
[199] : 30568
[200] : 10002
[201] : 16679
[202] : 23173
[203] : 10171
[204] : 3566
[205] : 15068
[206] : 28784
[207] : 4710
[208] : 29397
[209] : 69283
[210] : 4738
[211] : 20470
[212] : 14462
[213] : 71048
[214] : 52684
[215] : 26492
[216] : 79237
[217] : 102223
[218] : 53232
[219] : 92444
[220] : 30105
[221] : 157347
[222] : 9391
[223] : 39768
[224] : 12616
[225] : 9322
[226] : 66487
[227] : 13186
[228] : 17848
[229] : 23250
[230] : 132870
[231] : 28865
[232] : 34098
[233] : 48500
[234] : 46904
[235] : 17278
[236] : 6042
[237] : 7375
[238] : 82779
[239] : 8534
[240] : 18675
[241] : 12435
[242] : 29157
[243] : 13644
[244] : 11406
[245] : 21476
[246] : 54637
[247] : 16872
[248] : 19154
[249] : 16984
[250] : 44937
[251] : 13071
[252] : 9124
[253] : 10966
[254] : 56890
[255] : 6972At first I thought it was my C#/.NET code that was at fault in reading from the virtual port, but then I found the same results from the rngcapture tool.
The above breakdown was generated using this C# code:
`var arr = File.ReadAllBytes(@”C:\10milrandom”);
long[] map = new long[256];
arr.ForEach(t => map[t]++);
map.ForEach((d, i) => { File.AppendAllText(@”C:\rngdebug.txt”, “[” + i + “] : ” + d + “\r\n”); });`August 23, 2014 at 8:25 pm #832gee-one
MemberI just received a new V2 today, and ran it through some of its paces. I am not getting that much variation in results. I am on linux and pulled 64M from /dev/ttyAMC1 (I have a V1.0 in /dev/ttyAMC0). I used ent to analyze the byte count.
$ ent -c true2-d.64M Value Char Occurrences Fraction 0 262737 0.003915 1 261696 0.003900 2 261971 0.003904 3 261731 0.003900 4 262129 0.003906 5 261891 0.003903 6 261399 0.003895 7 262226 0.003908 8 262009 0.003904 9 262641 0.003914 10 262745 0.003915 11 261910 0.003903 12 262084 0.003905 13 261890 0.003903 14 262589 0.003913 15 261598 0.003898 16 261646 0.003899 17 262201 0.003907 18 262078 0.003905 19 261423 0.003896 20 261994 0.003904 21 261609 0.003898 22 261860 0.003902 23 262776 0.003916 24 261893 0.003903 25 262981 0.003919 26 262114 0.003906 27 262193 0.003907 28 262189 0.003907 29 261808 0.003901 30 260901 0.003888 31 261621 0.003899 32 261955 0.003903 33 ! 262377 0.003910 34 " 262009 0.003904 35 # 261406 0.003895 36 $ 262077 0.003905 37 % 262730 0.003915 38 & 262175 0.003907 39 ' 262527 0.003912 40 ( 261929 0.003903 41 ) 262344 0.003909 42 * 260944 0.003888 43 + 262077 0.003905 44 , 262244 0.003908 45 - 261416 0.003895 46 . 262570 0.003913 47 / 261889 0.003903 48 0 261547 0.003897 49 1 262411 0.003910 50 2 262164 0.003907 51 3 262497 0.003912 52 4 262601 0.003913 53 5 261805 0.003901 54 6 261278 0.003893 55 7 262042 0.003905 56 8 262377 0.003910 57 9 261656 0.003899 58 : 262322 0.003909 59 ; 262651 0.003914 60 < 262000 0.003904 61 = 262212 0.003907 62 > 261376 0.003895 63 ? 262016 0.003904 64 @ 262925 0.003918 65 A 262124 0.003906 66 B 260942 0.003888 67 C 263001 0.003919 68 D 261776 0.003901 69 E 261872 0.003902 70 F 261472 0.003896 71 G 262514 0.003912 72 H 261916 0.003903 73 I 261875 0.003902 74 J 262615 0.003913 75 K 262731 0.003915 76 L 261961 0.003904 77 M 263507 0.003927 78 N 261971 0.003904 79 O 262851 0.003917 80 P 262297 0.003909 81 Q 261781 0.003901 82 R 262564 0.003913 83 S 262058 0.003905 84 T 262398 0.003910 85 U 262133 0.003906 86 V 261908 0.003903 87 W 261417 0.003895 88 X 261944 0.003903 89 Y 262157 0.003907 90 Z 262178 0.003907 91 [ 261272 0.003893 92 \ 262893 0.003917 93 ] 263210 0.003922 94 ^ 262573 0.003913 95 _ 261595 0.003898 96 ** 262579 0.003913 97 a 262351 0.003909 98 b 261358 0.003895 99 c 261700 0.003900 100 d 262783 0.003916 101 e 262844 0.003917 102 f 262715 0.003915 103 g 261563 0.003898 104 h 262879 0.003917 105 i 261373 0.003895 106 j 261553 0.003898 107 k 262110 0.003906 108 l 261740 0.003900 109 m 261474 0.003896 110 n 263049 0.003920 111 o 262302 0.003909 112 p 262450 0.003911 113 q 261837 0.003902 114 r 262831 0.003917 115 s 262886 0.003917 116 t 262094 0.003906 117 u 262207 0.003907 118 v 262371 0.003910 119 w 261831 0.003902 120 x 262677 0.003914 121 y 262283 0.003908 122 z 262493 0.003912 123 { 261532 0.003897 124 | 262648 0.003914 125 } 261743 0.003900 126 ~ 262630 0.003914 127 262019 0.003904 128 262279 0.003908 129 263019 0.003919 130 262821 0.003916 131 262229 0.003908 132 262176 0.003907 133 262731 0.003915 134 262294 0.003909 135 262586 0.003913 136 262403 0.003910 137 261772 0.003901 138 262268 0.003908 139 262758 0.003915 140 261138 0.003891 141 262274 0.003908 142 262259 0.003908 143 263101 0.003921 144 262499 0.003912 145 262186 0.003907 146 261640 0.003899 147 261478 0.003896 148 261500 0.003897 149 263538 0.003927 150 262180 0.003907 151 262001 0.003904 152 263051 0.003920 153 262019 0.003904 154 261841 0.003902 155 262045 0.003905 156 261095 0.003891 157 262021 0.003904 158 261967 0.003904 159 262750 0.003915 160 262739 0.003915 161 � 262272 0.003908 162 � 261582 0.003898 163 � 261556 0.003898 164 � 261527 0.003897 165 � 262685 0.003914 166 � 262730 0.003915 167 � 261559 0.003898 168 � 262949 0.003918 169 � 262548 0.003912 170 � 261889 0.003903 171 � 262592 0.003913 172 � 261857 0.003902 173 � 262207 0.003907 174 � 261008 0.003889 175 � 261374 0.003895 176 � 263191 0.003922 177 � 262646 0.003914 178 � 262025 0.003905 179 � 261820 0.003901 180 � 262377 0.003910 181 � 262618 0.003913 182 � 261443 0.003896 183 � 262204 0.003907 184 � 263069 0.003920 185 � 261611 0.003898 186 � 262668 0.003914 187 � 262143 0.003906 188 � 262294 0.003909 189 � 262597 0.003913 190 � 261958 0.003904 191 � 261841 0.003902 192 � 262354 0.003909 193 � 262027 0.003905 194 � 263238 0.003923 195 � 261476 0.003896 196 � 261458 0.003896 197 � 261242 0.003893 198 � 262049 0.003905 199 � 262509 0.003912 200 � 262196 0.003907 201 � 261811 0.003901 202 � 261771 0.003901 203 � 262755 0.003915 204 � 261878 0.003902 205 � 261321 0.003894 206 � 261766 0.003901 207 � 262523 0.003912 208 � 262727 0.003915 209 � 261739 0.003900 210 � 262929 0.003918 211 � 263601 0.003928 212 � 262411 0.003910 213 � 262150 0.003906 214 � 262585 0.003913 215 � 262292 0.003909 216 � 261865 0.003902 217 � 261199 0.003892 218 � 261752 0.003900 219 � 262193 0.003907 220 � 261539 0.003897 221 � 262506 0.003912 222 � 262314 0.003909 223 � 262204 0.003907 224 � 262207 0.003907 225 � 262454 0.003911 226 � 262118 0.003906 227 � 263031 0.003920 228 � 261540 0.003897 229 � 262592 0.003913 230 � 261572 0.003898 231 � 261330 0.003894 232 � 261458 0.003896 233 � 261493 0.003897 234 � 261328 0.003894 235 � 262348 0.003909 236 � 262572 0.003913 237 � 261350 0.003894 238 � 261854 0.003902 239 � 262012 0.003904 240 � 262563 0.003913 241 � 262070 0.003905 242 � 262355 0.003909 243 � 261684 0.003899 244 � 262401 0.003910 245 � 262060 0.003905 246 � 263629 0.003928 247 � 261980 0.003904 248 � 263142 0.003921 249 � 261669 0.003899 250 � 261664 0.003899 251 � 262003 0.003904 252 � 262115 0.003906 253 � 261797 0.003901 254 � 261693 0.003900 255 � 262385 0.003910 Total: 67107840 1.000000 Entropy = 7.999997 bits per byte. Optimum compression would reduce the size of this 67107840 byte file by 0 percent. Chi square distribution for 67107840 samples is 271.85, and randomly would exceed this value 25.00 percent of the times. Arithmetic mean value of data bytes is 127.5058 (127.5 = random). Monte Carlo value for Pi is 3.142486124 (error 0.03 percent). Serial correlation coefficient is -0.000081 (totally uncorrelated = 0.0).
August 25, 2014 at 4:01 pm #885Ubld.it Staff
Moderator@zsaw We have been going back and forth amongst ourselves trying to theorize how this could happen. Those batch of v2’s were tested twice by 2 different people before shipping, and we ran them through ent/fips/histograms and they all checked out.
I’m going to contact you via email and see if we can gather some other info and possibly do a RMA.
For the record there is a 1mb test capture on the product page you can also run through your own code to rule out a capture problem (file is here) if you want to run that through your c# code.
August 25, 2014 at 4:18 pm #886zsaw
MemberI already ran the 1mb capture through my same C# code, and the 1mb file was well distributed, so it doesn’t seem to be my code there.
If there’s another environment to test in, without setting up a full VM with a unix distro, I’d be happy to run some other tests.
I don’t know if using USB 3.0 ports or 2.0 port would make a difference, but I’ll check some other ports.August 25, 2014 at 4:23 pm #887Ubld.it Staff
ModeratorWe have tested USB 3.0 ports and Win8 and haven’t noticed any issues. We’ve sent you an email (check your spam folder if you haven’t gotten it) about proceeding with RMA.
November 12, 2014 at 7:00 pm #996piersona
MemberI just got mine and saw the same thing:
0|14:35 ~/truerng$ dd if=/dev/ttyACM1 of=data.2.bin bs=1024 count=$((2**20)) iflag=fullblock ^C97419+0 records in 97419+0 records out 99757056 bytes (100 MB) copied, 2228.41 s, 44.8 kB/s 130|15:13 ~/truerng$ ent data.2.bin Entropy = 7.999998 bits per byte. Optimum compression would reduce the size of this 99757056 byte file by 0 percent. Chi square distribution for 99757056 samples is 270.00, and randomly would exceed this value 25.00 percent of the times. Arithmetic mean value of data bytes is 127.5062 (127.5 = random). Monte Carlo value for Pi is 3.141212507 (error 0.01 percent). Serial correlation coefficient is 0.000179 (totally uncorrelated = 0.0).
I did not get the same problem when I repeated with a smaller experiment without fullblock:
0|15:13 ~/truerng$ dd if=/dev/ttyACM1 of=data.2.bin bs=1024 count=$((2**15)) dd: warning: partial read (469 bytes); suggest iflag=fullblock 3+32765 records in 3+32765 records out 2068055 bytes (2.1 MB) copied, 45.1346 s, 45.8 kB/s 0|15:15 ~/truerng$ ent data.2.bin Entropy = 7.999914 bits per byte. Optimum compression would reduce the size of this 2068055 byte file by 0 percent. Chi square distribution for 2068055 samples is 246.19, and randomly would exceed this value 50.00 percent of the times. Arithmetic mean value of data bytes is 127.5313 (127.5 = random). Monte Carlo value for Pi is 3.140837020 (error 0.02 percent). Serial correlation coefficient is -0.001316 (totally uncorrelated = 0.0).
I’m running two devices simultaneously, as the previous poster was, as well. /dev/ttyACM1 is the misbehaving unit. I’m currently running the following test script and will update once it’s finished:
#!/bin/bash if test "${1}" == "" then echo "You must specify the device" exit 1 fi device=/dev/ttyACM${1} logfile=test.${1}.log for i in 1 2 3 4 5 6 7 8 9 0 do for bs in 3 4 5 6 7 8 9 10 do bbs=$((2**${bs})) bcount=$((2**(24-${bs}))) echo '===========================' >> ${logfile} 2>&1 filename=test.${1}.bs$((2**${bs})).fb0.${i}.bin echo ${filename} >> ${logfile} 2>&1 time dd if=${device} of=${filename} bs=${bbs} count=${bcount} >> ${logfile} 2>&1 ent ${filename} >> ${logfile} 2>&1 filename=test.${1}.bs$((2**${bs})).fb1.${i}.bin echo ${filename} >> ${logfile} 2>&1 time dd if=${device} of=${filename} bs=${bbs} count=${bcount} iflag=fullblock >> ${logfile} 2>&1 ent ${filename} >> ${logfile} 2>&1 done done
Additionally, I was playing with the rngd in the background, so potentially running that at the same time could have been causing problems. I’ll run a second test with that running once this finishes.
–Andrew
November 12, 2014 at 8:03 pm #1000piersona
MemberI’ve learned two things:
1. A chi squared result that “would exceed this value N percent of the times.” is not a failure for N != 50.00. See http://www.fourmilab.ch/random/2. The values I’m seeing for N are never as arbitrary as that website would lead me to believe, e.g. “40.98”. Instead, I’m seeing values of 25.00, 50.00, 75.00, 90.00, and 95.00.
Even for the 95.00% case, the data examined with “ent -c” looks well distributed. I think they are performing well; it’s just my misunderstanding.
-
AuthorPosts
- You must be logged in to reply to this topic.