Skip to content

Commit

Permalink
keccak1600: remove not needed spill + make it easier to make rounds l…
Browse files Browse the repository at this point in the history
…ocal function
  • Loading branch information
tfaoliveira committed Oct 22, 2023
1 parent 900ceec commit 5e1a1a3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
15 changes: 6 additions & 9 deletions src/common/keccak/keccak1600/amd64/bmi1/keccakf1600.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,13 @@ inline fn __set_row_bmi1(
}


inline fn __round_bmi1(reg ptr u64[25] e a, stack u64 s_rc) -> reg ptr u64[25]
inline fn __round_bmi1(reg ptr u64[25] e a, reg u64 rc) -> reg ptr u64[25]
{
inline int y;
reg u64[5] b c d;
stack u64 s_rc;

s_rc = rc;

c = __theta_sum_bmi1(a);
d = __theta_rol_bmi1(c);
Expand All @@ -130,7 +133,6 @@ inline fn __keccakf1600_bmi1(reg ptr u64[25] a) -> reg ptr u64[25]
stack u64[25] s_e;
reg ptr u64[25] e;
reg u64 c rc;
stack u64 s_c s_rc;

RC = KECCAK1600_RC;
s_RC = RC;
Expand All @@ -139,19 +141,14 @@ inline fn __keccakf1600_bmi1(reg ptr u64[25] a) -> reg ptr u64[25]
c = 0;
while (c < KECCAK_ROUNDS - 1)
{
s_c = c;

RC = s_RC;
rc = RC[(int) c];
s_rc = rc;
e = __round_bmi1(e, a, s_rc);
e = __round_bmi1(e, a, rc);

RC = s_RC;
rc = RC[(int) c + 1];
s_rc = rc;
a = __round_bmi1(a, e, s_rc);
a = __round_bmi1(a, e, rc);

c = s_c;
c += 2;
}

Expand Down
15 changes: 6 additions & 9 deletions src/common/keccak/keccak1600/amd64/ref1/keccakf1600.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,13 @@ inline fn __set_row_ref1(
}


inline fn __round_ref1(reg ptr u64[25] e a, stack u64 s_rc) -> reg ptr u64[25]
inline fn __round_ref1(reg ptr u64[25] e a, reg u64 rc) -> reg ptr u64[25]
{
inline int y;
reg u64[5] b c d;
stack u64 s_rc;

s_rc = rc;

c = __theta_sum_ref1(a);
d = __theta_rol_ref1(c);
Expand All @@ -131,7 +134,6 @@ inline fn __keccakf1600_ref1(reg ptr u64[25] a) -> reg ptr u64[25]
stack u64[25] s_e;
reg ptr u64[25] e;
reg u64 c rc;
stack u64 s_c s_rc;

RC = KECCAK1600_RC;
s_RC = RC;
Expand All @@ -140,19 +142,14 @@ inline fn __keccakf1600_ref1(reg ptr u64[25] a) -> reg ptr u64[25]
c = 0;
while (c < KECCAK_ROUNDS - 1)
{
s_c = c;

RC = s_RC;
rc = RC[(int) c];
s_rc = rc;
e = __round_ref1(e, a, s_rc);
e = __round_ref1(e, a, rc);

RC = s_RC;
rc = RC[(int) c + 1];
s_rc = rc;
a = __round_ref1(a, e, s_rc);
a = __round_ref1(a, e, rc);

c = s_c;
c += 2;
}

Expand Down

0 comments on commit 5e1a1a3

Please sign in to comment.