Generic functions vectorized bit

bit_vector_AND(input, number_of_inputs, output_bit_size, verbosity=False)

Computes the AND operation on binary vectors

INPUT:

  • inputlist; A list of binary numpy matrices to be ANDed, each with one row per bit, and one column per sample.

  • number_of_inputsinteger; is an integer representing the number of values to be xored together

  • output_bit_sizeinteger; is an integer representing the bit size of the output

  • verbosityboolean; (default: False); set this flag to True to print the input/output

bit_vector_CONCAT(input)

Concatenates binary values

INPUT:

  • inputlist; A list of binary numpy matrices to be concatenated, each with one row per bit, and one column per sample.

bit_vector_MODADD(input, number_of_inputs, output_bit_size, verbosity=False)

Computes modular addition of binary inputs.

INPUT:

  • inputlist; A list of binary numpy matrices to be added, each with one row per bit, and one column per sample.

  • number_of_inputsinteger; is an integer representing the number of values to be added together

  • output_bit_sizeinteger; is an integer representing the bit size of the output

  • verbosityboolean; (default: False); set this flag to True to print the input/output

bit_vector_MODSUB(input, number_of_inputs, output_bit_size, verbosity=False)

Computes the modular subtraction of 2 binary inputs

INPUT:

  • inputlist; A list of binary numpy matrices to be subtracted, each with one row per bit, and one column per sample.

  • number_of_inputsinteger; is an integer representing the number of values to be subtracted

  • output_bit_sizeinteger; is an integer representing the bit size of the output

  • verbosityboolean; (default: False); set this flag to True to print the input/output

bit_vector_NOT(input, verbosity=False)

Computes the NOT operation on binary values

INPUT:

  • input – – np.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.

  • verbosityboolean; (default: False); set this flag to True to print the input/output

bit_vector_OR(input, number_of_inputs, output_bit_size, verbosity=False)

Computes the OR operation on binary values

INPUT:

  • inputlist; A list of binary numpy matrices to be ORed, each with one row per bit, and one column per sample.

  • number_of_inputsinteger; is an integer representing the number of values to be xored together

  • output_bit_sizeinteger; is an integer representing the bit size of the output

  • verbosityboolean; (default: False); set this flag to True to print the input/output

bit_vector_ROTATE(input, rotation_amount, verbosity=False)

Computes the rotation of binary values.

INPUT:

  • inputnp.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.

  • rotation_amountinteger; the value of the rotation, positive for right rotation,

    negative for left rotation

  • verbosityboolean; (default: False); set this flag to True to print the input/output

bit_vector_SBOX(input, sbox, verbosity=False, output_bit_size=None)

Computes the SBox operation on binary values.

INPUT:

  • inputnp.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.

  • sboxnp.array(dtype = np.uint8) An integer numpy array representing the SBox.

  • verbosityboolean; (default: False); set this flag to True to print the input/output

bit_vector_SHIFT(input, shift_amount, verbosity=False)

Computes the shift of binary values. INPUT:

  • inputnp.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.

  • shift_amountinteger; the value of the shift, positive for right rotation,

    negative for left rotation

  • verbosityboolean; (default: False); set this flag to True to print the input/output

bit_vector_SHIFT_BY_VARIABLE_AMOUNT(input, input_size, shift_direction, verbosity=False)

Computes the shift by variable amount of binary values

INPUT:

  • input – – np.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.

  • input_sizeinteger; number of bits of the input string

  • shift_directioninteger; the value of the shift, positive for right and

    negative for left

  • verbosityboolean; (default: False); set this flag to True to print the input/output

bit_vector_XOR(input, number_of_inputs, output_bit_size, verbosity=False)

Computes the XOR operation on binary values.

INPUT:

  • inputlist; A list of binary numpy matrices to be XORed, each with one row per bit, and one column per sample.

  • number_of_inputsinteger; is an integer representing the number of values to be xored together

  • output_bit_sizeinteger; is an integer representing the bit size of the output

  • verbosityboolean; (default: False); set this flag to True to print the input/output

bit_vector_linear_layer(input, matrix, verbosity=False)

Computes the linear layer operation on binary values INPUT:

  • inputnp.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.

  • matrixlist; a list of lists of 0s and 1s. len(matrix) should be equal to input.len

  • verbosityboolean; (default: False); set this flag to True to print the input/output

bit_vector_mix_column(input, matrix, mul_table, input_size, verbosity=False)

Computes the mixcolumn operation on binary values

INPUT:

  • inputnp.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.

  • matrixlist; a list of lists of 0s and 1s. len(matrix) should be equal to input.len

  • mul_tablesdictionary; a dictionary such that mul_tables[x] is the multiplication table by x

  • input_sizeinteger; an integer giving the bit size of the words

  • verbosityboolean; (default: False); set this flag to True to print the input/output

bit_vector_mix_column_poly0(input, matrix, verbosity=False)

Computes the mixcolumn operation on binary values, for the special case where the polynomial is 0.

INPUT:

  • inputnp.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.

  • matrixlist; a list of lists of 0s and 1s. len(matrix) should be equal to input.len

  • verbosityboolean; (default: False); set this flag to True to print the input/output

bit_vector_print_as_hex_values(name, x)

Prints a binary vector x as an hex value - used for debugging INPUT:

  • namestring The name of the vector, for display purposes

  • xnp.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per word.

bit_vector_select_word(input, bits, verbosity=False)

Returns the bits indexed in the bits list from the binary matrix input.

INPUT:

  • inputnp.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.

  • bitslist; is the array representing the indexes of the bits to extract

  • verbosityboolean; (default: False); set this flag to True to print the input/output

bit_vector_to_integer(arr)

Converts a set of m bit strings of n bits (n <= 64) to m 64-bit unsigned integers

INPUT:

  • arrnp.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per word.

print_component_info(input, output, component_type)