From 055806bbad942b364d62cded68a8838b8ae55716 Mon Sep 17 00:00:00 2001 From: Andrew Ekstedt Date: Sat, 5 Oct 2024 20:54:51 -0700 Subject: [PATCH] de-unroll Chi loop in roundGeneric (reroll? no, that's something else) makes it more similar to the templatized code in gen.go. this isn't the optimized code, so performance doesn't matter. --- keccak.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/keccak.go b/keccak.go index ccdef4f..a6b75eb 100644 --- a/keccak.go +++ b/keccak.go @@ -26,11 +26,9 @@ func roundGeneric(a *[25]uint64) { // Chi for y := 0; y < 5; y++ { - a[y*5+0] = b[y][0] ^ ^b[y][1]&b[y][2] - a[y*5+1] = b[y][1] ^ ^b[y][2]&b[y][3] - a[y*5+2] = b[y][2] ^ ^b[y][3]&b[y][4] - a[y*5+3] = b[y][3] ^ ^b[y][4]&b[y][0] - a[y*5+4] = b[y][4] ^ ^b[y][0]&b[y][1] + for x := 0; x < 5; x++ { + a[y*5+x] = b[y][x] ^ (^b[y][(x+1)%5] & b[y][(x+2)%5]) + } } }