Generic functions continuous diffusion analysis¶
- AND_continuous_diffusion_analysis(input_lst, number_of_inputs)¶
Compute the continuous generalization of the and operation [MUR2020].
INPUT:
input_lst– list; is a list of real numbers in the range [-1, 1]number_of_inputs– integer; specify in how many parts must the input be split
- CONSTANT_continuous_diffusion_analysis(input_lst, number_of_outputs)¶
Compute the continuous generalization of a constant operation [MUR2020].
INPUT:
input_lst– list; is a list of real numbers in the range [-1, 1]number_of_inputs– integer; specify the number of elements of the input
- LINEAR_LAYER_continuous_diffusion_analysis(input_lst, linear_matrix)¶
Compute the continuous generalization of a linear_layer operation [MUR2020].
INPUT:
input_lst– list; is a list of real numbers in the range [-1, 1]linear_matrix– list; list of lists containing the matrix representation of the linear operation
- MIX_COLUMN_generalized_continuous_diffusion_analysis(input_lst, mix_column_matrix, sbox_dictionary, word_size)¶
Compute the continuous generalization of a mix_column operation [MUR2020].
INPUT:
input_lst– list; is a list of real numbers in the range [-1, 1]mix_column_matrix– list; matrix representing the mix column matrixsbox_dictionary– dictionary; contains precomputations for the mix column operationword_size– integer; integer representing the word size
EXAMPLES:
sage: from claasp.cipher_modules.generic_functions_continuous_diffusion_analysis import * sage: mix_column_matrix = [[2, 3, 1, 1], [1, 2, 3, 1], [1, 1, 2, 3], [3, 1, 1, 2]] sage: lookup_table_2 = [ ....: 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x10, 0x12, 0x14, 0x16, ....: 0x18, 0x1A, 0x1C, 0x1E, 0x20, 0x22, 0x24, 0x26, 0x28, 0x2A, 0x2C, 0x2E, ....: 0x30, 0x32, 0x34, 0x36, 0x38, 0x3A, 0x3C, 0x3E, 0x40, 0x42, 0x44, 0x46, ....: 0x48, 0x4A, 0x4C, 0x4E, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5A, 0x5C, 0x5E, ....: 0x60, 0x62, 0x64, 0x66, 0x68, 0x6A, 0x6C, 0x6E, 0x70, 0x72, 0x74, 0x76, ....: 0x78, 0x7A, 0x7C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C3, 0xC1, 0xC7, 0xC5, ....: 0xFB, 0xF9, 0xFF, 0xFD, 0xF3, 0xF1, 0xF7, 0xF5, 0xEB, 0xE9, 0xEF, 0xED, ....: 0xE3, 0xE1, 0xE7, 0xE5 ....: ] sage: lookup_table_3 = [ ....: 0x0, 0x3, 0x6, 0x5, 0xc, 0xf, 0xa, 0x9, 0x18, 0x1b, 0x1e, 0x1d, 0x14, ....: 0x17, 0x12, 0x11, 0x30, 0x33, 0x36, 0x35, 0x3c, 0x3f, 0x3a, 0x39, 0x28, ....: 0x2b, 0x2e, 0x2d, 0x24, 0x27, 0x22, 0x21, 0x60, 0x63, 0x66, 0x65, 0x6c, ....: 0x6f, 0x6a, 0x69, 0x78, 0x7b, 0x7e, 0x7d, 0x74, 0x77, 0x72, 0x71, 0x50, ....: 0x53, 0x56, 0x55, 0x5c, 0x5f, 0x5a, 0x59, 0x48, 0x4b, 0x4e, 0x4d, 0x44, ....: 0x47, 0x42, 0x41, 0xc0, 0xc3, 0xc6, 0xc5, 0xcc, 0xcf, 0xca, 0xc9, 0xd8, ....: 0xdb, 0xde, 0xdd, 0xd4, 0xd7, 0xd2, 0xd1, 0xf0, 0xf3, 0xf6, 0xf5, 0xfc, ....: 0xff, 0xfa, 0xf9, 0xe8, 0xeb, 0xee, 0xed, 0xe4, 0xe7, 0xe2, 0xe1, 0xa0, ....: 0xa3, 0xa6, 0xa5, 0xac, 0xaf, 0xaa, 0xa9, 0xb8, 0xbb, 0xbe, 0xbd, 0xb4, ....: 0xb7, 0xb2, 0xb1, 0x90, 0x93, 0x96, 0x95, 0x9c, 0x9f, 0x9a, 0x99, 0x88, ....: 0x8b, 0x8e, 0x8d, 0x84, 0x87, 0x82, 0x81, 0x9b, 0x98, 0x9d, 0x9e, 0x97, ....: 0x94, 0x91, 0x92, 0x83, 0x80, 0x85, 0x86, 0x8f, 0x8c, 0x89, 0x8a, 0xab, ....: 0xa8, 0xad, 0xae, 0xa7, 0xa4, 0xa1, 0xa2, 0xb3, 0xb0, 0xb5, 0xb6, 0xbf, ....: 0xbc, 0xb9, 0xba, 0xfb, 0xf8, 0xfd, 0xfe, 0xf7, 0xf4, 0xf1, 0xf2, 0xe3, ....: 0xe0, 0xe5, 0xe6, 0xef, 0xec, 0xe9, 0xea, 0xcb, 0xc8, 0xcd, 0xce, 0xc7, ....: 0xc4, 0xc1, 0xc2, 0xd3, 0xd0, 0xd5, 0xd6, 0xdf, 0xdc, 0xd9, 0xda, 0x5b, ....: 0x58, 0x5d, 0x5e, 0x57, 0x54, 0x51, 0x52, 0x43, 0x40, 0x45, 0x46, 0x4f, ....: 0x4c, 0x49, 0x4a, 0x6b, 0x68, 0x6d, 0x6e, 0x67, 0x64, 0x61, 0x62, 0x73, ....: 0x70, 0x75, 0x76, 0x7f, 0x7c, 0x79, 0x7a, 0x3b, 0x38, 0x3d, 0x3e, 0x37, ....: 0x34, 0x31, 0x32, 0x23, 0x20, 0x25, 0x26, 0x2f, 0x2c, 0x29, 0x2a, 0xb, ....: 0x8, 0xd, 0xe, 0x7, 0x4, 0x1, 0x2, 0x13, 0x10, 0x15, 0x16, 0x1f, 0x1c, ....: 0x19, 0x1a, ....: ] sage: evaluated_y_list_2, minus1_power_x_s_2 = compute_sbox_precomputations(lookup_table_2) sage: evaluated_y_list_3, minus1_power_x_s_3 = compute_sbox_precomputations(lookup_table_3) sage: sbox_precomputations = {} sage: sbox_precomputations["2"] = {} sage: sbox_precomputations["2"]["evaluated_boolean_function"] = evaluated_y_list_2 sage: sbox_precomputations["2"]["minus1_power_x_t"] = minus1_power_x_s_2 sage: sbox_precomputations["2"]["lookup_table"] = lookup_table_2 sage: sbox_precomputations["3"] = {} sage: sbox_precomputations["3"]["evaluated_boolean_function"] = evaluated_y_list_3 sage: sbox_precomputations["3"]["minus1_power_x_t"] = minus1_power_x_s_3 sage: sbox_precomputations["3"]["lookup_table"] = lookup_table_3 sage: input_lst = [Decimal(float(0.01*i)) for i in range(32)] sage: float(MIX_COLUMN_generalized_continuous_diffusion_analysis( ....: input_lst, mix_column_matrix, sbox_precomputations, 8)[0] ....: ) 3.2256000000000004e-05
- MODADD_continuous_diffusion_analysis(input_lst, number_of_inputs)¶
Compute the continuous generalization of a (or more) modular addition operation(s) [MUR2020].
INPUT:
input_lst– list; is a list of real numbers in the range [-1, 1]number_of_inputs– integer; specify in how many parts must the input be split
- MODADD_continuous_diffusion_analysis_two_words(input_lst)¶
Compute the continuous generalization of a modular addition component [MUR2020].
INPUT:
input_lst– list; is a list of real numbers in the range [-1, 1]
- MODSUB_continuous_diffusion_analysis(input_lst, number_of_inputs)¶
Compute the continuous generalization of a (or more) modular substraction operation (s) [MUR2020].
INPUT:
input_lst– list; is a list of real numbers in the range [-1, 1]number_of_inputs– integer; specify in how many parts must the input be split
- NOT_continuous_diffusion_analysis(input_lst)¶
Compute the continuous generalization of the not operation [MUR2020].
INPUT:
input_lst– list; is a list of real numbers in the range [-1, 1]
- OR_continuous_diffusion_analysis(input_lst, number_of_inputs)¶
Compute the continuous generalization of the or operation [MUR2020].
INPUT:
input_lst– list; is a list of real numbers in the range [-1, 1]number_of_inputs– integer; specify in how many parts must the input be split
- ROTATE_BY_VARIABLE_AMOUNT_continuous_diffusion_analysis(input_lst, input_size, rotation_direction)¶
INPUT:
input_lst– list; a list representing a list of real numbersinput_size– integer; size of the float list to be rotatedrotation_direction– integer; indicates the direction of the rotation, positive for right and negative for left
- ROTATE_continuous_diffusion_analysis(input_lst, rotation_amount)¶
Compute the continuous generalization of the rotate operation [MUR2020].
INPUT:
input_lst– list; a float listrotation_amount– integer; an integer indicating the amount of the rotation, positive for right rotation, negative for left rotation
- SBOX_continuous_diffusion_analysis(input_lst, sbox_precomputations)¶
Compute the continuous generalization of a sbox operation [MUR2020].
INPUT:
input_lst– list; is a list of real numbers in the range [-1, 1]sbox_precomputations– dictionary; is a dictionary containing precomputations for the sbox
EXAMPLES:
sage: from claasp.cipher_modules.generic_functions_continuous_diffusion_analysis import * sage: lookup_table = [ 0,1,5,4,4,7,5,6 ] sage: input_lst = [Decimal(float(0.1)), Decimal(float(0.1)), Decimal(float(0.1))] sage: evaluated_y_list, minus1_power_x_s = compute_sbox_precomputations(lookup_table) sage: sbox_precomputations = {} sage: sbox_precomputations["evaluated_boolean_function"] = evaluated_y_list sage: sbox_precomputations["minus1_power_x_t"] = minus1_power_x_s sage: sbox_precomputations["lookup_table"] = lookup_table sage: output_lst = [ ....: Decimal('-0.0100000000000000011102230245'), ....: Decimal('-0.3949999999999999938937733645'), ....: Decimal('0.595000000000000004996003611') ....: ] sage: SBOX_continuous_diffusion_analysis(input_lst, sbox_precomputations) == output_lst True
- SHIFT_BY_VARIABLE_AMOUNT_continuous_diffusion_analysis(_input, input_size, shift_direction)¶
INPUT:
input– list; a list representing a list of real numbersinput_size– integer; size of the float list to be rotatedshift_direction– integer; an integer indicating the direction of the shift, positive for right and negative for left
EXAMPLES:
sage: from claasp.cipher_modules.generic_functions_continuous_diffusion_analysis import SHIFT_BY_VARIABLE_AMOUNT_continuous_diffusion_analysis sage: from decimal import * sage: _input = [0.01, 0.02, 0.004, 0.01, 0.02] sage: _input = [Decimal(float(_input[i])) for i in range(len(_input))] sage: input_size = 3 sage: shift_direction = -1 sage: output = SHIFT_BY_VARIABLE_AMOUNT_continuous_diffusion_analysis( ....: _input, input_size, shift_direction ....: ) sage: float(output[2]) == -0.44658816949 True
- SHIFT_continuous_diffusion_analysis(input_lst, shift_amount)¶
Compute the continuous generalization of the shit operation [MUR2020].
INPUT:
input_lst– list; a BitArray representing a binary stringshift_amount– integer; an integer indicating the amount of the shift, positive for right shift, negative for left shift
- SIGMA_continuous_diffusion_analysis(input_lst, rotation_amounts)¶
INPUT:
input_lst– list; a list representing a list of real numbersrotation_amounts– list; list indicating the amount of the rotations
- XOR_continuous_diffusion_analysis(input_lst, number_of_inputs)¶
Compute the continuous generalization of a (or more) xor operation(s) [MUR2020].
INPUT:
input_lst– list; is a list of real numbers in the range [-1, 1]number_of_inputs– integer; specify in how many parts must the input be split
- XOR_continuous_diffusion_analysis_two_words(input_lst)¶
Compute the continuous generalization of a xor operation [MUR2020].
INPUT:
input_lst– list; is a list of real numbers in the range [-1, 1]
- compute_sbox_precomputations(sbox_lookup_table)¶
Compute precomputations for the extended sbox operation.
This method evaluates all possible values of y using the Boolean function f in Theorem 1 [MUR2020]. Also, this function computes all values (-1)^y_i in that theorem.
- create_lookup_table_by_matrix(mix_column_matrix, irreducible_polynomial_int_repr, degree)¶
- create_lookup_table_for_finite_field_element(degree, element, k)¶
Creates a lookup table for an element of the finite field k.
- extended_and_bit(a, b)¶
- extended_left_rotation_by_variable_amount(input_lst, rotation_amount_lst)¶
- extended_left_shift_by_variable_amount(input_lst, shift_amount_lst)¶
- extended_not_bit(input_bit)¶
- extended_one_left_rotation_iteration(input_lst, rotation_amount, rotation_stage)¶
- extended_one_left_shift_iteration(input_lst, shift_amount, shift_stage)¶
- extended_one_right_rotation_iteration(input_lst, rotation_amount, shift_stage)¶
- extended_one_right_shift_iteration(input_lst, shift_amount, shift_stage)¶
- extended_right_rotation_by_variable_amount(input_lst, rotation_amount_lst)¶
- extended_right_shift_by_variable_amount(input_lst, shift_amount_lst)¶
- extended_two_bit_multiplexer(input_lst)¶
- get_mix_column_precomputations(mix_column_components)¶
- get_sbox_precomputations(sbox_components)¶
- select_bits_continuous_diffusion_analysis(input_lst, bit_positions)¶