-rwxr-xr-x 6947 libntruprime-20241008/crypto_hashblocks/sha512/avx2/rer.py raw
#!/usr/bin/env python3 import sys j = int(sys.argv[1]) j0 = (j+0)&15 j1 = (j+1)&15 j2 = (j+2)&15 j3 = (j+3)&15 j9 = (j+9)&15 j14 = (j+14)&15 k0 = (j+8)&15 k1 = (j+9)&15 k2 = (j+10)&15 k3 = (j+11)&15 wcin = 'wc%d%d%d%d' % (k0,k1,k2,k3) wcout = 'wc%d%d%d%d' % (j0,j1,j2,j3) i0 = (j+0)&7 i1 = (j+1)&7 i2 = (j+2)&7 i3 = (j+3)&7 i4 = (j+4)&7 i5 = (j+5)&7 i6 = (j+6)&7 i7 = (j+7)&7 print(' X%d = mem256[&w + %d]' % (j1,8*j1)) print(' 4x X%dright1 = X%d unsigned>> 1' % (j1,j1)) print(' r%dSigma1 = r%d>>>14' % (i4,i4)) print(' r%d += %s[0]' % (i7,wcin)) print(' ch%d = r%d' % (i7,i6)) print(' ch%d ^= r%d' % (i7,i5)) print('') print(' 4x X%dleft63 = X%d << 63' % (j1,j1)) print(' r%d18 = r%d>>>18' % (i4,i4)) print(' ch%d &= r%d' % (i7,i4)) print(' maj%d = r%d' % (i6,i1)) print(' maj%d ^= r%d' % (i6,i0)) print('') print(' X%dsigma0 = X%dright1 ^ X%dleft63' % (j1,j1,j1)) print(' r%d41 = r%d>>>41' % (i4,i4)) print(' r%dSigma1 ^= r%d18' % (i4,i4)) print(' ch%d ^= r%d' % (i7,i6)) print('') print(' 4x X%dright8 = X%d unsigned>> 8' % (j1,j1)) print(' r%dSigma1 ^= r%d41' % (i4,i4)) print(' r%dSigma0 = r%d>>>28' % (i0,i0)) print(' r%d += ch%d' % (i7,i7)) print('') print(' X%dsigma0 = X%dsigma0 ^ X%dright8' % (j1,j1,j1)) print(' r%d34 = r%d>>>34' % (i0,i0)) print(' r%d += r%dSigma1' % (i7,i4)) print(' maj%d = r%d' % (i7,i2)) print(' maj%d &= maj%d' % (i7,i6)) print('') print(' W%d = mem128[&w + %d],0' % (j14,8*j14)) print(' 2x,0 W%dright19 = W%d unsigned>> 19' % (j14,j14)) print(' r%dSigma0 ^= r%d34' % (i0,i0)) print(' r%d39 = r%d>>>39' % (i0,i0)) print(' r%d += r%d' % (i3,i7)) print('') print(' 4x X%dleft56 = X%d << 56' % (j1,j1)) print(' r%dSigma0 ^= r%d39' % (i0,i0)) print(' r%d += %s[1]' % (i6,wcin)) print(' r%dandr%d = r%d' % (i0,i1,i1)) print(' r%dandr%d &= r%d' % (i0,i1,i0)) print('') print(' 2x,0 W%dleft45 = W%d << 45' % (j14,j14)) print(' r%d += r%dSigma0' % (i7,i0)) print(' maj%d ^= r%dandr%d' % (i7,i0,i1)) print(' ch%d = r%d' % (i6,i5)) print(' ch%d ^= r%d' % (i6,i4)) print('') print(' X%dsigma0 = X%dsigma0 ^ X%dleft56' % (j1,j1,j1)) print(' 2x,0 W%dright61 = W%d unsigned>> 61' % (j14,j14)) print(' r%dSigma1 = r%d>>>14' % (i3,i3)) print(' r%d += maj%d' % (i7,i7)) print('') print(' 4x X%dright7 = X%d unsigned>> 7' % (j1,j1)) print(' 1x,0 W%dsigma1 = W%dright19 ^ W%dleft45' % (j14,j14,j14)) print(' r%d18 = r%d>>>18' % (i3,i3)) print(' ch%d &= r%d' % (i6,i3)) print('') print(' X%dsigma0 = X%dsigma0 ^ X%dright7' % (j1,j1,j1)) print(' r%dSigma1 ^= r%d18' % (i3,i3)) print(' r%d41 = r%d>>>41' % (i3,i3)) print(' maj%d &= r%d' % (i6,i7)) print('') print(' 1x,0 W%dsigma1 ^= W%dright61' % (j14,j14)) print(' 4x X%d = X%d + mem256[&w + %d]' % (j0,j0,8*j9)) print(' r%dSigma1 ^= r%d41' % (i3,i3)) print(' maj%d ^= r%dandr%d' % (i6,i0,i1)) print('') print(' 2x,0 W%dleft3 = W%d << 3' % (j14,j14)) print(' r%dSigma0 = r%d>>>28' % (i7,i7)) print(' ch%d ^= r%d' % (i6,i5)) print(' r%d += r%dSigma1' % (i6,i3)) print('') print(' 4x X%d = X%d + X%dsigma0' % (j0,j0,j1)) print(' r%d34 = r%d>>>34' % (i7,i7)) print(' r%d += %s[2]' % (i5,wcin)) print(' r%d += ch%d' % (i6,i6)) print('') print(' 1x,0 W%dsigma1 ^= W%dleft3' % (j14,j14)) print(' r%dSigma0 ^= r%d34' % (i7,i7)) print(' r%d39 = r%d>>>39' % (i7,i7)) print(' r%d += r%d' % (i2,i6)) print('') print(' 2x,0 W%dright6 = W%d unsigned>> 6' % (j14,j14)) print(' r%dSigma0 ^= r%d39' % (i7,i7)) print(' r%d += maj%d' % (i6,i6)) print(' ch%d = r%d' % (i5,i4)) print(' ch%d ^= r%d' % (i5,i3)) print('') print(' 1x,0 W%dsigma1 ^= W%dright6' % (j14,j14)) print(' r%d += r%dSigma0' % (i6,i7)) print(' r%dSigma1 = r%d>>>14' % (i2,i2)) print(' ch%d &= r%d' % (i5,i2)) print('') print(' 4x X%d = W%dsigma1 + X%d' % (j0,j14,j0)) print(' r%d18 = r%d>>>18' % (i2,i2)) print(' r%d41 = r%d>>>41' % (i2,i2)) print(' ch%d ^= r%d' % (i5,i4)) print('') print(' 2x,0 W%dright19 = X%d unsigned>> 19' % (j0,j0)) print(' r%dSigma1 ^= r%d18' % (i2,i2)) print(' r%dSigma0 = r%d>>>28' % (i6,i6)) print(' r%d += ch%d' % (i5,i5)) print('') print(' 2x,0 W%dleft45 = X%d << 45' % (j0,j0)) print(' r%dSigma1 ^= r%d41' % (i2,i2)) print(' r%d34 = r%d>>>34' % (i6,i6)) print(' maj%d = r%d' % (i4,i7)) print(' maj%d ^= r%d' % (i4,i6)) print('') print(' 2x,0 W%dright61 = X%d unsigned>> 61' % (j0,j0)) print(' 1x,0 W%dsigma1 = W%dright19 ^ W%dleft45' % (j0,j0,j0)) print(' r%dSigma0 ^= r%d34' % (i6,i6)) print(' r%d39 = r%d>>>39' % (i6,i6)) print('') print(' 2x,0 W%dleft3 = X%d << 3' % (j0,j0)) print(' 1x,0 W%dsigma1 ^= W%dright61' % (j0,j0)) print(' r%dSigma0 ^= r%d39' % (i6,i6)) print(' r%d += r%dSigma1' % (i5,i2)) print('') print(' 2x,0 W%dright6 = X%d unsigned>> 6' % (j0,j0)) print(' 1x,0 W%dsigma1 ^= W%dleft3' % (j0,j0)) print(' r%d += r%d' % (i1,i5)) print(' r%dandr%d = r%d' % (i6,i7,i7)) print(' r%dandr%d &= r%d' % (i6,i7,i6)) print('') print(' 1x,0 W%dsigma1 ^= W%dright6' % (j0,j0)) print(' r%dSigma1 = r%d>>>14' % (i1,i1)) print(' r%d += r%dSigma0' % (i5,i6)) print(' maj%d = r%d' % (i5,i0)) print(' maj%d &= maj%d' % (i5,i4)) print('') print(' W%dsigma1 = W%dsigma1[1],W%dsigma1[0]' % (j0,j0,j0)) print(' maj%d ^= r%dandr%d' % (i5,i6,i7)) print(' ch%d = r%d' % (i4,i3)) print(' ch%d ^= r%d' % (i4,i2)) print('') print(' r%d += maj%d' % (i5,i5)) print(' ch%d &= r%d' % (i4,i1)) print(' r%d18 = r%d>>>18' % (i1,i1)) print('') print(' maj%d &= r%d' % (i4,i5)) print(' ch%d ^= r%d' % (i4,i3)) print(' r%d += %s[3]' % (i4,wcin)) print(' r%dSigma1 ^= r%d18' % (i1,i1)) print('') print(' r%d41 = r%d>>>41' % (i1,i1)) print(' 4x X%d = X%d + W%dsigma1' % (j0,j0,j0)) if j0 == 0: print(' mem256[&w + 128] = X%d' % (j0)) print(' mem256[&w + %d] = X%d' % (8*j0,j0)) print(' r%d += ch%d' % (i4,i4)) print(' maj%d ^= r%dandr%d' % (i4,i6,i7)) print('') print(' r%dSigma0 = r%d>>>28' % (i5,i5)) print(' 4x D%d = X%d + mem256[constants + %d]' % (j0,j0,8*j0)) print(' %s = D%d' % (wcout,j0)) print(' r%d34 = r%d>>>34' % (i5,i5)) print(' r%dSigma1 ^= r%d41' % (i1,i1)) print('') print(' r%d += r%dSigma1' % (i4,i1)) print(' r%dSigma0 ^= r%d34' % (i5,i5)) print(' r%d39 = r%d>>>39' % (i5,i5)) print('') print(' r%d += r%d' % (i0,i4)) print(' r%d += maj%d' % (i4,i4)) print(' r%dSigma0 ^= r%d39' % (i5,i5)) print('') print(' r%d += r%dSigma0' % (i4,i5))