Utils
- utils.analysis.all_equals(list: list)
Are all the elements of the list equal?
- Parameters:
list – Input list
- utils.analysis.all_inf_lowerbound(list: list, lowerbound: int)
Are all the elements of the list inferior to a lowerbound?
- utils.analysis.all_none(list: list)
Are all the elements of the list None or np.nan?
- Parameters:
list – Input list
- utils.analysis.dict_keys_equal_except_keys_specified(d1: dict, d2: dict, keys_to_ignore: list = None)
Return if two dictionnaries have the same values for all the keys except the ones in the list keys_to_ignore
- Parameters:
d1 (dict) – First dictionnary
d2 (dict) – Second dictionnary
keys_to_ignore (list) – List of keys to ignore
- utils.analysis.first_monomial_order_plus_transformation_statistics_analysis(data_list: list[dict])
Compute mean and standard deviation of the addition of the computation of the Gröbner basis and the term order change (log)
- Parameters:
data_list (list[dict]) – List of data
- utils.analysis.read_all_experiments(folder_results: str)
Read all the result dictionnaries for the experiment
- Parameters:
folder_results (str) – Name of the folder with results
- utils.analysis.read_pickle_experiment(folder_results: str, id: int)
Read the result dictionnary corresponding to a certain ID
- Parameters:
folder_results (str) – Name of the folder with results
id (int) – Numberof ID of the experiment
- utils.analysis.read_pickle_parameter_id(folder_results: str, id: int)
Read the parameter dictionnary corresponding to a certain ID
- Parameters:
folder_results (str) – Name of the folder with results
id (int) – Numberof ID of the experiment
- utils.analysis.read_pickle_parameters(folder_results: str)
Read the file containing all the parameter dictionnaries for the experiment
- Parameters:
folder_results (str) – Name of the folder with results
- utils.analysis.statistics_analysis(data_list: list, algo_time_computed: str)
Compute mean and standard deviation of the list (log)
- Parameters:
data_list (list) – List of data
algo_time_computed (str) – Key of the items to analyse in the dictionnary
- utils.analysis.statistics_analysis_no_log(data_list: list[dict], algo_time_computed: str)
Compute mean and standard deviation of the list (no log)
- Parameters:
data_list (list) – List of data
algo_time_computed (str) – Key of the items to analyse in the dictionnary
- utils.constants_generation.constants_random(field, size: int)
Random vector
- Parameters:
field – Field of the vector
size (int) – Size of the vector
- utils.constants_generation.constants_random_sparsity(field, size: int, sparsity: int, seed_nb: int)
Random vector with the sparsity equals to the number of non-zero entry
- Parameters:
field – Field of the vector
size (int) – Size of the vector
sparsity (int) – Number of non-zero entry
seed_nb (int) – Seed for randomness
- utils.constants_generation.constants_zero(field, size: int)
Zero vector
- Parameters:
field – Field of the vector
size (int) – Size of the vector
- exception utils.exception.TimeoutException
Timeout exception class
- utils.matrices_generation.matrix_identity(field, size: int)
Generate the identity matrix
- Parameters:
field – Field of the matrix
size (int) – Size of the matrix
- utils.matrices_generation.matrix_mds(permutation: str, field, size: int)
Define MDS matrix depending on the permutation.
For Zerolith the matrix is a 32x32 MDS matrix given in https://eprint.iacr.org/2023/1025
For Anemoi the matrix is given in https://eprint.iacr.org/2024/347
For Griffin the matrices are given in https://eprint.iacr.org/2022/403
For Polocolo the matrices are given in https://eprint.iacr.org/2025/926
- Parameters:
permutation (str) – Name of the permutation
field – Field of the matrix
size (int) – Size of the matrix
- utils.matrices_generation.matrix_random_invertible(field, size: int)
Generate a random invertible matrix
- Parameters:
field – Field of the matrix
size (int) – Size of the matrix
- utils.matrices_generation.matrix_sparse_invertible(field, size: int, p: float)
Generate a random sparse matrix It is done by giving higher probability to 0 to be drawn.
- Parameters:
field – Field of the matrix
size (int) – Size of the matrix
p (float) – probability to get a 0
- utils.matrices_generation.matrix_zero(field, size: int)
Generate the zero matrix
- Parameters:
field – Field of the matrix
size (int) – Size of the matrix
- utils.pickle_utils.change_dict_failed_to_skipped(filename: str, i: int, n: int)
Change all the “failed” value to “skipped” in the dictionnaries result
- Parameters:
filename (str) – Name of the file
i (int) – Number of the experiment in the pickle file
n (int) – Total number of experiment
- utils.pickle_utils.change_dict_failed_to_timeout(filename: str, i: int, n: int)
Change all the “failed” value to “timeout” in the dictionnaries result
- Parameters:
filename (str) – Name of the file
i (int) – Number of the experiment in the pickle file
n (int) – Total number of experiment
- utils.pickle_utils.change_dict_pkl(filename: str, i: int, n: int, key, new_value)
Change values in the dictionnaries in the result pickle file
- Parameters:
filename (str) – Name of the file
i (int) – Number of the experiment in the pickle file
n (int) – Total number of experiment
key – Key of the dictionnary to change
new_value – New value of the key
- utils.pickle_utils.read_and_print_pkl_file(filepath: str)
Read and print pickle file
- Parameters:
filepath (str) – Path to the file
- utils.pickle_utils.read_pkl_file(filepath: str)
Read pickle file
- Parameters:
filepath (str) – Path to the file
- utils.systems_solver.computation_shape_position_and_ideal_degree(gb_lex: list)
- The choice done in this function is to detect whether the ideal is in shape position.
- If shape position:
Compute the ideal degree Return Shape position and ideal degree (ideal_degree)
- Else:
Return Not shape position (-1)
Return -2 in case it is of zero-dimension ideal. It should not happen if FGLM is used as it detects it and crashs before
- Parameters:
gb_lex (list) – Gröbner basis for the LEX order
- Returns:
degree of the ideal and whether it is radical
- utils.systems_solver.is_shape_position_polynomial_var(p, special_var)
Check whether a polynomial has shape x_i - f_i(special_var), where f_i is a univariate polynomial in special_var
- Parameters:
p – Multivariate polynomial
special_var – Variable from the multivariate polynomial ring
- Returns:
Whether or not the polynomial is in shape position form as defined above
- Return type:
boolean
- utils.systems_solver.solve(file_log_result_path: str, file_output_result_path: str, i: int, number_test: int, system_of_equations: list, algo_gb: str, monomial_order: str, algo_order_change: str, options: dict[str, list[dict[str, any]]] = None)
Compute the LEX groebner basis either by computing straight LEX or Monomial Order and Change order algorithm
- Parameters:
file_log_result_path (str) – Path to the log file
file_output_result_path (str) – Path to the file containing result
i (int) – Number of the system of equations to solve
number_test (int) – Total number of systems of equations to solve
system_of_equations (list) – System of equations to solve
algo_gb (str) – Algorithm to compute the Gröbner basis
monomial_order (str) – Monomial order to use for the computation of the first Gröbner basis
algo_order_change (str) – Algorithm to use for the temr order change step
options (dict[str, list[dict[str, any]]]) – Options for the Gröbner basis algorithm
- class utils.timer.Chronograph(title: str)
Class to create a timer
- Parameters:
title (str) – Title of the timer
- time_measure()
Return the time measured by the timer
- utils.utils_all.import_perm(permutation: str)
Import the generation function of systems of the permutation
- Parameters:
permutation (str) – The name of the permutation that is the same than the file in the permutations folder.
- utils.utils_all.kill_process_tree(proc)
DKill the process and all its children
- Parameters:
proc – Process to kill, coming from the Process class in Python
- utils.utils_all.redirect_all_output(log_file_path: str)
Redirect all the outputs to a file
- Parameters:
log_file_path (str) – Path to the file