Skip to content

Commit

Permalink
debug cpgenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
hadipourh committed Dec 17, 2024
1 parent 7ee172b commit e4b54ce
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sboxanalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,23 +1128,23 @@ def generate_cp_constraints(self, propagation_dictionary, input_variables=None,
m = len(inputs[0])
n = len(outputs[0])
if input_variables is None:
a = [f"a{i}" for i in range(m)]
input_variables = [f"input_variables{i}" for i in range(m)]
else:
if len(input_variables) != m:
raise ValueError(f"The size of input variables should be {m}")
a = input_variables
input_variables = input_variables
if output_variables is None:
b = [f"b{i}" for i in range(n)]
output_variables = [f"output_variables{i}" for i in range(n)]
else:
if len(output_variables) != n:
raise ValueError(f"The size of output variables should be {n}")
b = output_variables
last_condition = " /\\ ".join([f"b{i} = -1" for i in range(n)])
output_variables = output_variables
last_condition = " /\\ ".join([f"output_variables{i} = -1" for i in range(n)])
constraints = ""
for i, (input, output) in enumerate(propagation_dictionary.items()):
input_str = [f"{a[i]} == {input[i]}" for i in range(m)]
input_str = [f"{input_variables[i]} == {input[i]}" for i in range(m)]
input_str = " /\\ ".join(input_str)
output_str = [f"{b[i]} = {output[i]}" for i in range(n)]
output_str = [f"{output_variables[i]} = {output[i]}" for i in range(n)]
output_str = " /\\ ".join(output_str)
if i == 0:
constraints += f"if ({input_str}) then ({output_str})\n"
Expand Down

0 comments on commit e4b54ce

Please sign in to comment.