unsafe void PrepareWork(Work work, out byte[] round1Blocks, out uint[] round1State, out byte[] round2Blocks, out uint[] round2State)
{
// allocate buffers to hold hashing work
round1Blocks = Sha256.AllocateInputBuffer(80);
round1State = Sha256.AllocateStateBuffer();
round2Blocks = Sha256.AllocateInputBuffer(Sha256.SHA256_HASH_SIZE);
round2State = Sha256.AllocateStateBuffer();
fixed (byte* round1BlocksPtr = round1Blocks, round2BlocksPtr = round2Blocks)
fixed (uint* round1StatePtr = round1State, round2StatePtr = round2State)
{
// header arrives in big endian, convert to host
fixed (byte* workHeaderPtr = work.Header)
Memory.ReverseEndian((uint*)workHeaderPtr, (uint*)round1BlocksPtr, 20);
// append '1' bit and trailing length
Sha256.Prepare(round1BlocksPtr, 80, 0);
Sha256.Prepare(round1BlocksPtr + Sha256.SHA256_BLOCK_SIZE, 80, 1);
// hash first half of header
Sha256.Initialize(round1StatePtr);
Sha256.Transform(round1StatePtr, round1BlocksPtr);
// initialize values for round 2
Sha256.Initialize(round2StatePtr);
Sha256.Prepare(round2BlocksPtr, Sha256.SHA256_HASH_SIZE, 0);
}
}