Keccak Algorithm Visualizer


What is Keccak?

Keccak is a family of sponge functions designed by Guido Bertoni, Joan Daemen, Michaël Peeters, and Gilles Van Assche. In October 2012, Keccak won the NIST hash function competition, and is proposed as the SHA-3 standard. Keccak is based on a novel approach called sponge construction.


Sponge Construction

Sponge construction is based on a wide random function or random permutation, and allows inputting ("absorbing" in sponge terminology) any amount of data, and outputting ( "squeezing") any amount of data. In the absorbing phase, message blocks are padded and XORed into the initial bits of the state, and then invertibly permuted. In the "squeeze" phase, output blocks are read from the same subset of the state, alternated with state transformations

sponge

Keccak-f Permutations

namingcov

The picture on the left shows the main state and parts of a state involved in Keccak.
This permutation defined for any power-of-two word size, w = 2ℓ bits
Main SHA-3 submission uses 64-bit words, where ℓ = 6.
Index arithmetic is performed modulo 5 for the first two dimensions and modulo w for the third.

The one-dimensional parts are:

  • A row is a set of 5 bits with constant y and z coordinates.
  • A column is a set of 5 bits with constant x and z coordinates.
  • A lane is a set of w bits with constant x and y coordinates.

The two-dimensional parts are:

  • A sheet is a set of 5w bits with constant x coordinate.
  • A plane is a set of 5w bits with constant y coordinate.
  • A slice is a set of 25 bits with constant z coordinate.

The round function consists of 5 sub-functions:
θ(Theta): iterates over each column of the state
ρ(Rho): iterates over each lane of the state
π(Pi): permutes positioning of lanes within state
χ(Chi): iterates over each row of state
ι(Iota): XORs a round constant with a modulus


Team Keccak, NIST Publication, SHA-3 Wikipedia, Bitcoin Wiki, SHIFT, NOT, AND, XOR, ROT/Circular Shift

Bitwise Operations


XOR

XOR is a bitwise operator that takes two bit values and performs a logical Exclusive OR operation on each pair of corresponding bits. The result of each bit is 1 if only one of the bits is 1, but will be 0 if both are 0 or both are 1.

AND

AND is a bitwise operator that takes two bit values and compares each bit of the first operand with a second operand. If both bits are 1, the result bit will be 1. Otherwise, the corresponding result bit is 0.

NOT

NOT is a bitwise operator that takes two bit values and. Unlike AND, NOT flips the resulting bits (e.g. if an operand is 1, it becomes 0) and vice versa.

Logical Shift

A logical shift is a bitwise operator that shifts all the binary digits within itself. A logical shift can work towards the left or to the right and in each shift, zeroes are shifted to replace the "lost" or "discarded" bits.

ROT (Circular Shift Right/Left)

A circular shift (also known as ROT/Rotate) is a bitwise operator of rearranging bits by moving them in a clockwise or anticlockwise position. Unlike a logical shift, the "discarded" bits are not replaced with zeroes. Instead, the discarded bit is shifted to the nth position of which the number of i shifts is declared.

Rotate Left Rotate Right