NOBODY can solve this - Generating random numbers on an ATmega328p

  Рет қаралды 8,725

Sine Lab

Sine Lab

Жыл бұрын

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 Жыл бұрын
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_ Жыл бұрын
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 💡.
@hgbugalou
@hgbugalou 11 ай бұрын
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 10 ай бұрын
I'm sure you'll use it sooner or later
@ironsm4sh
@ironsm4sh Жыл бұрын
The way GPU shaders generate "random" numbers is also very interesting.
@WilliamEllison
@WilliamEllison Жыл бұрын
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 Жыл бұрын
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 :)
@elangovanhariprashanth4087
@elangovanhariprashanth4087 11 ай бұрын
Used 2 Adc inputs and the selection between them was pseudo random.
@ezengondolkozom3700
@ezengondolkozom3700 4 ай бұрын
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 4 ай бұрын
That's an interesting way to generate entropy.
@gkdresden
@gkdresden Жыл бұрын
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 10 ай бұрын
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 :)
@Scyth3934
@Scyth3934 Жыл бұрын
Well made as always!
@SineLab
@SineLab Жыл бұрын
Glad you enjoyed!
@jkmelri
@jkmelri Жыл бұрын
awesomesauce!
@xzddakfdmiug5832
@xzddakfdmiug5832 Жыл бұрын
Another excellent video!
@SineLab
@SineLab Жыл бұрын
Thank you!
@chaosordeal294
@chaosordeal294 Жыл бұрын
"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 Жыл бұрын
"Anyone who considers arithmetic methods of generating random digits is, of course, in a state of sin" John Von Neumann
@alejandrorivera478
@alejandrorivera478 Жыл бұрын
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
@Waferdicing
@Waferdicing Жыл бұрын
🤎💙💚💜❤️
Hardware CPU Timers - PWM and Interrupts - Beyond Arduino #2
9:31
NMCS4ALL: Random number generators
20:10
Dave Ackley
Рет қаралды 69 М.
Неприятная Встреча На Мосту - Полярная звезда #shorts
00:59
Полярная звезда - Kuzey Yıldızı
Рет қаралды 4,4 МЛН
UFC Vegas 93 : Алмабаев VS Джонсон
02:01
Setanta Sports UFC
Рет қаралды 210 М.
Random Numbers - Numberphile
11:39
Numberphile
Рет қаралды 1,1 МЛН
Dialling Random Numbers Until Stranger Agrees to Hang Out
12:46
Yes Theory
Рет қаралды 7 МЛН
Tigger C : an efficient 6502 C compiler
49:04
Hopper Development Environment
Рет қаралды 1,3 М.
True Random numbers with the ATECC608B and ESP32
15:32
Rudolf
Рет қаралды 1 М.
How Ray Tracing (Modern CGI) Works And How To Do It 600x Faster
32:06
Josh's Channel
Рет қаралды 560 М.
Intel's biggest blunder: Itanium
10:35
RetroBytes
Рет қаралды 356 М.
I Designed A CPU (And So Can You)
19:14
Owen Gibson
Рет қаралды 4,8 М.
Samsung Galaxy 🔥 #shorts  #trending #youtubeshorts  #shortvideo ujjawal4u
0:10
Ujjawal4u. 120k Views . 4 hours ago
Рет қаралды 4,9 МЛН
Секретный смартфон Apple без камеры для работы на АЭС
0:22
💅🏻Айфон vs Андроид🤮
0:20
Бутылочка
Рет қаралды 484 М.
5 НЕЛЕГАЛЬНЫХ гаджетов, за которые вас посадят
0:59
Кибер Андерсон
Рет қаралды 1,6 МЛН
📦Он вам не медведь! Обзор FlyingBear S1
18:26