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_value– float; threshold value used to express the input differencenumber_of_samples– integer; number of samples used to compute the continuous avalanche factorseed– integer; RNG seednumber_of_processors– integer; 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_samples– integer; number of samples used to compute the continuous measure metricgf_number_samples– integer; number of vectors used to approximate gf_2seed– integer; RNG seednumber_of_processors– integer; 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_samples– integer (default: 100); number of samples used to obtain the metric continuous_avalanche_factorthreshold_for_avalanche_factor– float (default: 0.001); threshold value used to compute the input difference for the metric continuous_avalanche_factorcontinuous_neutral_measure_beta_number_of_samples– integer (default: 10); number of samples used to compute the continuous measure metriccontinuous_neutral_measure_gf_number_samples– integer (default: 10); number of vectors used to approximate gf_2continuous_diffusion_factor_beta_number_of_samples– integer (default: 10); number of samples used to compute the continuous measure metriccontinuous_diffusion_factor_gf_number_samples– integer (default: 10); number of vectors used to approximate gf_2is_continuous_avalanche_factor– boolean (default: True); flag indicating if we want the continuous_avalanche_factor or notis_continuous_neutrality_measure– boolean (default: True); flag indicating if we want the continuous_neutrality_measure or notis_diffusion_factor– boolean (default: True); flag indicating if we want the continuous_neutrality_measure, or notseed– integer; RNG seednumber_of_processors– integer; 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_samples– integer; number of samples used to compute the continuous measure metricgf_number_samples– integer; number of vectors used to approximate gf_2input_bit– integer (default: None); input bit position to be analyzedoutput_bits– list (default: None); output bit positions to be analyzedseed– integer; RNG seednumber_of_processors– integer; 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