Collects entropy from submitted floating point values of physical processes (measurements or simulations fed by physical processes). Uses the bitcount of the difference of submitted floating point values and a von Neumann unbiaser. The submissions of the values will yield usable entropy if: if the value changes sufficiently much between submissions the submissions are independent from the value generation either the value source or the submission trigger is based on a real physical random process (i.e. uncorrelated user trigger). More...
Public Member Functions | |
| SimpleEntropyCollector () | |
| Default constructor. | |
| void | Reset () |
| Reset collector to initial state. | |
| void | AddValue (double value) |
| Adds a float value to the collector. | |
| override string | ToString () |
| Return the current entropy collector bit-pool as string of 0 and 1 characters. | |
Properties | |
| int | BitsInPool [get] |
| Gets the current number of valid entropy bits in a the pool. | |
Collects entropy from submitted floating point values of physical processes (measurements or simulations fed by physical processes). Uses the bitcount of the difference of submitted floating point values and a von Neumann unbiaser. The submissions of the values will yield usable entropy if: if the value changes sufficiently much between submissions the submissions are independent from the value generation either the value source or the submission trigger is based on a real physical random process (i.e. uncorrelated user trigger).
Definition at line 24 of file SimpleEntropyCollector.cs.
| NewGamePhysics.Physics.SimpleEntropyCollector.SimpleEntropyCollector | ( | ) |
Default constructor.
Definition at line 71 of file SimpleEntropyCollector.cs.
00072 { 00073 // Initialize bitcount helper 00074 bitCount = new BitCount(); 00075 00076 // Initialize collector state 00077 this.Reset(); 00078 }
| void NewGamePhysics.Physics.SimpleEntropyCollector.AddValue | ( | double | value | ) |
Adds a float value to the collector.
| value | Value to add. |
Definition at line 105 of file SimpleEntropyCollector.cs.
00106 { 00107 if (numValues == 1) 00108 { 00109 // Different between values 00110 double delta = this.lastValue - value; 00111 00112 // Translate the double into a 64 bit long. 00113 long deltaBits = BitConverter.DoubleToInt64Bits(delta); 00114 00115 // Get bitcount 00116 int totalBits = this.bitCount.FastBitcount(deltaBits); 00117 00118 // Generate this bit 00119 bool newBit = (bool)((totalBits & 1) == 1); 00120 00121 // von Neumann corrector to unbias bitstream 00122 if (numBits == 1) 00123 { 00124 // Check for 10: add a 1 00125 if ((!newBit) && (this.lastBit)) 00126 { 00127 // Use LSB of bitcount 00128 if (this.bitsInPool < 1024) 00129 { 00130 this.bitPool[this.bitsInPool] = true; 00131 this.bitsInPool++; 00132 } 00133 } 00134 // Check for 01: add a 0 00135 else if ((newBit) && (!this.lastBit)) 00136 { 00137 // Use LSB of bitcount 00138 if (this.bitsInPool < 1024) 00139 { 00140 this.bitPool[this.bitsInPool] = false; 00141 this.bitsInPool++; 00142 } 00143 } 00144 else 00145 { 00146 // Discard 00 and 11 patterns 00147 } 00148 // Reset corrector counter 00149 this.numBits = 0; 00150 } 00151 else 00152 { 00153 // Store bit 00154 this.lastBit = newBit; 00155 this.numBits++; 00156 } 00157 00158 // Reset value count to we cache the next submission 00159 this.numValues = 0; 00160 } 00161 else 00162 { 00163 // Just cache value for next call 00164 this.lastValue = value; 00165 00166 // Set value count so we process the next submission 00167 this.numValues = 1; 00168 } 00169 }
| void NewGamePhysics.Physics.SimpleEntropyCollector.Reset | ( | ) |
Reset collector to initial state.
Definition at line 91 of file SimpleEntropyCollector.cs.
| override string NewGamePhysics.Physics.SimpleEntropyCollector.ToString | ( | ) |
Return the current entropy collector bit-pool as string of 0 and 1 characters.
Definition at line 176 of file SimpleEntropyCollector.cs.
00177 { 00178 StringBuilder sb = new StringBuilder(); 00179 00180 if (this.bitsInPool > 0) 00181 { 00182 for (int i = bitsInPool - 1; i >= 0; i--) 00183 { 00184 if (bitPool[i]) 00185 { 00186 sb.Append("1"); 00187 } 00188 else 00189 { 00190 sb.Append("0"); 00191 } 00192 } 00193 } 00194 00195 return sb.ToString(); 00196 }
int NewGamePhysics.Physics.SimpleEntropyCollector.BitsInPool [get] |
Gets the current number of valid entropy bits in a the pool.
Definition at line 84 of file SimpleEntropyCollector.cs.
1.6.2