From c220ee15d93fd550a3a4da6026c6c681fa09be36 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 16 Dec 2023 09:07:24 +0400 Subject: [PATCH] Fixed type bug --- claasp/cipher_modules/code_generator.py | 6 ------ claasp/cipher_modules/neural_network_tests.py | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/claasp/cipher_modules/code_generator.py b/claasp/cipher_modules/code_generator.py index b15fc2b0..ddb407af 100644 --- a/claasp/cipher_modules/code_generator.py +++ b/claasp/cipher_modules/code_generator.py @@ -248,7 +248,6 @@ def generate_bit_based_vectorized_python_code_string(cipher, store_intermediate_ code.extend([f' {cipher.inputs[i]}=input[{i}]' for i in range(len(cipher.inputs))]) for component in cipher.get_all_components(): - start = time.time() params = prepare_input_bit_based_vectorized_python_code_string(component) component_types_allowed = ['constant', 'linear_layer', 'concatenate', 'mix_column', 'sbox', 'cipher_output', 'intermediate_output', 'fsr'] @@ -260,8 +259,6 @@ def generate_bit_based_vectorized_python_code_string(cipher, store_intermediate_ name = component.id if verbosity and component.type != 'constant': code.append(f' bit_vector_print_as_hex_values("{name}_output", {name})') - end=time.time() - print(f'{component.id} time = {end-start}') if store_intermediate_outputs: code.append(' return intermediateOutputs') elif CIPHER_INVERSE_SUFFIX in cipher.id: @@ -319,7 +316,6 @@ def generate_byte_based_vectorized_python_code_string(cipher, store_intermediate code.append(f' {cipher.inputs[i]}=input[{i}]') bit_sizes[cipher.inputs[i]] = cipher.inputs_bit_size[i] for component in cipher.get_all_components(): - start = time.time() params = prepare_input_byte_based_vectorized_python_code_string(bit_sizes, component) bit_sizes[component.id] = component.output_bit_size component_types_allowed = ['constant', 'linear_layer', 'concatenate', 'mix_column', @@ -335,8 +331,6 @@ def generate_byte_based_vectorized_python_code_string(cipher, store_intermediate if verbosity and component.type != 'constant': code.append(f' byte_vector_print_as_hex_values("{name}_input", {params})') code.append(f' byte_vector_print_as_hex_values("{name}_output", {name})') - end=time.time() - print(f'{component.id} time = {end-start}') if store_intermediate_outputs: code.append(' return intermediateOutputs') elif CIPHER_INVERSE_SUFFIX in cipher.id: diff --git a/claasp/cipher_modules/neural_network_tests.py b/claasp/cipher_modules/neural_network_tests.py index 40ecbf35..c3a50abc 100644 --- a/claasp/cipher_modules/neural_network_tests.py +++ b/claasp/cipher_modules/neural_network_tests.py @@ -313,7 +313,7 @@ def train_neural_distinguisher(cipher, data_generator, starting_round, neural_ne bs = 5000 x, y = data_generator(samples=training_samples, nr=starting_round) x_eval, y_eval = data_generator(samples=testing_samples, nr=starting_round) - h = neural_network.fit(x, y, epochs=num_epochs, batch_size=bs, validation_data=(x_eval, y_eval)) + h = neural_network.fit(x, y, epochs=int(num_epochs), batch_size=bs, validation_data=(x_eval, y_eval)) acc = np.max(h.history["val_acc"]) print(f'Validation accuracy at {starting_round} rounds :{acc}') return acc