Replies: 7 comments 14 replies
-
A couple of common sources of entropy on microcontollers are analog inputs and the drift between two independent clock sources. |
Beta Was this translation helpful? Give feedback.
-
But wouldn't that require that you have clock sources, or that the analogue inputs are not used for something else? I can't possibly add something like this to a purely numerical package. |
Beta Was this translation helpful? Give feedback.
-
The problem is not the generator itself. Melissa O'Neill has a very nice overview of this in https://www.pcg-random.org/index.html, and in fact, micropython/extmod/modurandom.c Lines 58 to 66 in e8e8c7c But you can't avoid the problem of the seed. I do understand your point, but if you want to generate two independent random sequences, then you need the option of seeding the generators in a random way. This is what the |
Beta Was this translation helpful? Give feedback.
-
The RNG in the urandom module is seeded from a TRNG (or OS) for the ports UNIX, STM32, ESP32, ESP8266, RP2040, MIMXRT, SAMD51. This seeding happens when the module is imported or whenever you call urandom.seed() without an argument or with |
Beta Was this translation helpful? Give feedback.
-
@v923z I'm not sure I completely follow the discussion, but it sounds like what you want is an independent RNG that behaves like micropython's built-in urandom (i.e. a PRNG like yasmarang), but has the ability to set a seed independently of urandom. Is that correct? As @robert-hh points out, you can basically rely on urandom to provide you with a useful seed because all the major ports initialise urandom at startup from a hardware random source. So for example, if we made |
Beta Was this translation helpful? Give feedback.
-
Yes, that pretty much sums it up. It wasn't clear to me what I should do, when a particular platform doesn't have hardware RNG, and that's why I was curious to see what alternatives there are. But beyond that, I am not sure that making
However, in Of course, if |
Beta Was this translation helpful? Give feedback.
-
@jimmo This was not the case for the nrf port, So I made a little PR to enable the seeding. |
Beta Was this translation helpful? Give feedback.
-
Hi all,
I would like to ask for some advice on an issue raised in v923z/micropython-ulab#569. It seems to me that the
random
module innumpy
mandates something like a seedless initialisation of a random number generator, and they claim that in this case " fresh, unpredictable entropy will be pulled from the OS" . Yeah, good luck with that on bare metal.Still, I find the idea of adding some functions of the random module to
ulab
cool (though, there is a slow workaround via thevectorize
function), and I'd like to explore, what could generate something that is unpredictable, if there is no hardware for it. I would appreciate any comments.Zoltán
Beta Was this translation helpful? Give feedback.
All reactions