Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 8800
1
r"""
2
"""
3
#*****************************************************************************
4
# Copyright (C) 2016 Paul Leopardi [email protected]
5
#
6
# Distributed under the terms of the GNU General Public License (GPL)
7
# as published by the Free Software Foundation; either version 2 of
8
# the License, or (at your option) any later version.
9
# http://www.gnu.org/licenses/
10
#*****************************************************************************
11
12
import sys
13
14
from sage.all_cmdline import *
15
16
from boolean_cayley_graphs.bent_function_cayley_graph_classification import BentFunctionCayleyGraphClassification
17
from boolean_cayley_graphs.bent_function import BentFunction
18
19
r"""
20
"""
21
# Check that the correct number arguments exist.
22
if len(sys.argv) != 3:
23
print("Usage: save_cast128_from_parts bnbr fnbr")
24
sys.exit(1)
25
26
# Convert the arguments to int.
27
bnbr = int(sys.argv[1]) # S-box number
28
fnbr = int(sys.argv[2]) # Function number within S-box
29
30
# Load the required bent function.
31
load("read_cast_128_s_boxes.sage")
32
s_boxes = read_s_boxes_file()
33
bentf = s_boxes[bnbr][fnbr]
34
35
# Construct the classification from the existing parts.
36
c_name = "cast128_"+str(bnbr)+"_"+str(fnbr)
37
c = BentFunctionCayleyGraphClassification.from_parts(c_name)
38
39
# Save the classification.
40
c.save_mangled(c_name)
41
42
# Check the saved classification
43
c_check = BentFunctionCayleyGraphClassification.load_mangled(c_name)
44
c_check.report()
45
if (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.")
51
else:
52
print("Check failed.")
53
sys.exit(1)
54
55
quit
56
57
58