private static SpongeState Iota(SpongeState state, int round) { int w = state.Size.W; int l = state.Size.L; Bitstring rc = Bitstring.Zeroes(w); RoundT roundT; int t; int rnd = 7 * round; for (int j = 0; j <= l; j++) { t = j + rnd; roundT = new RoundT(round, t); if (!_roundTConstants.ContainsKey(roundT)) { _roundTConstants.Add(roundT, RoundConstant(t)); } rc[(1 << j) - 1] = _roundTConstants[roundT]; } state.XorLane(state.GetLane(0, 0), rc); return(state); }
private static SpongeState Rho(SpongeState state) { SpongeState newState = new SpongeState(state.Size, state.Rate); int w = state.Size.W; newState.SetLane(newState.GetLane(0, 0), state.GetLane(0, 0).GetBits()); int x = 1; int y = 0; int u, oldX; for (int t = 0; t < 24; t++) { u = ((t + 1) * (t + 2)) >> 1; for (int z = 0; z < w; z++) { newState[x, y, z] = state[x, y, Bin.Mod(z - u, w)]; } oldX = x; x = y; y = Bin.Mod(2 * oldX + 3 * y, 5); } state.SetBitstring(newState.Bitstring); return(state); }