<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Santhosh Murugaiah on Medium]]></title>
        <description><![CDATA[Stories by Santhosh Murugaiah on Medium]]></description>
        <link>https://medium.com/@santhosh_m?source=rss-763b066b297e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_6FrWfFpOS6aYWTssu4-gg.jpeg</url>
            <title>Stories by Santhosh Murugaiah on Medium</title>
            <link>https://medium.com/@santhosh_m?source=rss-763b066b297e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 01:54:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@santhosh_m/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Is Math.Random() truly random?]]></title>
            <link>https://medium.com/spidernitt/is-math-random-truly-random-49ffd7307636?source=rss-763b066b297e------2</link>
            <guid isPermaLink="false">https://medium.com/p/49ffd7307636</guid>
            <category><![CDATA[spiders]]></category>
            <category><![CDATA[random-number-generation]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[webwednesday]]></category>
            <dc:creator><![CDATA[Santhosh Murugaiah]]></dc:creator>
            <pubDate>Wed, 27 Oct 2021 12:32:28 GMT</pubDate>
            <atom:updated>2021-10-27T12:32:28.663Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Ok Google! Roll a dice... You rolled 2, said Google. On what basis did it select this number?</em></p><p>I got this question when I used <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random"><strong>Math.random()</strong></a> for the first time i.e., asking a computer program to give me a number itself. Casinos, Lottery, gambling, and other places with immense money flow use random number generation, and it is a critical security element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P0_hyBk0CxPRvslj" /><figcaption>Photo by <a href="https://unsplash.com/@stevesawusch?utm_source=medium&amp;utm_medium=referral">Steve Sawusch</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If a machine generates random numbers by some external influence or an algorithm, it becomes biased to a particular choice, Right? Then can’t we do reverse-engineering and determine the so-called random number??</p><p>Let’s delve deeper.</p><blockquote>“Randomness is a measure of uncertainty of an outcome. Random number generation means that the particular outcome sequence will contain some patterns detectable in hindsight but unpredictable to foresight” — Wikipedia</blockquote><p>We roll dice to play an unbiased game. But in 2012, researchers from Poland predicted the outcome of a dice roll by using <a href="https://en.wikipedia.org/wiki/Chaos_theory"><strong>Chaos theory</strong></a> and high school mechanics!</p><p>They considered the initial conditions of the dice such as viscosity of the air, the acceleration of gravity and friction of the table, and created a 3D model. They observed that the face that was initially facing the table had a larger probability to be landed on it than the other faces. This suggests toss of dice is not a perfectly random action. So sometimes, unpredictable events become predictable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h_ZKCY2Q338XgzAZ" /><figcaption>Photo by <a href="https://unsplash.com/@youngprodigy3?utm_source=medium&amp;utm_medium=referral">Mike Szczepanski</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><strong>Middle-square method</strong></h4><p>The middle-square method was invented by <a href="https://en.wikipedia.org/wiki/John_von_Neumann">John von Neumann</a>. This method is the pioneer for Random Number Generation (RNG) algorithms. Let’s take a look at this algorithm.</p><ol><li>Take a truly random number (highly non-deterministic). For example, it may be the milliseconds in the current time (132). This number is the <strong>seed value</strong>. Other sources are atmospheric noise, thermal noise, cosmic background radiation, or any random fluctuations.</li><li>Square it (132² =17424) and take the middle digits(742).</li><li>Repeat step-2, where the output becomes the new seed. [742² = 05<strong><em>505</em></strong>64, 505² = 02<strong><em>550</em></strong>25, 550² = 03<strong><em>025</em></strong>00, 025² = 0<strong><em>062</em></strong>5, 062² = 0<strong><em>384</em></strong>4,… ]</li></ol><p>Random number sequence = {132, 742, 550, 025, 062, 384,…}</p><p>The randomness of the number generated is dependent on the seed value’s randomness. We get the same sequence for the same seed. Importantly, this sequence repeats after a particular point and also misses many of the numbers. But this satisfied his need at that time. Today, the world has got a lot of <a href="https://en.wikipedia.org/wiki/List_of_random_number_generators">RNG</a>s.</p><blockquote>“Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin.” — <a href="https://en.wikipedia.org/wiki/John_von_Neumann">John von Neumann</a></blockquote><h4><strong>RNG by humans</strong></h4><p>Humans’ choices are deterministic and biased to their previous thoughts. <a href="https://content.apa.org/record/1972-09976-001">Studies</a> say humans have some degree of non-randomness. So, RNG by humans is not suitable.</p><h4>Computer-generated random numbers/Psuedo random numbers</h4><p>Computer-generated random numbers are generally determined by the seed. Seeds have to be secretive. We have seen before that an algorithm uses seeds to produce random numbers. Seeds are sometimes obtained from end-user activities such as mouse movements, keyboard activities, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vva2b2zubJtuKIcV" /><figcaption>Photo by <a href="https://unsplash.com/@louishansel?utm_source=medium&amp;utm_medium=referral">Louis Hansel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In cryptography, to generate <a href="https://forum.openzeppelin.com/t/keys-nonces-and-salts/1324">keys, nonce, salts,</a> random numbers are used. The entropy of the random number produced is very much crucial. So, pseudo RNGs have to be carefully selected.</p><p>The RNG in many of the programming languages is based on the <strong>Mersenne Twister algorithm</strong>. It has a period of 2¹⁹⁹³⁷ -1, which is very long. But still, this algorithm is not sufficient for cryptographical purposes and other needs which require higher entropy.</p><blockquote>Math.random() <em>does not</em> provide cryptographically secure random numbers. Do not use them for anything related to security — MDN</blockquote><p><a href="https://www.random.org/">RANDOM.ORG</a> uses atmospheric noise as their seed value to generate random numbers. People use it for lotteries, online games, sweepstakes, etc.</p><h4>Physical RNGs</h4><p><a href="http://www.fourmilab.ch/hotbits/">HotBits</a> produces genuine random numbers by using the time between successive pairs of radioactive decays which are uncertain and are interfaced to a computer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*iT6PGR6HRLjp0_AL198Ecg.jpeg" /><figcaption>Source: ggo.org</figcaption></figure><p>Hardware random number generators are considered to be <strong>true random number generators</strong>. These generations are from physical processes and quantum phenomena. They are completely unpredictable as long as the equations governing them are unknown.</p><p>Generally, hardware RNGs convert random physical fluctuations into digital numbers and these random fluctuations are read again and again to generate a sequence of random numbers.</p><p>Hardware RNGs play an important role in cryptographic systems. But still, there are potential attacks that can rig the output, mostly <a href="https://en.wikipedia.org/wiki/Side-channel_attack">side-channel attacks</a> i.e., based on the timing information, power consumption, EM leaks, etc.</p><p>If the random number generated is predictable, the encryption becomes vulnerable.</p><h4>Attacks and backdoors</h4><ul><li><a href="https://eprint.iacr.org/2007/419.pdf">Microsoft Windows 2000/XP random number generator</a> — <strong>Deterministic</strong></li><li><a href="https://ieeexplore.ieee.org/document/9237310">Hardware RNG attacks</a></li><li><a href="https://en.wikipedia.org/wiki/Hot_Lotto_fraud_scandal">Hot Lotto fraud scandal</a> — Lottery-rigging scandal <strong>($16,500,000)</strong></li><li><a href="https://www.edn.com/the-sony-playstation-3-hack-deciphered-what-consumer-electronics-designers-can-learn-from-the-failure-to-protect-a-billion-dollar-product-ecosystem/">PlayStation3 hack</a> — Sony failed to generate a <strong>random nonce</strong></li></ul><h4><strong>References</strong></h4><ul><li><a href="https://en.wikipedia.org/wiki/Random_number_generation">Wikipedia — Random_number_generation</a></li><li><a href="https://en.wikipedia.org/wiki/Random_number_generator_attack">Wikipedia — Random_number_generator_attack</a></li><li><a href="https://www.youtube.com/watch?v=GtOt7EBNEwQ/">Youtube — Pseudorandom Number Generators</a></li><li><a href="https://www.youtube.com/watch?v=r_5shyQGIeA">Youtube — How Chaos Theory Unravels the Mysteries of Nature</a></li></ul><h4>Further reading</h4><ul><li>Quantum RNG — <a href="https://www.idquantique.com/random-number-generation/overview/">https://www.idquantique.com/random-number-generation/overview/</a></li><li>Random number generators — <a href="https://en.wikipedia.org/wiki/List_of_random_number_generators">https://en.wikipedia.org/wiki/List_of_random_number_generators</a></li><li>Cryptographically secure pseudo RNGs — <a href="https://en.wikipedia.org/wiki/Cryptographically-secure_pseudorandom_number_generator">https://en.wikipedia.org/wiki/Cryptographically-secure_pseudorandom_number_generator</a></li><li>Chaos theory — <a href="https://en.wikipedia.org/wiki/Chaos_theory">https://en.wikipedia.org/wiki/Chaos_theory</a></li></ul><p><em>This article is published under </em><a href="https://medium.com/spidernitt"><em>Spider Research and Development Club, NIT Trichy</em></a><em> on a Web Wednesday!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49ffd7307636" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spidernitt/is-math-random-truly-random-49ffd7307636">Is Math.Random() truly random?</a> was originally published in <a href="https://medium.com/spidernitt">Spider R&amp;D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>