Python-random-module-cracker icon indicating copy to clipboard operation
Python-random-module-cracker copied to clipboard

[label:question] Instructions unclear

Open Iinksafe opened this issue 7 months ago • 1 comments

"It is important to feed cracker exactly 32-bit integers generated by the generator due to the fact that they will be generated anyway, but dropped if you don't request for them. As well, you must feed the cracker exactly after new seed is presented, or after 624*32 bits are generated since every 624 32-bit numbers generator shifts it's state and cracker is designed to be fed from the begining of some state."

Can someone explain in detail this line? I'm afraid I misinterpreted it.

"It is important to feed cracker exactly 32-bit integers generated by the generator due to the fact that they will be generated anyway, but dropped if you don't request for them."

That means I can't do (or I shouldn't do) the following: RandCrack.submit(random.getrandbits(16)) or RandCrack.submit(random.getrandbits(64)).

"As well, you must feed the cracker exactly after new seed is presented, or after 624*32 bits are generated since every 624 32-bit numbers generator shifts it's state and cracker is designed to be fed from the begining of some state."

So if I call, e.g., random.randint(0, 1234) 624 times, does the module resubmit 32-bit integers 624 times or do I need to do that again, in order to maintain prediction accuracy?

Iinksafe avatar Apr 13 '25 14:04 Iinksafe

Would love to mark this post as a question (as in, the label) but I'm unsure how to do that.

Iinksafe avatar Apr 13 '25 14:04 Iinksafe

The way I understand is that each twist produces exactly 624 subsequent 32-bit integers. Once the first 624 numbers are consumed, it does a new twist to generated a new batch of 624 32-bit integers.

The cracker needs to be fed such an exact batch in order to derive the internal state (or secret key) of the random generator. If you feed it anything other than 32-bit integers, the batches will no longer line up with the expected twists and so the cracker will no longer be able to deduct the internal state.

After you have successfully submitted 624 subsequent integers, you cannot submit any additional numbers since at that point the rng has been cracked. If you want to skip forwards or backwards in time you must do so with the offset() function

CisterMoke avatar Aug 22 '25 13:08 CisterMoke