DCC_2012_Sihong Su . Xiaohu Tang rotation symmetric boolean functions

论文名称:Construction of rotation symmetric Boolean functions with optimal algebraic immunity and high nonlinearity

1.majority function

这里写图片描述

2.Preliminaries

DCC_2012_Sihong Su . Xiaohu Tang rotation symmetric boolean functions_第1张图片

3 Compositions of an integer k

DCC_2012_Sihong Su . Xiaohu Tang rotation symmetric boolean functions_第2张图片

4 Construction of RSBFs on odd number of variables

DCC_2012_Sihong Su . Xiaohu Tang rotation symmetric boolean functions_第3张图片
DCC_2012_Sihong Su . Xiaohu Tang rotation symmetric boolean functions_第4张图片
这里写图片描述
DCC_2012_Sihong Su . Xiaohu Tang rotation symmetric boolean functions_第5张图片
5.SageMath程序实现

from sage.crypto.boolean_function import BooleanFunction
k=6
n=2*k+1
t=0
top=0
Sum=0
s=[None]*n
set=[]
#整数分解
def dfs():
    global Sum,top,t,k,s,set
    if Sum == k:
        if s[0] != 1:#构造的布尔函数要求开头不为1
            set.append(s[0:top])
        return
    if Sum > k:
        return
    for i in range(1,k+1):
        Sum+=i
        s[top]=i
        top=top+1
        dfs()
        Sum-=i
        top=top-1
        s[top]=i
dfs()
#print(set)
#求集合T
T=[]
for i in range(len(set)):
    tmp=[]
    for j in set[i]:
        for k in range(j):
            tmp.append(1)
        tmp.append(0)
    for k in range(n - len(tmp)):
        tmp.append(0 )
    T.append(tmp)
#print(T)
#print(len(T))
#求集合U
U=[]
for i in range(len(set)):
    k1=set[i][0]
    tmp=[0]*(n-k1)
    tmp=tmp+[1]*(k1-1)+[0]
    for j in range(n):
        tmp[j]=(tmp[j]+T[i][j])%2
    U.append(tmp)
#print(U)
#构造择多函数
f=[0]*(2^n)
for i in range(2^n):
    tmp=list(str('{0:b}'.format(i)).rjust(n,'0'))
    listkey=[int(x) for x in tmp ]
    wt=0
    for j in listkey:
        if j==0:
            wt=wt+1
    if wt >= ((n-1)/2+1):
        f[i]=1

TU=T+U
supp=[]
for Set in TU:
    for j in range(0,n):
        tmp=Set[j:]+Set[:j]
        index=0
        for k in range(len(tmp)):
            if tmp[k]==1:
                index=index+2^(n-k-1)
        supp.append(index)
for i in supp:
    f[i]=(f[i]+1)%2

B=BooleanFunction(f)
deg=0
ANF=str(B.algebraic_normal_form()).split("+")
for i in range(len(ANF)):
    count=0
    for j in range(len(ANF[i])):
        if ANF[i][j]=="x":
            count=count+1
    if count>deg:
        deg=count
#将真值表写入文件,使用其他程序测试函数抵抗快速代数攻击的能力
filename='truth_table.txt'
with open(filename,'w') as fw:
    fw.writelines(str(f))

你可能感兴趣的:(密码学布尔函数)