예제 #1
0
    public void Digest(ReadOnlySpan <byte> data, Span <byte> result, params object[] extra)
    {
        Contract.Requires <ArgumentException>(result.Length >= 32, $"{nameof(result)} must be greater or equal 32 bytes");

        // get nFactor
        var ts      = ((DateTimeOffset)Clock.Now).ToUnixTimeSeconds();
        var n       = timetable.First(x => ts >= x.Item2).Item1;
        var nFactor = Math.Log(n) / Math.Log(2);

        fixed(byte *input = data)
        {
            fixed(byte *output = result)
            {
                Multihash.scryptn(input, output, (uint)nFactor, (uint)data.Length);
            }
        }
    }