Skip to content

Commit

Permalink
Fix cp_xor_differential_model.py tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AnaCaceres committed May 21, 2024
1 parent de2bf78 commit 3c8750d
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def build_xor_differential_trail_model(self, weight=-1, fixed_variables=[]):
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher
sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=4)
sage: cp = CpXorDifferentialModel(speck)
sage: cp.build_xor_differential_trail_model(-1, fixed_variables)
sage: cp.build_xor_differential_trail_model()
"""
self.initialise_model()
self.c = 0
Expand Down Expand Up @@ -338,12 +338,19 @@ def find_lowest_weight_xor_differential_trail(self, fixed_values=[], solver_name
sage: speck = SpeckBlockCipher(number_of_rounds=5)
sage: cp = CpXorDifferentialModel(speck)
sage: cp.find_lowest_weight_xor_differential_trail(solver_name='Chuffed') # random
{'building_time': 0.007165431976318359,
'cipher_id': 'speck_p32_k64_o32_r4',
'components_values': {'cipher_output_4_12': {'value': '850a9520',
'weight': 0},
{'cipher': speck_p32_k64_o32_r5,
'model_type': 'xor_differential_one_solution',
'solver_name': 'Chuffed',
'solving_time_seconds': 120.349,
'memory_megabytes': 0.28,
'components_values': {'plaintext': {'value': '28000010', 'weight': 0},
'key': {'value': '0000000000000000', 'weight': 0},
...
'total_weight': '9.0'}
'cipher_output_4_12': {'value': '850a9520', 'weight': 0.0}},
'total_weight': '9.0',
'status': 'SATISFIABLE',
'building_time_seconds': 0.0021665096282958984,
'test_name': 'find_lowest_weight_xor_differential_trail'}
# related-key setting
sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_differential_model import (CpXorDifferentialModel)
Expand Down Expand Up @@ -386,7 +393,7 @@ def find_one_xor_differential_trail(self, fixed_values=[], solver_name=SOLVER_DE
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher
sage: speck = SpeckBlockCipher(number_of_rounds=2)
sage: cp = CpXorDifferentialModel(speck)
sage: cp.find_one_xor_differential_trail(solver_name=Chuffed') # random
sage: cp.find_one_xor_differential_trail(solver_name='Chuffed') # random
{'cipher_id': 'speck_p32_k64_o32_r2',
'model_type': 'xor_differential_one_solution',
...
Expand Down

0 comments on commit 3c8750d

Please sign in to comment.