Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 8800
1
r"""
2
Boolean polynomial representatives of extended affine equivalence classes
3
of bent functions.
4
"""
5
6
#*****************************************************************************
7
# Copyright (C) 2016 Paul Leopardi [email protected]
8
#
9
# Distributed under the terms of the GNU General Public License (GPL)
10
# as published by the Free Software Foundation; either version 2 of
11
# the License, or (at your option) any later version.
12
# http://www.gnu.org/licenses/
13
#*****************************************************************************
14
15
from sage.crypto.boolean_function import BooleanFunction
16
17
18
def bent_function_extended_affine_representative_polynomials_dimension_2():
19
r"""
20
The Boolean polynomial p2[1] is the representative of the single
21
extended affine equivalence class of bent functions in two variables,
22
as mentioned at 7.1 of Tokareva 2015.
23
"""
24
R2.<x1,x2> = BooleanPolynomialRing(2)
25
p2 = [None]*2
26
p2[1] = x1*x2
27
return p2
28
29
30
def bent_function_extended_affine_representative_polynomials_dimension_4():
31
r"""
32
The Boolean polynomial p4[1] is the representative of the single
33
extended affine equivalence class of bent functions in four variables,
34
as mentioned at 7.1 of Tokareva 2015.
35
"""
36
R4.<x1,x2,x3,x4> = BooleanPolynomialRing(4)
37
p4 = [None]*2
38
p4[1] = x1*x2 + x3*x4
39
return p4
40
41
42
def bent_function_extended_affine_representative_polynomials_dimension_6():
43
r"""
44
The Boolean polynomials p6[i] for from 1 to 4 are the representatives of
45
the extended affine equivalence classes of bent functions in six variables,
46
as listed at 7.2 of Tokareva 2015, with citation [318] to Rothaus 1976.
47
"""
48
R6.<x1,x2,x3,x4,x5,x6> = BooleanPolynomialRing(6)
49
p6 = [None]*5
50
p6[1] = x1*x2 + x3*x4 + x5*x6
51
p6[2] = x1*x2*x3 + x1*x4 + x2*x5 + x3*x6
52
p6[3] = x1*x2*x3 + x2*x4*x5 + x1*x2 + x1*x4 + x2*x6 + x3*x5 + x4*x5
53
p6[4] = x1*x2*x3 + x2*x4*x5 + x3*x4*x6 + x1*x4 + x2*x6 + x3*x4 + x3*x5 + x3*x6 + x4*x5 + x4*x6
54
return p6
55
56
57
def bent_function_extended_affine_representative_polynomials_dimension_8():
58
r"""
59
The Boolean polynomials p8[i] for from 1 to 10 are the representatives of
60
the extended affine equivalence classes of bent functions in 8 variables,
61
with degree up to 3, as listed at 7.3 of Tokareva 2015,
62
with citation [167] to Hou 1998.
63
"""
64
R8.<x1,x2,x3,x4,x5,x6,x7,x8> = BooleanPolynomialRing(8)
65
p8 = [None]*11
66
p8[1] = x1*x2 + x3*x4 + x5*x6 + x7*x8
67
p8[2] = x1*x2*x3 + x1*x4 + x2*x5 + x3*x6 + x7*x8
68
p8[3] = x1*x2*x3 + x2*x4*x5 + x3*x4 + x2*x6 + x1*x7 + x5*x8
69
p8[4] = x1*x2*x3 + x2*x4*x5 + x1*x3 + x1*x5 + x2*x6 + x3*x4 + x7*x8
70
p8[5] = x1*x2*x3 + x2*x4*x5 + x3*x4*x6 + x3*x5 + x2*x6 + x2*x5 + x1*x7 + x4*x8
71
p8[6] = x1*x2*x3 + x2*x4*x5 + x3*x4*x6 + x3*x5 + x1*x3 + x1*x4 + x2*x7 + x6*x8
72
p8[7] = x1*x2*x3 + x2*x4*x5 + x3*x4*x6 + x3*x5 + x2*x6 + x2*x5 + x1*x2 + x1*x3 + x1*x4 + x7*x8
73
p8[8] = x1*x2*x3 + x2*x4*x5 + x3*x4*x6 + x3*x5 + x1*x6 + x2*x7 + x4*x8
74
p8[9] = x1*x2*x7 + x3*x4*x7 + x5*x6*x7 + x1*x4 + x3*x6 + x2*x5 + x4*x5 + x7*x8
75
p8[10] = x1*x2*x3 + x2*x4*x5 + x3*x4*x6 + x1*x4*x7 + x3*x5 + x2*x7 + x1*x5 + x1*x6 + x4*x8
76
return p8
77
78
79
def bent_function_extended_affine_representative_polynomials(dimension):
80
r"""
81
Return the list of Boolean polynomial representatives of
82
extended affine equivalence classes of bent functions,
83
in the given dimension.
84
"""
85
dispatcher = {
86
2: bent_function_extended_affine_representative_polynomials_dimension_2,
87
4: bent_function_extended_affine_representative_polynomials_dimension_4,
88
6: bent_function_extended_affine_representative_polynomials_dimension_6,
89
8: bent_function_extended_affine_representative_polynomials_dimension_8
90
}
91
return dispatcher[dimension]()
92
93
94
def print_latex_table_of_representative_polynomials(
95
dimension, start=1, width=140):
96
r"""
97
For given dimension, print, in LaTeX format, the table
98
of algebraic normal forms of bent functions given by
99
the representative polynomials for that dimension.
100
101
Example:
102
103
sage: print_latex_table_of_representative_polynomials(4)
104
\def\arraystretch{1.2}
105
\begin{array}{|cl|}
106
\hline
107
\text{Class} &
108
\text{Representative}
109
\\
110
\hline
111
\,[f_{ 4 , 1 }] & f_{ 4 , 1 } :=
112
\begin{array}{l}
113
x_{0} x_{1} + x_{2} x_{3}
114
\end{array}
115
\\
116
\hline
117
\end{array}
118
119
"""
120
print("\\def\\arraystretch{1.2}")
121
print("\\begin{array}{|cl|}")
122
print("\\hline")
123
print("\\text{Class} &")
124
print("\\text{Representative}")
125
print("\\\\")
126
print("\\hline")
127
128
p = bent_function_extended_affine_representative_polynomials(dimension)
129
130
for n in range(start, len(p)):
131
boolf = BooleanFunction(p[n])
132
f = boolf.algebraic_normal_form()
133
print("\\,[f_{",dimension,",",n,"}] & f_{",dimension,",",n,"} :=")
134
print("\\begin{array}{l}")
135
lf = latex(f)
136
cut = 0
137
while cut >= 0 and len(lf) > width:
138
cut = lf.rfind('+', 0, width)
139
if cut > 0:
140
print(lf[:cut])
141
if cut >= 0 and cut < len(lf):
142
print("\\\\")
143
print("+\\,", end=' ')
144
lf = lf[cut + 1:]
145
print(lf)
146
print("\\end{array}")
147
print("\\\\")
148
print("\\hline")
149
print("\\end{array}")
150
151