private void BlockMix(ArraySegment <byte> B, byte[] Y) { ArraySegment <byte> .Copy(B, (2 * BlockSize - 1) * 64, BlockX, 0, 64); for (int i = 0; i < 2 * BlockSize; ++i) { for (int j = 0; j < 64; ++j) { BlockX[j] ^= B[i * 64 + j]; } Salsa.ComputeHash(BlockX, BlockX); Array.Copy(BlockX, 0, Y, i * 64, 64); } for (int i = 0; i < BlockSize; ++i) { ArraySegment <byte> .Copy(Y, (i * 2) * 64, B, i * 64, 64); } for (int i = 0; i < BlockSize; ++i) { ArraySegment <byte> .Copy(Y, (i * 2 + 1) * 64, B, (i + BlockSize) * 64, 64); } }
private void ROMix(ArraySegment <byte> B, byte[] X, byte[] Y, byte[] V) { B.CopyTo(X, 0); for (int i = 0; i < Cost; ++i) { Array.Copy(X, 0, V, i * (128 * BlockSize), 128 * BlockSize); BlockMix(X, Y); } for (int i = 0; i < Cost; ++i) { ulong j = BitConverter.ToUInt64(X, (2 * BlockSize - 1) * 64); j %= (ulong)Cost; for (int k = 0; k < 128 * BlockSize; ++k) { X[k] ^= V[j * (128 * (ulong)BlockSize) + (ulong)k]; } BlockMix(X, Y); } ArraySegment <byte> .Copy(X, B, 128 *BlockSize); }