CoCalc Public FilesBoolean-Cayley-graphs / sage-code / save_cast128_from_parts.py
Author: Paul Leopardi
Compute Environment: Ubuntu 18.04 (Deprecated)
1r"""
2"""
3#*****************************************************************************
4#       Copyright (C) 2016 Paul Leopardi [email protected]
5#
7#  as published by the Free Software Foundation; either version 2 of
10#*****************************************************************************
11
12import sys
13
14from sage.all_cmdline import *
15
16from boolean_cayley_graphs.bent_function_cayley_graph_classification import BentFunctionCayleyGraphClassification
17from boolean_cayley_graphs.bent_function import BentFunction
18
19r"""
20"""
21# Check that the correct number arguments exist.
22if len(sys.argv) != 3:
23    print("Usage: save_cast128_from_parts bnbr fnbr")
24    sys.exit(1)
25
26# Convert the arguments to int.
27bnbr  = int(sys.argv[1]) # S-box number
28fnbr  = int(sys.argv[2]) # Function number within S-box
29
30# Load the required bent function.
33bentf = s_boxes[bnbr][fnbr]
34
35# Construct the classification from the existing parts.
36c_name = "cast128_"+str(bnbr)+"_"+str(fnbr)
37c = BentFunctionCayleyGraphClassification.from_parts(c_name)
38
39# Save the classification.
40c.save_mangled(c_name)
41
42# Check the saved classification
44c_check.report()
45if (c.algebraic_normal_form == c_check.algebraic_normal_form and
46    c.cayley_graph_class_list == c_check.cayley_graph_class_list and
47    c.bent_cayley_graph_index_matrix == c_check.bent_cayley_graph_index_matrix and
48    c.dual_cayley_graph_index_matrix == c_check.dual_cayley_graph_index_matrix and
49    c.weight_class_matrix == c_check.weight_class_matrix):
50    print("Check succeeded.")
51else:
52    print("Check failed.")
53    sys.exit(1)
54
55quit
56
57