static SpongeState Rho(SpongeState state) { var newState = new SpongeState(state.Size, state.Rate); var w = state.Size.W; newState.SetLane(newState.GetLane(0, 0), state.GetLane(0, 0).GetBits()); var x = 1; var y = 0; for (var t = 0; t < 24; t++) { var u = ((t + 1) * (t + 2)) >> 1; for (var z = 0; z < w; z++) { newState[x, y, z] = state[x, y, BinaryFunctions.Mod(z - u, w)]; } var oldX = x; x = y; y = BinaryFunctions.Mod(2 * oldX + 3 * y, 5); } state.SetBitString(newState.BitString); return(state); }
static SpongeState Pi(SpongeState state) { var newState = new SpongeState(state.Size, state.Rate); var w = state.Size.W; for (var y = 0; y < 5; y++) { for (var x = 0; x < 5; x++) { for (var z = 0; z < w; z++) { newState[x, y, z] = state[BinaryFunctions.Mod(x + 3 * y, 5), x, z]; } } } state.SetBitString(newState.BitString); return(state); }