Cp xor linear model¶
- class CpXorLinearModel(cipher)¶
Bases:
CpModel- add_solution_to_components_values(component_id, component_solution, components_values, j, output_to_parse, solution_number, string)¶
- add_solutions_from_components_values(components_values, memory, model_type, solutions, solve_time, solver_name, solver_output, total_weight)¶
- and_xor_linear_probability_lat(numadd)¶
Return the lat of the and operation.
INPUT:
numadd– integer; the number of addenda
EXAMPLES:
sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel sage: from claasp.ciphers.block_ciphers.simon_block_cipher import SimonBlockCipher sage: simon = SimonBlockCipher() sage: cp = CpXorLinearModel(simon) sage: cp.and_xor_linear_probability_lat(2) [2, 1, 0, 1, 0, 1, 0, -1]
- branch_xor_linear_constraints()¶
Return a list of Cp constraints for the branching of the linear model.
INPUT:
None
EXAMPLES:
sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel 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 = CpXorLinearModel(speck) sage: cp.branch_xor_linear_constraints() ['constraint plaintext_o[0] = rot_0_0_i[0];', 'constraint plaintext_o[1] = rot_0_0_i[1];', 'constraint plaintext_o[2] = rot_0_0_i[2];', ... 'constraint xor_3_10_o[13] = cipher_output_3_12_i[29];', 'constraint xor_3_10_o[14] = cipher_output_3_12_i[30];', 'constraint xor_3_10_o[15] = cipher_output_3_12_i[31];']
- build_mix_column_truncated_table(component)¶
Return a model that generates the list of possible input/output couples for the given mix column.
INPUT:
component– Component object; the mix column component in Cipher
EXAMPLES:
sage: from claasp.cipher_modules.models.cp.cp_model import CpModel sage: from claasp.ciphers.block_ciphers.aes_block_cipher import AESBlockCipher sage: aes = AESBlockCipher(number_of_rounds=3) sage: cp = CpModel(aes) sage: mix_column = aes.component_from(0, 21) sage: cp.build_mix_column_truncated_table(mix_column) 'array[0..93, 1..8] of int: mix_column_truncated_table_mix_column_0_21 = array2d(0..93, 1..8, [0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,1,0,1,1,1,1,0,0,1,1,0,1,1,1,0,0,1,1,1,0,1,1,0,0,1,1,1,1,0,1,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,1,0,1,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,1,0,1,1,0,1,0,1,1,1,0,1,0,1,0,1,1,1,1,0,0,1,0,1,1,1,1,1,0,1,1,0,0,1,1,1,0,1,1,0,1,0,1,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1,1,0,0,1,1,0,1,1,1,1,0,1,1,1,0,0,1,1,0,1,1,1,0,1,0,1,0,1,1,1,0,1,1,0,0,1,1,1,0,1,1,1,0,1,1,1,1,0,0,1,0,1,1,1,1,0,1,0,0,1,1,1,1,0,1,1,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,1,0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,1,0,1,1,1,1,0,0,1,1,0,1,1,1,0,0,1,1,1,0,1,1,0,0,1,1,1,1,0,1,0,0,1,1,1,1,1,1,0,1,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,1,0,1,1,0,1,0,1,1,1,0,1,0,1,0,1,1,1,1,1,0,1,1,0,0,1,1,1,0,1,1,0,1,0,1,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1,1,1,0,1,1,1,0,0,1,1,0,1,1,1,0,1,0,1,0,1,1,1,0,1,1,1,0,1,1,1,1,0,0,1,0,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,1,0,1,1,1,1,0,0,1,1,0,1,1,1,0,0,1,1,1,0,1,1,0,0,1,1,1,1,1,1,0,1,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,1,0,1,1,0,1,0,1,1,1,1,1,0,1,1,0,0,1,1,1,0,1,1,0,1,0,1,1,0,1,1,0,1,1,1,1,0,1,1,1,0,0,1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,1,0,1,1,1,1,0,0,1,1,0,1,1,1,0,0,1,1,1,1,1,1,0,1,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,1,1,1,1,0,1,1,0,0,1,1,1,0,1,1,0,1,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,1,0,1,1,1,1,0,0,1,1,1,1,1,1,0,1,0,0,1,1,1,1,0,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,1,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1]);'
- build_xor_linear_trail_model(weight=- 1, fixed_variables=[])¶
Build the Cp model for the search of XOR linear trails.
INPUT:
weight– integer (default: 1); a specific weight. If set to non-negative integer, fixes the XOR trail weightfixed_variables– list (default: []); dictionaries containing the variables to be fixed in standard format
EXAMPLES:
sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: from claasp.cipher_modules.models.utils import set_fixed_variables, integer_to_bit_list sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=4) sage: speck = speck.remove_key_schedule() sage: cp = CpXorLinearModel(speck) sage: fixed_variables = [set_fixed_variables('plaintext', 'not_equal', list(range(32)), integer_to_bit_list(0, 32, 'little'))] sage: cp.build_xor_linear_trail_model(-1, fixed_variables)
- calculate_bit_positions(bit_positions, input_length)¶
- calculate_bit_values(bit_values, input_length)¶
- calculate_input_bit_positions(word_index, input_name_1, input_name_2, new_input_bit_positions_1, new_input_bit_positions_2)¶
- property cipher¶
- property cipher_id¶
- final_xor_linear_constraints(weight)¶
Return a list of Cp constraints for the outputs of the cipher and solving indications for single step or second step model for xor linear model.
INPUT:
weight– integer; a specific weight. If set to non-negative integer, fixes the XOR trail weight
EXAMPLES:
sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: from claasp.cipher_modules.models.utils import set_fixed_variables, integer_to_bit_list sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=4) sage: speck = speck.remove_key_schedule() sage: cp = CpXorLinearModel(speck) sage: fixed_variables = [set_fixed_variables('plaintext', 'not_equal', list(range(32)), integer_to_bit_list(0, 32, 'little'))] sage: cp.build_xor_linear_trail_model(-1, fixed_variables) sage: cp.final_xor_linear_constraints(-1)[:-1] ['solve:: int_search(p, smallest, indomain_min, complete) minimize sum(p);']
- find_all_xor_linear_trails_with_fixed_weight(fixed_weight, fixed_values=[], solver_name='Chuffed')¶
Return a list of solutions containing all the linear trails having the
fixed_weightweight of correlation. By default, the search removes the key schedule, if any.INPUT:
fixed_weight– integer; the weight to be fixedfixed_values– list (default: []); can be created usingset_fixed_variablesmethodsolver_name– string (default: Chuffed); the name of the solver. Available values are:'Chuffed''Gecode''COIN-BC'
EXAMPLES:
sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(block_bit_size=8, key_bit_size=16, number_of_rounds=3) sage: cp = CpXorLinearModel(speck) sage: trails = cp.find_all_xor_linear_trails_with_fixed_weight(1) # long sage: len(trails) 12 # including the key schedule in the model sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: from claasp.cipher_modules.models.utils import set_fixed_variables sage: speck = SpeckBlockCipher(block_bit_size=8, key_bit_size=16, number_of_rounds=4) sage: cp = CpXorLinearModel(speck) sage: key = set_fixed_variables('key', 'not_equal', list(range(16)), [0] * 16) sage: trails = cp.find_all_xor_linear_trails_with_fixed_weight(2, fixed_values=[key]) sage: len(trails) 8
- find_all_xor_linear_trails_with_weight_at_most(min_weight, max_weight=64, fixed_values=[], solver_name='Chuffed')¶
Return a list of solutions containing all the linear trails having the weight of correlation lying in the interval
[min_weight, max_weight]. By default, the search removes the key schedule, if any.INPUT:
min_weight– integer; the weight from which to start the searchmax_weight– integer (default: 64); the weight at which the search stopsfixed_values– list (default: []); can be created usingset_fixed_variablesmethodsolver_name– string (default: Chuffed); the name of the solver. Available values are:'Chuffed''Gecode''COIN-BC'
EXAMPLES:
sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(block_bit_size=8, key_bit_size=16, number_of_rounds=3) sage: cp = CpXorLinearModel(speck) sage: trails = cp.find_all_xor_linear_trails_with_weight_at_most(0, 1) sage: len(trails) 13 # including the key schedule in the model sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(block_bit_size=8, key_bit_size=16, number_of_rounds=4) sage: cp = CpXorLinearModel(speck) sage: from claasp.cipher_modules.models.utils import set_fixed_variables sage: key = set_fixed_variables('key', 'not_equal', list(range(16)), [0] * 16) sage: trails = cp.find_all_xor_linear_trails_with_weight_at_most(0, 3, fixed_values=[key]) sage: len(trails) 73
- find_lowest_weight_xor_linear_trail(fixed_values=[], solver_name='Chuffed')¶
Return the solution representing a linear trail with the lowest weight of correlation. By default, the search removes the key schedule, if any.
Note
There could be more than one trail with the lowest weight. In order to find all the lowest weight trail, run
find_all_xor_linear_trails_with_fixed_weight().INPUT:
fixed_values– list (default: []); they can be created usingset_fixed_variablesmethodsolver_name– string (default: Chuffed); the name of the solver. Available values are:'Chuffed''Gecode''COIN-BC'
EXAMPLES:
sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(number_of_rounds=4) sage: cp= CpXorLinearModel(speck) sage: trail = cp.find_lowest_weight_xor_linear_trail() sage: trail['total_weight'] '3.0' # including the key schedule in the model sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: from claasp.cipher_modules.models.utils import set_fixed_variables sage: speck = SpeckBlockCipher(block_bit_size=16, key_bit_size=32, number_of_rounds=4) sage: cp = CpXorLinearModel(speck) sage: key = set_fixed_variables('key', 'not_equal', list(range(32)), [0] * 32) sage: trail = cp.find_lowest_weight_xor_linear_trail(fixed_values=[key]) sage: trail['total_weight'] '3.0'
- find_one_xor_linear_trail(fixed_values=[], solver_name='Chuffed')¶
Return the solution representing a linear trail with any weight of correlation. By default, the search removes the key schedule, if any.
INPUT:
fixed_values– list (default: []); can be created usingset_fixed_variablesmethodsolver_name– string (default: Chuffed); the name of the solver. Available values are:'Chuffed''Gecode''COIN-BC'
EXAMPLES:
sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel 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 = CpXorLinearModel(speck) sage: cp.find_one_xor_linear_trail() # random # including the key schedule in the model sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel 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 = CpXorLinearModel(speck) sage: from claasp.cipher_modules.models.utils import set_fixed_variables sage: key = set_fixed_variables('key', 'not_equal', list(range(64)), [0] * 64) sage: cp.find_one_xor_linear_trail(fixed_values=[key]) # random
- find_one_xor_linear_trail_with_fixed_weight(fixed_weight=- 1, fixed_values=[], solver_name='Chuffed')¶
Return the solution representing a linear trail with the weight of correlation equal to
fixed_weight. By default, the search removes the key schedule, if any.INPUT:
fixed_weight– integer; the value to which the weight is fixed, if non-negativefixed_values– list (default: []); can be created usingset_fixed_variablesmethodsolver_name– string (default: Chuffed); the name of the solver. Available values are:'Chuffed''Gecode''COIN-BC'
EXAMPLES:
sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel 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 = CpXorLinearModel(speck) sage: trail = cp.find_one_xor_linear_trail_with_fixed_weight(3) sage: trail['total_weight'] '3.0' # including the key schedule in the model sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(block_bit_size=8, key_bit_size=16, number_of_rounds=4) sage: cp = CpXorLinearModel(speck) sage: from claasp.cipher_modules.models.utils import set_fixed_variables sage: key = set_fixed_variables('key', 'not_equal', list(range(16)), [0] * 16) sage: trail = cp.find_one_xor_linear_trail_with_fixed_weight(3, fixed_values=[key]) sage: trail['total_weight'] '3.0'
- find_possible_number_of_active_sboxes(weight)¶
Return a set whose numbers are the possible numbers of active S-boxes.
INPUT:
weight– integer; the fixed weight that must be able to be obtained with the found numbers of active S-boxes
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.midori_block_cipher import MidoriBlockCipher sage: from claasp.cipher_modules.models.cp.cp_model import CpModel sage: midori = MidoriBlockCipher() sage: cp = CpModel(midori) sage: model = cp.find_possible_number_of_active_sboxes(9) sage: model {3, 4}
- fix_variables_value_constraints(fixed_variables=[], step='full_model')¶
Return a list of CP constraints that fix the input variables to a specific value.
INPUT:
fixed_variables– list (default: []); dictionaries containing name, bit_size, value (as integer) for the variables that need to be fixed to a certain value:- {
‘component_id’: ‘plaintext’,
‘constraint_type’: ‘equal’/’not_equal’
‘bit_size’: 32,
‘value’: 753
}
step– string (default: full_model)
EXAMPLES:
sage: from claasp.cipher_modules.models.cp.cp_model import CpModel sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: from claasp.cipher_modules.models.utils import set_fixed_variables, integer_to_bit_list sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=4) sage: cp = CpModel(speck) sage: cp.fix_variables_value_constraints([set_fixed_variables('plaintext', 'equal', range(4), integer_to_bit_list(5, 4, 'big'))]) ['constraint plaintext[0] = 0 /\\ plaintext[1] = 1 /\\ plaintext[2] = 0 /\\ plaintext[3] = 1;'] sage: cp.fix_variables_value_constraints([set_fixed_variables('plaintext', 'not_equal', list(range(4)), integer_to_bit_list(5, 4, 'big'))]) ['constraint plaintext[0] != 0 \\/ plaintext[1] != 1 \\/ plaintext[2] != 0 \\/ plaintext[3] != 1;']
- fix_variables_value_xor_linear_constraints(fixed_variables=[])¶
Return a list of Cp constraints that fix the input variables to a specific value.
INPUT: -
fixed_variables– list (default: []); dictionaries containing name, bit_size,value (as integer) for the variables that need to be fixed to a certain value:
{
‘component_id’: ‘key’,
‘constraint_type’: ‘equal’
‘bit_positions’: [0, 1, 2, 3],
‘bit_values’: [1, 0, 1, 0],
}
EXAMPLES:
sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: from claasp.cipher_modules.models.utils import set_fixed_variables, integer_to_bit_list sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=4) sage: cp = CpXorLinearModel(speck) sage: cp.fix_variables_value_xor_linear_constraints([set_fixed_variables('plaintext', 'equal', list(range(4)), integer_to_bit_list(5, 4, 'big'))]) ['constraint plaintext_o[0] = 0 /\\ plaintext_o[1] = 1 /\\ plaintext_o[2] = 0 /\\ plaintext_o[3] = 1;'] sage: cp.fix_variables_value_xor_linear_constraints([set_fixed_variables('plaintext', 'not_equal', list(range(4)), integer_to_bit_list(5, 4, 'big'))]) ['constraint plaintext_o[0] != 0 \\/ plaintext_o[1] != 1 \\/ plaintext_o[2] != 0 \\/ plaintext_o[3] != 1;']
- property float_and_lat_values¶
- format_component_value(component_id, string)¶
- get_command_for_solver_process(input_file_path, model_type, solver_name, num_of_processors, timelimit)¶
- get_lat_values(lat_table, numadd)¶
- get_mix_column_all_inputs(input_bit_positions_1, input_id_link_1, numb_of_inp_1)¶
- get_total_weight(string_total_weight)¶
- get_word_operation_final_xor_linear_constraints(component, new_constraint)¶
- initialise_model()¶
- input_xor_linear_constraints()¶
Return lists of declarations and constraints for the first part of CP model for the xor linear model.
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=4) sage: cp = CpXorLinearModel(speck) sage: cp.input_xor_linear_constraints() (['array[0..31] of var 0..1: plaintext_o;', 'array[0..63] of var 0..1: key_o;', 'array[0..6] of var {0, 1600, 900, 200, 1100, 400, 1300, 600, 1500, 800, 100, 1000, 300, 1200, 500, 1400, 700}: p;', 'var int: weight = sum(p);'], [])
- property model_constraints¶
Return the model specified by
model_type.INPUT:
model_type– string; the model to retrieve
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: from claasp.cipher_modules.models.cp.cp_model import CpModel sage: speck = SpeckBlockCipher(number_of_rounds=4) sage: cp = CpModel(speck) sage: cp.model_constraints() Traceback (most recent call last): ... ValueError: No model generated
- parse_solver_information(output_to_parse, truncated)¶
- set_component_solution_value(component_solution, truncated, value)¶
- solve(model_type, solver_name='Chuffed', num_of_processors=None, timelimit=None)¶
Return the solution of the model.
INPUT:
model_type– string; the model to solve:‘cipher’
‘xor_differential’
‘xor_differential_one_solution’
‘xor_linear’
‘xor_linear_one_solution’
‘deterministic_truncated_xor_differential’
‘deterministic_truncated_xor_differential_one_solution’
‘impossible_xor_differential’
solver_name– string (default: None); the name of the solver. Available values are:'Chuffed''Gecode''COIN-BC'
num_of_processors– integer; the number of processors to be usedtimelimit– integer; time limit to output a result
EXAMPLES:
sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_differential_trail_search_model import CpXorDifferentialTrailSearchModel sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: from claasp.cipher_modules.models.utils import set_fixed_variables, integer_to_bit_list sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=4) sage: cp = CpXorDifferentialTrailSearchModel(speck) sage: fixed_variables = [set_fixed_variables('key', 'equal', list(range(64)), integer_to_bit_list(0, 64, 'little')), set_fixed_variables('plaintext', 'not_equal', list(range(32)), integer_to_bit_list(0, 32, 'little'))] sage: cp.build_xor_differential_trail_model(-1, fixed_variables) sage: cp.solve('xor_differential', 'Chuffed') # random [{'cipher_id': 'speck_p32_k64_o32_r4', ... 'total_weight': '7'}, {'cipher_id': 'speck_p32_k64_o32_r4', ... 'total_weight': '5'}]
- solver_names(verbose=False)¶
- update_and_or_lat_valid_probabilities(and_already_added, component, cp_declarations, valid_probabilities)¶
- update_sbox_lat_valid_probabilities(component, valid_probabilities)¶
- weight_constraints(weight)¶
Return a list of CP constraints that fix the total weight to a specific value.
INPUT:
weight– integer; a specific weight. If set to non-negative integer, fixes the XOR trail weight
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: from claasp.cipher_modules.models.cp.cp_model import CpModel sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=4) sage: cp = CpModel(speck) sage: cp.weight_constraints(10) (['constraint weight = 1000;'], [])
- weight_xor_linear_constraints(weight)¶
Return a list of Cp constraints that fix the total weight to a specific value for xor linear model.
INPUT:
weight– integer; a specific weight. If set to non-negative integer, fixes the XOR trail weight
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: from claasp.cipher_modules.models.cp.cp_models.cp_xor_linear_model import CpXorLinearModel sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=4) sage: cp = CpXorLinearModel(speck) sage: cp.weight_xor_linear_constraints(10) (['constraint weight = 1000;'], [])