Continuous diffusion analysis

class ContinuousDiffusionAnalysis(cipher)

Bases: object

continuous_avalanche_factor(lambda_value, number_of_samples, seed=None, number_of_processors=1)

Continuous generalization of the metric Avalanche Factor. This method implements Definition 14 of [MUR2020].

INPUT:

  • lambda_valuefloat; threshold value used to express the input difference

  • number_of_samplesinteger; number of samples used to compute the continuous avalanche factor

  • seedinteger; RNG seed

  • number_of_processorsinteger; number of processes to use for parallelization

EXAMPLES:

sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher as speck
sage: from claasp.cipher_modules.continuous_diffusion_analysis import ContinuousDiffusionAnalysis
sage: speck_cipher = speck(number_of_rounds=2)
sage: cda = ContinuousDiffusionAnalysis(speck_cipher)
sage: result = cda.continuous_avalanche_factor(0.001, 10)
sage: result['plaintext']['round_key_output']['continuous_avalanche_factor']['values'][0]
0.0
continuous_diffusion_factor(beta_number_of_samples, gf_number_samples, seed=None, number_of_processors=1)

Continuous Diffusion Factor. This method implements Definition 16 of [MUR2020].

INPUT:

  • beta_number_of_samplesinteger; number of samples used to compute the continuous measure metric

  • gf_number_samplesinteger; number of vectors used to approximate gf_2

  • seedinteger; RNG seed

  • number_of_processorsinteger; number of processes to use for parallelization

EXAMPLES:

sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher as speck
sage: from claasp.cipher_modules.continuous_diffusion_analysis import ContinuousDiffusionAnalysis
sage: speck_cipher = speck(number_of_rounds=2) # long time
sage: cda = ContinuousDiffusionAnalysis(speck_cipher) # doctest: +SKIP
sage: output = cda.continuous_diffusion_factor(5, 20) # long time # doctest: +SKIP
sage: output['plaintext']['cipher_output']['diffusion_factor']['values'][0] > 0 # long time # doctest: +SKIP
True
continuous_diffusion_tests(continuous_avalanche_factor_number_of_samples=100, threshold_for_avalanche_factor=0.001, continuous_neutral_measure_beta_number_of_samples=10, continuous_neutral_measure_gf_number_samples=10, continuous_diffusion_factor_beta_number_of_samples=10, continuous_diffusion_factor_gf_number_samples=10, is_continuous_avalanche_factor=True, is_continuous_neutrality_measure=True, is_diffusion_factor=True, seed=None, number_of_processors=1)

Return a python dictionary that contains the dictionaries corresponding to each metric in [MUR2020].

INPUT:

  • continuous_avalanche_factor_number_of_samplesinteger (default: 100); number of samples used to obtain the metric continuous_avalanche_factor

  • threshold_for_avalanche_factorfloat (default: 0.001); threshold value used to compute the input difference for the metric continuous_avalanche_factor

  • continuous_neutral_measure_beta_number_of_samplesinteger (default: 10); number of samples used to compute the continuous measure metric

  • continuous_neutral_measure_gf_number_samplesinteger (default: 10); number of vectors used to approximate gf_2

  • continuous_diffusion_factor_beta_number_of_samplesinteger (default: 10); number of samples used to compute the continuous measure metric

  • continuous_diffusion_factor_gf_number_samplesinteger (default: 10); number of vectors used to approximate gf_2

  • is_continuous_avalanche_factorboolean (default: True); flag indicating if we want the continuous_avalanche_factor or not

  • is_continuous_neutrality_measureboolean (default: True); flag indicating if we want the continuous_neutrality_measure or not

  • is_diffusion_factorboolean (default: True); flag indicating if we want the continuous_neutrality_measure, or not

  • seedinteger; RNG seed

  • number_of_processorsinteger; number of processes to use for parallelization

OUTPUT:

  • A python dictionary that contains the test result to each metric. E.g.: continuous_neutrality_measure, continuous_avalanche_factor, diffusion_factor

EXAMPLES:

sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher as speck
sage: from claasp.cipher_modules.continuous_diffusion_analysis import ContinuousDiffusionAnalysis
sage: speck_cipher = speck(number_of_rounds=1) # long time
sage: cda = ContinuousDiffusionAnalysis(speck_cipher) # doctest: +SKIP
sage: output = cda.continuous_diffusion_tests() # long time # doctest: +SKIP
sage: output["test_results"]['plaintext']['round_key_output']['continuous_neutrality_measure'][0]['values'][0] == 0.0  # long time # doctest: +SKIP
True
continuous_neutrality_measure_for_bit_j(beta_number_of_samples, gf_number_samples, input_bit=None, output_bits=None, seed=None, number_of_processors=1)

Continuous Neutrality Measure. This method implements Definition 15 of [MUR2020].

INPUT:

  • beta_number_of_samplesinteger; number of samples used to compute the continuous measure metric

  • gf_number_samplesinteger; number of vectors used to approximate gf_2

  • input_bitinteger (default: None); input bit position to be analyzed

  • output_bitslist (default: None); output bit positions to be analyzed

  • seedinteger; RNG seed

  • number_of_processorsinteger; number of processes to use for parallelization

EXAMPLES:

sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher as speck
sage: from claasp.cipher_modules.continuous_diffusion_analysis import ContinuousDiffusionAnalysis
sage: speck_cipher = speck(number_of_rounds=2)
sage: cda = ContinuousDiffusionAnalysis(speck_cipher)
sage: output = cda.continuous_neutrality_measure_for_bit_j(50, 200) # long time
sage: output['plaintext']['cipher_output']['continuous_neutrality_measure']['values'][0]['2'] > 0 # long time
True