Skip to content

Commit

Permalink
Fixed modular_component.py for doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharwan Tiwari authored and Sharwan Tiwari committed Jun 7, 2024
1 parent 73254b9 commit fe5cdd0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions claasp/components/modular_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ def milp_bitwise_deterministic_truncated_xor_differential_constraints(self, mode
sage: milp.init_model_in_sage_milp_class()
sage: modadd_component = cipher.get_component_from_id("modadd_0_1")
sage: variables, constraints = modadd_component.milp_bitwise_deterministic_truncated_xor_differential_constraints(milp)
...
sage: constraints
[x_48 <= 15,
0 <= x_48,
Expand Down Expand Up @@ -904,20 +905,22 @@ def extend_constraints_for_window_size_with_full_windows(
hw_bit_ids[i: i + (model.window_size_weight_pr_vars + 1)]))
component_round_number = model._cipher.get_round_from_component_id(self.id)

if model.window_size_by_round_values is not None:
from claasp.cipher_modules.models.sat.sat_models.sat_xor_differential_model import SatXorDifferentialModel
if type(model) == SatXorDifferentialModel and model.window_size_by_round_values is not None:
window_size = model.window_size_by_round_values[component_round_number]
extend_constraints_for_window_size(output_bit_len, window_size, input_bit_ids, output_bit_ids, constraints)

if model.window_size_by_component_id_values is not None:
if type(model) == SatXorDifferentialModel and model.window_size_by_component_id_values is not None:
if self.id not in model.window_size_by_component_id_values:
raise ValueError(f"component with id {self.id} is not in the list window_size_by_component_id")
window_size = model.window_size_by_component_id_values[self.id]
extend_constraints_for_window_size(output_bit_len, window_size, input_bit_ids, output_bit_ids, constraints)

if model.window_size_number_of_full_window is not None:
extend_constraints_for_window_size_with_full_windows(
if type(model) == SatXorDifferentialModel and model.window_size_number_of_full_window is not None:
if model.window_size_number_of_full_window is not None:
extend_constraints_for_window_size_with_full_windows(
model, output_bit_len, window_size, input_bit_ids, output_bit_ids, constraints
)
)

variables = output_bit_ids + dummy_bit_ids + hw_bit_ids

Expand Down

0 comments on commit fe5cdd0

Please sign in to comment.