Skip to content

Instantly share code, notes, and snippets.

@back-seat-driver
Last active July 25, 2017 22:20
Show Gist options
  • Save back-seat-driver/ea2d4a4a5bf59611509befe3061df844 to your computer and use it in GitHub Desktop.
Save back-seat-driver/ea2d4a4a5bf59611509befe3061df844 to your computer and use it in GitHub Desktop.
SHA-3
from theta_data import theta_data
from theta_index_data import theta_index_data
from theta_delta_data import theta_delta_data
def bin_n_bit(dec,n):
return(str(format(dec,'0'+n+'b')))
def bin_8bit(dec):
return(str(format(dec,'08b')))
def bin_32bit(dec):
return(str(format(dec,'032b')))
def bin_4bit(dec):
return(str(format(dec,'04b')))
def bin_64bit(dec):
return(str(format(dec,'064b')))
def hex_return(dec):
return(str(format(dec,'08x')))
def hex_double(dec):
return(str(format(dec,'02x')))
def hex_single(dec):
return(str(format(dec,'01x')))
def dec_return_bin(bin_string):
return(int(bin_string,2))
def dec_return_hex(hex_string):
return(int(hex_string,16))
def str_build(a_list):
to_return=''
for i in range(len(a_list)):
to_return+=str(a_list[i])
return(to_return)
def set_main_build(size,iter_len):
import numpy
to_return=[]
for i in range(iter_len):
to_return.append(str_build(list(numpy.random.randint(2,size=(size,)))))
return(to_return)
def sha_seed():
return(set_main_build(64,25))
def trunc(string,index):
return(string[0:index])
def U_V(LIST):
to_iter = len(LIST)
total_items = []
for i in range(to_iter):
insert = LIST[i]
total_items.append(insert)
unique_items = []
for i in range(len(total_items)):
count = 0
for x in range(len(unique_items)):
if total_items[i]==unique_items[x]:
count+=1
if count==0:
unique_items.append(total_items[i])
return(unique_items)
def L_P(SET,n):
to_return=[]
j=0
k=n
while k<len(SET)+1:
to_return.append(SET[j:k])
j=k
k+=n
return(to_return)
def s_l(bit_string):
bit_list=[]
for i in range(len(bit_string)):
bit_list.append(bit_string[i])
return(bit_list)
def l_s(bit_list):
bit_string=''
for i in range(len(bit_list)):
bit_string+=bit_list[i]
return(bit_string)
def rotate_left(bit_string,n):
if n==0:
return(bit_string)
bit_list = s_l(bit_string)
count=0
while count <= n-1:
list_main=list(bit_list)
var_0=list_main.pop(0)
list_main=list(list_main+[var_0])
bit_list=list(list_main)
count+=1
return(l_s(list_main))
def rotate_right(bit_string,n):
if n==0:
return(bit_string)
bit_list = s_l(bit_string)
count=0
while count <= n-1:
list_main=list(bit_list)
var_0=list_main.pop(-1)
list_main=list([var_0]+list_main)
bit_list=list(list_main)
count+=1
return(l_s(list_main))
def shift_right(bit_string,n):
bit_list=s_l(bit_string)
count=0
while count <= n-1:
bit_list.pop(-1)
count+=1
front_append=['0']*n
return(l_s(front_append+bit_list))
def mod_32_addition(input_set):
value=0
for i in range(len(input_set)):
value+=input_set[i]
mod_32 = 4294967296
return(value%mod_32)
def xor_bit(a,b):
return('1' if ((a == '1') ^ (b == '1')) else '0')
def xo(bit_string_1,bit_string_2):
xor_list=[]
for i in range(len(bit_string_1)):
if bit_string_1[i]=='0' and bit_string_2[i]=='0':
xor_list.append('0')
if bit_string_1[i]=='1' and bit_string_2[i]=='1':
xor_list.append('0')
if bit_string_1[i]=='0' and bit_string_2[i]=='1':
xor_list.append('1')
if bit_string_1[i]=='1' and bit_string_2[i]=='0':
xor_list.append('1')
return(l_s(xor_list))
def xor_seq(bit_str):
#Just XOR's a bit string sequence very simple
init='0'
for i in range(len(bit_str)):
init=xor_bit(init,bit_str[i])
return(init)
def and_2str(bit_string_1,bit_string_2):
and_list=[]
for i in range(len(bit_string_1)):
if bit_string_1[i]=='1' and bit_string_2[i]=='1':
and_list.append('1')
else:
and_list.append('0')
return(l_s(and_list))
def or_2str(bit_string_1,bit_string_2):
or_list=[]
for i in range(len(bit_string_1)):
if bit_string_1[i]=='0' and bit_string_2[i]=='0':
or_list.append('0')
else:
or_list.append('1')
return(l_s(or_list))
def not_str(bit_string):
not_list=[]
for i in range(len(bit_string)):
if bit_string[i]=='0':
not_list.append('1')
else:
not_list.append('0')
return(l_s(not_list))
def sub_str_concat(list_of_lists):
to_return=[]
for i in range(len(list_of_lists)):
insert=''
for x in range(len(list_of_lists[i])):
insert+=list_of_lists[i][x]
to_return.append(insert)
return(to_return)
def str_concat(list_of_strings):
to_return=''
for i in range(len(list_of_strings)):
to_return+=list_of_strings[i]
return(to_return)
def list_concat(list_of_lists):
to_return=[]
for i in range(len(list_of_lists)):
to_return+=list_of_lists[i]
return(to_return)
def flip_string(a_string):
to_return=''
for i in range(1,len(a_string)+1):
to_return+=a_string[-i]
return(to_return)
def access_function(index):
a_list = [
[[1], [1, 2, 5, 7, 10, 12, 15, 17, 20, 22, 25], ['00101010101']],
[[2], [1, 2, 3, 6, 8, 11, 13, 16, 18, 21, 23], ['10010101010']],
[[3], [2, 3, 4, 7, 9, 12, 14, 17, 19, 22, 24], ['10010101010']],
[[4], [3, 4, 5, 8, 10, 13, 15, 18, 20, 23, 25], ['10010101010']],
[[5], [1, 4, 5, 6, 9, 11, 14, 16, 19, 21, 24], ['01001010101']],
[[6], [2, 5, 6, 7, 10, 12, 15, 17, 20, 22, 25], ['01001010101']],
[[7], [1, 3, 6, 7, 8, 11, 13, 16, 18, 21, 23], ['10100101010']],
[[8], [2, 4, 7, 8, 9, 12, 14, 17, 19, 22, 24], ['10100101010']],
[[9], [3, 5, 8, 9, 10, 13, 15, 18, 20, 23, 25], ['10100101010']],
[[10], [1, 4, 6, 9, 10, 11, 14, 16, 19, 21, 24], ['01010010101']],
[[11], [2, 5, 7, 10, 11, 12, 15, 17, 20, 22, 25], ['01010010101']],
[[12], [1, 3, 6, 8, 11, 12, 13, 16, 18, 21, 23], ['10101001010']],
[[13], [2, 4, 7, 9, 12, 13, 14, 17, 19, 22, 24], ['10101001010']],
[[14], [3, 5, 8, 10, 13, 14, 15, 18, 20, 23, 25], ['10101001010']],
[[15], [1, 4, 6, 9, 11, 14, 15, 16, 19, 21, 24], ['01010100101']],
[[16], [2, 5, 7, 10, 12, 15, 16, 17, 20, 22, 25], ['01010100101']],
[[17], [1, 3, 6, 8, 11, 13, 16, 17, 18, 21, 23], ['10101010010']],
[[18], [2, 4, 7, 9, 12, 14, 17, 18, 19, 22, 24], ['10101010010']],
[[19], [3, 5, 8, 10, 13, 15, 18, 19, 20, 23, 25], ['10101010010']],
[[20], [1, 4, 6, 9, 11, 14, 16, 19, 20, 21, 24], ['01010101001']],
[[21], [2, 5, 7, 10, 12, 15, 17, 20, 21, 22, 25], ['01010101001']],
[[22], [1, 3, 6, 8, 11, 13, 16, 18, 21, 22, 23], ['10101010100']],
[[23], [2, 4, 7, 9, 12, 14, 17, 19, 22, 23, 24], ['10101010100']],
[[24], [3, 5, 8, 10, 13, 15, 18, 20, 23, 24, 25], ['10101010100']],
[[25], [1, 4, 6, 9, 11, 14, 16, 19, 21, 24, 25], ['01010101010']]
]
to_return=[]
for i in range(len(a_list)):
for x in range(len(a_list[i][1])):
if a_list[i][1][x]==index:
to_return.append([a_list[i][0][0],a_list[i][2][0][a_list[i][1].index(index)]])
return(to_return)
def theta(s):
c_xz=[]
for i in range(5):
c_xz.append(xo(xo(xo(xo(s[i],s[i+5]),s[i+10]),s[i+15]),s[i+20]))
d_xz=[]
for i in range(5):
d_xz.append(xo(c_xz[(i-1)%5],rotate_left(c_xz[(i+1)%5],1)))
a_xyz=[]
for i in range(5):
a_xyz.append([xo(s[i],d_xz[i]),
xo(s[i+5],d_xz[i]),
xo(s[i+10],d_xz[i]),
xo(s[i+15],d_xz[i]),
xo(s[i+20],d_xz[i])])
a_xyz=list_concat(a_xyz)
order_return=[]
for i in range(5):
order_return.append([a_xyz[i],a_xyz[i+5],a_xyz[i+10],a_xyz[i+15],a_xyz[i+20]])
return(list_concat(order_return))
def _theta(input_list):
def access_function(index):
a_list = [
[[1], [1, 2, 5, 7, 10, 12, 15, 17, 20, 22, 25], ['00101010101']],
[[2], [1, 2, 3, 6, 8, 11, 13, 16, 18, 21, 23], ['10010101010']],
[[3], [2, 3, 4, 7, 9, 12, 14, 17, 19, 22, 24], ['10010101010']],
[[4], [3, 4, 5, 8, 10, 13, 15, 18, 20, 23, 25], ['10010101010']],
[[5], [1, 4, 5, 6, 9, 11, 14, 16, 19, 21, 24], ['01001010101']],
[[6], [2, 5, 6, 7, 10, 12, 15, 17, 20, 22, 25], ['01001010101']],
[[7], [1, 3, 6, 7, 8, 11, 13, 16, 18, 21, 23], ['10100101010']],
[[8], [2, 4, 7, 8, 9, 12, 14, 17, 19, 22, 24], ['10100101010']],
[[9], [3, 5, 8, 9, 10, 13, 15, 18, 20, 23, 25], ['10100101010']],
[[10], [1, 4, 6, 9, 10, 11, 14, 16, 19, 21, 24], ['01010010101']],
[[11], [2, 5, 7, 10, 11, 12, 15, 17, 20, 22, 25], ['01010010101']],
[[12], [1, 3, 6, 8, 11, 12, 13, 16, 18, 21, 23], ['10101001010']],
[[13], [2, 4, 7, 9, 12, 13, 14, 17, 19, 22, 24], ['10101001010']],
[[14], [3, 5, 8, 10, 13, 14, 15, 18, 20, 23, 25], ['10101001010']],
[[15], [1, 4, 6, 9, 11, 14, 15, 16, 19, 21, 24], ['01010100101']],
[[16], [2, 5, 7, 10, 12, 15, 16, 17, 20, 22, 25], ['01010100101']],
[[17], [1, 3, 6, 8, 11, 13, 16, 17, 18, 21, 23], ['10101010010']],
[[18], [2, 4, 7, 9, 12, 14, 17, 18, 19, 22, 24], ['10101010010']],
[[19], [3, 5, 8, 10, 13, 15, 18, 19, 20, 23, 25], ['10101010010']],
[[20], [1, 4, 6, 9, 11, 14, 16, 19, 20, 21, 24], ['01010101001']],
[[21], [2, 5, 7, 10, 12, 15, 17, 20, 21, 22, 25], ['01010101001']],
[[22], [1, 3, 6, 8, 11, 13, 16, 18, 21, 22, 23], ['10101010100']],
[[23], [2, 4, 7, 9, 12, 14, 17, 19, 22, 23, 24], ['10101010100']],
[[24], [3, 5, 8, 10, 13, 15, 18, 20, 23, 24, 25], ['10101010100']],
[[25], [1, 4, 6, 9, 11, 14, 16, 19, 21, 24, 25], ['01010101010']]
]
to_return=[]
for i in range(len(a_list)):
for x in range(len(a_list[i][1])):
if a_list[i][1][x]==index:
to_return.append([a_list[i][0][0],a_list[i][2][0][a_list[i][1].index(index)]])
return(to_return)
to_return=[]
for i in range(25):
init='0'*64
insert = access_function(i+1)
for x in range(len(insert)):
if insert[x][-1]=='0':
init=xo(init,input_list[insert[x][0]-1])
if insert[x][-1]=='1':
init=xo(init,rotate_left(input_list[insert[x][0]-1],1))
to_return.append(init)
return(to_return)
def __theta(input_list):
def access_function(index):
a_list = [
[[1], [1, 2, 5, 7, 10, 12, 15, 17, 20, 22, 25], ['00101010101']],
[[2], [1, 2, 3, 6, 8, 11, 13, 16, 18, 21, 23], ['10010101010']],
[[3], [2, 3, 4, 7, 9, 12, 14, 17, 19, 22, 24], ['10010101010']],
[[4], [3, 4, 5, 8, 10, 13, 15, 18, 20, 23, 25], ['10010101010']],
[[5], [1, 4, 5, 6, 9, 11, 14, 16, 19, 21, 24], ['01001010101']],
[[6], [2, 5, 6, 7, 10, 12, 15, 17, 20, 22, 25], ['01001010101']],
[[7], [1, 3, 6, 7, 8, 11, 13, 16, 18, 21, 23], ['10100101010']],
[[8], [2, 4, 7, 8, 9, 12, 14, 17, 19, 22, 24], ['10100101010']],
[[9], [3, 5, 8, 9, 10, 13, 15, 18, 20, 23, 25], ['10100101010']],
[[10], [1, 4, 6, 9, 10, 11, 14, 16, 19, 21, 24], ['01010010101']],
[[11], [2, 5, 7, 10, 11, 12, 15, 17, 20, 22, 25], ['01010010101']],
[[12], [1, 3, 6, 8, 11, 12, 13, 16, 18, 21, 23], ['10101001010']],
[[13], [2, 4, 7, 9, 12, 13, 14, 17, 19, 22, 24], ['10101001010']],
[[14], [3, 5, 8, 10, 13, 14, 15, 18, 20, 23, 25], ['10101001010']],
[[15], [1, 4, 6, 9, 11, 14, 15, 16, 19, 21, 24], ['01010100101']],
[[16], [2, 5, 7, 10, 12, 15, 16, 17, 20, 22, 25], ['01010100101']],
[[17], [1, 3, 6, 8, 11, 13, 16, 17, 18, 21, 23], ['10101010010']],
[[18], [2, 4, 7, 9, 12, 14, 17, 18, 19, 22, 24], ['10101010010']],
[[19], [3, 5, 8, 10, 13, 15, 18, 19, 20, 23, 25], ['10101010010']],
[[20], [1, 4, 6, 9, 11, 14, 16, 19, 20, 21, 24], ['01010101001']],
[[21], [2, 5, 7, 10, 12, 15, 17, 20, 21, 22, 25], ['01010101001']],
[[22], [1, 3, 6, 8, 11, 13, 16, 18, 21, 22, 23], ['10101010100']],
[[23], [2, 4, 7, 9, 12, 14, 17, 19, 22, 23, 24], ['10101010100']],
[[24], [3, 5, 8, 10, 13, 15, 18, 20, 23, 24, 25], ['10101010100']],
[[25], [1, 4, 6, 9, 11, 14, 16, 19, 21, 24, 25], ['01010101010']]
]
to_return=[]
for i in range(len(a_list)):
for x in range(len(a_list[i][1])):
if a_list[i][1][x]==index:
to_return.append([a_list[i][0][0],a_list[i][2][0][a_list[i][1].index(index)]])
return(to_return)
def bitwise_set(set_0,set_1):
to_return=''
for i in range(len(set_1)):
if set_1[i]=='1':
if set_0[i]=='0':
to_return+='1'
if set_0[i]=='1':
to_return+='0'
if set_1[i]!='1':
to_return+=set_0[i]
return(to_return)
to_return=[]
for i in range(25):
insert = access_function(i+1)
init='0'*64
for x in range(len(insert)):
if insert[x][-1]=='0':
init=bitwise_set(init,input_list[insert[x][0]-1])
if insert[x][-1]=='1':
init=bitwise_set(init,rotate_left(input_list[insert[x][0]-1],1))
to_return.append(init)
return(to_return)
def ___theta(s):
def xor_bit(a,b):
return('1' if ((a == '1') ^ (b == '1')) else '0')
init=['0']*1600
a_set=s_l(str_concat(s))
for i in range(len(a_set)):
if a_set[i]=='1':
for x in range(len(theta_data[i])):
init[theta_data[i][x]]=xor_bit(init[theta_data[i][x]],'1')
return(L_P(str_concat(init),64))
def ____THETA(s):
s=str_concat(s)
to_return=''
for i in range(len(theta_index_data)):
insert=''
for x in range(len(theta_index_data[i])):
insert+=s[theta_index_data[i][x]]
to_return+=xor_seq(insert)
return(L_P(to_return,64))
def rho(s):
off_set=[0,1,190,28,91,
36,300,6,55,276,
3,10,171,153,231,
105,45,15,21,136,
210,66,253,120,78]
to_return=[]
for i in range(len(s)):
to_return.append(rotate_left(s[i],off_set[i]))
return(to_return)
def pi(s):
index=[0,6,12,18,24,
3,9,10,16,22,
1,7,13,19,20,
4,5,11,17,23,
2,8,14,15,21]
to_return=[]
for i in range(len(index)):
for x in range(len(s)):
if index[i]==x:
to_return.append(s[x])
return(to_return)
def chi(s):
def sf(find_list,set_main):
return(set_main.index(find_list))
sm=[[0,0],[1,0],[2,0],[3,0],[4,0],
[0,1],[1,1],[2,1],[3,1],[4,1],
[0,2],[1,2],[2,2],[3,2],[4,2],
[0,3],[1,3],[2,3],[3,3],[4,3],
[0,4],[1,4],[2,4],[3,4],[4,4]]
to_return=[]
for i in range(25):
to_return.append(xo(s[i],and_2str(not_str(s[sf([(sm[i][0]+1)%5,sm[i][1]],sm)]),s[sf([(sm[i][0]+2)%5,sm[i][1]],sm)])))
return(to_return)
def _chi(s):
set_0=['00000','00101','01011','01010',
'10110','10111','10001','10100',
'01101','01000','01110','01111',
'00011','00010','01100','01001',
'11010','11101','10011','10000',
'11100','11111','11001','11110',
'00110','00001','00111','00100',
'11000','11011','10101','10010']
set_1=['00000','00001','00011','00010',
'00110','00111','00101','00100',
'01100','01101','01111','01110',
'01010','01011','01001','01000',
'11000','11001','11011','11010',
'11110','11111','11101','11100',
'10100','10101','10111','10110',
'10010','10011','10001','10000']
def list_concat(list_of_lists):
to_return=[]
for i in range(len(list_of_lists)):
to_return+=list_of_lists[i]
return(to_return)
def L_P(SET,n):
to_return=[]
j=0
k=n
while k<len(SET)+1:
to_return.append(SET[j:k])
j=k
k+=n
return(to_return)
def rc_con(sub_set):
to_return=[]
for i in range(len(sub_set[0])):
insert=''
for x in range(len(sub_set)):
insert+=sub_set[x][i]
to_return.append(insert)
return(to_return)
to_return=[]
to_iter=L_P(s,5)
for i in range(len(to_iter)):
insert=[]
convert=rc_con(to_iter[i])
for x in range(len(convert)):
insert.append(set_0[set_1.index(convert[x])])
insert=rc_con(insert)
to_return.append(insert)
return(list_concat(to_return))
def iota(s,i_r):
def rc(t):
def xor_bit(a,b):
return('1' if ((a == '1') ^ (b == '1')) else '0')
if t%255==0:
return('1')
r=['1','0','0','0','0','0','0','0']
for i in range(1,(t%255)+1):
r = ['0'] + r
r[0] = xor_bit(r[0],r[8])
r[4] = xor_bit(r[4],r[8])
r[5] = xor_bit(r[5],r[8])
r[6] = xor_bit(r[6],r[8])
r = trunc(r,8)
return(r[0])
to_index=[]
for x in range(24):
to_check=''
RC = ['0']*64
for i in range(7):
RC[(2**i)-1]=rc(i+(7*x))
to_index.append(flip_string(str_concat(RC)))
s[0]=xo(s[0],to_index[i_r])
return(s)
def _iota(s,i_r):
iota_constants=['0000000000000000000000000000000000000000000000000000000000000001',
'0000000000000000000000000000000000000000000000001000000010000010',
'1000000000000000000000000000000000000000000000001000000010001010',
'1000000000000000000000000000000010000000000000001000000000000000',
'0000000000000000000000000000000000000000000000001000000010001011',
'0000000000000000000000000000000010000000000000000000000000000001',
'1000000000000000000000000000000010000000000000001000000010000001',
'1000000000000000000000000000000000000000000000001000000000001001',
'0000000000000000000000000000000000000000000000000000000010001010',
'0000000000000000000000000000000000000000000000000000000010001000',
'0000000000000000000000000000000010000000000000001000000000001001',
'0000000000000000000000000000000010000000000000000000000000001010',
'0000000000000000000000000000000010000000000000001000000010001011',
'1000000000000000000000000000000000000000000000000000000010001011',
'1000000000000000000000000000000000000000000000001000000010001001',
'1000000000000000000000000000000000000000000000001000000000000011',
'1000000000000000000000000000000000000000000000001000000000000010',
'1000000000000000000000000000000000000000000000000000000010000000',
'0000000000000000000000000000000000000000000000001000000000001010',
'1000000000000000000000000000000010000000000000000000000000001010',
'1000000000000000000000000000000010000000000000001000000010000001',
'1000000000000000000000000000000000000000000000001000000010000000',
'0000000000000000000000000000000010000000000000000000000000000001',
'1000000000000000000000000000000010000000000000001000000000001000']
s[0]=xo(s[0],iota_constants[i_r])
return(s)
def message_append(str_msg):
return(str_msg+'01')
def sha_3_hack_rate(output_len):
if output_len==224:
return(18)
if output_len==256:
return(17)
if output_len==384:
return(13)
if output_len==512:
return(9)
def sha_3_rate(output_len):
if output_len==224:
return(1152)
if output_len==256:
return(1088)
if output_len==384:
return(832)
if output_len==512:
return(576)
def pad(x,m):
j=(-m-2)%x
return('1'+'0'*j+'1')
def message_processing(bit_string,digest_len):
if len(bit_string)!=sha_3_rate(digest_len):
msg_bs = message_append(bit_string)
p = msg_bs + pad(sha_3_rate(digest_len),len(msg_bs))
if len(bit_string)==sha_3_rate(digest_len):
p=bit_string
to_split = L_P(p,8)
new_hex=[]
for i in range(len(to_split)):
new_hex.append(hex_double(int(flip_string(to_split[i]),2)))
back_append = 200-len(new_hex)
new_hex = new_hex+['00']*back_append
total_string=''
for i in range(len(new_hex)):
total_string+=new_hex[i]
to_insert = L_P(total_string,16)
to_return=[]
for i in range(len(to_insert)):
to_return.append(flip_string(L_P(to_insert[i],2)))
return(to_return)
def message_expansion(hex_list):
to_convert=''
for i in range(len(hex_list)):
to_convert+=bin_8bit(int(hex_list[i],16))
return(to_convert)
def message_bit_return(string_input):
bit_list=[]
for i in range(len(string_input)):
bit_list.append(bin_8bit(ord(string_input[i])))
return(l_s(bit_list))
def processing(message_string):
to_invert=L_P(message_bit_return(message_string),8)
to_return=[]
for i in range(len(to_invert)):
to_return.append(flip_string(to_invert[i]))
return(str_concat(to_return))
def main_bit_set(bit_string,digest_len):
#All this function does is take the primary sha_3 seed
#and return the block chain to be iterated to hashing.
front_append=L_P(bit_string,sha_3_rate(digest_len))
back_string=''
for i in range(len(bit_string)%sha_3_rate(digest_len)):
back_string+=bit_string[-(i+1)]
back_string=flip_string(back_string)
return(front_append+[back_string])
def xo_set(list_string_0,list_string_1):
to_return=[]
for i in range(len(list_string_0)):
to_return.append(xo(list_string_0[i],list_string_1[i]))
return(to_return)
def zero_pad(bit_string):
while len(bit_string)!=1600:
bit_string+='0'
return(L_P(bit_string,64))
def edian_bit_convert(list_of_strings):
to_return=[]
for i in range(len(list_of_strings)):
inter=L_P(list_of_strings[i],8)
insert=''
for x in range(1,len(inter)+1):
insert+=inter[-x]
to_return.append(insert)
return(to_return)
def edian_byte_convert(list_strings):
to_return=[]
for i in range(len(list_strings)):
inter=L_P(list_strings[i],2)
insert=''
for x in range(1,len(inter)+1):
insert+=inter[-x]
to_return.append(insert)
return(to_return)
def hex_bin_convert(hex_string):
to_return=''
for i in range(len(hex_string)):
to_return+=bin_4bit(int(hex_string[i],16))
return(to_return)
def set_convert(list_hex_string):
to_return=[]
def hex_bin_convert(hex_string):
to_return=''
for i in range(len(hex_string)):
to_return+=bin_4bit(int(hex_string[i],16))
return(to_return)
for i in range(len(list_hex_string)):
to_return.append(hex_bin_convert(list_hex_string[i]))
return(to_return)
def output_final(input_set,digest_len):
to_flip=[]
if digest_len!=224:
for i in range(int(digest_len/64)):
to_flip.append(input_set[i])
if digest_len==224:
for i in range((digest_len//64)+1):
to_flip.append(input_set[i])
to_convert=[]
for i in range(len(to_flip)):
to_convert.append(L_P(to_flip[i],8))
bin_list=[]
for i in range(len(to_convert)):
bin_list.append(flip_string(to_convert[i]))
bin_list=L_P(str_concat(bin_list),4)
to_return=[]
for i in range(len(bin_list)):
to_return.append(hex_single(int(bin_list[i],2)))
to_return=str_concat(to_return)
if digest_len!=224:
return(to_return)
return(to_return[0:56])
#=========================================================================
#BELOW
#=========================================================================
def set_invert(list_bin_string):
to_return=[]
for i in range(len(list_bin_string)):
inter=L_P(list_bin_string[i],4)
insert=''
for x in range(len(inter)):
insert+=hex_single(int(inter[x],2))
to_return.append(insert)
return(to_return)
def message_processing_invert(a_input,digest_len):
invert_0=edian_byte_convert(a_input)
invert_1=[]
for i in range(sha_3_hack_rate(digest_len)):
invert_1.append(invert_0[i])
invert_2=L_P(str_concat(invert_1),2)
invert_3=''
for i in range(len(invert_2)):
insert=''
for x in range(1,len(invert_2[i])+1):
insert+=flip_string(bin_4bit(int(invert_2[i][-x],16)))
invert_3+=insert
return(invert_3)
def s3b(bit_string,digest_len):
if len(bit_string) < sha_3_rate(digest_len):
x = L_P(message_expansion(L_P(str_concat(message_processing(bit_string,digest_len)),2)),64)
for i in range(24):
x = _iota(_chi(pi(rho(theta(x)))),i)
return(output_final(x,digest_len))
if len(bit_string) >= sha_3_rate(digest_len):
set_main=main_bit_set(bit_string,digest_len)
#print(set_main)
x=L_P(message_expansion(L_P(str_concat(message_processing(set_main[0],digest_len)),2)),64)
for i in range(24):
x = _iota(_chi(pi(rho(theta(x)))),i)
for c in range(len(set_main)-1):
var_0=edian_bit_convert(x)
#print(var_0)
#XOR var_0 pass through invert then execute
var_1=set_convert(edian_byte_convert(message_processing(set_main[c+1],digest_len)))
#print(var_1)
#print(message_processing_invert(edian_byte_convert(set_invert(var_1)),digest_len))
var_2=edian_bit_convert(xo_set(var_0,var_1))
#return(var_2)
#break
for i in range(24):
var_2=_iota(_chi(pi(rho(theta(var_2)))),i)
x=var_2
return(output_final(x,digest_len))
def tv_bit_return(tv_string,len_str):
tv_string=hex_bin_convert(tv_string)
tv_string=edian_bit_convert(L_P(tv_string,8))
for i in range(len(tv_string)):
tv_string[i]=flip_string(tv_string[i])
total=''
for i in range(len(tv_string)):
total+=tv_string[i]
return(total[0:len_str])
def NIST_test_vector(digest_len,test_vector_string,tl):
return(s3b(tv_bit_return(test_vector_string,tl),digest_len))
def online_convert(a_string,digest_len):
#Online convert will match sha_3 implementation provided
#by python 3.6 distribution. And online sha_3 generators.
#It's a one for one string conversions. s3b is a bit aligned
#sha_3 implementations.
to_return=''
for i in range(len(a_string)):
to_return+=flip_string(message_bit_return(a_string[i]))
return(s3b(to_return,digest_len))
def str_build(a_list):
to_return=''
for i in range(len(a_list)):
to_return+=str(a_list[i])
return(to_return)
def set_main_build(size,iter_len):
import numpy
to_return=[]
for i in range(iter_len):
to_return.append(str_build(list(numpy.random.randint(2,size=(size,)))))
return(to_return)
def sha_seed():
return(set_main_build(64,25))
def to_print(object):
for i in range(len(object)):
print(object[i])
#============================================================================================
#DIRECTION DOWN THETA INVERT CORE
#============================================================================================
def THETA_COMPARE(t_0,t_1,col):
#Theta compare will take two possible theta through puts and returns True
#if both col's of the theta through puts are equal values. Returns
#False is the theta through puts are not the same values.
for i in range(len(t_0)):
if t_0[i][col]!=t_1[i][col]:
return(False)
return(True)
def t_3(a_xyz):
order_return=[]
for i in range(5):
order_return.append([a_xyz[i],a_xyz[i+5],a_xyz[i+10],a_xyz[i+15],a_xyz[i+20]])
return(list_concat(order_return))
def rc_con(sub_set):
#Function to take take some set and do a row column split
to_return=[]
for i in range(len(sub_set[0])):
insert=''
for x in range(len(sub_set)):
insert+=sub_set[x][i]
to_return.append(insert)
return(to_return)
def mod_5_split(theta_through_put):
#Function will take a theta throug put and will grab 5 row checks
#for processing. Once 5 rwo chucks are returned the function return
#do a row column conversion.
to_convert=L_P(theta_through_put,5)
to_return=[]
for i in range(len(to_convert)):
to_return.append(rc_con(to_convert[i]))
return(to_return)
def COI_RETURN(op,coi):
#First call to mod_5_split
if coi != 63:
to_iter=mod_5_split(t_3(op))
set_0=[]
for i in range(len(to_iter)):
set_0.append(to_iter[i][coi])
to_return_0=[]
for i in range(len(set_0)):
to_return_0.append([set_0[i],not_str(set_0[i])])
set_1=[]
for i in range(len(to_iter)):
set_1.append(to_iter[i][coi+1])
to_return_1=[]
for i in range(len(set_1)):
to_return_1.append([set_1[i],not_str(set_1[i])])
return(to_return_0,to_return_1)
if coi == 63:
to_iter=mod_5_split(t_3(op))
set_0=[]
for i in range(len(to_iter)):
set_0.append(to_iter[i][coi])
to_return_0=[]
for i in range(len(set_0)):
to_return_0.append([set_0[i],not_str(set_0[i])])
set_1=[]
for i in range(len(to_iter)):
set_1.append(to_iter[i][0])
to_return_1=[]
for i in range(len(set_1)):
to_return_1.append([set_1[i],not_str(set_1[i])])
return(to_return_0,to_return_1)
def theta_allocation_builder(str_set_0,str_set_1,coi):
#This is a lazy step to handel end point index wrapping code length could
#be reduced pointing to the index 63 for to_allocate[i][0].
if coi != 63:
to_allocate=L_P([0]*1600,64)
for i in range(len(str_set_0)):
to_allocate[i][coi]=str_set_0[i]
to_allocate[i][coi+1]=str_set_1[i]
to_return=[]
for i in range(len(to_allocate)):
insert=''
for x in range(len(to_allocate[i])):
if type(to_allocate[i][x])!=type(''):
insert+=str(to_allocate[i][x])
if type(to_allocate[i][x])==type(''):
insert+=to_allocate[i][x]
to_return.append(insert)
return(to_return)
if coi == 63:
to_allocate=L_P([0]*1600,64)
for i in range(len(str_set_0)):
to_allocate[i][coi]=str_set_0[i]
to_allocate[i][0]=str_set_1[i]
to_return=[]
for i in range(len(to_allocate)):
insert=''
for x in range(len(to_allocate[i])):
if type(to_allocate[i][x])!=type(''):
insert+=str(to_allocate[i][x])
if type(to_allocate[i][x])==type(''):
insert+=to_allocate[i][x]
to_return.append(insert)
return(to_return)
def THETA_BOUND(theta_input,digest_len):
front_append=theta_input[0:sha_3_hack_rate(digest_len)]
back_append=['0'*64]*(25-sha_3_hack_rate(digest_len))
return(front_append+back_append)
def MOD_5_THETA_BREAK(op,coi):
coi_hold=list_concat(COI_RETURN(op,coi))
to_return=[]
for i in range(1024):
a_str=''
c_str=bin_n_bit(i,'10')
for x in range(len(c_str)):
if c_str[x]=='0':
a_str+=coi_hold[x][0]
if c_str[x]=='1':
a_str+=coi_hold[x][1]
allocation_set=L_P(a_str,25)
insert=t_3(theta_allocation_builder(allocation_set[0],allocation_set[1],coi))
a_theta=theta(insert)
if THETA_COMPARE(a_theta,op,coi)==True:
to_return.append(insert)
return(to_return)
def index_search(a_set,index_set):
#This function will take a set and a respective index set and
#return the index locations if a_set
to_return=[]
for i in range(len(index_set)):
to_return.append(a_set[index_set[i]])
return(to_return)
def rc_lcon(sub_set):
to_return=[]
for i in range(len(sub_set[0])):
insert=[]
for x in range(len(sub_set)):
insert+=[sub_set[x][i]]
to_return.append(insert)
return(to_return)
def THETA_SET_COMPARE(t_0,t_1,col_set):
for i in range(len(col_set)):
if THETA_COMPARE(t_0,t_1,col_set[i])==False:
return(False)
return(True)
def THETA_COL_EXTRACT(a_theta,col_set):
return(index_search(rc_con(a_theta),col_set))
def THETA_COL_INSERT(insert_val_str_set,col_set):
to_allocate=rc_lcon(L_P([0]*1600,64))
for i in range(len(col_set)):
for x in range(len(to_allocate)):
to_allocate[col_set[i]]=insert_val_str_set[i]
to_return=[]
for i in range(len(to_allocate)):
if type(to_allocate[i])!=type(''):
to_return.append('0'*25)
if type(to_allocate[i])==type(''):
to_return.append(to_allocate[i])
return(rc_con(to_return))
#=================================================================================================
#DIRECTION UP THETA INVERT CORE
#==================================================================================================
'''
BELOW INVERT FUNCTION CORE
'''
def THETA_INVERT(op,fuzzy_bool,digest_len):
data=[]
for i in range(64):
if fuzzy_bool==True:
data.append(MOD_5_THETA_BREAK(THETA_BOUND(op,digest_len),i))
if fuzzy_bool==False:
data.append(MOD_5_THETA_BREAK(op,i))
print(i)
print(len(data[-1]))
to_return=[]
for i in range(len(data[0])):
for x in range(len(data[1])):
if THETA_COMPARE(data[0][i],data[1][x],1)==True:
i_0=THETA_COL_EXTRACT(data[0][i],[0,1])
i_1=THETA_COL_EXTRACT(data[1][x],[2])
to_insert=THETA_COL_INSERT(i_0+i_1,[0,1,2])
to_check=theta(to_insert)
if THETA_SET_COMPARE(to_check,op,[0,1])==True:
to_return.append(to_insert)
to_hold=[to_return]
for meta in range(2,63):
insert=[]
print(meta)
for i in range(len(data[meta])):
for x in range(len(to_hold[-1])):
if THETA_COMPARE(data[meta][i],to_hold[-1][x],meta)==True:
i_0=THETA_COL_EXTRACT(to_hold[-1][x],range(meta+1))
i_1=THETA_COL_EXTRACT(data[meta][i],[meta+1])
to_insert=THETA_COL_INSERT(i_0+i_1,range(meta+2))
to_check=theta(to_insert)
if THETA_SET_COMPARE(to_check,op,range(meta+1))==True:
insert.append(to_insert)
to_hold.append(insert)
for i in range(len(to_hold[-1])):
if theta(to_hold[-1][i])==op:
return(to_hold[-1][i])
def RHO_INVERT(s):
off_set=[0,1,190,28,91,
36,300,6,55,276,
3,10,171,153,231,
105,45,15,21,136,
210,66,253,120,78]
to_return=[]
for i in range(len(s)):
to_return.append(rotate_right(s[i],off_set[i]))
return(to_return)
def PI_INVERT(s):
index=[0,10,20,5,15,
16,1,11,21,6,
7,17,2,12,22,
23,8,18,3,13,
14,24,9,19,4]
to_return=[]
for i in range(len(index)):
for x in range(len(s)):
if index[i]==x:
to_return.append(s[x])
return(to_return)
def CHI_INVERT(s):
set_1=['00000','00101','01011','01010',
'10110','10111','10001','10100',
'01101','01000','01110','01111',
'00011','00010','01100','01001',
'11010','11101','10011','10000',
'11100','11111','11001','11110',
'00110','00001','00111','00100',
'11000','11011','10101','10010']
set_0=['00000','00001','00011','00010',
'00110','00111','00101','00100',
'01100','01101','01111','01110',
'01010','01011','01001','01000',
'11000','11001','11011','11010',
'11110','11111','11101','11100',
'10100','10101','10111','10110',
'10010','10011','10001','10000']
def list_concat(list_of_lists):
to_return=[]
for i in range(len(list_of_lists)):
to_return+=list_of_lists[i]
return(to_return)
def L_P(SET,n):
to_return=[]
j=0
k=n
while k<len(SET)+1:
to_return.append(SET[j:k])
j=k
k+=n
return(to_return)
def rc_con(sub_set):
to_return=[]
for i in range(len(sub_set[0])):
insert=''
for x in range(len(sub_set)):
insert+=sub_set[x][i]
to_return.append(insert)
return(to_return)
to_return=[]
to_iter=L_P(s,5)
for i in range(len(to_iter)):
insert=[]
convert=rc_con(to_iter[i])
for x in range(len(convert)):
insert.append(set_0[set_1.index(convert[x])])
insert=rc_con(insert)
to_return.append(insert)
return(list_concat(to_return))
def IOTA_INVERT(s,i_r):
return(_iota(s,i_r))
'''
When producing a FSC the first call will be to import a random bit string
at a user defined capacity length defined for one of the sha-3 family of
functions. Once this capacity length has been established the nest step
will be to produce the compliment of that that same bit string. Once this
has been completed both functions will be back appended with zeros until
they reach 1600 bits. The unpadded versions will be held to pass through
message_processing_invert().
'''
'''
Free start Dump
'''
def FORMATING_INVERT(primary_seed,digest_len):
return(message_processing_invert(edian_byte_convert(set_invert(primary_seed)),digest_len))
def FREE_START_TEST(initial_vector,next_block):
for i in range(24):
initial_vector=_iota(_chi(pi(rho(____THETA(initial_vector)))),i)
for i in range(24):
next_block=_iota(_chi(pi(rho(____THETA(next_block)))),i)
return(xo_set(initial_vector,next_block))
'''
When building a free start collision values that should be returned are
input_copy and inverted
'''
initial_vector_0=[
'0001100010111010010011010010100010111011000100001110101001001100',
'1111101100111100001110010110111001100001110101101101101000100001',
'0110010010111111000111101000000100010010111101011110001011010101',
'0001111000111111111100011001100001110011100010010111100100000110',
'1101000001010010011100110101010101001111100100001111111111110011',
'0110101010110100110110010001100111011000100110001101000110011111',
'0101110001101010100010000100001101001111111000001101011000000101',
'1101001100001000101001000000111100011100000111011011010110000010',
'1111001100100111011011110011000101010100111010000001011100100111',
'0010101111001100000101011000100100100010010111111000111100101000',
'0100011010101111010000010011011101110010111001100101000000011101',
'0010001101111100001010110101000101011100110111010110110011110100',
'1110101011110000111111000001010011001011100101010100011101101100',
'1100110001100111011001110001001010000011110001110001101101000011',
'0000010011101111010111001100000111000101010001111001101010101011',
'1101011111011011011011110011010011001101011011100101101010000111',
'0011010101110100101011101010100101010001010011100001111010001001',
'1011100001001010001000001010110000111010001110101001100101011000',
'0000100000101101111101001000001011011001000101000001000010010101',
'0111011010010110100111111111110010011011000110111110000001010101',
'1010000111011001001101011110110000001001100010010110000000011100',
'1001001110001111000001000110100001100000110100011101000100100110',
'1011110010000110001111010011110101111101110001110010100010010001',
'1110101110011000011000000111010011010111101000110010110011011101',
'0001111011111100001000110001011101001110110001101110010000101001']
next_block_0=[
'1100111010000010101001100011001000100110110111001011010111101001',
'0101110001011011111011101001101011001101001001011000111101111100',
'1001001101001000101111101111011110010101110011111001001100000001',
'0101000010111111011000000000110001000111011100110001110110000010',
'0010001100100011010100011011010000110101111100110010110010010010',
'0010101001101000110000111111000110011000111000011010011101001011',
'1110110001111001011100011110100100010001100000010101010101001001',
'1001011000001110010101100001110011111001001000000000010011000010',
'1011111001011111000001101011000110110000111110011101001011100011',
'0001100111010001111110011001010011000111011010110010010000101010',
'0000101000001111101000101001000110001111000100011111010101110001',
'0000011101010101001110010000000111011100010001101010101100111010',
'1010101011000011110001111000111011000010110011110111100011110110',
'0000111100010100111001110001000000000001110111011110001000000000',
'0101001100100000011100111001111111001000110111111001010100101000',
'0010000111101100110101101011010100011111110010000001101000001100',
'1101001010100000111011000111100100000111011111101100101001111010',
'0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000']
initial_vector_1=[
'1110011111100100011110011010011110110000000110011011111001110011',
'1010000001101101010101010111001011101100011100110000111111000100',
'1000101101000110110110010011110001011010111110111011100001010100',
'1010011000010011111000001100101100111010100001011110101110110100',
'1111011001010101000101111000011101010110111001001111111110001000',
'1011011001110101110101000110100011000001010111010111000101101100',
'1101111010011010011100110101111010000100110101010011001011001011',
'1001001011000101101100101010010001011011101110111000001000111011',
'1010001101011110001001000000010001101010011011010100010001110110',
'0111101000011011111011101011111101001111100101011110110001011011',
'0111110110101100011101110111010011100001001000011100110000010100',
'1111001011000111111101111000010100010001101110111110110010001000',
'1011011111111011111101110101011001101101100100101001010010100110',
'1000000001100110010001000111111011011101001000011010001000100110',
'1011000000000110001011100000110110001100001101100000111111110111',
'1110110000101110101111101111110001110111111100001001111100100110',
'1011011001100110100101101100101101110101101100000001111101010000',
'0111001000111111011010010101110101010111100011110010100101001011',
'0101010001000011110111000110000101101110100111010010110101000000',
'1001000101010001001000010100101010111101001010101110010001001101',
'0000110100100101011000101010010110011101100011110010011101001110',
'1011011000101011110111001001100101111001110000011011001100111010',
'1000010100110010110001000101011011101110111001000110110110111011',
'0110001100101111000101111001101001011000011101000100001110100011',
'0110001011001101101011101000101000010001001101011010111010110111']
next_block_1=[
'1011010000000001011100101111000000011010001101001010110101111010',
'1001011111101110111010010101101000100000101010111111010110101100',
'1001010011111101101001101110010010000110000010101010101101111101',
'1011100101001110000100000110100000101001110000110110000011101010',
'1100101100111100000000011100111100111010000110000001101100011010',
'0001011000111110010000001011010000111110101111010110101010000000',
'1011010000110110101100100111100100010001011101001110001010111000',
'1001100111100100111100110110000101001001010101100001000001101110',
'0101011111100111100111111011110010010110000111110001101000101110',
'0011010111011001010110001010010101111111111111101010001001100000',
'0110001101011101101010010101000001001111111011110100011111111011',
'0111000101101011101101010001001011101101101011100000110101010010',
'1101110110001011111100011010100000010001100100110100101100100101',
'0110000000010011110000000110100000100100100001111000111000010000',
'0000110000101001011010100001111010101111011110101110101010110110',
'0100000101110101001110110011000110001110111000011000010100001101',
'0111001101100010010011100000101111100010100010000011001001101001',
'0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000']
##digest_len=256
##fuzzy_bool=True
##primary_seed=str_concat(set_main_build(64,sha_3_hack_rate(digest_len)))
##set_main=main_bit_set(primary_seed,digest_len)
##x=L_P(message_expansion(L_P(str_concat(message_processing(set_main[0],digest_len)),2)),64)
##input_copy=list(x)
##to_print(x)
##for i in range(24):
## x = _iota(_chi(pi(rho(____THETA(x)))),i)
##to_invert=list(x)
##for i in range(sha_3_hack_rate(digest_len)):
## to_invert[i]=not_str(to_invert[i])
##inverted=list(to_invert)
##for i in range(24):
## inverted=THETA_INVERT(RHO_INVERT(PI_INVERT(CHI_INVERT(IOTA_INVERT(inverted,23-i)))),fuzzy_bool,digest_len)
## print('COMPLETED',i)
####x=['1110100111010001001110111110100010110000001100101010001101101000',
#### '0100110100110110000100011100101101100111001000110111001101011110',
#### '1010011000011110001011100011111000110011110101011100110110100000',
#### '0111110100000000011001111110101110110111011001110111011010011000',
#### '1001000000000001101011010000000110100110000111110001111110011101',
#### '0100110111010000110000011000111001011101111011110110111011100101',
#### '1011110000001001001101010110011101101110010011110011100110101110',
#### '0011100110100000101011100010011001110100111111101000110010000110',
#### '0001011101111001000111001101000111000111111000110000010110011110',
#### '1101111010000001110101100110000100110101001010110000011010010011',
#### '0001010101001100000101010001101110101000110010011000110110001100',
#### '1101110000110010001011110111000000000010010010110001110011111100',
#### '0101001110110001110111010001000111110000001010001110100111011111',
#### '1000010000001111101010100001111111100011000010000100101100001000',
#### '0110000101011100110100100101111101101111001110001000111011101101',
#### '1000010111011100110011101001001001011001101110101110000001011010',
#### '0010101000000010111001001110100010001111010111110001110001011000',
#### '1101001101000100010011111100001111001111100001100000011101111001',
#### '1101111011000011100101110110000001100001010111010111000110101101',
#### '1110111000000010000100010111101101100011010110011001001110111001',
#### '0101110110010000111001000101001010010100100011101100110100001101',
#### '0010010111111000101000101000010000001000101100011001010001100110',
#### '0101011010011010011110000001000100010111000011011101111101101011',
#### '1011111011100110111111011101001101000011000001101110000010011100',
#### '0100001011010100111001010001100010000101010001000100011100011101']
##
####inverted=['1110011111100100011110011010011110110000000110011011111001110011',
#### '1010000001101101010101010111001011101100011100110000111111000100',
#### '1000101101000110110110010011110001011010111110111011100001010100',
#### '1010011000010011111000001100101100111010100001011110101110110100',
#### '1111011001010101000101111000011101010110111001001111111110001000',
#### '1011011001110101110101000110100011000001010111010111000101101100',
#### '1101111010011010011100110101111010000100110101010011001011001011',
#### '1001001011000101101100101010010001011011101110111000001000111011',
#### '1010001101011110001001000000010001101010011011010100010001110110',
#### '0111101000011011111011101011111101001111100101011110110001011011',
#### '0111110110101100011101110111010011100001001000011100110000010100',
#### '1111001011000111111101111000010100010001101110111110110010001000',
#### '1011011111111011111101110101011001101101100100101001010010100110',
#### '1000000001100110010001000111111011011101001000011010001000100110',
#### '1011000000000110001011100000110110001100001101100000111111110111',
#### '1110110000101110101111101111110001110111111100001001111100100110',
#### '1011011001100110100101101100101101110101101100000001111101010000',
#### '0111001000111111011010010101110101010111100011110010100101001011',
#### '0101010001000011110111000110000101101110100111010010110101000000',
#### '1001000101010001001000010100101010111101001010101110010001001101',
#### '0000110100100101011000101010010110011101100011110010011101001110',
#### '1011011000101011110111001001100101111001110000011011001100111010',
#### '1000010100110010110001000101011011101110111001000110110110111011',
#### '0110001100101111000101111001101001011000011101000100001110100011',
#### '0110001011001101101011101000101000010001001101011010111010110111']
##
####to_invert=['0000111010001000001100010101010011010001100100000111010101111110',
#### '1110100101011100101101101101110111111000101011101010100011010110',
#### '1010000011011101101110000001110100100001101101111000100011110011',
#### '0100011110001010001110000110011110010110010001010001111111110111',
#### '0111101010000010000100110011000110101001101101111110001010111111',
#### '1001011011110010010010111111101111111000000011111101001100110101',
#### '1001010100101011100100011011100110100000110111111111110111111110',
#### '1011101000010011001001101110010000100110011000111100001011010000',
#### '1100111111101101110011110100100001101000000010100011100010110111',
#### '0110111110001100010011000011110110101000101110101101011111001001',
#### '1101110111100000100101001001001101100110101011100101011000111101',
#### '1001100000010101100001011100001110100011011001010011000000000110',
#### '0110010110011100101101101110110010010100101001101100100010001000',
#### '1111111101000101111101000100101111101101000010000111100111011000',
#### '1101001010000110110001010100110011111101000110011011111111010010',
#### '1000000101111001000100110001011000000100001110010110011110011110',
#### '1110101101110011110101001110100111011111001100000000010100110111',
#### '1011110010100111000000111101001000110001111110100100101011001000',
#### '1110100001111010110110011110101101010000110100111100111001000011',
#### '0110110011110111110000110011011001001111111101011010101100001001',
#### '0011011101010110000110111000101111111101111110000001011110101101',
#### '0010100100101111110100110101101010100001110110100000110011100101',
#### '1000111001101010011010001010110001010110100110111000100100010010',
#### '0010111101001011111000001100111001010010000110001010001011101110',
#### '0110110100100010101110010011000100000001110011111100110110101000']
####
####input_copy=['1011010000000001011100101111000000011010001101001010110101111010',
#### '1001011111101110111010010101101000100000101010111111010110101100',
#### '1001010011111101101001101110010010000110000010101010101101111101',
#### '1011100101001110000100000110100000101001110000110110000011101010',
#### '1100101100111100000000011100111100111010000110000001101100011010',
#### '0001011000111110010000001011010000111110101111010110101010000000',
#### '1011010000110110101100100111100100010001011101001110001010111000',
#### '1001100111100100111100110110000101001001010101100001000001101110',
#### '0101011111100111100111111011110010010110000111110001101000101110',
#### '0011010111011001010110001010010101111111111111101010001001100000',
#### '0110001101011101101010010101000001001111111011110100011111111011',
#### '0111000101101011101101010001001011101101101011100000110101010010',
#### '1101110110001011111100011010100000010001100100110100101100100101',
#### '0110000000010011110000000110100000100100100001111000111000010000',
#### '0000110000101001011010100001111010101111011110101110101010110110',
#### '0100000101110101001110110011000110001110111000011000010100001101',
#### '0111001101100010010011100000101111100010100010000011001001101001',
#### '0000000000000000000000000000000000000000000000000000000000000000',
#### '0000000000000000000000000000000000000000000000000000000000000000',
#### '0000000000000000000000000000000000000000000000000000000000000000',
#### '0000000000000000000000000000000000000000000000000000000000000000',
#### '0000000000000000000000000000000000000000000000000000000000000000',
#### '0000000000000000000000000000000000000000000000000000000000000000',
#### '0000000000000000000000000000000000000000000000000000000000000000',
#### '0000000000000000000000000000000000000000000000000000000000000000']
####to_check_0=list(input_copy)
####to_check_1=list(inverted)
####for i in range(24):
#### input_copy = _iota(_chi(pi(rho(____THETA(input_copy)))),i)
####
####for i in range(24):
#### inverted=_iota(_chi(pi(rho(____THETA(inverted)))),i)
##
##
##
####for i in range(24):
#### test_0 = _iota(_chi(pi(rho(____THETA(test_0)))),i)
####
####for i in range(24):
#### v_1=_iota(_chi(pi(rho(____THETA(v_1)))),i)
##
##
##
##
##
##
###print(set_main)
####for i in range(24):
#### x = _iota(_chi(pi(rho(____THETA(x)))),i)
####for c in range(len(set_main)-1):
#### var_0=edian_bit_convert(x)
#### #print(var_0)
#### #XOR var_0 pass through invert then execute
#### var_1=set_convert(edian_byte_convert(message_processing(set_main[c+1],digest_len)))
#### #print(var_1)
#### #print(message_processing_invert(edian_byte_convert(set_invert(var_1)),digest_len))
#### var_2=edian_bit_convert(xo_set(var_0,var_1))
#### #return(var_2)
#### #break
#### for i in range(24):
#### var_2=_iota(_chi(pi(rho(____THETA(var_2)))),i)
#### x=var_2
####print(output_final(x,digest_len))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment