Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is known about the randomization quality? #1

Open
daniel-vainsencher opened this issue Oct 16, 2015 · 1 comment
Open

What is known about the randomization quality? #1

daniel-vainsencher opened this issue Oct 16, 2015 · 1 comment

Comments

@daniel-vainsencher
Copy link

"No guarantees" is pretty discouraging... is this using a published algorithm? is there a high-level overview of what it does?

@TimNN
Copy link
Owner

TimNN commented Oct 22, 2015

I mainly wrote this for a toy project which has by now been scraped.

When testing the code, the generated sequences "looked" random enough to me, however I never tried running it through some kind of randomness evaluator.

Internally it essentially uses a block cipher with a randomised key, however I could not find a published algorithm which supported sufficiently small / variable block sizes which is why I had to roll my own.

The actual algorithm used is defined here:

https://github.com/TimNN/shuffled-iter/blob/master/src/lib.rs#L106-L108

and basically looks like

next_value = ((((previous_value * f1) ^ x1) * f2) ^ x2) & mask

Where x1 and x2 are arbitrary numbers, & mask is essentially modulo 2^n and f1 and f2 are factors for which a multiplicative inverse modulo 2^n exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants