-
Notifications
You must be signed in to change notification settings - Fork 19
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
The first output should be the last cell not -1 #4
Comments
Hi, the output of LFSR is indeed the last bit of intial state, but there is no output bit, if no clock cycle (L.next() ) is excuted. -1 has been intentionally used to show that LSFR has not been passed any clock input. In other words, Imagine LFSR has been initialize, but no clock is attached yet, in that case, no bit will be shifted out. I checked the code for this question, the print line is used at wrong place. It should be at end of the first cycle.
Output::
I think, author in given paper consider the first output as initial value, without any clock, in that case, L.output is just a shifted version. To get what you exactly expect, here is alternative code
which produces
|
I hope above code answers the issue. I should add this functionality to library, to use first output as last bit of LFSR. |
Thanks for the response. I've considered using |
@kelalaka153 You were right, I checked it in detail, somehow it was missing first output bit, which should not be the case. I have fixed it in latest version 1.0.5, along with detailed examples and help docstring. Check out here. I have added an option counter_start_zero, which is by default True to keep output -1 untill first clock is passed, but it can be set to False. Now, answer to your original question with your original code comes out to be correct with counter_start_zero=False
Output
OR Alternatively run first cycle before checking the output for first time
I think, now this issue is properly closed 👍 :) |
I've used this library to answer this question in cryptography.se. During my implementation, I've seen that the first output is -1. This creates inconsistency or extra code to mitigate.
This is very unusual, at least for me. The output should be the last cell of the LFSR, not -1. The easiest solution should be setting the output immediately.
The text was updated successfully, but these errors were encountered: