TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: True-Random – Generate “truly” random numbers

31 pointsby jaybosamiyaabout 9 years ago

18 comments

balls187about 9 years ago
&gt; Since the number of times it would be able to flip the bit changes due to random fluctuations in time due to context switching of processes, this generates an arguably truly random bit (I would love to see a PoC that shows otherwise, however).<p>This wouldn&#x27;t be true random. It&#x27;s just using the time jitter introduced by context switching to introduce entropy. Similar to many other pRNGs that use system entropy, mouse movements, etc in order to seed the pRNG.<p>A pRNG is &#x27;p&#x27; because if you know the conditions used, you can deterministically predict the outcome. The difficulty of recreating those conditions has nothing to do with being truly random.
jsonninjaabout 9 years ago
&#x27;fuck, not again&#x27; - said the cryptographer. The title of the project is potentially very misleading.<p>I know most of you take this stuff seriously in your codes and rely on the well know cryptographically secure random number generators: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Cryptographically_secure_pseudorandom_number_generator" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Cryptographically_secure_pseud...</a>
评论 #11669151 未加载
DanielStraightabout 9 years ago
It seems a bit ambitious to call this true random without any analysis of randomness quality or predictability.<p>I find it very unlikely this will be shown to be better than existing RNG solutions.<p>It&#x27;s clever, but clever in the way that sleep sort is clever, at least until proven to be of actual benefit.
评论 #11668940 未加载
评论 #11670559 未加载
geofftabout 9 years ago
This looks to be the same technique as Dan Kaminsky&#x27;s DakaRand, including the debiasing: <a href="https:&#x2F;&#x2F;dankaminsky.com&#x2F;2012&#x2F;08&#x2F;15&#x2F;dakarand&#x2F;" rel="nofollow">https:&#x2F;&#x2F;dankaminsky.com&#x2F;2012&#x2F;08&#x2F;15&#x2F;dakarand&#x2F;</a><p>See also Kaminsky&#x27;s implementation of the same approach in pure JS: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;PaulCapestany&#x2F;6148566" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;PaulCapestany&#x2F;6148566</a><p>and Ryan Finnie&#x27;s implementation in Perl: <a href="http:&#x2F;&#x2F;www.finnie.org&#x2F;2012&#x2F;08&#x2F;14&#x2F;twuewand-2-0-released&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.finnie.org&#x2F;2012&#x2F;08&#x2F;14&#x2F;twuewand-2-0-released&#x2F;</a><p>The big concern I have is how reliable this is on virtual machines. Just about all physical machines I&#x27;d want to use have high-quality, trustworthy-within-my-threat-model (i.e., &quot;if the NSA wanted to attack my silicon, there&#x27;s easier silicon for them to attack&quot;) hardware random number generators, and all physical machines I&#x27;d want to use pick up sufficient randomness from the kernel&#x27;s entropy magic thing. But virtual machines often don&#x27;t have access to the hardware RNG, and they don&#x27;t have access to enough other hardware to populate entropy. It seems like this technique would be particularly risky there ... although I don&#x27;t think anyone&#x27;s published an attack on DakaRand yet, so maybe it&#x27;s fine!
评论 #11670495 未加载
评论 #11669492 未加载
caffeinewriterabout 9 years ago
I&#x27;m really hesitant to even consider this without it being run through the Diehard Tests[0], since from my understanding, &quot;True Randomness&quot; should be cryptographically secure should this be used in a CSPRNG.<p>[0]: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Diehard_tests" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Diehard_tests</a>
评论 #11683514 未加载
评论 #11670012 未加载
gjmulholabout 9 years ago
This is almost certainly not more random than this: <a href="http:&#x2F;&#x2F;www.fourmilab.ch&#x2F;hotbits&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.fourmilab.ch&#x2F;hotbits&#x2F;</a><p>It is a cool idea.
评论 #11669334 未加载
jamesbowmanabout 9 years ago
The debiasing idea is due to von Neumann himself:<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Fair_coin" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Fair_coin</a>
valarauca1about 9 years ago
How does checking `get_fair_bit(0)&#x27; that the next bit isn&#x27;t the same as the current help fairness?
评论 #11669040 未加载
评论 #11670112 未加载
Grue3about 9 years ago
What if get_bit happens to be deterministic on a particular machine? Then get_fair_bit would be stuck in an infinite loop. This can potentially happen when CPU is so overloaded that executing the bit-flipping instruction takes longer than a millisecond.
coldcodeabout 9 years ago
Could you not build a &quot;truly&quot; random number generator using a quantum computer?
spamfilter247about 9 years ago
Wouldn&#x27;t an example of a truly random number generator be to open up a pseudo random webpage (say something like www.engadget.com&#x2F;page&#x2F;&lt;pseudo_random_number&gt;) and do a modulo count of the number of whitespace separated words&#x2F;tokens?
anishathalyeabout 9 years ago
This post reminded me of this other project: <a href="https:&#x2F;&#x2F;github.com&#x2F;dasmithii&#x2F;RCRand" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dasmithii&#x2F;RCRand</a> (a similarly silly but fun race condition based RNG)
wyagerabout 9 years ago
The only thing in the world that might be classified as truly random is wavefunction collapse under observation, and even then we&#x27;re not sure.
评论 #11671092 未加载
TickleSteveabout 9 years ago
this is <i>not</i> random.... it is deterministic.<p>typical round-robin times are on the order of 10ms, so you would have a significant amount of non-context-switched &#x27;random&#x27; numbers, which when combined with analysis using the cycle counter.... namely a counter running at the clock-speed of your processor would yield a <i>very</i> non-random value.
szcabout 9 years ago
The periodic interrupt frequency of the system this is run on will have an impact on the numbers produced.
highCsabout 9 years ago
You have to ship the hardware with it.
arno1about 9 years ago
ugly tests<p>1. (&quot;true&quot;-random) 10 iterations; 32 random bytes | Result Avg Entropy: 4.82<p><pre><code> $ echo $(echo -n &quot;(&quot;; for i in $(seq 1 10); do echo -n $(.&#x2F;generate_constant_stream |head -c 32 |ent |head -1 |awk &#x27;{print $3}&#x27;)&quot;+&quot;; done; echo -n &quot;0)&#x2F;10&quot;) |bc -l 4.81945500000000000000 </code></pre> 2. (&quot;true&quot;-random) 100 iterations; 32 random bytes | Result Avg Entropy: 4.37<p><pre><code> $ echo $(echo -n &quot;(&quot;; for i in $(seq 1 100); do echo -n $(.&#x2F;generate_constant_stream |head -c 32 |ent |head -1 |awk &#x27;{print $3}&#x27;)&quot;+&quot;; done; echo -n &quot;0)&#x2F;100&quot;) |bc -l 4.37395291000000000000 </code></pre> 3. (&quot;true&quot;-random) 200 iterations; 32 random bytes | Result Avg Entropy: 4.35<p><pre><code> $ echo $(echo -n &quot;(&quot;; for i in $(seq 1 200); do echo -n $(.&#x2F;generate_constant_stream |head -c 32 |ent |head -1 |awk &#x27;{print $3}&#x27;)&quot;+&quot;; done; echo -n &quot;0)&#x2F;200&quot;) |bc -l 4.34563333000000000000 </code></pre> 1. (openssl) 10 iterations; 32 random bytes | Result Avg Entropy: 4.88<p><pre><code> $ echo $(echo -n &quot;(&quot;; for i in $(seq 1 10); do echo -n $(openssl rand 32 |ent |head -1 |awk &#x27;{print $3}&#x27;)&quot;+&quot;; done; echo -n &quot;0)&#x2F;10&quot;) |bc -l 4.88125000000000000000 </code></pre> 2. (openssl) 100 iterations; 32 random bytes | Result Avg Entropy: 4.87<p><pre><code> $ echo $(echo -n &quot;(&quot;; for i in $(seq 1 100); do echo -n $(openssl rand 32 |ent |head -1 |awk &#x27;{print $3}&#x27;)&quot;+&quot;; done; echo -n &quot;0)&#x2F;100&quot;) |bc -l 4.87404420000000000000 </code></pre> 3. (openssl) 200 iterations; 32 random bytes | Result Avg Entropy: 4.88<p><pre><code> $ echo $(echo -n &quot;(&quot;; for i in $(seq 1 200); do echo -n $(openssl rand 32 |ent |head -1 |awk &#x27;{print $3}&#x27;)&quot;+&quot;; done; echo -n &quot;0)&#x2F;200&quot;) |bc -l 4.87885575000000000000 </code></pre> 1. (&#x2F;dev&#x2F;urandom) 10 iterations; 32 random bytes | Result Avg Entropy: 4.82<p><pre><code> $ echo $(echo -n &quot;(&quot;; for i in $(seq 1 10); do echo -n $(head -c32 &lt; &#x2F;dev&#x2F;urandom |ent |head -1 |awk &#x27;{print $3}&#x27;)&quot;+&quot;; done; echo -n &quot;0)&#x2F;10&quot;) |bc -l 4.82264100000000000000 </code></pre> 2. (&#x2F;dev&#x2F;urandom) 100 iterations; 32 random bytes | Result Avg Entropy: 4.89<p><pre><code> $ echo $(echo -n &quot;(&quot;; for i in $(seq 1 100); do echo -n $(head -c32 &lt; &#x2F;dev&#x2F;urandom |ent |head -1 |awk &#x27;{print $3}&#x27;)&quot;+&quot;; done; echo -n &quot;0)&#x2F;100&quot;) |bc -l 4.88655640000000000000 </code></pre> 3. (&#x2F;dev&#x2F;urandom) 200 iterations; 32 random bytes | Result Avg Entropy: 4.88<p><pre><code> $ echo $(echo -n &quot;(&quot;; for i in $(seq 1 200); do echo -n $(head -c32 &lt; &#x2F;dev&#x2F;urandom |ent |head -1 |awk &#x27;{print $3}&#x27;)&quot;+&quot;; done; echo -n &quot;0)&#x2F;200&quot;) |bc -l 4.88061280000000000000</code></pre>
评论 #11669921 未加载
egoegoegoabout 9 years ago
Ego has infected this thread. We can&#x27;t just say that this project is interesting. We have to talk about &quot;expensive&quot; computation. Why? What does &quot;ambition&quot; have to do with computer science?
评论 #11669245 未加载
评论 #11669233 未加载
评论 #11669241 未加载