0

Does it is possible to implement the components of a SBOX tables using lookup_tables. For example for a 4-bit SBOX it is possible to obtain the component 3 using SAGE in the following way

sage: from sage.crypto.sbox import SBox
sage: S = SBox([7,6,0,4,2,5,1,3])
sage: f3 = S.component_function(3)
sage: f3.algebraic_normal_form()
x0*x1 + x0*x2 + x0 + x2

But I need all components several times (like $2^{20}$), and boolean function substitution in SAGE is so slow to evaluate $2^20$ inputs. Then I think it is better to use lookup tables.

juaninf
  • 1,264
  • It's not clear what you're trying to do. That example is a 3×3 bit S-box (3 bits input, 3 bits output). The component bit numbers are 1, 2 & 4. The function f3 doesn't give you the 3rd component, it gives you the XOR of bit 1 and bit 2. If you just want to look up S-box bits, you don't need those Sage functions, you can easily create lookup tables using standard Python bitwise operators (which also work in Sage, although you need to write ^^ for XOR). See the next comment for a brief demo. – PM 2Ring Sep 28 '21 at 10:35

0 Answers0