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

Add explicit assert to get_permutated_index #634

Merged
merged 3 commits into from
Feb 18, 2019
Merged

Conversation

paulhauner
Copy link
Contributor

What

Add an explicit assertion that the list size is within the bounds of the shuffler.

Why

There is an implicit assert in int_to_bytes4 but I don't think it' immediately obvious.

To find it you would need to be thinking about how Python handles x.to_bytes(len, ..) when x >= 2**(len * 8).

Also, it illustrates the bounds of the algorithm.

Additional Info

You could assert SHUFFLE_ROUND_COUNT < 2**8 for int_to_bytes1 but it's a constant so I omitted that.

There is an implicit assert in `int_to_bytes4`, however I think it's rather hidden.
@JustinDrake
Copy link
Collaborator

Can we go up to list_size <= 2**40 (4 bytes + 1 byte from the // 258).

@paulhauner
Copy link
Contributor Author

Oh yeah, sorry my bad.

I did 2**32 / 256 == 2**24 instead of 2**32 * 256 == 2**40.

I'll change it now

@hwwhww hwwhww requested a review from vbuterin February 17, 2019 15:36
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

Successfully merging this pull request may close these issues.

3 participants