Exemplo n.º 1
0
        private unsafe bool Loop12()
        {
            var cartesian = CartesianProduct.Create(Enumerable.Repeat(Enumerable.Range(0, 2048), missCount));

            fixed(uint *wPt = &sha.w[0], hPt = &sha.hashState[0], wrd = &wordIndexes[0])
            fixed(int *mi = &missingIndexes[0])
            {
                wPt[4]  = 0b10000000_00000000_00000000_00000000U;
                wPt[15] = 128;

                foreach (var item in cartesian)
                {
                    int j = 0;
                    foreach (var k in item)
                    {
                        wrd[mi[j]] = (uint)k;
                        j++;
                    }

                    wPt[0] = wrd[0] << 21 | wrd[1] << 10 | wrd[2] >> 1;
                    wPt[1] = wrd[2] << 31 | wrd[3] << 20 | wrd[4] << 9 | wrd[5] >> 2;
                    wPt[2] = wrd[5] << 30 | wrd[6] << 19 | wrd[7] << 8 | wrd[8] >> 3;
                    wPt[3] = wrd[8] << 29 | wrd[9] << 18 | wrd[10] << 7 | wrd[11] >> 4;

                    sha.Compress16(hPt, wPt);

                    if ((wrd[11] & 0b1111) == hPt[0] >> 28)
                    {
                        StringBuilder sb = new StringBuilder(12);
                        for (int i = 0; i < 11; i++)
                        {
                            sb.Append($"{allWords[wrd[i]]} ");
                        }

                        // no space at the end.
                        sb.Append($"{allWords[wrd[11]]}");

                        SetBip32(Encoding.UTF8.GetBytes(sb.ToString()));
                    }
                }
            }

            return(Final.Count != 0);
        }