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.Thu, 27 May 2021 00:37:22 +0200Evaluation 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/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/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/