From e43e3b9ea386c25f1f5891a12e35fe7fef4422ca Mon Sep 17 00:00:00 2001 From: Juan del Carmen Grados Vasquez Date: Wed, 9 Oct 2024 20:11:33 +0400 Subject: [PATCH] FIX/fix: calculate_component_weight This method calculates the number of ones in the output of a component model for SAT models. It checks whether the component is non-linear. Although CLAASP supported the MODSUB component, it was not included in this method. This update fixes that oversight. --- claasp/cipher_modules/models/sat/sat_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/claasp/cipher_modules/models/sat/sat_model.py b/claasp/cipher_modules/models/sat/sat_model.py index 86a4dbd3..0f8fef4e 100644 --- a/claasp/cipher_modules/models/sat/sat_model.py +++ b/claasp/cipher_modules/models/sat/sat_model.py @@ -397,7 +397,7 @@ def fix_variables_value_constraints(fixed_variables=[]): def calculate_component_weight(self, component, out_suffix, output_values_dict): weight = 0 - if ('MODADD' in component.description or 'AND' in component.description + if ('MODSUB' in component.description or 'MODADD' in component.description or 'AND' in component.description or 'OR' in component.description or SBOX in component.type): weight = sum([output_values_dict[f'hw_{component.id}_{i}{out_suffix}'] for i in range(component.output_bit_size)])