-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
Debug component_function
in S-box Module and Add the S-box of WARP Block Cipher
#35913
Conversation
@@ -1334,7 +1334,7 @@ cdef class SBox(SageObject): | |||
b = list(b) | |||
if len(b) > n: | |||
raise ValueError("input (%s) is too long and would be truncated" % (b,)) | |||
b = self.from_bits(b) | |||
b = self.from_bits(b, n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test for this?
One small change, then it should be fine. |
@hadipourh Have you read what I wrote? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
Documentation preview for this PR (built with commit f43f1f9; changes) is ready! 🎉 |
Sorry for the late reply. Your added sage: from sage.crypto.sboxes import SBox
sage: sb = SBox(7, 6, 0, 4, 2, 5, 1, 3)
sage: sb.component_function([1, 0, 0])
Boolean function with 3 variables
sage: sb.input_size()
3
sage: sb.output_size()
3 (And hence this actually runs for the latest Sage version already.) Please replace it with an example that has differing input and output size |
Thank you @grhkm21 for your review!
|
src/sage/crypto/sbox.pyx
Outdated
sage: from sage.crypto.sboxes import SBox | ||
sage: sb = SBox([0, 1, 2, 3, 0, 1, 2, 3]) | ||
sage: sb.component_function([1, 0]) | ||
Boolean function with 3 variabl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix this :)
After fixing the test output this should be ready :) |
The test output was fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thanks :)
Thank you too for your review! As seen in the road map, I would like to integrate this tool into the SageMath. |
I took a look at your sboxanalyzer project, it looks interesting and would be great to have in Sage. Is the entire |
The entire Espresso package is, of course, not needed, but I believe Espresso, once integrated into the SageMath project, will be incredibly useful for people working on Boolean functions and binary fields. To the best of my knowledge, Espresso is one of the most efficient (in terms of speed) open-source logic minimizers available. Hence, it makes sense to integrate the entire Espresso package together with SboxAnalyzer into SageMath. This way, Espresso can be reused for many other applications in the context of Boolean functions and binary fields. If you, @tscrim, or anyone else is interested and can help, you are very welcome to contribute to this project by integrating it into SageMath. |
Please do not rebase PRs after they are positively reviewed... It retriggers CI and requires a re-review (automated by bot, as you can see) etc. |
@grhkm21 So including C code in Sage is basically the same as any other bit of code (we do have some in Sage already as I recall) except with a bit of Cython bindings. It might be best to keep Espresso as a separate (upstream?) optional package with specific hooks/classes within Sage to use that. |
📚 Description
1- Debugging
component_function
in sbox module:from_bits(self, x, n=None)
function is invoked within thecomponent_function
of the Sbox class. When theinput_size
andoutput_size
of the S-box differ, thefrom_bits
function operates correctly if then
argument is specified. However, the current implementation of thecomponent_function
callsfrom_bits
without setting then
argument. Consequently, calling thecomponent_function
of the Sbox class with differinginput_size
andoutput_size
results in an error.n
into thefrom_bits
functions inside thecomponent_function
.2- Adding the s-box of WARP to s-box suite of SageMath
[1] - https://link.springer.com/chapter/10.1007/978-3-030-81652-0_21
📝 Checklist
⌛ Dependencies
This change does not rely on any dependencies.