Example #1
0
        public override bool Verify(byte[] header, byte[] solution)
        {
            Contract.RequiresNonNull(header, nameof(header));
            Contract.Requires <ArgumentException>(header.Length == 140, $"{nameof(header)} must be exactly 140 bytes");
            Contract.RequiresNonNull(solution, nameof(solution));
            Contract.Requires <ArgumentException>(solution.Length == 1344, $"{nameof(solution)} must be exactly 1344 bytes");

            logger.LogInvoke();

            try
            {
                sem.Value.WaitOne();

                fixed(byte *h = header)
                {
                    fixed(byte *s = solution)
                    {
                        return(LibMultihash.equihash_verify(h, header.Length, s, solution.Length));
                    }
                }
            }

            finally
            {
                sem.Value.Release();
            }
        }
Example #2
0
        /// <summary>
        /// Verify an Equihash solution
        /// </summary>
        /// <param name="header">header including nonce (140 bytes)</param>
        /// <param name="solution">equihash solution (excluding 3 bytes with size, so 1344 bytes length) - Do not include byte size preamble "fd4005"</param>
        /// <returns></returns>
        public bool Verify(byte[] header, byte[] solution)
        {
            Contract.RequiresNonNull(header, nameof(header));
            Contract.Requires <ArgumentException>(header.Length == 140, $"{nameof(header)} must be exactly 140 bytes");
            Contract.RequiresNonNull(solution, nameof(solution));
            Contract.Requires <ArgumentException>(solution.Length == 1344, $"{nameof(solution)} must be exactly 1344 bytes");

            try
            {
                sem.WaitOne();

                fixed(byte *_header = header)
                {
                    fixed(byte *_solution = solution)
                    {
                        return(LibMultihash.equihash_verify(_header, _solution));
                    }
                }
            }

            finally
            {
                sem.Release();
            }
        }