Generic functions vectorized bit¶
- bit_vector_AND(input, number_of_inputs, output_bit_size, verbosity=False)¶
Computes the AND operation on binary vectors
INPUT:
input– list; A list of binary numpy matrices to be ANDed, each with one row per bit, and one column per sample.number_of_inputs– integer; is an integer representing the number of values to be xored togetheroutput_bit_size– integer; is an integer representing the bit size of the outputverbosity– boolean; (default: False); set this flag to True to print the input/output
- bit_vector_CONCAT(input)¶
Concatenates binary values
INPUT:
input– list; 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:
input– list; A list of binary numpy matrices to be added, each with one row per bit, and one column per sample.number_of_inputs– integer; is an integer representing the number of values to be added togetheroutput_bit_size– integer; is an integer representing the bit size of the outputverbosity– boolean; (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:
input– list; A list of binary numpy matrices to be subtracted, each with one row per bit, and one column per sample.number_of_inputs– integer; is an integer representing the number of values to be subtractedoutput_bit_size– integer; is an integer representing the bit size of the outputverbosity– boolean; (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.verbosity– boolean; (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:
input– list; A list of binary numpy matrices to be ORed, each with one row per bit, and one column per sample.number_of_inputs– integer; is an integer representing the number of values to be xored togetheroutput_bit_size– integer; is an integer representing the bit size of the outputverbosity– boolean; (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:
input– np.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.rotation_amount– integer; the value of the rotation, positive for right rotation,negative for left rotation
verbosity– boolean; (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:
input– np.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.sbox– np.array(dtype = np.uint8) An integer numpy array representing the SBox.verbosity– boolean; (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:
input– np.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.shift_amount– integer; the value of the shift, positive for right rotation,negative for left rotation
verbosity– boolean; (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_size– integer; number of bits of the input stringshift_direction– integer; the value of the shift, positive for right andnegative for left
verbosity– boolean; (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:
input– list; A list of binary numpy matrices to be XORed, each with one row per bit, and one column per sample.number_of_inputs– integer; is an integer representing the number of values to be xored togetheroutput_bit_size– integer; is an integer representing the bit size of the outputverbosity– boolean; (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:
input– np.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.matrix– list; a list of lists of 0s and 1s. len(matrix) should be equal to input.lenverbosity– boolean; (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:
input– np.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.matrix– list; a list of lists of 0s and 1s. len(matrix) should be equal to input.lenmul_tables– dictionary; a dictionary such that mul_tables[x] is the multiplication table by xinput_size– integer; an integer giving the bit size of the wordsverbosity– boolean; (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:
input– np.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.matrix– list; a list of lists of 0s and 1s. len(matrix) should be equal to input.lenverbosity– boolean; (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:
name– string The name of the vector, for display purposesx– np.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:
input– np.array(dtype = np.uint8) A binary numpy matrix with one row per bit, and one column per sample.bits– list; is the array representing the indexes of the bits to extractverbosity– boolean; (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:
arr– np.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)¶