NOBODY can solve this - Generating random numbers on an ATmega328p

Поділитися
Вставка
  • Опубліковано 22 лис 2022
  • Creating random numbers is easy right? Just call the rand() function... but how does that actually work? With so much of modern security and cryptography relying on these random numbers, it's important that the numbers actually are random. Find out how these numbers are randomly created.
    -- Links --
    My Website: sinelab.net
    ENT: www.fourmilab.ch/random/
    AVR Crypto Library (SHA-256): github.com/cantora/avr-crypto...
    LCG Algorithm: en.wikipedia.org/wiki/Linear_...
    Microcontroller Code: sinelab.net/code/RNG/main.c
    PC LCG Code: sinelab.net/code/RNG/LCG.c
    --
  • Наука та технологія

КОМЕНТАРІ • 27

  • @dan00b8
    @dan00b8 Рік тому +5

    just a small correction: at 9:43, the miners don't "reverse" a hash, they try to append random garbage to the end of each block so that the hashes match a certain number of 0 at the beginning. you might know that already, since 2 seconds ago you had an image with those 0s there, tongue slips happen, but just wanted to make sure that to someone else hearing this to not get fooled into thinking SHA2 is reversible for anything other than rainbow tables (we havent even found the 256 0s or 1s pattern as far as i am aware)
    edit: this does not change the validity of the method shown in the video, it basically empowers it even further

  • @cognisent_
    @cognisent_ Рік тому +2

    This is super good and so cool that you showed a practical example of an entropy source. My favorite example is the Cloudflare lava lamps 💡.

  • @ironsm4sh
    @ironsm4sh Рік тому +4

    The way GPU shaders generate "random" numbers is also very interesting.

  • @hgbugalou
    @hgbugalou 10 місяців тому +1

    Reading floating analog pins is a great way to get entropy on micro boards. I'm going to have to keep that in my back pocket.

    • @SineLab
      @SineLab  9 місяців тому

      I'm sure you'll use it sooner or later

  • @WilliamEllison
    @WilliamEllison Рік тому +3

    Somebody help this kid out.
    Here is an example of how to generate a random number between 0 and 10:
    int randomNumber = random(10);
    If you need truly random numbers, you can use the "noise()" function in conjunction with an analog input, such as a photoresistor, to generate random numbers based on environmental noise. Here is an example of how to generate a random number between 0 and 10 using the "noise()" function:
    int randomNumber = noise(analogRead(A0)) % 10;
    Keep in mind that the quality of random numbers generated using this method depends on the quality of the analog input used.

    • @someguy4915
      @someguy4915 Рік тому

      'If you need truly random numbers', advises to use a 10 bit ADC input which is very predictable with only 1024 possible states, with a photoresistor tied to it predicting the number becomes quite easy, even easier than when leaving the input floating.

  • @pfb3264
    @pfb3264 Рік тому +3

    I used A0 input which was floating in the air and read the last digit on that port ADC value to be the random number for electronic dice with large led strips to create the 7 segment display with slow down feature :)

  • @ezengondolkozom3700
    @ezengondolkozom3700 2 місяці тому

    Great video. An improvement would be to drive a diode or transistor in reverse breakdown mode and amplify the signal to the ADC-s voltage range. That way you get a good entropy signal from thermal noise.

    • @SineLab
      @SineLab  2 місяці тому

      That's an interesting way to generate entropy.

  • @Scyth3934
    @Scyth3934 Рік тому

    Well made as always!

  • @gkdresden
    @gkdresden 11 місяців тому

    The problem with the readout of open analog pins is that they are sensitive to EM. And a lot of the environmental EM is predictable. Another important point is to use noise source which is evenly distributed. Noise of semiconductor sources is often "colored". So I prefer metal film resistors as noise source in combination with a low noise opamp, whos input referred noise is considerably lower than the noise of the resistive noise source (100 kOhm resistor) in order to do signal conditioning for the analog input by use of amplification and offset.

    • @SineLab
      @SineLab  9 місяців тому

      Thanks for sharing! I didn't really think much about the predictability of environmental EM, so it's definitely something to consider. The inclusion of a metal film resistor is definitely intriguing to say the least :)

  • @jkmelri
    @jkmelri Рік тому +1

    awesomesauce!

  • @xzddakfdmiug5832
    @xzddakfdmiug5832 Рік тому

    Another excellent video!

  • @chaosordeal294
    @chaosordeal294 Рік тому +2

    "Why else would we create coins?" No reason, other than to flip them. Coins aren't used for anything else.

  • @deelowe3
    @deelowe3 Рік тому

    Why didn’t you use the random and noise functions? Generating a random number on micros is actually easier than a pc if you’re willing to add some hardware. It’s pretty easy to come up with a seed that’s impossible to guess if you leverage inputs with high entropy. For example, a well calibrated photo resistor in front of a lava lamp.

    • @someguy4915
      @someguy4915 Рік тому

      Attached to a 10 bit ADC... If you at least add a high precision ADC this becomes useful but with just 10 bits it's a joke for RnG.

  • @dlbiggins
    @dlbiggins Рік тому +3

    "Anyone who considers arithmetic methods of generating random digits is, of course, in a state of sin"
    John Von Neumann

  • @alejandrorivera478
    @alejandrorivera478 Рік тому +3

    Everytime u get to say something, u breath, it is not an issue but as a suggestion, u should look out for that. (Sounds kinda weird, but my point is that for each sentence, we get to hear u taking a fast breath)

    • @deelowe3
      @deelowe3 Рік тому

      Also, what’s an algithim?

    • @vilian9185
      @vilian9185 Рік тому

      honestly i like itb feels more real

  • @Dreddwinner
    @Dreddwinner Рік тому

    🤎💙💚💜❤️