Skip to content

Commit

Permalink
Merge branch 'develop' into feat/extend_external_solvers_support_for_…
Browse files Browse the repository at this point in the history
…milp_modules
  • Loading branch information
p-huynh committed Nov 27, 2023
2 parents e564a27 + 7d0ce68 commit 269b9c3
Show file tree
Hide file tree
Showing 268 changed files with 75,921 additions and 16,746 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def add_constraints_to_build_fully_automatic_model_in_sage_milp_class(self, fixe
p["number_of_unknown_patterns"] == sum(x[output_msb] for output_msb in [id[0] for id in forward_output_id_tuple]))


def find_one_wordwise_impossible_xor_differential_trail(self, middle_round=None, fixed_bits=[], fixed_words=[], solver_name=SOLVER_DEFAULT):
def find_one_wordwise_impossible_xor_differential_trail(self, middle_round=None, fixed_bits=[], fixed_words=[], solver_name=SOLVER_DEFAULT, external_solver_name=None):
"""
Returns one wordwise impossible XOR differential trail.
Expand All @@ -324,6 +324,7 @@ def find_one_wordwise_impossible_xor_differential_trail(self, middle_round=None,
- ``middle_round`` -- **integer**; the round number for which the incompatibility occurs
- ``fixed_bits`` -- *list of dict*, the bit variables to be fixed in standard format
- ``fixed_words`` -- *list of dict*, the word variables to be fixed in standard format
- ``external_solver_name`` -- **string** (default: None); if specified, the library will write the internal Sagemath MILP model as a .lp file and solve it outside of Sagemath, using the external solver.
EXAMPLE::
Expand All @@ -343,12 +344,12 @@ def find_one_wordwise_impossible_xor_differential_trail(self, middle_round=None,
self.add_constraints_to_build_in_sage_milp_class(middle_round, fixed_bits, fixed_words)
end = time.time()
building_time = end - start
solution = self.solve(MILP_WORDWISE_IMPOSSIBLE, solver_name)
solution = self.solve(MILP_WORDWISE_IMPOSSIBLE, solver_name, external_solver_name)
solution['building_time'] = building_time

return solution

def find_one_wordwise_impossible_xor_differential_trail_with_fixed_component(self, component_id_list, fixed_bits=[], fixed_words=[], solver_name=SOLVER_DEFAULT):
def find_one_wordwise_impossible_xor_differential_trail_with_chosen_components(self, component_id_list, fixed_bits=[], fixed_words=[], solver_name=SOLVER_DEFAULT, external_solver_name=None):
"""
Returns one wordwise impossible XOR differential trail.
Expand All @@ -358,6 +359,7 @@ def find_one_wordwise_impossible_xor_differential_trail_with_fixed_component(sel
- ``component_id_list`` -- **str**; the list of component ids for which the incompatibility occurs
- ``fixed_bits`` -- *list of dict*, the bit variables to be fixed in standard format
- ``fixed_words`` -- *list of dict*, the word variables to be fixed in standard format
- ``external_solver_name`` -- **string** (default: None); if specified, the library will write the internal Sagemath MILP model as a .lp file and solve it outside of Sagemath, using the external solver.
EXAMPLE::
Expand All @@ -366,7 +368,7 @@ def find_one_wordwise_impossible_xor_differential_trail_with_fixed_component(sel
sage: aes = AESBlockCipher(number_of_rounds=2)
sage: from claasp.cipher_modules.models.milp.milp_models.milp_wordwise_impossible_xor_differential_model import MilpWordwiseImpossibleXorDifferentialModel
sage: milp = MilpWordwiseImpossibleXorDifferentialModel(aes)
sage: trail = milp.find_one_wordwise_impossible_xor_differential_trail_with_fixed_component(['mix_column_0_21'], get_single_key_scenario_format_for_fixed_values(aes))
sage: trail = milp.find_one_wordwise_impossible_xor_differential_trail_with_chosen_components(['mix_column_0_21'], get_single_key_scenario_format_for_fixed_values(aes))
"""
start = time.time()
Expand All @@ -377,12 +379,12 @@ def find_one_wordwise_impossible_xor_differential_trail_with_fixed_component(sel
self.add_constraints_to_build_in_sage_milp_class_with_fixed_components(component_id_list, fixed_bits, fixed_words)
end = time.time()
building_time = end - start
solution = self.solve(MILP_WORDWISE_IMPOSSIBLE, solver_name)
solution = self.solve(MILP_WORDWISE_IMPOSSIBLE, solver_name, external_solver_name)
solution['building_time'] = building_time

return solution

def find_one_wordwise_impossible_xor_differential_trail_with_fully_automatic_model(self, fixed_bits=[], fixed_words=[], solver_name=SOLVER_DEFAULT):
def find_one_wordwise_impossible_xor_differential_trail_with_fully_automatic_model(self, fixed_bits=[], fixed_words=[], solver_name=SOLVER_DEFAULT, external_solver_name=None):
"""
Returns one wordwise impossible XOR differential trail.
Expand All @@ -391,6 +393,7 @@ def find_one_wordwise_impossible_xor_differential_trail_with_fully_automatic_mod
- ``solver_name`` -- *str*, the solver to call
- ``fixed_bits`` -- *list of dict*, the bit variables to be fixed in standard format
- ``fixed_words`` -- *list of dict*, the word variables to be fixed in standard format
- ``external_solver_name`` -- **string** (default: None); if specified, the library will write the internal Sagemath MILP model as a .lp file and solve it outside of Sagemath, using the external solver.
EXAMPLE::
Expand All @@ -410,7 +413,7 @@ def find_one_wordwise_impossible_xor_differential_trail_with_fully_automatic_mod
self.add_constraints_to_build_fully_automatic_model_in_sage_milp_class(fixed_bits, fixed_words)
end = time.time()
building_time = end - start
solution = self.solve(MILP_WORDWISE_IMPOSSIBLE_AUTO, solver_name)
solution = self.solve(MILP_WORDWISE_IMPOSSIBLE_AUTO, solver_name, external_solver_name)
solution['building_time'] = building_time

return solution
Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 6d848c87a72724c8c4808ff7e1d931a1
config: 08a53bd5d60dd2e28390fe56d9e51a12
tags: 645f666f9bcd5a90fca523b33c5a78b7
10 changes: 10 additions & 0 deletions docs/build/html/_sources/cipher_modules/graph_generator.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---------------
Graph generator
---------------

.. automodule:: cipher_modules.graph_generator
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

10 changes: 10 additions & 0 deletions docs/build/html/_sources/cipher_modules/inverse_cipher.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--------------
Inverse cipher
--------------

.. automodule:: cipher_modules.inverse_cipher
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-------------------------
Cp xor differential model
-------------------------

.. automodule:: cipher_modules.models.cp.cp_models.cp_xor_differential_model
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----------------------------------------------------------
Milp bitwise deterministic truncated xor differential model
-----------------------------------------------------------

.. automodule:: cipher_modules.models.milp.milp_models.milp_bitwise_deterministic_truncated_xor_differential_model
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
----------------------------------------------
Milp bitwise impossible xor differential model
----------------------------------------------

.. automodule:: cipher_modules.models.milp.milp_models.milp_bitwise_impossible_xor_differential_model
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
------------------------------------------------------------
Milp wordwise deterministic truncated xor differential model
------------------------------------------------------------

.. automodule:: cipher_modules.models.milp.milp_models.milp_wordwise_deterministic_truncated_xor_differential_model
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----------------------------------------------
Milp wordwise impossible xor differential model
-----------------------------------------------

.. automodule:: cipher_modules.models.milp.milp_models.milp_wordwise_impossible_xor_differential_model
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
----------------------------------------------------------
Dictionary containing truncated input pattern inequalities
----------------------------------------------------------

.. automodule:: cipher_modules.models.milp.utils.dictionary_containing_truncated_input_pattern_inequalities
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
------------------------------------------------
Dictionary containing truncated mds inequalities
------------------------------------------------

.. automodule:: cipher_modules.models.milp.utils.dictionary_containing_truncated_mds_inequalities
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---------------------------------------------------------------------
Dictionary containing truncated xor inequalities between n input bits
---------------------------------------------------------------------

.. automodule:: cipher_modules.models.milp.utils.dictionary_containing_truncated_xor_inequalities_between_n_input_bits
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----------------------------------------------------------
Dictionary containing xor inequalities between n input bits
-----------------------------------------------------------

.. automodule:: cipher_modules.models.milp.utils.dictionary_containing_xor_inequalities_between_n_input_bits
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
------------------------------------------------------
Dictionary that contains inequalities for large sboxes
------------------------------------------------------

.. automodule:: cipher_modules.models.milp.utils.dictionary_that_contains_inequalities_for_large_sboxes
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----------------------------------------------------------------
Dictionary that contains inequalities for large sboxes xor linear
-----------------------------------------------------------------

.. automodule:: cipher_modules.models.milp.utils.dictionary_that_contains_inequalities_for_large_sboxes_xor_linear
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
----------------------------------------------------------------------
Dictionary that contains inequalities for sboxes with undisturbed bits
----------------------------------------------------------------------

.. automodule:: cipher_modules.models.milp.utils.dictionary_that_contains_inequalities_for_sboxes_with_undisturbed_bits
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
------------------------------------------------------
Dictionary that contains inequalities for small sboxes
------------------------------------------------------

.. automodule:: cipher_modules.models.milp.utils.dictionary_that_contains_inequalities_for_small_sboxes
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----------------------------------------------------------------
Dictionary that contains inequalities for small sboxes xor linear
-----------------------------------------------------------------

.. automodule:: cipher_modules.models.milp.utils.dictionary_that_contains_inequalities_for_small_sboxes_xor_linear
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---------------------------------------------------------
Generate inequalities for wordwise truncated mds matrices
---------------------------------------------------------

.. automodule:: cipher_modules.models.milp.utils.generate_inequalities_for_wordwise_truncated_mds_matrices
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
------------------------------------------------------------------
Generate inequalities for wordwise truncated xor with n input bits
------------------------------------------------------------------

.. automodule:: cipher_modules.models.milp.utils.generate_inequalities_for_wordwise_truncated_xor_with_n_input_bits
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-------------------------------------------------
Generate undisturbed bits inequalities for sboxes
-------------------------------------------------

.. automodule:: cipher_modules.models.milp.utils.generate_undisturbed_bits_inequalities_for_sboxes
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
------------------
Milp name mappings
------------------

.. automodule:: cipher_modules.models.milp.utils.milp_name_mappings
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----
Utils
-----

.. automodule:: cipher_modules.models.milp.utils.utils
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----------------
Bea1 block cipher
-----------------

.. automodule:: ciphers.block_ciphers.bea1_block_cipher
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-------------------
Lblock block cipher
-------------------

.. automodule:: ciphers.block_ciphers.lblock_block_cipher
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--------------------
Qarmav2 block cipher
--------------------

.. automodule:: ciphers.block_ciphers.qarmav2_block_cipher
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
----------------
Rc5 block cipher
----------------

.. automodule:: ciphers.block_ciphers.rc5_block_cipher
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----------------------
Whirlpool hash function
-----------------------

.. automodule:: ciphers.hash_functions.whirlpool_hash_function
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----------------
Salsa permutation
-----------------

.. automodule:: ciphers.permutations.salsa_permutation
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---------------------------
Spongent pi fsr permutation
---------------------------

.. automodule:: ciphers.permutations.spongent_pi_fsr_permutation
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Loading

0 comments on commit 269b9c3

Please sign in to comment.