Intermediate output component¶
- class IntermediateOutput(current_round_number, current_round_number_of_components, input_id_links, input_bit_positions, output_bit_size, output_tag)¶
Bases:
CipherOutput- as_python_dictionary()¶
- check_output_size(available_word_sizes, fixed, word_size)¶
- cms_constraints()¶
Return a list of variables and a list of clauses for OUTPUT in CMS CIPHER model.
This method support OUTPUT operation using more than two operands.
See also
SAT standard of Cipher for the format.
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(number_of_rounds=3) sage: cipher_output_component = speck.component_from(2, 12) sage: cipher_output_component.cms_constraints() (['cipher_output_2_12_0', 'cipher_output_2_12_1', 'cipher_output_2_12_2', ... 'xor_2_10_14 -cipher_output_2_12_30', 'cipher_output_2_12_31 -xor_2_10_15', 'xor_2_10_15 -cipher_output_2_12_31'])
- cms_xor_differential_propagation_constraints(model)¶
- cp_constraints()¶
Return a list of CP declarations and a list of CP constraints for OUTPUT component.
(both intermediate and cipher)
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(number_of_rounds=3) sage: output_component = speck.component_from(2, 12) sage: output_component.cp_constraints() ([], ['constraint cipher_output_2_12[0] = xor_2_8[0];', 'constraint cipher_output_2_12[1] = xor_2_8[1];', ... 'constraint cipher_output_2_12[31] = xor_2_10[15];'])
- cp_deterministic_truncated_xor_differential_trail_constraints()¶
- cp_wordwise_deterministic_truncated_xor_differential_constraints(model)¶
Return lists declarations and constraints for OUTPUT component (both intermediate and cipher), for CP wordwise deterministic truncated xor differential.
This is for the first step model.
INPUT:
model– model object; a model instance
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.aes_block_cipher import AESBlockCipher sage: from claasp.cipher_modules.models.cp.mzn_model import MznModel sage: aes = AESBlockCipher(number_of_rounds=3) sage: cp = MznModel(aes) sage: output_component = aes.component_from(0, 35) sage: output_component.cp_wordwise_deterministic_truncated_xor_differential_constraints(cp) ([], ['constraint intermediate_output_0_35_value[0] = xor_0_31_value[0];', ... 'constraint intermediate_output_0_35_active[15] = xor_0_34_active[3];'])
- cp_xor_differential_propagation_constraints(model)¶
- cp_xor_differential_propagation_first_step_constraints(model)¶
Return lists declarations and constraints for OUTPUT component (both intermediate and cipher), for CP xor differential first step.
This is for the first step model.
INPUT:
model– model object; a model instance
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.aes_block_cipher import AESBlockCipher sage: from claasp.cipher_modules.models.cp.mzn_model import MznModel sage: aes = AESBlockCipher(number_of_rounds=3) sage: cp = MznModel(aes) sage: output_component = aes.component_from(0, 35) sage: output_component.cp_xor_differential_propagation_first_step_constraints(cp) (['array[0..15] of var 0..1: intermediate_output_0_35;'], ['constraint intermediate_output_0_35[0] = xor_0_31[0];', ... 'constraint intermediate_output_0_35[15] = xor_0_34[3];'])
- cp_xor_linear_mask_propagation_constraints(model)¶
Return lists declarations and constraints for OUTPUT component (both intermediate and cipher).
This is for CP xor linear model.
INPUT:
model– model object; a model instance
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: from claasp.cipher_modules.models.cp.mzn_models.mzn_xor_linear_model import MznXorLinearModel sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=2) sage: speck_without_key_schedule = speck.remove_key_schedule() sage: cp = MznXorLinearModel(speck_without_key_schedule) sage: intermediate_component = speck.get_component_from_id("intermediate_output_0_6") sage: variables, constraints = intermediate_component.cp_xor_linear_mask_propagation_constraints(cp) sage: constraints ['constraint intermediate_output_0_6_o[0] = intermediate_output_0_6_i[0];', 'constraint intermediate_output_0_6_o[1] = intermediate_output_0_6_i[1];', 'constraint intermediate_output_0_6_o[2] = intermediate_output_0_6_i[2];', ... 'constraint intermediate_output_0_6_i[29] = xor_0_4_o[13];', 'constraint intermediate_output_0_6_i[30] = xor_0_4_o[14];', 'constraint intermediate_output_0_6_i[31] = xor_0_4_o[15];']
- property description¶
- get_bit_based_vectorized_python_code(params, convert_output_to_bytes)¶
- get_byte_based_vectorized_python_code(params)¶
- get_graph_representation()¶
- property id¶
- property input_bit_positions¶
- property input_bit_size¶
- property input_id_links¶
- is_forbidden(forbidden_types, forbidden_descriptions)¶
- is_id_equal_to(component_id)¶
- is_power_of_2_word_based(dto)¶
- milp_bitwise_deterministic_truncated_xor_differential_constraints(model)¶
Returns a list of variables and a list of constraints modeling a component of type Intermediate_output or Cipher_output for the bitwise deterministic truncated xor differential model.
EXAMPLE:
sage: from claasp.ciphers.block_ciphers.simon_block_cipher import SimonBlockCipher sage: simon = SimonBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=2) sage: from claasp.cipher_modules.models.milp.milp_models.milp_bitwise_deterministic_truncated_xor_differential_model import MilpBitwiseDeterministicTruncatedXorDifferentialModel sage: milp = MilpBitwiseDeterministicTruncatedXorDifferentialModel(simon) sage: milp.init_model_in_sage_milp_class() sage: output_component = simon.component_from(1,8) sage: variables, constraints = output_component.milp_bitwise_deterministic_truncated_xor_differential_constraints(milp) sage: variables [('x_class[xor_1_6_0]', x_0), ('x_class[xor_1_6_1]', x_1), ... ('x_class[cipher_output_1_8_30]', x_62), ('x_class[cipher_output_1_8_31]', x_63)] sage: constraints [x_32 == x_0, ... x_63 == x_31]
- milp_constraints(model)¶
Return lists variables and constrains modeling a component of type OUTPUT (both intermediate and cipher), for MILP CIPHER model.
INPUT:
model– model object; a model instance
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.simon_block_cipher import SimonBlockCipher sage: from claasp.cipher_modules.models.milp.milp_model import MilpModel sage: simon = SimonBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=2) sage: milp = MilpModel(simon) sage: milp.init_model_in_sage_milp_class() sage: output_component = simon.get_component_from_id("cipher_output_1_8") sage: variables, constraints = output_component.milp_constraints(milp) sage: variables [('x[xor_1_6_0]', x_0), ('x[xor_1_6_1]', x_1), ... ('x[cipher_output_1_8_30]', x_62), ('x[cipher_output_1_8_31]', x_63)] sage: constraints[0] x_32 == x_0
- milp_wordwise_deterministic_truncated_xor_differential_constraints(model)¶
Returns a list of variables and a list of constrains modeling a component of type Intermediate_output or Cipher_output for the wordwise deterministic truncated xor differential model.
EXAMPLE:
sage: from claasp.ciphers.block_ciphers.aes_block_cipher import AESBlockCipher sage: aes = AESBlockCipher(number_of_rounds=2) sage: from claasp.cipher_modules.models.milp.milp_models.milp_wordwise_deterministic_truncated_xor_differential_model import MilpWordwiseDeterministicTruncatedXorDifferentialModel sage: milp = MilpWordwiseDeterministicTruncatedXorDifferentialModel(aes) sage: milp.init_model_in_sage_milp_class() sage: output_component = aes.component_from(1, 32) sage: variables, constraints = output_component.milp_wordwise_deterministic_truncated_xor_differential_constraints(milp) sage: variables [('x_class[xor_1_31_word_0_class]', x_0), ('x_class[xor_1_31_word_1_class]', x_1), ... ('x[cipher_output_1_32_126]', x_286), ('x[cipher_output_1_32_127]', x_287)] sage: constraints [x_16 == x_0, x_17 == x_1, ... x_286 == x_158, x_287 == x_159]
- milp_xor_differential_propagation_constraints(model)¶
- milp_xor_linear_mask_propagation_constraints(model)¶
Return a list of variables and a list of constraints for OUTPUT component for MILP xor linear.
INPUT:
model– model object; a model instance
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: from claasp.cipher_modules.models.milp.milp_models.milp_xor_linear_model import MilpXorLinearModel sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=2) sage: speck_without_key_schedule = speck.remove_key_schedule() sage: milp = MilpXorLinearModel(speck_without_key_schedule) sage: milp.init_model_in_sage_milp_class() sage: intermediate_component = speck.get_component_from_id("intermediate_output_0_6") sage: variables, constraints = intermediate_component.milp_xor_linear_mask_propagation_constraints(milp) ... sage: variables [('x[intermediate_output_0_6_0_i]', x_0), ('x[intermediate_output_0_6_1_i]', x_1), ('x[intermediate_output_0_6_2_i]', x_2), ... ('x[xor_0_4_14_o]', x_110), ('x[xor_0_4_15_o]', x_111)] sage: constraints[0] x_32 == x_0
- minizinc_constraints(model)¶
Return variables and constraints for the components with type OUTPUT (both intermediate and cipher), for MINIZINC CIPHER constraints.
INPUT:
model– model object; a model instance
- minizinc_deterministic_truncated_xor_differential_trail_constraints(model)¶
- minizinc_xor_differential_propagation_constraints(model)¶
- property output_bit_size¶
- output_size_for_concatenate(available_word_sizes, fixed, word_size)¶
- print()¶
- print_as_python_dictionary()¶
- print_values(code)¶
- print_word_values(code)¶
- sat_bitwise_deterministic_truncated_xor_differential_constraints()¶
Return a list of variables and a list of clauses representing CIPHER OUTPUT for SAT DETERMINISTIC TRUNCATED XOR DIFFERENTIAL model
See also
SAT standard of Cipher for the format.
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(number_of_rounds=3) sage: output_component = speck.component_from(2, 12) sage: output_component.sat_bitwise_deterministic_truncated_xor_differential_constraints() (['cipher_output_2_12_0_0', 'cipher_output_2_12_1_0', ... 'cipher_output_2_12_30_1', 'cipher_output_2_12_31_1'], ['cipher_output_2_12_0_0 -xor_2_8_0_0', 'xor_2_8_0_0 -cipher_output_2_12_0_0', ... 'cipher_output_2_12_31_1 -xor_2_10_15_1', 'xor_2_10_15_1 -cipher_output_2_12_31_1'])
- sat_constraints()¶
Return a list of variables and a list of clauses representing CIPHER OUTPUT for SAT CIPHER model
See also
SAT standard of Cipher for the format.
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(number_of_rounds=3) sage: output_component = speck.component_from(2, 12) sage: output_component.sat_constraints() (['cipher_output_2_12_0', 'cipher_output_2_12_1', ... 'cipher_output_2_12_30', 'cipher_output_2_12_31'], ['cipher_output_2_12_0 -xor_2_8_0', 'xor_2_8_0 -cipher_output_2_12_0', ... 'cipher_output_2_12_31 -xor_2_10_15', 'xor_2_10_15 -cipher_output_2_12_31'])
- sat_semi_deterministic_truncated_xor_differential_constraints()¶
- sat_xor_differential_propagation_constraints(model=None)¶
Return a list of variables and a list of clauses representing CIPHER OUTPUT for SAT XOR DIFFERENTIAL model
See also
SAT standard of Cipher for the format.
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(number_of_rounds=3) sage: output_component = speck.component_from(2, 12) sage: output_component.sat_xor_differential_propagation_constraints() (['cipher_output_2_12_0', 'cipher_output_2_12_1', ... 'cipher_output_2_12_30', 'cipher_output_2_12_31'], ['cipher_output_2_12_0 -xor_2_8_0', 'xor_2_8_0 -cipher_output_2_12_0', ... 'cipher_output_2_12_31 -xor_2_10_15', 'xor_2_10_15 -cipher_output_2_12_31'])
- sat_xor_linear_mask_propagation_constraints(model=None)¶
Return a list of variables and a list of clauses representing INTERMEDIATE OUTPUT for SAT XOR LINEAR model
INPUT:
model– model object; a model instance
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: from claasp.cipher_modules.models.sat.sat_models.sat_xor_linear_model import SatXorLinearModel sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=2) sage: speck_without_key_schedule = speck.remove_key_schedule() sage: sat = SatXorLinearModel(speck_without_key_schedule) sage: intermediate_component = speck.get_component_from_id("intermediate_output_0_6") sage: intermediate_component.sat_xor_linear_mask_propagation_constraints(sat) (['intermediate_output_0_6_0_i', 'intermediate_output_0_6_1_i', ... 'intermediate_output_0_6_30_o', 'intermediate_output_0_6_31_o'], ['intermediate_output_0_6_0_i -intermediate_output_0_6_0_o', 'intermediate_output_0_6_0_o -intermediate_output_0_6_0_i', ... 'intermediate_output_0_6_31_i -xor_0_4_15_o', 'xor_0_4_15_o -intermediate_output_0_6_31_i'])
- select_bits(code)¶
- select_words(code, word_size, input=True)¶
- set_description(description)¶
- set_id(id_string)¶
- set_input_bit_positions(bit_positions)¶
- set_input_id_links(input_id_links)¶
- smt_constraints()¶
Return a variable list and SMT-LIB list asserts representing CIPHER OUTPUT for SMT CIPHER model
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(number_of_rounds=3) sage: output_component = speck.component_from(2, 12) sage: output_component.smt_constraints() (['cipher_output_2_12_0', 'cipher_output_2_12_1', ... 'cipher_output_2_12_30', 'cipher_output_2_12_31'], ['(assert (= cipher_output_2_12_0 xor_2_8_0))', '(assert (= cipher_output_2_12_1 xor_2_8_1))', ... '(assert (= cipher_output_2_12_30 xor_2_10_14))', '(assert (= cipher_output_2_12_31 xor_2_10_15))'])
- smt_xor_differential_propagation_constraints(model=None)¶
Return a variable list and SMT-LIB list asserts representing CIPHER OUTPUT for SMT XOR DIFFERENTIAL model
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(number_of_rounds=3) sage: output_component = speck.component_from(2, 12) sage: output_component.smt_xor_differential_propagation_constraints() (['cipher_output_2_12_0', 'cipher_output_2_12_1', ... 'cipher_output_2_12_30', 'cipher_output_2_12_31'], ['(assert (= cipher_output_2_12_0 xor_2_8_0))', '(assert (= cipher_output_2_12_1 xor_2_8_1))', ... '(assert (= cipher_output_2_12_30 xor_2_10_14))', '(assert (= cipher_output_2_12_31 xor_2_10_15))'])
- smt_xor_linear_mask_propagation_constraints(model=None)¶
Return a variable list and SMT-LIB list asserts representing INTERMEDIATE OUTPUT for SMT XOR LINEAR model
INPUT:
model– model object; a model instance
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: from claasp.cipher_modules.models.smt.smt_models.smt_xor_linear_model import SmtXorLinearModel sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=2) sage: speck_without_key_schedule = speck.remove_key_schedule() sage: smt = SmtXorLinearModel(speck_without_key_schedule) sage: intermediate_component = speck.get_component_from_id("intermediate_output_0_6") sage: intermediate_component.smt_xor_linear_mask_propagation_constraints(smt) (['intermediate_output_0_6_0_o', 'intermediate_output_0_6_1_o', ... 'intermediate_output_0_6_30_i', 'intermediate_output_0_6_31_i'], ['(assert (= intermediate_output_0_6_0_i intermediate_output_0_6_0_o))', '(assert (= intermediate_output_0_6_1_i intermediate_output_0_6_1_o))', ... '(assert (= intermediate_output_0_6_30_i xor_0_4_14_o))', '(assert (= intermediate_output_0_6_31_i xor_0_4_15_o))'])
- property suffixes¶
- property type¶
- update_xor_linear_constraints_for_more_than_one_bit(constraints, intermediate_var, linked_components, x)¶