U
�Ul_}, � @ s` d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZ
G dd � d e
�ZdS )
a�
Bent Boolean functions
======================
The ``bent_function`` module defines
the ``BentFunction`` class,
which represents a bent Boolean function and some of its properties.
AUTHORS:
- Paul Leopardi (2016-09-25): initial version
EXAMPLES:
::
sage: from sage.crypto.boolean_function import BooleanFunction
sage: bf = BooleanFunction([0,1,0,0])
sage: bf.algebraic_normal_form()
x0*x1 + x0
sage: from boolean_cayley_graphs.bent_function import BentFunction
sage: bentf = BentFunction(bf)
sage: type(bentf)
<class 'boolean_cayley_graphs.bent_function.BentFunction'>
sage: bentf.algebraic_normal_form()
x0*x1 + x0
REFERENCES:
.. Dillon [Dil1974]_, Rothaus [Rot1976]_, Tokareva [Tok2015]_.
� )�Graph)�%strongly_regular_from_two_weight_code��require_version)�matrix)�BooleanFunctionImprovedNc @ s: e Zd ZdZddd�Zdd� Zdd� Zd d
� Zdd� Zd
S )�BentFunctiona
A bent Boolean function, with methods corresponding to some of its properties.
The class inherits from BooleanFunctionImproved and is initialized
in the same way as BooleanFunction.
Since BooleanFunctionImproved inherits from Saveable, so does BentFunction.
EXAMPLES:
::
sage: import os
sage: from boolean_cayley_graphs.bent_function import BentFunction
sage: bentf = BentFunction([0,0,0,1])
sage: bentf.algebraic_normal_form()
x0*x1
sage: d = tmp_dir()
sage: bentf.save_mangled('example', dir=d)
sage: ex = BentFunction.load_mangled('example', dir=d)
sage: type(ex)
<class 'boolean_cayley_graphs.bent_function.BentFunction'>
sage: ex is bentf
False
sage: ex == bentf
True
sage: BentFunction.remove_mangled('example', dir=d)
sage: os.rmdir(d)
TESTS:
::
sage: from sage.crypto.boolean_function import BooleanFunction
sage: bf = BentFunction([0,1,0,0])
sage: print(bf)
Boolean function with 2 variables
sage: from sage.crypto.boolean_function import BooleanFunction
sage: bf = BentFunction([0,1,0,0])
sage: latex(bf)
\text{\texttt{Boolean{ }function{ }with{ }2{ }variables}}
Fc
sV | � � }d|d � | �� }|�d�}� fdd�|D ��t��}|dkrX|rTdg fS dS t|�}t|�D ]J}t|d |�D ]6}�| �| @ dhkr�dnd |||f<