SHA-3: http://csrc.nist.gov/publications/drafts/fips-202/fips_202_draft.pdf
I’m working on a Python implementation of SHA-3(256) and using the intermediate hash value found at http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA3-256_Msg30.pdf for the example 30-bit hash message. I’m having trouble with the indexing of the state array.
In the 30-bit SHA-3(256) example message, see “Xor'd state (as lanes of integers)”, before Theta() of Round #0.
[0, 0] = 00000001997b5853
[1, 0] = 0000000000000000
[2, 0] = 0000000000000000
[3, 0] = 0000000000000000
[4, 0] = 0000000000000000
[0, 1] = 0000000000000000
[1, 1] = 0000000000000000
[2, 1] = 0000000000000000
[3, 1] = 0000000000000000
[4, 1] = 0000000000000000
[0, 2] = 0000000000000000
[1, 2] = 0000000000000000
[2, 2] = 0000000000000000
[3, 2] = 0000000000000000
[4, 2] = 0000000000000000
[0, 3] = 0000000000000000
[1, 3] = 8000000000000000
[2, 3] = 0000000000000000
[3, 3] = 0000000000000000
[4, 3] = 0000000000000000
[0, 4] = 0000000000000000
[1, 4] = 0000000000000000
[2, 4] = 0000000000000000
[3, 4] = 0000000000000000
[4, 4] = 0000000000000000
I'm assuming that the lanes are labeled [x,y], and are with respect to the convention outline in SHA-3, 3.1.4 Where [0,0]=00000001997b5853 would represent the middle lane of the state array.
I can produce those 25 64-bit lanes. My understanding is that, if you concatenate those lanes top to bottom, that is to say in the order with which they appear in the example document, that you will have produced the total bit string representing the state array, that is to then be passed to Theta()? string_representing_state_array='0000000000000000000000000000000110011001011110110101100001010011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
Now the from 3.1.2, A[x,y,z]=S[w(5y+x)+z]
And w is constant 64.
C[x,z]=S[w(5(0)+x)+z] ? S[w(5(1)+x)+z] ? S[w(5(2)+x)+z] ? S[w(5(3)+x)+z] ? S[w(5(4)+x)+z].
Function exclusive or:
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 L_P(SET,n):
#A function to break SET into n length chunks
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 beta_theta(s):
c_xz=[]
for x in range(5):
for z in range(64):
c_xz.append(xo(xo(xo(xo(s[(64*((5*4)+x))+z],s[(64*((5*3)+x))+z]),s[(64*((5*2)+x))+z]),s[(64*((5*1)+x))+z]),s[(64*((5*0)+x))+z]))
c_xz=L_P(c_xz,64)
return(c_xz)
Where s=string_representing_state_array.
My question now is if the function beta_theta(s) returns, c_xz, with the correct indexing for step 2 in theta()? I'm taking a 320 bit c_xz and splitting it into 5 64-bit chunks, but I don't feel like this would return the correct index to produce d_xz.
PS. SHA-3 <<<<<<< Occam's Razor.
