Cipher output component

class CipherOutput(current_round_number, current_round_number_of_components, input_id_links, input_bit_positions, output_bit_size, is_intermediate=False, output_tag='')

Bases: Component

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:

  • modelmodel 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:

  • modelmodel 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=None)

Return lists declarations and constraints for OUTPUT component (both intermediate and cipher), for CP xor linear.

This is for xor linear model.

INPUT:

  • modelmodel object (default: None); a model instance

EXAMPLES:

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=22)
sage: output_component = speck.component_from(21, 12)
sage: output_component.cp_xor_linear_mask_propagation_constraints()
(['array[0..31] of var 0..1: cipher_output_21_12_i;',
  'array[0..31] of var 0..1: cipher_output_21_12_o;'],
 ['constraint cipher_output_21_12_o[0] = cipher_output_21_12_i[0];',
  'constraint cipher_output_21_12_o[1] = cipher_output_21_12_i[1];',
  ...
  'constraint cipher_output_21_12_o[30] = cipher_output_21_12_i[30];',
  'constraint cipher_output_21_12_o[31] = cipher_output_21_12_i[31];'])
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
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:

  • modelmodel 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:

  • modelmodel object; a model instance

EXAMPLES:

sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher
sage: from claasp.cipher_modules.models.milp.milp_model import MilpModel
sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=2)
sage: speck = speck.remove_key_schedule()
sage: milp = MilpModel(speck)
sage: milp.init_model_in_sage_milp_class()
sage: output_component = speck.get_component_from_id("cipher_output_1_12")
sage: variables, constraints = output_component.milp_xor_linear_mask_propagation_constraints(milp)
sage: variables
[('x[cipher_output_1_12_0_i]', x_0),
 ('x[cipher_output_1_12_1_i]', x_1),
 ('x[cipher_output_1_12_2_i]', x_2),
...
('x[cipher_output_1_12_30_o]', x_62),
('x[cipher_output_1_12_31_o]', x_63)]
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:

  • modelmodel 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 CIPHER OUTPUT for SAT XOR LINEAR model

See also

SAT standard of Cipher for the format

INPUT:

  • modelmodel object (default: None); a model instance

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_linear_mask_propagation_constraints()
(['cipher_output_2_12_0_i',
  'cipher_output_2_12_1_i',
  ...
  'cipher_output_2_12_30_o',
  'cipher_output_2_12_31_o'],
 ['cipher_output_2_12_0_i -cipher_output_2_12_0_o',
  'cipher_output_2_12_0_o -cipher_output_2_12_0_i',
  ...
  'cipher_output_2_12_31_i -cipher_output_2_12_31_o',
  'cipher_output_2_12_31_o -cipher_output_2_12_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)
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 CIPHER OUTPUT for SMT XOR LINEAR model

INPUT:

  • modelmodel object (default: None); a model instance

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_linear_mask_propagation_constraints()
(['cipher_output_2_12_0_o',
  'cipher_output_2_12_1_o',
  ...
  'cipher_output_2_12_30_i',
  'cipher_output_2_12_31_i'],
 ['(assert (= cipher_output_2_12_0_i cipher_output_2_12_0_o))',
  '(assert (= cipher_output_2_12_1_i cipher_output_2_12_1_o))',
  ...
  '(assert (= cipher_output_2_12_30_i cipher_output_2_12_30_o))',
  '(assert (= cipher_output_2_12_31_i cipher_output_2_12_31_o))'])
property suffixes
property type