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

Apparent issues with cipher quality #10

Open
FrozenBob opened this issue Jun 25, 2020 · 1 comment
Open

Apparent issues with cipher quality #10

FrozenBob opened this issue Jun 25, 2020 · 1 comment

Comments

@FrozenBob
Copy link

I was testing an implementation of shuffling lists using pyffx, in an attempt to avoid holding the entire shuffled list in memory. One of my implementations is as follows:

def shuffle_generator(sequence):
  key = secrets.token_bytes()
  cipher = pyffx.Sequence(key, alphabet=sequence, length=1)
  for i in sequence:
    yield cipher.encrypt([i])[0]

In tests, this quickly proved to be a terrible shuffle. The result was always a rotation of the input - for example, list(shuffle_generator(range(5))) could produce [2, 3, 4, 0, 1] or [0, 1, 2, 3, 4], but never [0, 4, 2, 3, 1].

Am I using pyffx wrong in some way I'm not realizing?

I'm on pyffx 0.3.0 and Python 3.8.3.

@bschoening
Copy link

bschoening commented Jun 18, 2021

Likely your domain is too small. See the NIST FPE standards FF1 & FF3 and the requirement for a domain of > 1M. You have a domain of just 5 values.

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