Rotate component¶
- class Rotate(current_round_number, current_round_number_of_components, input_id_links, input_bit_positions, output_bit_size, parameter)¶
Bases:
Component- algebraic_polynomials(model)¶
Return a list of polynomials for bitwise ROTATION.
INPUT:
model– model object; a model instance
EXAMPLES:
sage: from claasp.ciphers.toys.fancy_block_cipher import FancyBlockCipher sage: from claasp.cipher_modules.models.algebraic.algebraic_model import AlgebraicModel sage: fancy = FancyBlockCipher(number_of_rounds=2) sage: rotate_component = fancy.get_component_from_id("rot_1_11") sage: algebraic = AlgebraicModel(fancy) sage: rotate_component.algebraic_polynomials(algebraic) [rot_1_11_y0 + rot_1_11_x3, rot_1_11_y1 + rot_1_11_x4, rot_1_11_y2 + rot_1_11_x5, rot_1_11_y3 + rot_1_11_x0, rot_1_11_y4 + rot_1_11_x1, rot_1_11_y5 + rot_1_11_x2]
- 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 ROTATION in CMS 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: rotate_component = speck.component_from(1, 1) sage: rotate_component.cms_constraints() (['rot_1_1_0', 'rot_1_1_1', 'rot_1_1_2', ... 'key_39 -rot_1_1_14', 'rot_1_1_15 -key_40', 'key_40 -rot_1_1_15'])
- cms_xor_differential_propagation_constraints(model=None)¶
- cms_xor_linear_mask_propagation_constraints(model=None)¶
- cp_constraints()¶
Return lists of declarations and constraints for ROTATE component for CP CIPHER model.
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(number_of_rounds=3) sage: rotate_component = speck.component_from(0, 0) sage: rotate_component.cp_constraints() ([], ['constraint rot_0_0[0] = plaintext[9];', ... 'constraint rot_0_0[15] = plaintext[8];'])
- cp_deterministic_truncated_xor_differential_trail_constraints()¶
- cp_inverse_constraints()¶
Return lists of declarations and constraints for ROTATE component for CP INVERSE CIPHER model.
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(number_of_rounds=3) sage: rotate_component = speck.component_from(0, 0) sage: rotate_component.cp_inverse_constraints() ([], ['constraint rot_0_0_inverse[0] = plaintext[9];', ... 'constraint rot_0_0_inverse[15] = plaintext[8];'])
- cp_wordwise_deterministic_truncated_xor_differential_constraints(model)¶
- cp_xor_differential_first_step_constraints(model)¶
Return lists of declarations and constraints for ROTATE component for the CP xor differential 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: rotate_component = aes.component_from(0, 18) sage: rotate_component.cp_xor_differential_first_step_constraints(cp) (['array[0..3] of var 0..1: rot_0_18;'], ['constraint rot_0_18[0] = sbox_0_6[0];', 'constraint rot_0_18[1] = sbox_0_10[0];', 'constraint rot_0_18[2] = sbox_0_14[0];', 'constraint rot_0_18[3] = sbox_0_2[0];'])
- cp_xor_differential_propagation_constraints(model=None)¶
- cp_xor_differential_propagation_first_step_constraints(model)¶
- cp_xor_linear_mask_propagation_constraints(model=None)¶
Return lists of declarations and constraints for ROTATE component for CP xor linear model.
INPUT:
model– model 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=4) sage: rotate_component = speck.component_from(0, 0) sage: rotate_component.cp_xor_linear_mask_propagation_constraints() (['array[0..15] of var 0..1: rot_0_0_i;', 'array[0..15] of var 0..1: rot_0_0_o;'], ['constraint rot_0_0_o[0]=rot_0_0_i[9];', ... 'constraint rot_0_0_o[15]=rot_0_0_i[8];'])
- property description¶
- get_bit_based_vectorized_python_code(params, convert_output_to_bytes)¶
- get_byte_based_vectorized_python_code(params)¶
- get_graph_representation()¶
- get_word_based_c_code(verbosity, word_size, wordstring_variables)¶
- get_word_operation_sign(sign, solution)¶
- 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 constrains modeling a component of type Rotate for the deterministic truncated xor differential model.
INPUTS:
component– dict, the rotate component in Graph Representation of a cipher
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: cipher = SpeckBlockCipher(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(cipher) sage: milp.init_model_in_sage_milp_class() sage: rotate_component = cipher.get_component_from_id("rot_1_1") sage: variables, constraints = rotate_component.milp_bitwise_deterministic_truncated_xor_differential_constraints(milp) sage: variables [('x_class[key_32]', x_0), ('x_class[key_33]', x_1), ... ('x_class[rot_1_1_14]', x_30), ('x_class[rot_1_1_15]', x_31)] sage: constraints [x_16 == x_9, x_17 == x_10, ... x_30 == x_7, x_31 == x_8]
- milp_constraints(model)¶
Return a list of variables and a list of constrains modeling a component of type ROTATE for MILP CIPHER 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.milp.milp_model import MilpModel sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=2) sage: milp = MilpModel(speck) sage: milp.init_model_in_sage_milp_class() sage: rotate_component = speck.get_component_from_id("rot_1_1") sage: variables, constraints = rotate_component.milp_constraints(milp) sage: variables [('x[key_32]', x_0), ('x[key_33]', x_1), ... ('x[rot_1_1_14]', x_30), ('x[rot_1_1_15]', x_31)] sage: constraints [x_16 == x_9, x_17 == x_10, ... x_30 == x_7, x_31 == x_8]
- milp_wordwise_deterministic_truncated_xor_differential_constraints(model)¶
Returns a list of variables and a list of constrains modeling a component of type Rotate for the deterministic truncated xor differential model.
INPUTS:
component– dict, the rotate component in Graph Representation of a cipher
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.aes_block_cipher import AESBlockCipher sage: cipher = AESBlockCipher(number_of_rounds=3) sage: from claasp.cipher_modules.models.milp.milp_models.milp_wordwise_deterministic_truncated_xor_differential_model import MilpWordwiseDeterministicTruncatedXorDifferentialModel sage: milp = MilpWordwiseDeterministicTruncatedXorDifferentialModel(cipher) sage: milp.init_model_in_sage_milp_class() sage: rotate_component = cipher.get_component_from_id("rot_0_18") sage: variables, constraints = rotate_component.milp_wordwise_deterministic_truncated_xor_differential_constraints(milp) sage: variables [('x_class[sbox_0_2_word_0_class]', x_0), ('x_class[sbox_0_6_word_0_class]', x_1), ... ('x[rot_0_18_30]', x_70), ('x[rot_0_18_31]', x_71)] sage: constraints [x_4 == x_1, x_5 == x_2, ... x_70 == x_14, x_71 == x_15]
- milp_xor_differential_propagation_constraints(model)¶
- milp_xor_linear_mask_propagation_constraints(model)¶
Return a list of variables and a list of constraints for ROTATE operation in MILP 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.milp.milp_model import MilpModel sage: speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=2) sage: milp = MilpModel(speck) sage: milp.init_model_in_sage_milp_class() sage: rotate_component = speck.get_component_from_id("rot_1_1") sage: variables, constraints = rotate_component.milp_xor_linear_mask_propagation_constraints(milp) sage: variables [('x[rot_1_1_0_i]', x_0), ('x[rot_1_1_1_i]', x_1), ... ('x[rot_1_1_14_o]', x_30), ('x[rot_1_1_15_o]', x_31)] sage: constraints [x_16 == x_9, x_17 == x_10, ... x_30 == x_7, x_31 == x_8]
- minizinc_constraints(model)¶
Return variables and constraints for the component ROTATE for MINIZINC CIPHER model.
INPUT:
model– model object; a model instance
EXAMPLES:
sage: from claasp.ciphers.toys.fancy_block_cipher import FancyBlockCipher sage: from claasp.cipher_modules.models.cp.mzn_model import MznModel sage: fancy = FancyBlockCipher(number_of_rounds=2) sage: minizinc = MznModel(fancy) sage: rotate_component = fancy.get_component_from_id("rot_1_11") sage: _, rotate_mzn_constraints = rotate_component.minizinc_constraints(minizinc) sage: rotate_mzn_constraints[0] 'constraint LRot(array1d(0..6-1, [rot_1_11_x0,rot_1_11_x1,rot_1_11_x2,rot_1_11_x3,rot_1_11_x4,rot_1_11_x5]), 3)=array1d(0..6-1, [rot_1_11_y0,rot_1_11_y1,rot_1_11_y2,rot_1_11_y3,rot_1_11_y4,rot_1_11_y5]);\n'
- 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 ROTATION for SAT DETERMINISTIC TRUNCATED XOR DIFFERENTIAL model
Note that encoding symbols for deterministic truncated XOR differential model requires two variables per each symbol.
See also
SAT standard of Cipher for the format.
sat_constraints()for the model.
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(number_of_rounds=3) sage: rotate_component = speck.component_from(1, 1) sage: rotate_component.sat_bitwise_deterministic_truncated_xor_differential_constraints() (['rot_1_1_0_0', 'rot_1_1_1_0', ... 'rot_1_1_14_1', 'rot_1_1_15_1'], ['rot_1_1_0_0 -key_41_0', 'key_41_0 -rot_1_1_0_0', ... 'rot_1_1_15_1 -key_40_1', 'key_40_1 -rot_1_1_15_1'])
- sat_constraints()¶
Return a list of variables and a list of clauses representing ROTATION for SAT CIPHER model
The list of clauses encodes equalities ensuring that input variables are correctly positioned in the output. Each clause represents a logical condition where input variables are mapped to their corresponding output positions through rotation.
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: rotate_component = speck.component_from(1, 1) sage: rotate_component.sat_constraints() (['rot_1_1_0', 'rot_1_1_1', ... 'rot_1_1_14', 'rot_1_1_15'], ['rot_1_1_0 -key_41', 'key_41 -rot_1_1_0', ... 'rot_1_1_15 -key_40', 'key_40 -rot_1_1_15'])
- 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 ROTATION for SAT XOR DIFFERENTIAL model
See also
SAT standard of Cipher for the format.
sat_constraints()for the model.
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(number_of_rounds=3) sage: rotate_component = speck.component_from(1, 1) sage: rotate_component.sat_xor_differential_propagation_constraints() (['rot_1_1_0', 'rot_1_1_1', ... 'rot_1_1_14', 'rot_1_1_15'], ['rot_1_1_0 -key_41', 'key_41 -rot_1_1_0', ... 'rot_1_1_15 -key_40', 'key_40 -rot_1_1_15'])
- sat_xor_linear_mask_propagation_constraints(model=None)¶
Return a list of variables and a list of clauses representing ROTATION for SAT XOR LINEAR model
Note that encoding symbols for deterministic truncated XOR differential model requires different encodings for input and ouput variables.
See also
SAT standard of Cipher for the format.
sat_constraints()for the model.
INPUT:
model– model 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: rotate_component = speck.component_from(1, 1) sage: rotate_component.sat_xor_linear_mask_propagation_constraints() (['rot_1_1_0_i', 'rot_1_1_1_i', ... 'rot_1_1_14_o', 'rot_1_1_15_o'], ['rot_1_1_0_o -rot_1_1_9_i', 'rot_1_1_9_i -rot_1_1_0_o', ... 'rot_1_1_15_o -rot_1_1_8_i', 'rot_1_1_8_i -rot_1_1_15_o'])
- 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 ROTATION for SMT CIPHER model
The list of asserts encodes equalities ensuring that input variables are correctly positioned in the output. Each assert represents a condition where input variables are mapped to their corresponding output positions through rotation.
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(number_of_rounds=3) sage: rotate_component = speck.component_from(0, 0) sage: rotate_component.smt_constraints() (['rot_0_0_0', 'rot_0_0_1', ... 'rot_0_0_14', 'rot_0_0_15'], ['(assert (= rot_0_0_0 plaintext_9))', '(assert (= rot_0_0_1 plaintext_10))', ... '(assert (= rot_0_0_14 plaintext_7))', '(assert (= rot_0_0_15 plaintext_8))'])
- smt_xor_differential_propagation_constraints(model=None)¶
Return a variable list and SMT-LIB list asserts representing ROTATION for SMT CIPHER model
See also
smt_constraints()for the model.INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher sage: speck = SpeckBlockCipher(number_of_rounds=3) sage: rotate_component = speck.component_from(0, 0) sage: rotate_component.smt_xor_differential_propagation_constraints() (['rot_0_0_0', 'rot_0_0_1', ... 'rot_0_0_14', 'rot_0_0_15'], ['(assert (= rot_0_0_0 plaintext_9))', '(assert (= rot_0_0_1 plaintext_10))', ... '(assert (= rot_0_0_14 plaintext_7))', '(assert (= rot_0_0_15 plaintext_8))'])
- smt_xor_linear_mask_propagation_constraints(model=None)¶
Return a variable list and SMT-LIB list asserts representing ROTATION for SMT XOR LINEAR model
Note that encoding symbols for deterministic truncated XOR differential model requires different encodings for input and ouput variables.
See also
smt_constraints()for the model.INPUT:
model– model 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: rotate_component = speck.component_from(0, 0) sage: rotate_component.smt_xor_linear_mask_propagation_constraints() (['rot_0_0_0_i', 'rot_0_0_1_i', ... 'rot_0_0_14_o', 'rot_0_0_15_o'], ['(assert (= rot_0_0_0_o rot_0_0_9_i))', '(assert (= rot_0_0_1_o rot_0_0_10_i))', ... '(assert (= rot_0_0_14_o rot_0_0_7_i))', '(assert (= rot_0_0_15_o rot_0_0_8_i))'])
- property suffixes¶
- property type¶