Variable shift component¶
- class VariableShift(current_round_number, current_round_number_of_components, input_id_links, input_bit_positions, output_bit_size, parameter)¶
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 SHIFT BY VARIABLE AMOUNT in CMS CIPHER model.
See also
SAT standard of Cipher for the format.
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.raiden_block_cipher import RaidenBlockCipher sage: raiden = RaidenBlockCipher(number_of_rounds=3) sage: variable_shift_component = raiden.component_from(0, 2) sage: variable_shift_component.cms_constraints() (['var_shift_0_2_0', 'var_shift_0_2_1', 'var_shift_0_2_2', ... '-var_shift_0_2_31 state_3_var_shift_0_2_31', '-var_shift_0_2_31 -key_91', 'var_shift_0_2_31 -state_3_var_shift_0_2_31 key_91'])
- cp_constraints()¶
Return lists of declarations and constraints for SHIFT BY VARIABLE AMOUNT component for CP CIPHER model.
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.raiden_block_cipher import RaidenBlockCipher sage: raiden = RaidenBlockCipher(number_of_rounds=3) sage: variable_shift_component = raiden.component_from(0, 2) sage: variable_shift_component.cp_constraints() (['array[0..31] of var 0..1: pre_var_shift_0_2;', 'var int: shift_amount_var_shift_0_2;'], ['constraint pre_var_shift_0_2[0]=key[0];', ... 'constraint pre_var_shift_0_2[31]=key[31];', 'constraint bitArrayToInt([key[i]|i in 91..95],shift_amount_var_shift_0_2);', 'constraint var_shift_0_2=LShift(pre_var_shift_0_2,shift_amount_var_shift_0_2);'])
- 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)¶
- minizinc_xor_differential_propagation_constraints(model)¶
Return variables and constraints for the component SHIFT BY VARIABLE AMOUNT for MINIZINC xor differential.
INPUT:
model– model object; a model instance
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.raiden_block_cipher import RaidenBlockCipher sage: from claasp.cipher_modules.models.cp.mzn_model import MznModel sage: raiden = RaidenBlockCipher(number_of_rounds=16) sage: minizinc = MznModel(raiden) sage: variable_shift_component = raiden.component_from(0, 2) sage: _, mzn_shift_by_variable_amount_constraints = variable_shift_component.minizinc_xor_differential_propagation_constraints(minizinc) sage: mzn_shift_by_variable_amount_constraints[0] 'constraint LSHIFT_BY_VARIABLE_AMOUNT(array1d(0..32-1, [var_shift_0_2_x0,var_shift_0_2_x1,var_shift_0_2_x2,var_shift_0_2_x3,var_shift_0_2_x4,var_shift_0_2_x5,var_shift_0_2_x6,var_shift_0_2_x7,var_shift_0_2_x8,var_shift_0_2_x9,var_shift_0_2_x10,var_shift_0_2_x11,var_shift_0_2_x12,var_shift_0_2_x13,var_shift_0_2_x14,var_shift_0_2_x15,var_shift_0_2_x16,var_shift_0_2_x17,var_shift_0_2_x18,var_shift_0_2_x19,var_shift_0_2_x20,var_shift_0_2_x21,var_shift_0_2_x22,var_shift_0_2_x23,var_shift_0_2_x24,var_shift_0_2_x25,var_shift_0_2_x26,var_shift_0_2_x27,var_shift_0_2_x28,var_shift_0_2_x29,var_shift_0_2_x30,var_shift_0_2_x31]), 2147483648*var_shift_0_2_x63+1073741824*var_shift_0_2_x62+536870912*var_shift_0_2_x61+268435456*var_shift_0_2_x60+134217728*var_shift_0_2_x59+67108864*var_shift_0_2_x58+33554432*var_shift_0_2_x57+16777216*var_shift_0_2_x56+8388608*var_shift_0_2_x55+4194304*var_shift_0_2_x54+2097152*var_shift_0_2_x53+1048576*var_shift_0_2_x52+524288*var_shift_0_2_x51+262144*var_shift_0_2_x50+131072*var_shift_0_2_x49+65536*var_shift_0_2_x48+32768*var_shift_0_2_x47+16384*var_shift_0_2_x46+8192*var_shift_0_2_x45+4096*var_shift_0_2_x44+2048*var_shift_0_2_x43+1024*var_shift_0_2_x42+512*var_shift_0_2_x41+256*var_shift_0_2_x40+128*var_shift_0_2_x39+64*var_shift_0_2_x38+32*var_shift_0_2_x37+16*var_shift_0_2_x36+8*var_shift_0_2_x35+4*var_shift_0_2_x34+2*var_shift_0_2_x33+1*var_shift_0_2_x32)=array1d(0..32-1, [var_shift_0_2_y0,var_shift_0_2_y1,var_shift_0_2_y2,var_shift_0_2_y3,var_shift_0_2_y4,var_shift_0_2_y5,var_shift_0_2_y6,var_shift_0_2_y7,var_shift_0_2_y8,var_shift_0_2_y9,var_shift_0_2_y10,var_shift_0_2_y11,var_shift_0_2_y12,var_shift_0_2_y13,var_shift_0_2_y14,var_shift_0_2_y15,var_shift_0_2_y16,var_shift_0_2_y17,var_shift_0_2_y18,var_shift_0_2_y19,var_shift_0_2_y20,var_shift_0_2_y21,var_shift_0_2_y22,var_shift_0_2_y23,var_shift_0_2_y24,var_shift_0_2_y25,var_shift_0_2_y26,var_shift_0_2_y27,var_shift_0_2_y28,var_shift_0_2_y29,var_shift_0_2_y30,var_shift_0_2_y31]);\n'
- 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_constraints()¶
Return a list of variables and a list of clauses representing SHIFT BY VARIABLE AMOUNT for SAT CIPHER model
See also
SAT standard of Cipher for the format.
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.raiden_block_cipher import RaidenBlockCipher sage: raiden = RaidenBlockCipher(number_of_rounds=3) sage: variable_shift_component = raiden.component_from(0, 2) sage: variable_shift_component.sat_constraints() (['var_shift_0_2_0', 'var_shift_0_2_1', ... 'var_shift_0_2_30', 'var_shift_0_2_31'], ['-state_0_var_shift_0_2_0 key_0 key_95', 'state_0_var_shift_0_2_0 -key_0 key_95', ... '-var_shift_0_2_31 -key_91', 'var_shift_0_2_31 -state_3_var_shift_0_2_31 key_91'])
- 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 SHIFT BY VARIABLE AMOUNT for SMT CIPHER model
INPUT:
None
EXAMPLES:
sage: from claasp.ciphers.block_ciphers.raiden_block_cipher import RaidenBlockCipher sage: raiden = RaidenBlockCipher(number_of_rounds=3) sage: variable_shift_component = raiden.component_from(0, 2) sage: variable_shift_component.smt_constraints() (['state_0_var_shift_0_2_0', 'state_0_var_shift_0_2_1', ... 'var_shift_0_2_30', 'var_shift_0_2_31'], ['(assert (ite key_95 (= state_0_var_shift_0_2_0 key_1) (= state_0_var_shift_0_2_0 key_0)))', '(assert (ite key_95 (= state_0_var_shift_0_2_1 key_2) (= state_0_var_shift_0_2_1 key_1)))', ... '(assert (ite key_91 (not var_shift_0_2_30) (= var_shift_0_2_30 state_3_var_shift_0_2_30)))', '(assert (ite key_91 (not var_shift_0_2_31) (= var_shift_0_2_31 state_3_var_shift_0_2_31)))'])
- property suffixes¶
- property type¶