ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 02 Aug 2021 22:03:56 +0200Truth table of Maiorana McFarland type functionshttps://ask.sagemath.org/question/58223/truth-table-of-maiorana-mcfarland-type-functions/I want to find truth table and Algebraic Normal Form of a Maiorana McFarland type bent function with the support set.
I do a sample function by hand from $F_4$x$F_4$ to $F_2$ such that the Finite Field $F_4$ is generated by the irreducible polynomial $a^2+a+1$ so that $a^2=a+1$.
$F_4$x$F_4$={(0,0),(0,1),(0,a),(0,a+1),(1,0),(1,1),(1,a),(1,a+1),(a,0),(a,1),(a,a),(a,a+1),(a+1,0),(a+1,1),(a+1,a),(a+1,a+1)}
Take the support set as S={(0,a+1),(1,a),(a,a+1),(a+1,0),(a+1,1),(a+1,a+1)}. I want to find the boolean function which has the support set S.
The whole elements of $F_4$x$F_4$ and the corresponding elements of $F_2^4$ and Truth Table results are given in table. 0=00, 1=01, a=10, a+1=11
$$ \left[
\begin{array}{c|c|c}
(0,0) & (00,00)& 0000 & 0\newline
(0,1) &(00,01)&0001& 0 \newline
(0,a) & (00,10)&0010 & 0 \newline
\textbf{(0,a+1)} & (00,11)& 0011 & \textbf{1} \newline
(1,0) & (01,00)&0100 & 0 \newline
(1,1) &(01,01)& 0101 & 0 \newline
\textbf{(1,a)} & (01,10)& 0110 & \textbf{1} \newline
(1,a+1) & (01,11)& 0111 & 0 \newline
(a,0) & (10,00)& 1000 & 0 \newline
(a,1) & (10,01)& 10001 & 0 \newline
(a,a) & (10,10)&1010 & 0 \newline
\textbf{(a,a+1)} & (10,11)& 1011 & \textbf{1} \newline
\textbf{(a+1,0)} & (11,00)& 1100 & \textbf{1} \newline
\textbf{(a+1,1) } & (11,01)&1101 & \textbf{1} \newline
(a+1,a) & (11,10)&1110 & 0 \newline
\textbf{(a+1,a+1) } & (11,11)& 1111 & \textbf{1}
\end{array}
\right] $$
By the truth table, I can find whether this function is bent or not with the codes below:
from sage.crypto.boolean_function import BooleanFunction
B = BooleanFunction([0,0,0,1,0,0,1,0,0,0,0,1,1,1,0,1])
P = B.algebraic_normal_form()
print (P)
f = BooleanFunction(P)
print ("Bent :", f.is_bent())
The problem is I need the SAGE program that finds the truth table if I have the support set of a function from $F_{64}$x$F_{64}$ to $F_2$.
FF=FiniteField(64,"a")
a=FF.gen()
tr= [a, a^2, a^4, a^5, a^5 + a^4 + a^2 + a + 1, a^5 + a^4 + 1, a^4 + a + 1, a^5 + a^2 + a, a^2 + a + 1, a^5 + a^4 + a^2, a^5 + a^4 + a, a^5 + a^2 + 1, a^4 + a^2 + 1, a^5 + a + 1, a^4 + a^2 + a, 1, a^3, a^5 + a^3 + 1, a^3 + a^2 + a, a^4 + a^3 + a^2, a^5 + a^4 + a^3, a^3 + a^2 + 1, a^4 + a^3 + a, a^5 + a^4 + a^3 + a^2 + 1, a^4 + a^3 + 1, a^4 + a^3 + a^2 + a + 1, a^5 + a^4 + a^3 + a^2 + a, a^5 + a^3 + a, a^5 + a^3 + a^2 + a + 1, a^3 + a + 1, a^5 + a^3 + a^2, a^5 + a^4 + a^3 + a + 1]
FF=[x for x in FF]
U_s=[]
for s in tr:
for x in FF:
if x!=0:
U_s.append(x,s*x^5)
I generated the support set U_s in $F_{64}$x$F_{64}$ . How can I find the truth table of the corresponding function?
Thanks in advance.Kenan DOGANMon, 02 Aug 2021 22:03:56 +0200https://ask.sagemath.org/question/58223/Boolean Polynomial Ringhttps://ask.sagemath.org/question/58007/boolean-polynomial-ring/ Dear all,
I am working polynomial ring of 100 binary variables. Sometime I get polynomial with only 4 variables.
I want to study these polynomials. My following code is giving error:
from sage.crypto.boolean_function import BooleanFunction
V = BooleanPolynomialRing(100,['x%d'%(i) for i in range(100)])
V.inject_variables()
f=x1*x2+x3*x4
xx=f.variables()
l=len(xx)
P=BooleanPolynomialRing(l,map(str,xx))
f=P(f)SanuWed, 14 Jul 2021 09:47:05 +0200https://ask.sagemath.org/question/58007/Evaluation of Boolean function at a point.https://ask.sagemath.org/question/57285/evaluation-of-boolean-function-at-a-point/Hello! I am struggling with the following code. I have a random Boolean function, f, in n variables (n varies) and also a set of n tuples which is generated from some other code. Now I want to evaluate the function f at one of the points, i.e., I want to determine f(a). But a, being of the form say a = [random.randit(0,1) for i in range(n)], is not being taken as an input for f. Moreover changing a to tuple(a) or list(a) neither works. I am writing down the problem in the following code:
`n = 4`
`R = BooleanPolynomialRing(n,['x%d'%i for i in range(n)])`
`f = R.random_element()`
`print(f)`
`import random`
`a = [random.randint(0,1) for i in range(n)]`
`print(f(a))`
Upon running this shows the error:
`"Number of arguments is different from the number of variables of parent ring."`DodulThu, 27 May 2021 00:37:22 +0200https://ask.sagemath.org/question/57285/How to define functionhttps://ask.sagemath.org/question/56835/how-to-define-function/I want to generate a random function from $GF(2)^4$ to $GF(2)^4$. So my function takes 4 bit input value and 4 bit output value. Also how to define if my function is say
$f(x_1,x_2,x_3,x_4)=(x_1 \oplus x_2, x_3, x_4,x_1)$?SanuTue, 27 Apr 2021 21:23:20 +0200https://ask.sagemath.org/question/56835/General form of ANF of degree dhttps://ask.sagemath.org/question/56796/general-form-of-anf-of-degree-d/I need to create a general form of ANF of degree d, so I could
substitute values of x in it to find the actual ANF of the function.
I'm trying to write an algorithm that calculates algebraic immunity
of the function of degree d.
1. Substitute all N arguments x with f(x) = 1 in the ANF
of a general boolean function g(x) of degree d.
This gives a system of N linear equations for the coefficients of g(x).
2. Solve this linear system.
3. If there is no (nontrivial) solution, output no annihilator of degree d,
else determine sets of coefficients for linearly independent annihilators.vet99Sat, 24 Apr 2021 19:49:45 +0200https://ask.sagemath.org/question/56796/Call polynomial ring variables by indexhttps://ask.sagemath.org/question/56797/call-polynomial-ring-variables-by-index/In my study I have to work with something like `BooleanPolynomialRing(... 'x', 10)`.
After that I can create function in the form `x1 + x1*x3 + ...`.
However I would like to create functions in more generic form like
`x[1] + x[2]*x[3]` where `x[1]` is equivalent for `x1`, etc.
The final goal is to be able to construct functions programmatically
combining indexed expressions like `x[i] + x[j]` etc.vet99Sat, 24 Apr 2021 20:11:27 +0200https://ask.sagemath.org/question/56797/boolean function algebraic degreehttps://ask.sagemath.org/question/52195/boolean-function-algebraic-degree/ Hey, in the doc of the sage.crypto.boolean-function module, there's a algebraic_degree() method mentioned, but it's not available on my implementation of sage. Is it not up to date, or has it been deleted? Anyway, is there a more efficient way to find it than using B.algebraic_normal_form().deg()?HippolyteWed, 24 Jun 2020 11:54:06 +0200https://ask.sagemath.org/question/52195/What happened to BooleanFunction.algebraic_degree?https://ask.sagemath.org/question/52194/what-happened-to-booleanfunctionalgebraic_degree/ Hey, in the doc of the sage.crypto.boolean-function module, there's a algebraic_degree() method mentioned, but it's not available on my implementation of sage. Is it not up to date, or has it been deleted? Anyway, is there a more efficient way to find it than using B.algebraic_normal_form().deg()?HippolyteWed, 24 Jun 2020 11:53:04 +0200https://ask.sagemath.org/question/52194/Representing sboxes by using smaller GF multiplicationshttps://ask.sagemath.org/question/51036/representing-sboxes-by-using-smaller-gf-multiplications/Hello,
Up to now, I work on representing the PRESENT sbox in different ways. I tried to compute the algebraic normal form (ANF) which returns 4 output equations. Each output equation processes 4 input variables in GF(2) and returns one output variable in GF(2) while using single AND gates. After that, I used Lagrange interpolation which returned one function with one GF(2^4) input and one GF(2^4) output while using GF(2^4) multipliers. Since both equations are not very helpful for solving my problem, I look for a method to represent the sbox as two polynomials with two GF(2^2) input variables and two GF(2^2) outputs. So more detailed I want to redesign the PRESENT by only using GF(2^2) multiplications and linear components. Is there any method in SAGE to get such a representation? Dirk0579Sun, 26 Apr 2020 11:07:10 +0200https://ask.sagemath.org/question/51036/What does the 'a' and x^254 in code means?https://ask.sagemath.org/question/46401/what-does-the-a-and-x254-in-code-means/
sage: R.<x>=GF(2^8,'a')[]
sage: from sage.crypto.boolean_function import BooleanFunction
sage: B = BooleanFunction( x^254 ) # the Boolean function Tr(x^254)
sage: BathulanMon, 29 Apr 2019 14:24:34 +0200https://ask.sagemath.org/question/46401/What can i do about this large boolean function?https://ask.sagemath.org/question/46400/what-can-i-do-about-this-large-boolean-function/If i have a large boolean function like this:
FUN() = (
(( ~g&(f^i^0))|(g&(1^f^h^0)))^(( ~x&(w^z^0))|(x&(1^w^y^0)))
^((d&(1^a^b^e))|( ~d&(1^a^c^e)))^((m&(1^j^k^n))|( ~m&(1^j^l^n)))
^o^p^q^0^r^s^t^u^v
)
can anyone explain how can i code to obtain the non-linearity of this boolean formula?
I didn't really understand the `BooleanFunction()` function in Sage.athulanMon, 29 Apr 2019 13:56:28 +0200https://ask.sagemath.org/question/46400/